* Routines for NTP packet dissection
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
*
- * $Id: packet-ntp.c,v 1.29 2001/07/15 19:14:00 guy Exp $
+ * $Id: packet-ntp.c,v 1.36 2002/08/02 23:35:55 jmayer Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Copied from packet-tftp.c
#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
#include <string.h>
#include <time.h>
#include <math.h>
# include "snprintf.h"
#endif
-#include "packet.h"
-#include "resolv.h"
+#include <epan/packet.h>
+#include <epan/resolv.h>
#include "packet-ntp.h"
/*
} else {
temptime = tempstmp - (guint32) NTP_BASETIME;
bd = gmtime(&temptime);
- if (bd != NULL) {
- fractime = bd->tm_sec + tempfrac / 4294967296.0;
- snprintf(buff, NTP_TS_SIZE, "%04d-%02d-%02d %02d:%02d:%07.4f UTC",
- bd->tm_year + 1900, bd->tm_mon + 1, bd->tm_mday,
- bd->tm_hour, bd->tm_min, fractime);
- } else {
- strncpy(buff, "Not representable", NTP_TS_SIZE);
- }
+ if (bd != NULL) {
+ fractime = bd->tm_sec + tempfrac / 4294967296.0;
+ snprintf(buff, NTP_TS_SIZE,
+ "%04d-%02d-%02d %02d:%02d:%07.4f UTC",
+ bd->tm_year + 1900, bd->tm_mon + 1, bd->tm_mday,
+ bd->tm_hour, bd->tm_min, fractime);
+ } else
+ strncpy(buff, "Not representable", NTP_TS_SIZE);
}
return buff;
}
double rootdelay;
double rootdispersion;
const guint8 *refid;
+ guint32 refid_addr;
const guint8 *reftime;
const guint8 *org;
const guint8 *rec;
gchar buff[NTP_TS_SIZE];
int i;
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "NTP");
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "NTP");
- if (check_col(pinfo->fd, COL_INFO))
- col_set_str(pinfo->fd, COL_INFO, "NTP");
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_set_str(pinfo->cinfo, COL_INFO, "NTP");
if (tree) {
/* Adding NTP item and subtree */
- ti = proto_tree_add_item(tree, proto_ntp, tvb, 0,
- tvb_length(tvb), FALSE);
+ ti = proto_tree_add_item(tree, proto_ntp, tvb, 0, -1, FALSE);
ntp_tree = proto_item_add_subtree(ti, ett_ntp);
flags = tvb_get_guint8(tvb, 0);
}
} else {
buff[sizeof(buff) - 1] = '\0';
- strncpy (buff, get_hostname (htonl(tvb_get_ntohl(tvb, 12))),
+ tvb_memcpy(tvb, (guint8 *)&refid_addr, 12, 4);
+ strncpy (buff, get_hostname (refid_addr),
sizeof(buff));
if (buff[sizeof(buff) - 1] != '\0')
strcpy(&buff[sizeof(buff) - 4], "...");
void
proto_reg_handoff_ntp(void)
{
- dissector_add("udp.port", UDP_PORT_NTP, dissect_ntp, proto_ntp);
- dissector_add("tcp.port", TCP_PORT_NTP, dissect_ntp, proto_ntp);
+ dissector_handle_t ntp_handle;
+
+ ntp_handle = create_dissector_handle(dissect_ntp, proto_ntp);
+ dissector_add("udp.port", UDP_PORT_NTP, ntp_handle);
+ dissector_add("tcp.port", TCP_PORT_NTP, ntp_handle);
}