summaryrefslogtreecommitdiff
path: root/module/bsnmp-ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/bsnmp-ping.c')
-rw-r--r--module/bsnmp-ping.c26
1 files changed, 20 insertions, 6 deletions
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);