]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
5eef597e MP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2014 Kay Sievers, Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
5eef597e | 23 | #include "list.h" |
4c89c718 | 24 | #include "socket-util.h" |
5eef597e MP |
25 | |
26 | typedef struct ServerAddress ServerAddress; | |
27 | typedef struct ServerName ServerName; | |
28 | ||
29 | typedef enum ServerType { | |
30 | SERVER_SYSTEM, | |
31 | SERVER_FALLBACK, | |
32 | SERVER_LINK, | |
33 | } ServerType; | |
34 | ||
35 | #include "timesyncd-manager.h" | |
36 | ||
37 | struct ServerAddress { | |
38 | ServerName *name; | |
39 | ||
40 | union sockaddr_union sockaddr; | |
41 | socklen_t socklen; | |
42 | ||
43 | LIST_FIELDS(ServerAddress, addresses); | |
44 | }; | |
45 | ||
46 | struct ServerName { | |
47 | Manager *manager; | |
48 | ||
49 | ServerType type; | |
50 | char *string; | |
51 | ||
52 | bool marked:1; | |
53 | ||
54 | LIST_HEAD(ServerAddress, addresses); | |
55 | LIST_FIELDS(ServerName, names); | |
56 | }; | |
57 | ||
58 | int server_address_new(ServerName *n, ServerAddress **ret, const union sockaddr_union *sockaddr, socklen_t socklen); | |
59 | ServerAddress* server_address_free(ServerAddress *a); | |
60 | static inline int server_address_pretty(ServerAddress *a, char **pretty) { | |
e3bff60a | 61 | return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, true, pretty); |
5eef597e MP |
62 | } |
63 | ||
64 | int server_name_new(Manager *m, ServerName **ret, ServerType type,const char *string); | |
65 | ServerName *server_name_free(ServerName *n); | |
66 | void server_name_flush_addresses(ServerName *n); |