]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Fix printing refclocks and IPv6 sources in statistics log
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 30 Nov 2009 16:18:28 +0000 (17:18 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 30 Nov 2009 16:18:28 +0000 (17:18 +0100)
sources.c
sourcestats.c
sourcestats.h
util.c
util.h

index 5abc5a21b03cbe18b8a3957ed7de48d6a12f9bd9..d898b89e02833666a9cd0600e61d2862b6ab63bf 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -170,7 +170,7 @@ SRC_Instance SRC_CreateNewInstance(unsigned long ref_id, SRC_Type type, IPAddr *
   }
 
   result = MallocNew(struct SRC_Instance_Record);
-  result->stats = SST_CreateInstance(ref_id);
+  result->stats = SST_CreateInstance(ref_id, addr);
 
   if (n_sources == max_n_sources) {
     /* Reallocate memory */
index 7260fdee4ec41aae7c185682de52cd92bfc8f4a3..c3ed1ead0e7db3880de92d2e3962bb151f7570b2 100644 (file)
@@ -66,8 +66,9 @@ static unsigned long logwrites = 0;
 
 struct SST_Stats_Record {
 
-  /* Reference ID of source, used for logging to statistics log */
+  /* Reference ID and IP address of source, used for logging to statistics log */
   unsigned long refid;
+  IPAddr *ip_addr;
 
   /* Number of samples currently stored.  sample[n_samples-1] is the
      newest.  The samples are expected to be sorted in order, but that
@@ -187,11 +188,12 @@ SST_Finalise(void)
 /* This function creates a new instance of the statistics handler */
 
 SST_Stats
-SST_CreateInstance(unsigned long refid)
+SST_CreateInstance(unsigned long refid, IPAddr *addr)
 {
   SST_Stats inst;
   inst = MallocNew(struct SST_Stats_Record);
   inst->refid = refid;
+  inst->ip_addr = addr;
   inst->n_samples = 0;
   inst->estimated_frequency = 0;
   inst->skew = 2000.0e-6;
@@ -473,7 +475,7 @@ SST_DoNewRegression(SST_Stats inst)
             
       fprintf(logfile, "%s %-15s %10.3e %10.3e %10.3e %10.3e %10.3e %7.1e %3d %3d %3d\n",
               UTI_TimeToLogForm(inst->offset_time.tv_sec),
-              UTI_IPToDottedQuad(inst->refid),
+              inst->ip_addr ? UTI_IPToString(inst->ip_addr) : UTI_RefidToString(inst->refid),
               sqrt(inst->variance),
               inst->estimated_offset,
               inst->estimated_offset_sd,
index fd19c0ba648aa45c12679acdc55b48f659d1e331..6baf5b653488797148eaa3692a9771baa143d2c7 100644 (file)
@@ -42,7 +42,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);
+extern SST_Stats SST_CreateInstance(unsigned long 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 2acf7e7c2f1795d440f1fc48306f324fb292d900..199733be343de4ea9bec2ec1371da9314e31349b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -257,22 +257,6 @@ UTI_RefidToString(unsigned long ref_id)
 
 /* ================================================== */
 
-char *
-UTI_IPToDottedQuad(unsigned long ip)
-{
-  unsigned long a, b, c, d;
-  char *result;
-  a = (ip>>24) & 0xff;
-  b = (ip>>16) & 0xff;
-  c = (ip>> 8) & 0xff;
-  d = (ip>> 0) & 0xff;
-  result = NEXT_BUFFER;
-  snprintf(result, BUFFER_LENGTH, "%ld.%ld.%ld.%ld", a, b, c, d);
-  return result;
-}
-
-/* ================================================== */
-
 char *
 UTI_IPToString(IPAddr *addr)
 {
diff --git a/util.h b/util.h
index 6427686bf1165beea68a5c5227e37d8f5cc3b4f5..31e790c1a5655fb96d973223ce8d4588ea6968a8 100644 (file)
--- a/util.h
+++ b/util.h
@@ -78,7 +78,6 @@ extern char *UTI_TimestampToString(NTP_int64 *ts);
 extern char *UTI_RefidToString(unsigned long ref_id);
 
 /* Convert an IP address to string, for diagnostics */
-extern char *UTI_IPToDottedQuad(unsigned long ip);
 extern char *UTI_IPToString(IPAddr *ip);
 
 extern int UTI_StringToIP(const char *addr, IPAddr *ip);