1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2014 Kay Sievers, Lennart Poettering
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.
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.
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/>.
24 #include "sd-network.h"
25 #include "sd-resolve.h"
28 #include "ratelimit.h"
29 #include "time-util.h"
31 typedef struct Manager Manager
;
33 #include "timesyncd-server.h"
36 * "A client MUST NOT under any conditions use a poll interval less
39 #define NTP_POLL_INTERVAL_MIN_USEC (32 * USEC_PER_SEC)
40 #define NTP_POLL_INTERVAL_MAX_USEC (2048 * USEC_PER_SEC)
46 LIST_HEAD(ServerName
, system_servers
);
47 LIST_HEAD(ServerName
, link_servers
);
48 LIST_HEAD(ServerName
, fallback_servers
);
50 bool have_fallbacks
:1;
53 bool exhausted_servers
;
56 sd_event_source
*network_event_source
;
57 sd_network_monitor
*network_monitor
;
60 sd_resolve_query
*resolve_query
;
61 sd_event_source
*event_receive
;
62 ServerName
*current_server_name
;
63 ServerAddress
*current_server_address
;
66 uint64_t packet_count
;
67 sd_event_source
*event_timeout
;
70 /* last sent packet */
71 struct timespec trans_time_mon
;
72 struct timespec trans_time
;
73 usec_t retry_interval
;
77 sd_event_source
*event_timer
;
78 usec_t poll_interval_usec
;
79 usec_t poll_interval_min_usec
;
80 usec_t poll_interval_max_usec
;
88 unsigned int samples_idx
;
89 double samples_jitter
;
90 usec_t max_root_distance_usec
;
97 /* watch for time changes */
98 sd_event_source
*event_clock_watch
;
101 /* Retry connections */
102 sd_event_source
*event_retry
;
104 /* RTC runs in local time, leave it alone */
108 int manager_new(Manager
**ret
);
109 void manager_free(Manager
*m
);
111 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager
*, manager_free
);
113 void manager_set_server_name(Manager
*m
, ServerName
*n
);
114 void manager_set_server_address(Manager
*m
, ServerAddress
*a
);
115 void manager_flush_server_names(Manager
*m
, ServerType t
);
117 int manager_connect(Manager
*m
);
118 void manager_disconnect(Manager
*m
);