]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/timesync/timesyncd.h
networkctl: make networkctl status without link name show all local IP addresses
[thirdparty/systemd.git] / src / timesync / timesyncd.h
CommitLineData
e8af6973
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3/***
4 This file is part of systemd.
5
6 Copyright 2014 Kay Sievers, Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
22#include "list.h"
23#include "socket-util.h"
24#include "ratelimit.h"
25#include "sd-event.h"
26#include "sd-resolve.h"
e0e5ce23 27#include "sd-network.h"
e8af6973
LP
28
29typedef struct Manager Manager;
30typedef struct ServerAddress ServerAddress;
31typedef struct ServerName ServerName;
32
33struct ServerAddress {
34 union sockaddr_union sockaddr;
35 socklen_t socklen;
36 LIST_FIELDS(ServerAddress, addresses);
37};
38
39struct ServerName {
40 char *string;
41 LIST_HEAD(ServerAddress, addresses);
42 LIST_FIELDS(ServerName, names);
43};
44
ae2db4e7
ZJS
45static inline int server_address_pretty(ServerAddress *a, char **pretty) {
46 return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, pretty);
47}
48
e8af6973
LP
49struct Manager {
50 sd_event *event;
51 sd_resolve *resolve;
52
53 LIST_HEAD(ServerName, servers);
54
55 RateLimit ratelimit;
56
e0e5ce23
TG
57 /* network */
58 sd_event_source *network_event_source;
59 sd_network_monitor *network_monitor;
60
e8af6973
LP
61 /* peer */
62 sd_resolve_query *resolve_query;
63 sd_event_source *event_receive;
64 ServerName *current_server_name;
65 ServerAddress *current_server_address;
66 int server_socket;
67 uint64_t packet_count;
68 sd_event_source *event_timeout;
69
70 /* last sent packet */
71 struct timespec trans_time_mon;
72 struct timespec trans_time;
73 usec_t retry_interval;
74 bool pending;
75
76 /* poll timer */
77 sd_event_source *event_timer;
78 usec_t poll_interval_usec;
79 bool poll_resync;
80
81 /* history data */
82 struct {
83 double offset;
84 double delay;
85 } samples[8];
86 unsigned int samples_idx;
87 double samples_jitter;
88
89 /* last change */
90 bool jumped;
d636d376 91 bool sync;
e8af6973
LP
92 int drift_ppm;
93
94 /* watch for time changes */
95 sd_event_source *event_clock_watch;
96 int clock_watch_fd;
97
98 /* Retry connections */
99 sd_event_source *event_retry;
c264aeab
KS
100
101 /* RTC runs in local time, leave it alone */
102 bool rtc_local_time;
e8af6973
LP
103};
104
105const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, unsigned length);
106
107int config_parse_servers(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);