Fix printing refclocks and IPv6 sources in statistics log

This commit is contained in:
Miroslav Lichvar 2009-11-30 17:18:28 +01:00
parent 19651dc767
commit 0f9892fe7a
5 changed files with 7 additions and 22 deletions

View file

@ -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 */

View 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,

View 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);

16
util.c
View file

@ -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)
{

1
util.h
View file

@ -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);