From 6f3317f40e457286de194b0aeaf98f3099a842b5 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 7 Apr 2006 15:19:43 +0000 Subject: Change latency to MS. Change 'pingData' MIB to simple 'ping' --- module/bsnmp-ping.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'module/bsnmp-ping.c') diff --git a/module/bsnmp-ping.c b/module/bsnmp-ping.c index d63e0a9..012db5c 100644 --- a/module/bsnmp-ping.c +++ b/module/bsnmp-ping.c @@ -67,7 +67,7 @@ static struct lmodule *module; /* OIDs */ -static const struct asn_oid oid_ping = OIDX_pingData; +static const struct asn_oid oid_ping = OIDX_ping; /* the Object Resource registration index */ static u_int reg_index = 0; @@ -127,9 +127,23 @@ static void emsg(const char *format, ...) { va_list va; - va_start(va, format); - vsyslog(LOG_ERR, format, va); - va_end(va); + va_start (va, format); + vsyslog (LOG_ERR, format, va); + va_end (va); +} + +static uint64_t +get_current_ms () +{ + struct timeval tv; + + if (gettimeofday (&tv, NULL) < 0) { + emsg ("couldn't get current time: %s", strerror (errno)); + return get_ticks () * 10; + } + + return ((uint64_t)(tv.tv_sec)) * 1000 + + ((uint64_t)(tv.tv_usec)) / 1000; } /* ----------------------------------------------------------------------------- @@ -180,7 +194,7 @@ process_icmp (u_char *packet, int len, struct sockaddr_in *from) triptime = -1; - ctime = get_ticks (); + ctime = get_current_ms (); #ifndef icmp_data tp = &icp->icmp_ip; @@ -323,7 +337,7 @@ ping_fire (void *user_data) icp->icmp_id = ping->index; /* ID */ /* Include the current time in the packet */ - ptime = get_ticks (); + ptime = get_current_ms (); memcpy (icmp_packet + ICMP_MINLEN, &ptime, sizeof (ptime)); CLR (ping->ck_table, seq % MAX_DUP_CHK); -- cgit v1.2.3