}
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 */
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
/* 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;
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,
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);
/* ================================================== */
-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)
{
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);