]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/timesync/timesyncd-manager.h
timesync: add RootDistanceMaxSec= to timesyncd.conf (#7215)
[thirdparty/systemd.git] / src / timesync / timesyncd-manager.h
CommitLineData
84e51726
LP
1#pragma once
2
e8af6973
LP
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
e8af6973 22#include "sd-event.h"
e0e5ce23 23#include "sd-network.h"
71d35b6b
TA
24#include "sd-resolve.h"
25
84e51726 26#include "list.h"
84e51726 27#include "ratelimit.h"
e8af6973
LP
28
29typedef struct Manager Manager;
ae2db4e7 30
874ff7bf
LP
31#include "timesyncd-server.h"
32
e8af6973
LP
33struct Manager {
34 sd_event *event;
35 sd_resolve *resolve;
36
874ff7bf 37 LIST_HEAD(ServerName, system_servers);
84e51726 38 LIST_HEAD(ServerName, link_servers);
84e51726 39 LIST_HEAD(ServerName, fallback_servers);
e8af6973 40
3745770a
MB
41 bool have_fallbacks:1;
42
e8af6973 43 RateLimit ratelimit;
63463bf0 44 bool exhausted_servers;
e8af6973 45
e0e5ce23
TG
46 /* network */
47 sd_event_source *network_event_source;
48 sd_network_monitor *network_monitor;
49
e8af6973
LP
50 /* peer */
51 sd_resolve_query *resolve_query;
52 sd_event_source *event_receive;
53 ServerName *current_server_name;
54 ServerAddress *current_server_address;
55 int server_socket;
e8206972 56 int missed_replies;
e8af6973
LP
57 uint64_t packet_count;
58 sd_event_source *event_timeout;
481b3f9e 59 bool good;
e8af6973
LP
60
61 /* last sent packet */
62 struct timespec trans_time_mon;
63 struct timespec trans_time;
ab4df227 64 usec_t retry_interval;
e8af6973
LP
65 bool pending;
66
67 /* poll timer */
68 sd_event_source *event_timer;
69 usec_t poll_interval_usec;
70 bool poll_resync;
71
72 /* history data */
73 struct {
74 double offset;
75 double delay;
76 } samples[8];
77 unsigned int samples_idx;
78 double samples_jitter;
f907cc16 79 usec_t max_root_distance_usec;
e8af6973
LP
80
81 /* last change */
82 bool jumped;
d636d376 83 bool sync;
e8af6973
LP
84 int drift_ppm;
85
86 /* watch for time changes */
87 sd_event_source *event_clock_watch;
88 int clock_watch_fd;
89
90 /* Retry connections */
91 sd_event_source *event_retry;
c264aeab
KS
92
93 /* RTC runs in local time, leave it alone */
94 bool rtc_local_time;
e8af6973
LP
95};
96
84e51726
LP
97int manager_new(Manager **ret);
98void manager_free(Manager *m);
99
100DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
e8af6973 101
874ff7bf
LP
102void manager_set_server_name(Manager *m, ServerName *n);
103void manager_set_server_address(Manager *m, ServerAddress *a);
104void manager_flush_server_names(Manager *m, ServerType t);
105
84e51726
LP
106int manager_connect(Manager *m);
107void manager_disconnect(Manager *m);