]> git.ipfire.org Git - thirdparty/chrony.git/blame - sources.h
ntp: fix log message for replaced source
[thirdparty/chrony.git] / sources.h
CommitLineData
88840341 1/*
88840341
RC
2 chronyd/chronyc - Programs for keeping computer clocks accurate.
3
4 **********************************************************************
5 * Copyright (C) Richard P. Curnow 1997-2002
cb74f3e7 6 * Copyright (C) Miroslav Lichvar 2014
88840341
RC
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.,
8e23110a 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
88840341
RC
20 *
21 **********************************************************************
22
23 =======================================================================
24
25 This is the header for the module that manages the collection of all
26 sources that we are making measurements from. This include all NTP
27 servers & peers, locally connected reference sources, eye/wristwatch
28 drivers etc */
29
30#ifndef GOT_SOURCES_H
31#define GOT_SOURCES_H
32
33#include "sysincl.h"
34
35#include "ntp.h"
36#include "reports.h"
1045adaa 37#include "sourcestats.h"
88840341 38
70928dba
ML
39/* Size of the source reachability register */
40#define SOURCE_REACH_BITS 8
41
88840341
RC
42/* This datatype is used to hold information about sources. The
43 instance must be passed when calling many of the interface
44 functions */
45
46typedef struct SRC_Instance_Record *SRC_Instance;
47
48/* Initialisation function */
49extern void SRC_Initialise(void);
50
51/* Finalisation function */
52extern void SRC_Finalise(void);
53
ac30bb06
ML
54typedef enum {
55 SRC_NTP, /* NTP client/peer */
56 SRC_REFCLOCK /* Rerefence clock */
57} SRC_Type;
58
88840341
RC
59/* Function to create a new instance. This would be called by one of
60 the individual source-type instance creation routines. */
61
b06d74ab
ML
62extern SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, int sel_options,
63 IPAddr *addr, int min_samples, int max_samples,
64 double min_delay, double asymmetry);
88840341
RC
65
66/* Function to get rid of a source when it is being unconfigured.
67 This may cause the current reference source to be reselected, if this
68 was the reference source or contributed significantly to a
69 falseticker decision. */
70
71extern void SRC_DestroyInstance(SRC_Instance instance);
72
42dd5caa
ML
73/* Function to reset a source */
74extern void SRC_ResetInstance(SRC_Instance instance);
75
76/* Function to change the sources's reference ID and IP address */
77extern void SRC_SetRefid(SRC_Instance instance, uint32_t ref_id, IPAddr *addr);
88840341 78
1045adaa
ML
79/* Function to get access to the sourcestats instance */
80extern SST_Stats SRC_GetSourcestats(SRC_Instance instance);
88840341 81
2582be87
ML
82/* Function to set the current leap status according to the source */
83extern void SRC_SetLeapStatus(SRC_Instance instance, NTP_Leap leap);
84
85/* Function to accumulate a new sample from the source */
6bef8aa0 86extern void SRC_AccumulateSample(SRC_Instance instance, NTP_Sample *sample);
88840341 87
8671002b
ML
88/* This routine sets the source as receiving reachability updates */
89extern void SRC_SetActive(SRC_Instance inst);
90
91/* This routine sets the source as not receiving reachability updates */
92extern void SRC_UnsetActive(SRC_Instance inst);
93
0c4968ec
ML
94/* This routine updates the reachability register */
95extern void SRC_UpdateReachability(SRC_Instance inst, int reachable);
96
97/* This routine marks the source unreachable */
98extern void SRC_ResetReachability(SRC_Instance inst);
88840341
RC
99
100/* This routine is used to select the best source from amongst those
101 we currently have valid data on, and use it as the tracking base
e930d947
ML
102 for the local time. Updates are made to the local reference only
103 when the selected source was updated (set as updated_inst) since
104 the last reference update. This avoids updating the frequency
7f6ed731 105 tracking for every sample from other sources - only the ones from
e930d947 106 the selected reference make a difference. */
0094128c 107extern void SRC_SelectSource(SRC_Instance updated_inst);
88840341 108
6e96b4ba
ML
109/* Force reselecting the best source */
110extern void SRC_ReselectSource(void);
111
8d3d45ea
ML
112/* Set reselect distance */
113extern void SRC_SetReselectDistance(double distance);
114
88840341 115extern void SRC_DumpSources(void);
88840341 116extern void SRC_ReloadSources(void);
a06a5f1b 117extern void SRC_RemoveDumpFiles(void);
88840341 118
e7a25426
ML
119extern void SRC_ResetSources(void);
120
88840341 121extern int SRC_IsSyncPeer(SRC_Instance inst);
4e66b5ce 122extern int SRC_IsReachable(SRC_Instance inst);
88840341 123extern int SRC_ReadNumberOfSources(void);
8671002b 124extern int SRC_ActiveSources(void);
d0dfa1de 125extern int SRC_ReportSource(int index, RPT_SourceReport *report, struct timespec *now);
88840341 126
d0dfa1de 127extern int SRC_ReportSourcestats(int index, RPT_SourcestatsReport *report, struct timespec *now);
88840341 128
ac30bb06
ML
129extern SRC_Type SRC_GetType(int index);
130
88840341 131#endif /* GOT_SOURCES_H */