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 */
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;
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);
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;
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;
/* 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;
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;
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;
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 */
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);
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;
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;
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,
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
*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
} else {
- rep->ref_id = 0UL;
+ rep->ref_id = 0;
rep->ip_addr.family = IPADDR_UNSPEC;
rep->stratum = 0;
rep->ref_time.tv_sec = 0;
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
(
int stratum,
NTP_Leap leap,
- unsigned long ref_id,
+ uint32_t ref_id,
IPAddr *ref_ip,
struct timeval *ref_time,
double offset,
} RPT_SourceReport ;
typedef struct {
- unsigned long ref_id;
+ uint32_t ref_id;
IPAddr ip_addr;
unsigned long stratum;
struct timeval ref_time;
} RPT_TrackingReport;
typedef struct {
- unsigned long ref_id;
+ uint32_t ref_id;
IPAddr ip_addr;
unsigned long n_samples;
unsigned long n_runs;
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 */
/* 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;
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;
/* 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;
#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) {
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 */
/* 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
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);
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
/* 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);
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);
/* ================================================== */
char *
-UTI_RefidToString(unsigned long ref_id)
+UTI_RefidToString(uint32_t ref_id)
{
unsigned int i, j, c;
char buf[5], *result;
/* ================================================== */
-unsigned long
+uint32_t
UTI_IPToRefid(IPAddr *ip)
{
MD5_CTX ctx;
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);