diff --git a/acquire.c b/acquire.c index 742f0f8..6b38fe3 100644 --- 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 */ diff --git a/broadcast.c b/broadcast.c index 1e3314b..6b022a0 100644 --- a/broadcast.c +++ b/broadcast.c @@ -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; diff --git a/client.c b/client.c index 0f84247..77bdd42 100644 --- 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 f898cba..d698550 100644 --- 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; diff --git a/ntp_core.c b/ntp_core.c index eec6d9c..75c4b77 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -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; diff --git a/refclock.c b/refclock.c index 4f8226b..6a47ff1 100644 --- a/refclock.c +++ b/refclock.c @@ -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); diff --git a/refclock.h b/refclock.h index a653006..fa90337 100644 --- a/refclock.h +++ b/refclock.h @@ -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; diff --git a/reference.c b/reference.c index 2c58b3b..b8841f4 100644 --- a/reference.c +++ b/reference.c @@ -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; diff --git a/reference.h b/reference.h index 5b50768..2b66f6a 100644 --- a/reference.h +++ b/reference.h @@ -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, diff --git a/reports.h b/reports.h index ff3c2f8..4b4f55e 100644 --- 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; diff --git a/sources.c b/sources.c index 5b022f3..6ebd620 100644 --- 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 */ diff --git a/sources.h b/sources.h index ec98338..e96a942 100644 --- 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); diff --git a/sourcestats.c b/sourcestats.c index e36356a..257b6f5 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -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); diff --git a/sourcestats.h b/sourcestats.h index 740a3c1..e523a39 100644 --- a/sourcestats.h +++ b/sourcestats.h @@ -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 0761c94..33bc28f 100644 --- 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 8c0171a..249e778 100644 --- 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);