]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Store reference IDs in uint32_t
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 13 Jun 2011 13:34:16 +0000 (15:34 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 13 Jun 2011 13:34:16 +0000 (15:34 +0200)
16 files changed:
acquire.c
broadcast.c
client.c
conf.c
ntp_core.c
refclock.c
refclock.h
reference.c
reference.h
reports.h
sources.c
sources.h
sourcestats.c
sourcestats.h
util.c
util.h

index 742f0f836b976b418a9bf0475ed20091fa9796c3..6b38fe399af718157b72979fb5d1db9b9df27bdf 100644 (file)
--- a/acquire.c
+++ b/acquire.c
@@ -270,7 +270,7 @@ probe_source(SourceRecord *src)
   pkt.precision = -6; /* as ntpdate */
   pkt.root_delay = double_to_int32(1.0); /* 1 second */
   pkt.root_dispersion = double_to_int32(1.0); /* likewise */
-  pkt.reference_id = 0UL;
+  pkt.reference_id = 0;
   pkt.reference_ts.hi = 0; /* Set to 0 */
   pkt.reference_ts.lo = 0; /* Set to 0 */
   pkt.originate_ts.hi = 0; /* Set to 0 */
index 1e3314bbabba77a0be2e379b69a763a0e835c4e3..6b022a00eee2b3aa368d475d7674e819254b8f18 100644 (file)
@@ -73,7 +73,7 @@ timeout_handler(void *arbitrary)
   int leap;
   int are_we_synchronised, our_stratum;
   NTP_Leap leap_status;
-  unsigned long our_ref_id;
+  uint32_t our_ref_id;
   struct timeval our_ref_time;
   double our_root_delay, our_root_dispersion;
   struct timeval local_transmit;
index 0f8424715f452e73fffc20b3fa5edd60d9a2e06c..77bdd425fdf2be1f3ab6a5f676495cfb270ecd71 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1789,7 +1789,7 @@ process_cmd_sourcestats(char *line)
   char hostname_buf[50];
   unsigned long n_samples, n_runs, span_seconds;
   double resid_freq_ppm, skew_ppm, sd, est_offset;
-  unsigned long ref_id;
+  uint32_t ref_id;
   IPAddr ip_addr;
 
   verbose = check_for_verbose_flag(line);
@@ -1868,7 +1868,7 @@ process_cmd_tracking(char *line)
   CMD_Request request;
   CMD_Reply reply;
   IPAddr ip_addr;
-  unsigned long ref_id;
+  uint32_t ref_id;
   char host[50];
   char *ref_ip;
   struct timeval ref_time;
diff --git a/conf.c b/conf.c
index f898cbade2c1f178ff4ef3785e9cc0d89546a3f2..d69855084a07227897d1cf9f16150f6f238e89ba 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -468,7 +468,7 @@ static void
 parse_refclock(const char *line)
 {
   int i, n, poll, dpoll, filter_length, pps_rate;
-  unsigned long ref_id, lock_ref_id;
+  uint32_t ref_id, lock_ref_id;
   double offset, delay, precision;
   const char *tmp;
   char cmd[10 + 1], *name, *param;
index eec6d9c3eb770e70ac48ceb1460e11cc10155820..75c4b77ad73e100e27df05ba6dd372c459b1c551 100644 (file)
@@ -515,7 +515,7 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
   /* Parameters read from reference module */
   int are_we_synchronised, our_stratum;
   NTP_Leap leap_status;
-  unsigned long our_ref_id;
+  uint32_t our_ref_id;
   struct timeval our_ref_time;
   double our_root_delay, our_root_dispersion;
 
index 4f8226be8c45fdd4e05d42875c2206770d535f34..6a47ff11205ae84a48f9ddd6432699bbeae7b396 100644 (file)
@@ -74,8 +74,8 @@ struct RCL_Instance_Record {
   int leap_status;
   int pps_rate;
   struct MedianFilter filter;
-  unsigned long ref_id;
-  unsigned long lock_ref;
+  uint32_t ref_id;
+  uint32_t lock_ref;
   double offset;
   double delay;
   double precision;
@@ -279,7 +279,7 @@ void
 RCL_ReportSource(RPT_SourceReport *report, struct timeval *now)
 {
   int i;
-  unsigned long ref_id;
+  uint32_t ref_id;
 
   assert(report->ip_addr.family == IPADDR_INET4);
   ref_id = report->ip_addr.addr.in4;
@@ -420,7 +420,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
     int is_synchronised, stratum;
     double root_delay, root_dispersion, distance;
     NTP_Leap leap;
-    unsigned long ref_id;
+    uint32_t ref_id;
 
     /* Ignore the pulse if we are not well synchronized */
 
@@ -471,7 +471,7 @@ pps_stratum(RCL_Instance instance, struct timeval *tv)
   int is_synchronised, stratum, i;
   double root_delay, root_dispersion;
   NTP_Leap leap;
-  unsigned long ref_id;
+  uint32_t ref_id;
 
   REF_GetReferenceParams(tv, &is_synchronised, &leap, &stratum,
       &ref_id, &ref_time, &root_delay, &root_dispersion);
index a653006e97e529bdce49dfd45fae47b22f587661..fa90337840fc08ea65aec17c9afb78e3f5e9eebc 100644 (file)
@@ -38,8 +38,8 @@ typedef struct {
   int poll;
   int filter_length;
   int pps_rate;
-  unsigned long ref_id;
-  unsigned long lock_ref_id;
+  uint32_t ref_id;
+  uint32_t lock_ref_id;
   double offset;
   double delay;
   double precision;
index 2c58b3b590dfb13a6ad3a935c20caf87ed87b6de..b8841f4f17f2a7fec813280f71ec7f58b162a608 100644 (file)
@@ -45,7 +45,7 @@ static int local_stratum;
 static NTP_Leap our_leap_status;
 static int our_leap_sec;
 static int our_stratum;
-static unsigned long our_ref_id;
+static uint32_t our_ref_id;
 static IPAddr our_ref_ip;
 struct timeval our_ref_time; /* Stored relative to reference, NOT local time */
 static double our_offset;
@@ -516,7 +516,7 @@ write_log(struct timeval *ref_time, char *ref, int stratum, double freq, double
 void
 REF_SetReference(int stratum,
                  NTP_Leap leap,
-                 unsigned long ref_id,
+                 uint32_t ref_id,
                  IPAddr *ref_ip,
                  struct timeval *ref_time,
                  double offset,
@@ -741,7 +741,7 @@ REF_GetReferenceParams
  int *is_synchronised,
  NTP_Leap *leap_status,
  int *stratum,
- unsigned long *ref_id,
+ uint32_t *ref_id,
  struct timeval *ref_time,
  double *root_delay,
  double *root_dispersion
@@ -794,7 +794,7 @@ REF_GetReferenceParams
 
     *leap_status = LEAP_Unsynchronised;
     *stratum = 0;
-    *ref_id = 0UL;
+    *ref_id = 0;
     ref_time->tv_sec = ref_time->tv_usec = 0;
     /* These values seem to be standard for a client, and
        any peer or client of ours will ignore them anyway because
@@ -900,7 +900,7 @@ REF_GetTrackingReport(RPT_TrackingReport *rep)
 
   } else {
 
-    rep->ref_id = 0UL;
+    rep->ref_id = 0;
     rep->ip_addr.family = IPADDR_UNSPEC;
     rep->stratum = 0;
     rep->ref_time.tv_sec = 0;
index 5b507688b50752d97be3025d7c8efef4b2dc38c2..2b66f6ab734abd8266573572aacf01466db50e53 100644 (file)
@@ -71,7 +71,7 @@ extern void REF_GetReferenceParams
  int *is_synchronised,
  NTP_Leap *leap,
  int *stratum,
- unsigned long *ref_id,
+ uint32_t *ref_id,
  struct timeval *ref_time,
  double *root_delay,
  double *root_dispersion
@@ -105,7 +105,7 @@ extern void REF_SetReference
 (
  int stratum,
  NTP_Leap leap,
- unsigned long ref_id,
+ uint32_t ref_id,
  IPAddr *ref_ip,
  struct timeval *ref_time,
  double offset,
index ff3c2f862c36df7456b679899f48d503e9ccba89..4b4f55e75b8e20daf2df379c157c32a993f1f928 100644 (file)
--- a/reports.h
+++ b/reports.h
@@ -46,7 +46,7 @@ typedef struct {
 } RPT_SourceReport ;
 
 typedef struct {
-  unsigned long ref_id;
+  uint32_t ref_id;
   IPAddr ip_addr;
   unsigned long stratum;
   struct timeval ref_time;
@@ -59,7 +59,7 @@ typedef struct {
 } RPT_TrackingReport;
 
 typedef struct {
-  unsigned long ref_id;
+  uint32_t ref_id;
   IPAddr ip_addr;
   unsigned long n_samples;
   unsigned long n_runs;
index 5b022f37186bb797fa430568858aa4592bd488b0..6ebd62040f524a109941d151f9af44e2747e2847 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -84,8 +84,8 @@ struct SRC_Instance_Record {
   SST_Stats stats;
   NTP_Leap leap_status;         /* Leap status */
   int index;                    /* Index back into the array of source */
-  unsigned long ref_id;         /* The reference ID of this source
-                                   (i.e. its IP address, NOT the
+  uint32_t ref_id;              /* The reference ID of this source
+                                   (i.e. from its IP address, NOT the
                                    reference _it_ is sync'd to) */
   IPAddr *ip_addr;              /* Its IP address if NTP source */
 
@@ -183,7 +183,7 @@ void SRC_Finalise(void)
 /* Function to create a new instance.  This would be called by one of
    the individual source-type instance creation routines. */
 
-SRC_Instance SRC_CreateNewInstance(unsigned long ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr)
+SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr)
 {
   SRC_Instance result;
 
@@ -420,10 +420,10 @@ source_to_string(SRC_Instance inst)
    of sources we are holding. 
    
    Updates are only made to the local reference if a new source is selected
-   or match_addr is equal to the selected reference source address */
+   or match_refid is equal to the selected reference source refid */
 
 void
-SRC_SelectSource(unsigned long match_addr)
+SRC_SelectSource(uint32_t match_refid)
 {
   int i, j, index, old_selected_index;
   struct timeval now, ref_time;
@@ -783,8 +783,8 @@ SRC_SelectSource(unsigned long match_addr)
 
             /* Update score, but only for source pairs where one source
                has a new sample */
-            if (sources[i]->ref_id == match_addr ||
-                sources[selected_source_index]->ref_id == match_addr) {
+            if (sources[i]->ref_id == match_refid ||
+                sources[selected_source_index]->ref_id == match_refid) {
 
               sources[i]->sel_score *= sel_src_distance / distance;
 
@@ -803,7 +803,7 @@ SRC_SelectSource(unsigned long match_addr)
 
 #if 0
           LOG(LOGS_INFO, LOGF_Sources, "select score=%f refid=%lx match_refid=%lx status=%d dist=%f",
-              sources[i]->sel_score, sources[i]->ref_id, match_addr, sources[i]->status, distance);
+              sources[i]->sel_score, sources[i]->ref_id, match_refid, sources[i]->status, distance);
 #endif
         
           if (max_score < sources[i]->sel_score) {
@@ -840,9 +840,9 @@ SRC_SelectSource(unsigned long match_addr)
         sources[selected_source_index]->status = SRC_SYNC;
 
         /* Update local reference only when a new source was selected or a new
-           sample was received (i.e. match_addr is equal to selected ref_id) */
+           sample was received (i.e. match_refid is equal to selected refid) */
         if (selected_source_index != old_selected_index ||
-            match_addr == sources[selected_source_index]->ref_id) {
+            match_refid == sources[selected_source_index]->ref_id) {
 
           /* Now just use the statistics of the selected source for
              trimming the local clock */
index ec9833823b03dd5225d7294586324d9a8328a740..e96a9421911494a4e0ff36ed7bb942f47ada3aeb 100644 (file)
--- a/sources.h
+++ b/sources.h
@@ -61,7 +61,7 @@ typedef enum {
 /* Function to create a new instance.  This would be called by one of
    the individual source-type instance creation routines. */
 
-extern SRC_Instance SRC_CreateNewInstance(unsigned long ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr);
+extern SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr);
 
 /* Function to get rid of a source when it is being unconfigured.
    This may cause the current reference source to be reselected, if this
@@ -135,7 +135,7 @@ extern void SRC_ResetReachability(SRC_Instance inst);
    reference source address. (This avoids updating the frequency
    tracking for every sample from other sources - only the ones from
    the selected reference make a difference) */
-extern void SRC_SelectSource(unsigned long match_addr);
+extern void SRC_SelectSource(uint32_t match_refid);
 
 /* Force reselecting the best source */
 extern void SRC_ReselectSource(void);
index e36356a612b5faad67a6a17f3f04a724aa5f02fd..257b6f5a32bde3a8a2370480d7ef3f365c93eeae 100644 (file)
@@ -58,7 +58,7 @@ static LOG_FileID logfileid;
 struct SST_Stats_Record {
 
   /* Reference ID and IP address of source, used for logging to statistics log */
-  unsigned long refid;
+  uint32_t refid;
   IPAddr *ip_addr;
 
   /* Number of samples currently stored.  The samples are stored in circular
@@ -173,7 +173,7 @@ SST_Finalise(void)
 /* This function creates a new instance of the statistics handler */
 
 SST_Stats
-SST_CreateInstance(unsigned long refid, IPAddr *addr)
+SST_CreateInstance(uint32_t refid, IPAddr *addr)
 {
   SST_Stats inst;
   inst = MallocNew(struct SST_Stats_Record);
index 740a3c1c8188bfbb5964d9697122e361bb29ffd3..e523a39f2300263cd100dbe0ee1271cf4fe9d842 100644 (file)
@@ -38,7 +38,7 @@ extern void SST_Initialise(void);
 extern void SST_Finalise(void);
 
 /* This function creates a new instance of the statistics handler */
-extern SST_Stats SST_CreateInstance(unsigned long refid, IPAddr *addr);
+extern SST_Stats SST_CreateInstance(uint32_t refid, IPAddr *addr);
 
 /* This function deletes an instance of the statistics handler. */
 extern void SST_DeleteInstance(SST_Stats inst);
diff --git a/util.c b/util.c
index 0761c94e7351be6a36bf270cf9c3898bb51a4430..33bc28f257d708860081357522633e8633925acf 100644 (file)
--- a/util.c
+++ b/util.c
@@ -240,7 +240,7 @@ UTI_TimestampToString(NTP_int64 *ts)
 /* ================================================== */
 
 char *
-UTI_RefidToString(unsigned long ref_id)
+UTI_RefidToString(uint32_t ref_id)
 {
   unsigned int i, j, c;
   char buf[5], *result;
@@ -333,7 +333,7 @@ UTI_StringToIP(const char *addr, IPAddr *ip)
 
 /* ================================================== */
 
-unsigned long
+uint32_t
 UTI_IPToRefid(IPAddr *ip)
 {
   MD5_CTX ctx;
diff --git a/util.h b/util.h
index 8c0171a8f0451e37d75909aaf41ea113c921541d..249e7781484ff6c02d232a8bfe50be6c95155c8e 100644 (file)
--- a/util.h
+++ b/util.h
@@ -71,13 +71,13 @@ extern char *UTI_TimevalToString(struct timeval *tv);
 extern char *UTI_TimestampToString(NTP_int64 *ts);
 
 /* Convert ref_id into a temporary string, for diagnostics */
-extern char *UTI_RefidToString(unsigned long ref_id);
+extern char *UTI_RefidToString(uint32_t ref_id);
 
 /* Convert an IP address to string, for diagnostics */
 extern char *UTI_IPToString(IPAddr *ip);
 
 extern int UTI_StringToIP(const char *addr, IPAddr *ip);
-extern unsigned long UTI_IPToRefid(IPAddr *ip);
+extern uint32_t UTI_IPToRefid(IPAddr *ip);
 extern void UTI_IPHostToNetwork(IPAddr *src, IPAddr *dest);
 extern void UTI_IPNetworkToHost(IPAddr *src, IPAddr *dest);
 extern int UTI_CompareIPs(IPAddr *a, IPAddr *b, IPAddr *mask);