4 This file is part of systemd.
6 Copyright 2014 Kay Sievers, Lennart Poettering
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.
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.
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/>.
23 #include "sd-network.h"
24 #include "sd-resolve.h"
27 #include "ratelimit.h"
28 #include "time-util.h"
30 typedef struct Manager Manager
;
32 #include "timesyncd-server.h"
35 * "A client MUST NOT under any conditions use a poll interval less
38 #define NTP_POLL_INTERVAL_MIN_USEC (32 * USEC_PER_SEC)
39 #define NTP_POLL_INTERVAL_MAX_USEC (2048 * USEC_PER_SEC)
45 LIST_HEAD(ServerName
, system_servers
);
46 LIST_HEAD(ServerName
, link_servers
);
47 LIST_HEAD(ServerName
, fallback_servers
);
49 bool have_fallbacks
:1;
52 bool exhausted_servers
;
55 sd_event_source
*network_event_source
;
56 sd_network_monitor
*network_monitor
;
59 sd_resolve_query
*resolve_query
;
60 sd_event_source
*event_receive
;
61 ServerName
*current_server_name
;
62 ServerAddress
*current_server_address
;
65 uint64_t packet_count
;
66 sd_event_source
*event_timeout
;
69 /* last sent packet */
70 struct timespec trans_time_mon
;
71 struct timespec trans_time
;
72 usec_t retry_interval
;
76 sd_event_source
*event_timer
;
77 usec_t poll_interval_usec
;
78 usec_t poll_interval_min_usec
;
79 usec_t poll_interval_max_usec
;
87 unsigned int samples_idx
;
88 double samples_jitter
;
89 usec_t max_root_distance_usec
;
96 /* watch for time changes */
97 sd_event_source
*event_clock_watch
;
100 /* Retry connections */
101 sd_event_source
*event_retry
;
103 /* RTC runs in local time, leave it alone */
107 int manager_new(Manager
**ret
);
108 void manager_free(Manager
*m
);
110 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager
*, manager_free
);
112 void manager_set_server_name(Manager
*m
, ServerName
*n
);
113 void manager_set_server_address(Manager
*m
, ServerAddress
*a
);
114 void manager_flush_server_names(Manager
*m
, ServerType t
);
116 int manager_connect(Manager
*m
);
117 void manager_disconnect(Manager
*m
);