1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "list.h"
5 #include "socket-util.h"
6
7 typedef struct ServerAddress ServerAddress;
8 typedef struct ServerName ServerName;
9
10 typedef enum ServerType {
11 SERVER_SYSTEM,
12 SERVER_FALLBACK,
13 SERVER_LINK,
14 SERVER_RUNTIME,
15 _SERVER_TYPE_MAX,
16 _SERVER_TYPE_INVALID = -EINVAL,
17 } ServerType;
18
19 #include "timesyncd-manager.h"
20
21 struct ServerAddress {
22 ServerName *name;
23
24 union sockaddr_union sockaddr;
25 socklen_t socklen;
26
27 LIST_FIELDS(ServerAddress, addresses);
28 };
29
30 struct ServerName {
31 Manager *manager;
32
33 ServerType type;
34 char *string;
35
36 bool marked:1;
37
38 LIST_HEAD(ServerAddress, addresses);
39 LIST_FIELDS(ServerName, names);
40 };
41
42 int server_address_new(ServerName *n, ServerAddress **ret, const union sockaddr_union *sockaddr, socklen_t socklen);
43 ServerAddress* server_address_free(ServerAddress *a);
server_address_pretty(ServerAddress * a,char ** pretty)44 static inline int server_address_pretty(ServerAddress *a, char **pretty) {
45 return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, true, pretty);
46 }
47
48 int server_name_new(Manager *m, ServerName **ret, ServerType type,const char *string);
49 ServerName *server_name_free(ServerName *n);
50 void server_name_flush_addresses(ServerName *n);
51