]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/timesync/timesyncd-server.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / timesync / timesyncd-server.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
84e51726
LP
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
874ff7bf 23#include "list.h"
71d35b6b 24#include "socket-util.h"
874ff7bf 25
84e51726
LP
26typedef struct ServerAddress ServerAddress;
27typedef struct ServerName ServerName;
28
874ff7bf
LP
29typedef enum ServerType {
30 SERVER_SYSTEM,
31 SERVER_FALLBACK,
32 SERVER_LINK,
33} ServerType;
34
35#include "timesyncd-manager.h"
84e51726
LP
36
37struct ServerAddress {
874ff7bf
LP
38 ServerName *name;
39
84e51726
LP
40 union sockaddr_union sockaddr;
41 socklen_t socklen;
874ff7bf 42
84e51726
LP
43 LIST_FIELDS(ServerAddress, addresses);
44};
45
46struct ServerName {
874ff7bf
LP
47 Manager *manager;
48
49 ServerType type;
84e51726 50 char *string;
874ff7bf
LP
51
52 bool marked:1;
53
84e51726
LP
54 LIST_HEAD(ServerAddress, addresses);
55 LIST_FIELDS(ServerName, names);
56};
57
874ff7bf
LP
58int server_address_new(ServerName *n, ServerAddress **ret, const union sockaddr_union *sockaddr, socklen_t socklen);
59ServerAddress* server_address_free(ServerAddress *a);
84e51726 60static inline int server_address_pretty(ServerAddress *a, char **pretty) {
3b1c5241 61 return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, true, pretty);
84e51726 62}
874ff7bf
LP
63
64int server_name_new(Manager *m, ServerName **ret, ServerType type,const char *string);
65ServerName *server_name_free(ServerName *n);
66void server_name_flush_addresses(ServerName *n);