From 292e38e2c61edcd14bfa30ca3c72bacda1bcbe32 Mon Sep 17 00:00:00 2001 From: Gilbert Ramirez Date: Thu, 11 May 2000 08:18:09 +0000 Subject: Add tvbuff class. Add exceptions routines. Convert proto_tree_add_*() routines to require tvbuff_t* argument. Convert all dissectors to pass NULL argument ("NullTVB" macro == NULL) as the tvbuff_t* argument to proto_tree_add_*() routines. dissect_packet() creates a tvbuff_t, wraps the next dissect call in a TRY block, will print "Short Frame" on the proto_tree if a BoundsError exception is caught. The FDDI dissector is converted to use tvbuff's. svn path=/trunk/; revision=1939 --- packet-ntp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'packet-ntp.c') diff --git a/packet-ntp.c b/packet-ntp.c index 463d2a6a9c..751a44b927 100644 --- a/packet-ntp.c +++ b/packet-ntp.c @@ -2,7 +2,7 @@ * Routines for NTP packet dissection * Copyright 1999, Nathan Neulinger * - * $Id: packet-ntp.c,v 1.11 2000/04/08 07:07:32 guy Exp $ + * $Id: packet-ntp.c,v 1.12 2000/05/11 08:15:30 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -255,21 +255,21 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) if (tree) { /* Adding NTP item and subtree */ - ti = proto_tree_add_item(tree, proto_ntp, offset, END_OF_FRAME, NULL); + ti = proto_tree_add_item(tree, proto_ntp, NullTVB, offset, END_OF_FRAME, NULL); ntp_tree = proto_item_add_subtree(ti, ett_ntp); - tf = proto_tree_add_item(ntp_tree, hf_ntp_flags, offset, 1, pkt->flags); + tf = proto_tree_add_item(ntp_tree, hf_ntp_flags, NullTVB, offset, 1, pkt->flags); /* Adding flag subtree and items */ flags_tree = proto_item_add_subtree(tf, ett_ntp_flags); - proto_tree_add_uint_format(flags_tree, hf_ntp_flags_li, offset, 1, + proto_tree_add_uint_format(flags_tree, hf_ntp_flags_li, NullTVB, offset, 1, *pkt->flags & NTP_LI_MASK, decode_enumerated_bitfield(*pkt->flags, NTP_LI_MASK, sizeof(pkt->flags) * 8, li_types, "Leap Indicator: %s")); - proto_tree_add_uint_format(flags_tree, hf_ntp_flags_vn, offset, 1, + proto_tree_add_uint_format(flags_tree, hf_ntp_flags_vn, NullTVB, offset, 1, *pkt->flags & NTP_VN_MASK, decode_enumerated_bitfield(*pkt->flags, NTP_VN_MASK, sizeof(pkt->flags) * 8, ver_nums, "Version number: %s")); - proto_tree_add_uint_format(flags_tree, hf_ntp_flags_mode, offset, 1, + proto_tree_add_uint_format(flags_tree, hf_ntp_flags_mode, NullTVB, offset, 1, *pkt->flags & NTP_MODE_MASK, decode_enumerated_bitfield(*pkt->flags, NTP_MODE_MASK, sizeof(pkt->flags) * 8, mode_types, "Mode: %s")); @@ -285,12 +285,12 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) } else { strcpy (buff, "Peer Clock Stratum: reserved: %d"); } - proto_tree_add_bytes_format(ntp_tree, hf_ntp_stratum, offset+1, 1, pkt->stratum, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_stratum, NullTVB, offset+1, 1, pkt->stratum, buff, (int) *pkt->stratum); /* Poll interval, 1byte field indicating the maximum interval between * successive messages, in seconds to the nearest power of two. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_ppoll, offset+2, 1, pkt->ppoll, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_ppoll, NullTVB, offset+2, 1, pkt->ppoll, (((*pkt->ppoll >= 4) && (*pkt->ppoll <= 16)) ? "Peer Pooling Interval: %d (%d sec)" : "Peer Pooling Interval: invalid (%d)"), (int) *pkt->ppoll, @@ -298,13 +298,13 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) /* Precision, 1byte field indicating the precision of the * local clock, in seconds to the nearest power of two. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_precision, offset+3, 1, pkt->precision, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_precision, NullTVB, offset+3, 1, pkt->precision, "Peer Clock Precision: %8.6f sec", pow(2, *pkt->precision)); /* Root Delay is a 32-bit signed fixed-point number indicating the * total roundtrip delay to the primary reference source, in seconds * with fraction point between bits 15 and 16. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_rootdelay, offset+4, 4, pkt->rootdelay, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_rootdelay, NullTVB, offset+4, 4, pkt->rootdelay, "Root Delay: %9.4f sec", ((gint32) pntohs(pkt->rootdelay)) + pntohs(pkt->rootdelay + 2) / 65536.0); @@ -312,7 +312,7 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) * the nominal error relative to the primary reference source, in * seconds with fraction point between bits 15 and 16. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_rootdispersion, offset+8, 4, pkt->rootdispersion, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_rootdispersion, NullTVB, offset+8, 4, pkt->rootdispersion, "Clock Dispersion: %9.4f sec", ((gint32) pntohs(pkt->rootdispersion)) + pntohs(pkt->rootdispersion + 2) / 65536.0); @@ -335,30 +335,30 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) } } else strcpy (buff, get_hostname (pntohl(pkt->refid))); - proto_tree_add_bytes_format(ntp_tree, hf_ntp_refid, offset+12, 4, pkt->refid, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_refid, NullTVB, offset+12, 4, pkt->refid, "Reference Clock ID: %s", buff); /* Reference Timestamp: This is the time at which the local clock was * last set or corrected. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_reftime, offset+16, 8, pkt->reftime, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_reftime, NullTVB, offset+16, 8, pkt->reftime, "Reference Clock Update Time: %s", ntp_fmt_ts(pkt->reftime, buff)); /* Originate Timestamp: This is the time at which the request departed * the client for the server. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_org, offset+24, 8, pkt->org, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_org, NullTVB, offset+24, 8, pkt->org, "Originate Time Stamp: %s", ntp_fmt_ts(pkt->org, buff)); /* Receive Timestamp: This is the time at which the request arrived at * the server. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_rec, offset+32, 8, pkt->rec, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_rec, NullTVB, offset+32, 8, pkt->rec, "Receive Time Stamp: %s", ntp_fmt_ts(pkt->rec, buff)); /* Transmit Timestamp: This is the time at which the reply departed the * server for the client. */ - proto_tree_add_bytes_format(ntp_tree, hf_ntp_xmt, offset+40, 8, pkt->xmt, + proto_tree_add_bytes_format(ntp_tree, hf_ntp_xmt, NullTVB, offset+40, 8, pkt->xmt, "Transmit Time Stamp: %s", ntp_fmt_ts(pkt->xmt, buff)); @@ -368,9 +368,9 @@ dissect_ntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) * hex code for now. */ if ( BYTES_ARE_IN_FRAME(offset, 50) ) - proto_tree_add_item(ntp_tree, hf_ntp_keyid, offset+48, 4, pkt->keyid); + proto_tree_add_item(ntp_tree, hf_ntp_keyid, NullTVB, offset+48, 4, pkt->keyid); if ( BYTES_ARE_IN_FRAME(offset, 53) ) - proto_tree_add_item(ntp_tree, hf_ntp_mac, offset+52, END_OF_FRAME, pkt->mac); + proto_tree_add_item(ntp_tree, hf_ntp_mac, NullTVB, offset+52, END_OF_FRAME, pkt->mac); } } -- cgit v1.2.3