[chrony-dev] [RFC PATCH v1 05/17] conf: Add configuration options enabling use of pre-configured auxiliary clocks

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Add a new configuration directive: auxclockid. This enables use of auxiliary clocks on Linux builds. To
support use of pre-configured auxiliary clocks one option is implemented: 'set'. The 'set' option
specifies the clock ID of the auxiliary clock and assumes that the user has already configured the clock.

This patch adds CNF_GetClockId() returning the configured clock ID. Internal methods get_auxclockid_last()
and get_auxclockid_first() call OS specific code to determine the range of auxiliary clocks are available.
Each compile target should have code in these internal methods to implement support for auxiliary clocks.
---
 conf.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 conf.h |  3 +++
 2 files changed, 87 insertions(+)

diff --git a/conf.c b/conf.c
index b19bd20..2b428af 100644
--- a/conf.c
+++ b/conf.c
@@ -62,6 +62,9 @@ static void parse_double(char *line, double *result);
 static void parse_null(char *line, int *result);
 static void parse_ints(char *line, ARR_Instance array, int min, int max);
 
+#ifdef FEAT_AUXCLOCK
+static void parse_auxclockid(char *line, int *enable, int *clockid);
+#endif
 static void parse_allow_deny(char *line, ARR_Instance restrictions, int allow);
 static void parse_authselectmode(char *);
 static void parse_bindacqaddress(char *);
@@ -93,6 +96,11 @@ static void parse_source(char *line, char *type, int fatal);
 static void parse_sourcedir(char *);
 static void parse_tempcomp(char *);
 
+#ifdef FEAT_AUXCLOCK
+static int get_auxclockid_first(int *clockid);
+static int get_auxclockid_last(int *clockid);
+#endif
+
 /* ================================================== */
 /* Configuration variables */
 
@@ -111,6 +119,10 @@ static double max_clock_error = 1.0; /* in ppm */
 static double max_drift = 500000.0; /* in ppm */
 static double max_slew_rate = 1e6 / 12.0; /* in ppm */
 static double clock_precision = 0.0; /* in seconds */
+#ifdef FEAT_AUXCLOCK
+static int use_auxclock = 0;
+static int auxclock_id;
+#endif
 
 static SRC_AuthSelectMode authselect_mode = SRC_AUTHSELECT_MIX;
 static double max_distance = 3.0;
@@ -610,6 +622,10 @@ CNF_ParseLine(const char *filename, int number, char *line)
     parse_allow_deny(p, ntp_restrictions, 1);
   } else if (!strcasecmp(command, "authselectmode")) {
     parse_authselectmode(p);
+#ifdef FEAT_AUXCLOCK
+  } else if (!strcasecmp(command, "auxclockid")) {
+    parse_auxclockid(p, &use_auxclock, &auxclock_id);
+#endif
   } else if (!strcasecmp(command, "bindacqaddress")) {
     parse_bindacqaddress(p);
   } else if (!strcasecmp(command, "bindacqdevice")) {
@@ -1684,6 +1700,43 @@ parse_hwtimestamp(char *line)
 
 /* ================================================== */
 
+#ifdef FEAT_AUXCLOCK
+
+static void parse_auxclockid(char *subcmd, int *enable, int *clockid)
+{
+  int arg_count;
+  char *arg = NULL;
+
+  arg_count = get_number_of_args(subcmd);
+  switch (arg_count) {
+  default:
+  case 1:
+    command_parse_error();
+    break;
+  case 2:
+    arg = CPS_SplitWord(subcmd);
+    break;
+  }
+
+  *enable = 0;
+  if (!strcasecmp(subcmd, "set") && arg_count == 2) {
+    int first_clockid, last_clockid;
+
+    if (get_auxclockid_first(&first_clockid) || get_auxclockid_last(&last_clockid))
+      other_parse_error("AUX clock ID specified, but allowed IDs is unknown\n");
+    parse_int(arg, clockid, first_clockid, last_clockid);
+    *enable = 1;
+  } else if (!strcasecmp(subcmd, "off")) {
+    ;
+  } else {
+    command_parse_error();
+  }
+}
+
+#endif /* FEAT_AUXCLOCK */
+
+/* ================================================== */
+
 static void
 parse_pidfile(char *line)
 {
@@ -2919,3 +2972,34 @@ CNF_GetNoCertTimeCheck(void)
 {
   return no_cert_time_check;
 }
+
+/* ================================================== */
+
+#ifdef FEAT_AUXCLOCK
+
+static int
+get_auxclockid_first(int *clockid)
+{
+  return -1;
+}
+
+/* ================================================== */
+
+static int
+get_auxclockid_last(int *clockid)
+{
+  return -1;
+}
+
+/* ================================================== */
+
+const int*
+CNF_GetAuxClockId()
+{
+  if (use_auxclock) {
+    return &auxclock_id;
+  }
+  return NULL;
+}
+
+#endif
diff --git a/conf.h b/conf.h
index 4b2ad21..613851e 100644
--- a/conf.h
+++ b/conf.h
@@ -181,5 +181,8 @@ extern int CNF_GetNtsRotate(void);
 extern int CNF_GetNtsTrustedCertsPaths(const char ***paths, uint32_t **ids);
 extern int CNF_GetNoSystemCert(void);
 extern int CNF_GetNoCertTimeCheck(void);
+#ifdef FEAT_AUXCLOCK
+extern const int *CNF_GetAuxClockId(void);
+#endif
 
 #endif /* GOT_CONF_H */
-- 
2.34.1


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/