Add option to trim RTC automatically

This commit is contained in:
Miroslav Lichvar
2013-11-27 17:33:03 +01:00
parent 61dbdd80b9
commit 162c6a49b5
4 changed files with 74 additions and 0 deletions

25
conf.c
View File

@@ -90,6 +90,7 @@ static void parse_pidfile(char *);
static void parse_port(char *);
static void parse_refclock(char *);
static void parse_reselectdist(char *);
static void parse_rtcautotrim(char *);
static void parse_rtcdevice(char *);
static void parse_rtcfile(char *);
static void parse_rtconutc(char *);
@@ -158,6 +159,9 @@ static int rtc_sync = 0;
static int make_step_limit = 0;
static double make_step_threshold = 0.0;
/* Threshold for automatic RTC trimming */
static double rtc_autotrim_threshold = 0.0;
/* Number of updates before offset checking, number of ignored updates
before exiting and the maximum allowed offset */
static int max_offset_delay = -1;
@@ -441,6 +445,8 @@ CNF_ReadFile(const char *filename)
parse_refclock(p);
} else if (!strcasecmp(command, "reselectdist")) {
parse_reselectdist(p);
} else if (!strcasecmp(command, "rtcautotrim")) {
parse_rtcautotrim(p);
} else if (!strcasecmp(command, "rtcdevice")) {
parse_rtcdevice(p);
} else if (!strcasecmp(command, "rtcfile")) {
@@ -789,6 +795,17 @@ parse_keyfile(char *line)
/* ================================================== */
static void
parse_rtcautotrim(char *line)
{
check_number_of_args(line, 1);
if (sscanf(line, "%lf", &rtc_autotrim_threshold) != 1) {
command_parse_error();
}
}
/* ================================================== */
static void
parse_rtcfile(char *line)
{
@@ -1586,6 +1603,14 @@ CNF_GetKeysFile(void)
/* ================================================== */
double
CNF_GetRtcAutotrim(void)
{
return rtc_autotrim_threshold;
}
/* ================================================== */
char *
CNF_GetRtcFile(void)
{