]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/timesync/timesyncd-manager.h
man: avoid confusion regarding "time synchronization state"
[thirdparty/systemd.git] / src / timesync / timesyncd-manager.h
CommitLineData
e8af6973
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
84e51726
LP
3#pragma once
4
e8af6973
LP
5/***
6 This file is part of systemd.
7
8 Copyright 2014 Kay Sievers, Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
e8af6973
LP
24#include "sd-event.h"
25#include "sd-resolve.h"
e0e5ce23 26#include "sd-network.h"
84e51726 27#include "list.h"
84e51726 28#include "ratelimit.h"
e8af6973
LP
29
30typedef struct Manager Manager;
ae2db4e7 31
874ff7bf
LP
32#include "timesyncd-server.h"
33
e8af6973
LP
34struct Manager {
35 sd_event *event;
36 sd_resolve *resolve;
37
874ff7bf 38 LIST_HEAD(ServerName, system_servers);
84e51726 39 LIST_HEAD(ServerName, link_servers);
84e51726 40 LIST_HEAD(ServerName, fallback_servers);
e8af6973
LP
41
42 RateLimit ratelimit;
63463bf0 43 bool exhausted_servers;
e8af6973 44
e0e5ce23
TG
45 /* network */
46 sd_event_source *network_event_source;
47 sd_network_monitor *network_monitor;
48
e8af6973
LP
49 /* peer */
50 sd_resolve_query *resolve_query;
51 sd_event_source *event_receive;
52 ServerName *current_server_name;
53 ServerAddress *current_server_address;
54 int server_socket;
e8206972 55 int missed_replies;
e8af6973
LP
56 uint64_t packet_count;
57 sd_event_source *event_timeout;
58
59 /* last sent packet */
60 struct timespec trans_time_mon;
61 struct timespec trans_time;
ab4df227 62 usec_t retry_interval;
e8af6973
LP
63 bool pending;
64
65 /* poll timer */
66 sd_event_source *event_timer;
67 usec_t poll_interval_usec;
68 bool poll_resync;
69
70 /* history data */
71 struct {
72 double offset;
73 double delay;
74 } samples[8];
75 unsigned int samples_idx;
76 double samples_jitter;
77
78 /* last change */
79 bool jumped;
d636d376 80 bool sync;
e8af6973
LP
81 int drift_ppm;
82
83 /* watch for time changes */
84 sd_event_source *event_clock_watch;
85 int clock_watch_fd;
86
87 /* Retry connections */
88 sd_event_source *event_retry;
c264aeab
KS
89
90 /* RTC runs in local time, leave it alone */
91 bool rtc_local_time;
e8af6973
LP
92};
93
84e51726
LP
94int manager_new(Manager **ret);
95void manager_free(Manager *m);
96
97DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
e8af6973 98
874ff7bf
LP
99void manager_set_server_name(Manager *m, ServerName *n);
100void manager_set_server_address(Manager *m, ServerAddress *a);
101void manager_flush_server_names(Manager *m, ServerType t);
102
84e51726
LP
103int manager_connect(Manager *m);
104void manager_disconnect(Manager *m);