]> git.ipfire.org Git - thirdparty/chrony.git/blob - ntp_sources.h
conf: rework allow/deny parser
[thirdparty/chrony.git] / ntp_sources.h
1 /*
2 chronyd/chronyc - Programs for keeping computer clocks accurate.
3
4 **********************************************************************
5 * Copyright (C) Richard P. Curnow 1997-2002
6 * Copyright (C) Miroslav Lichvar 2014
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 **********************************************************************
22
23 =======================================================================
24
25 Header for the part of the software that deals with the set of
26 current NTP servers and peers, which can resolve an IP address into
27 a source record for further processing.
28
29 */
30
31 #ifndef GOT_NTP_SOURCES_H
32 #define GOT_NTP_SOURCES_H
33
34 #include "ntp.h"
35 #include "addressing.h"
36 #include "srcparams.h"
37 #include "ntp_core.h"
38 #include "reports.h"
39
40 /* Status values returned by operations that indirectly result from user
41 input. */
42 typedef enum {
43 NSR_Success, /* Operation successful */
44 NSR_NoSuchSource, /* Remove - attempt to remove a source that is not known */
45 NSR_AlreadyInUse, /* AddSource - attempt to add a source that is already known */
46 NSR_TooManySources, /* AddSource - too many sources already present */
47 NSR_InvalidAF, /* AddSource - attempt to add a source with invalid address family */
48 NSR_InvalidName, /* AddSourceByName - attempt to add a source with invalid name */
49 NSR_UnresolvedName, /* AddSourceByName - name will be resolved later */
50 } NSR_Status;
51
52 /* Procedure to add a new server or peer source. */
53 extern NSR_Status NSR_AddSource(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
54 SourceParameters *params, uint32_t *conf_id);
55
56 /* Procedure to add a new server, peer source, or pool of servers specified by
57 name instead of address. The name is resolved in exponentially increasing
58 intervals until it succeeds or fails with a non-temporary error. If the
59 name is an address, it is equivalent to NSR_AddSource(). */
60 extern NSR_Status NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type,
61 SourceParameters *params, uint32_t *conf_id);
62
63 /* Function type for handlers to be called back when an attempt
64 * (possibly unsuccessful) to resolve unresolved sources ends */
65 typedef void (*NSR_SourceResolvingEndHandler)(void);
66
67 /* Set the handler, or NULL to disable the notification */
68 extern void NSR_SetSourceResolvingEndHandler(NSR_SourceResolvingEndHandler handler);
69
70 /* Procedure to start resolving unresolved sources */
71 extern void NSR_ResolveSources(void);
72
73 /* Procedure to start all sources */
74 extern void NSR_StartSources(void);
75
76 /* Start new sources automatically */
77 extern void NSR_AutoStartSources(void);
78
79 /* Procedure to remove a source */
80 extern NSR_Status NSR_RemoveSource(IPAddr *address);
81
82 /* Procedure to remove all sources matching a configuration ID */
83 extern void NSR_RemoveSourcesById(uint32_t conf_id);
84
85 /* Procedure to remove all sources */
86 extern void NSR_RemoveAllSources(void);
87
88 /* Procedure to try to find a replacement for a bad source */
89 extern void NSR_HandleBadSource(IPAddr *address);
90
91 /* Procedure to resolve all names again */
92 extern void NSR_RefreshAddresses(void);
93
94 /* Procedure to update the address of a source. The update may be
95 postponed. */
96 extern NSR_Status NSR_UpdateSourceNtpAddress(NTP_Remote_Address *old_addr,
97 NTP_Remote_Address *new_addr);
98
99 /* Procedure to get local reference ID corresponding to a source */
100 extern uint32_t NSR_GetLocalRefid(IPAddr *address);
101
102 /* Procedure to get the name of a source as it was specified (it may be
103 an IP address) */
104 extern char *NSR_GetName(IPAddr *address);
105
106 /* This routine is called by ntp_io when a new packet arrives off the network */
107 extern void NSR_ProcessRx(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
108 NTP_Local_Timestamp *rx_ts, NTP_Packet *message, int length);
109
110 /* This routine is called by ntp_io when a packet was sent to the network and
111 an accurate transmit timestamp was captured */
112 extern void NSR_ProcessTx(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
113 NTP_Local_Timestamp *tx_ts, NTP_Packet *message, int length);
114
115 /* Initialisation function */
116 extern void NSR_Initialise(void);
117
118 /* Finalisation function */
119 extern void NSR_Finalise(void);
120
121 /* This routine is used to indicate that sources whose IP addresses
122 match a particular subnet should be set online or offline. It returns
123 a flag indicating whether any hosts matched the address. */
124 extern int NSR_SetConnectivity(IPAddr *mask, IPAddr *address, SRC_Connectivity connectivity);
125
126 extern int NSR_ModifyMinpoll(IPAddr *address, int new_minpoll);
127
128 extern int NSR_ModifyMaxpoll(IPAddr *address, int new_maxpoll);
129
130 extern int NSR_ModifyMaxdelay(IPAddr *address, double new_max_delay);
131
132 extern int NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio);
133
134 extern int NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_ratio);
135
136 extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
137
138 extern int NSR_ModifyPolltarget(IPAddr *address, int new_poll_target);
139
140 extern int NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples, IPAddr *mask, IPAddr *address);
141
142 extern void NSR_ReportSource(RPT_SourceReport *report, struct timespec *now);
143
144 extern int NSR_GetAuthReport(IPAddr *address, RPT_AuthReport *report);
145
146 extern int NSR_GetNTPReport(RPT_NTPReport *report);
147
148 extern void NSR_GetActivityReport(RPT_ActivityReport *report);
149
150 extern void NSR_DumpAuthData(void);
151
152 #endif /* GOT_NTP_SOURCES_H */