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