aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ntp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-12-06 03:18:24 +0000
committerGuy Harris <guy@alum.mit.edu>1999-12-06 03:18:24 +0000
commit9cff0cb1375a1925a65b132304d901f3fa323796 (patch)
treed4b21450d6d5e8734aa0c0c16af0008a4e28f248 /packet-ntp.c
parent0de40f3c42483faf969bde48e5869df06d7e1cf6 (diff)
When dissecting the reference clock ID field:
if it's stratum 0 or 1, use "memcmp()" to compare it against the strings in our table, rather than assuming it's aligned on a 4-byte boundary and doing an integral comparison - neither of the strings being compared are necessarily so aligned - and, if it doesn't match any of them, include the value in the "Unidentified reference source" description; if it's stratum 2 or higher, extract the value with "pntohl()" before interpreting it as an IP address - IP addresses are in network byte order, and, again, it's not necessarily neatly aligned on a 4-byte boundary. svn path=/trunk/; revision=1223
Diffstat (limited to 'packet-ntp.c')
-rw-r--r--packet-ntp.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/packet-ntp.c b/packet-ntp.c
index b511fdbce0..e1aa4cdfeb 100644
--- a/packet-ntp.c
+++ b/packet-ntp.c
@@ -2,7 +2,7 @@
* Routines for NTP packet dissection
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
*
- * $Id: packet-ntp.c,v 1.5 1999/11/16 11:42:43 guy Exp $
+ * $Id: packet-ntp.c,v 1.6 1999/12/06 03:18:24 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -320,11 +320,18 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
* level server. My decision was to resolve this address.
*/
if (*pkt->stratum <= 1) {
- strcpy (buff, "unindentified reference source");
- for (i = 0; primary_sources[i].id; i++)
- if (*((guint32 *) pkt->refid) == *((guint32 *) primary_sources[i].id))
- strcpy (buff, primary_sources[i].data);
- } else strcpy (buff, get_hostname (*((u_int *) pkt->refid)));
+ snprintf (buff, sizeof buff,
+ "Unindentified reference source '%.4s'",
+ pkt->refid);
+ for (i = 0; primary_sources[i].id; i++) {
+ if (memcmp (pkt->refid, primary_sources[i].id,
+ 4) == 0) {
+ strcpy (buff, primary_sources[i].data);
+ break;
+ }
+ }
+ } else
+ strcpy (buff, get_hostname (pntohl(pkt->refid)));
proto_tree_add_item_format(ntp_tree, hf_ntp_refid, offset+12, 4, pkt->refid,
"Reference Clock ID: %s", buff);
/* Reference Timestamp: This is the time at which the local clock was