Move "bytes_to_str()" to "strutil.c" from "packet.c" - it's just a
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 13 Nov 2000 07:19:37 +0000 (07:19 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 13 Nov 2000 07:19:37 +0000 (07:19 +0000)
string formatter, like "format_text()", and, as "tvbuff.c" now calls it
(*vide infra*), we don't want to have to make "tvbuff.c" drag "packet.h"
in just to declare "bytes_to_str()".  It's now declared in "strutil.h",
so include it in modules that use "bytes_to_str()" and weren't already
including it.

Add a "tvb_bytes_to_str()" wrapper that calls "tvb_get_ptr()" to get a
pointer to a chunk of N bytes at a given offset in a tvbuff and then
hands that chunk to "bytes_to_str()".  Convert the code that was doing
that to use "tvb_bytes_to_str()" instead (which caught what I suspect is
a bug in the Q.2931 dissector, where it was handing an offset of 0 to
"tvb_get_ptr()" - a cut-and-pasteo, I think).

Tvbuffify the ARP dissector.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2634 f5534014-38df-0310-8fa8-9805f1628bb7

18 files changed:
epan/packet.c
epan/packet.h
epan/proto.c
epan/strutil.c
epan/strutil.h
epan/tvbuff.c
epan/tvbuff.h
packet-aarp.c
packet-arp.c
packet-arp.h
packet-atm.c
packet-cdp.c
packet-ipp.c
packet-kerberos.c
packet-nfs.c
packet-q2931.c
packet-q931.c
packet-snmp.c

index 1a4f1d444b22487022e49eee4750d052eeba2a31..9c174514a0f09b1a56c12f5beb4466972228dc1e 100644 (file)
@@ -1,7 +1,7 @@
 /* packet.c
  * Routines for packet disassembly
  *
- * $Id: packet.c,v 1.3 2000/11/01 08:31:35 guy Exp $
+ * $Id: packet.c,v 1.4 2000/11/13 07:19:24 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -287,44 +287,6 @@ time_secs_to_str(guint32 time)
   return cur;
 }
 
-/* Max string length for displaying byte string.  */
-#define        MAX_BYTE_STR_LEN        32
-
-/* Turn an array of bytes into a string showing the bytes in hex. */
-#define        N_BYTES_TO_STR_STRINGS  6
-gchar *
-bytes_to_str(const guint8 *bd, int bd_len) {
-  static gchar  str[N_BYTES_TO_STR_STRINGS][MAX_BYTE_STR_LEN+3+1];
-  static int    cur_idx;
-  gchar        *cur;
-  gchar        *p;
-  int           len;
-  static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
-                                '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-
-  cur_idx++;
-  if (cur_idx >= N_BYTES_TO_STR_STRINGS)
-    cur_idx = 0;
-  cur = &str[cur_idx][0];
-  p = cur;
-  len = MAX_BYTE_STR_LEN;
-  while (bd_len > 0 && len > 0) {
-    *p++ = hex[(*bd) >> 4];
-    *p++ = hex[(*bd) & 0xF];
-    len -= 2;
-    bd++;
-    bd_len--;
-  }
-  if (bd_len != 0) {
-    /* Note that we're not showing the full string.  */
-    *p++ = '.';
-    *p++ = '.';
-    *p++ = '.';
-  }
-  *p = '\0';
-  return cur;
-}
-
 static const char *mon_names[12] = {
        "Jan",
        "Feb",
index 047e603b1159dccd4f85246635093df83b1f7ce5..3ab1f5f90ed363099e1e8c651b09561743563c43 100644 (file)
@@ -1,7 +1,7 @@
 /* packet.h
  * Definitions for packet disassembly structures and routines
  *
- * $Id: packet.h,v 1.3 2000/11/01 08:31:35 guy Exp $
+ * $Id: packet.h,v 1.4 2000/11/13 07:19:27 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -259,7 +259,6 @@ gchar*     ipx_addr_to_str(guint32, const guint8 *);
 gchar*    abs_time_to_str(struct timeval*);
 gchar*    rel_time_to_str(struct timeval*);
 gchar*     time_secs_to_str(guint32);
-gchar*     bytes_to_str(const guint8 *, int);
 gchar*     val_to_str(guint32, const value_string *, const char *);
 gchar*     match_strval(guint32, const value_string*);
 char * decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width);
index 89169e3d9ba60d7ba1344338cf48b6879b60da5f..67fbc3e706afffa1a8fa88d770eee8a5bb9d19cb 100644 (file)
@@ -1,7 +1,7 @@
 /* proto.c
  * Routines for protocol tree
  *
- * $Id: proto.c,v 1.2 2000/11/03 17:26:47 nneul Exp $
+ * $Id: proto.c,v 1.3 2000/11/13 07:19:29 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -40,6 +40,7 @@
 #endif
 
 #include "packet.h"
+#include "strutil.h"
 #include "resolv.h"
 #include "register.h"
 #include "packet-ipv6.h"
index a01c3453aec9e36ac1bec6e4f5d8e9a0590fc420..8c73202dd9aa4cc78595ff60d652db7b683f0f7f 100644 (file)
@@ -1,7 +1,7 @@
 /* strutil.c
  * String utility routines
  *
- * $Id: strutil.c,v 1.5 2000/11/10 06:50:37 guy Exp $
+ * $Id: strutil.c,v 1.6 2000/11/13 07:19:32 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -238,3 +238,41 @@ format_text(const u_char *string, int len)
   fmtbuf[column] = '\0';
   return fmtbuf;
 }
+
+/* Max string length for displaying byte string.  */
+#define        MAX_BYTE_STR_LEN        32
+
+/* Turn an array of bytes into a string showing the bytes in hex. */
+#define        N_BYTES_TO_STR_STRINGS  6
+gchar *
+bytes_to_str(const guint8 *bd, int bd_len) {
+  static gchar  str[N_BYTES_TO_STR_STRINGS][MAX_BYTE_STR_LEN+3+1];
+  static int    cur_idx;
+  gchar        *cur;
+  gchar        *p;
+  int           len;
+  static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
+                                '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+  cur_idx++;
+  if (cur_idx >= N_BYTES_TO_STR_STRINGS)
+    cur_idx = 0;
+  cur = &str[cur_idx][0];
+  p = cur;
+  len = MAX_BYTE_STR_LEN;
+  while (bd_len > 0 && len > 0) {
+    *p++ = hex[(*bd) >> 4];
+    *p++ = hex[(*bd) & 0xF];
+    len -= 2;
+    bd++;
+    bd_len--;
+  }
+  if (bd_len != 0) {
+    /* Note that we're not showing the full string.  */
+    *p++ = '.';
+    *p++ = '.';
+    *p++ = '.';
+  }
+  *p = '\0';
+  return cur;
+}
index 10ff9477107ebf141fbef4bee2655e81221fd360..652f07e0f75e115fafc69dcc943be2a5774be772 100644 (file)
@@ -1,7 +1,7 @@
 /* strutil.h
  * String utility definitions
  *
- * $Id: strutil.h,v 1.4 2000/11/10 06:50:37 guy Exp $
+ * $Id: strutil.h,v 1.5 2000/11/13 07:19:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -41,6 +41,6 @@ const u_char *find_line_end(const u_char *data, const u_char *dataend,
 int        get_token_len(const u_char *linep, const u_char *lineend,
     const u_char **next_token);
 gchar*     format_text(const u_char *line, int len);
-
+gchar*     bytes_to_str(const guint8 *, int);
 
 #endif /* __STRUTIL_H__ */
index 6b72151d187443ce33e7018c83ec00ef952201f7..5e4fddaa444c4a41f42c3adf2c11b615de5c8bb3 100644 (file)
@@ -9,7 +9,7 @@
  *             the data of a backing tvbuff, or can be a composite of
  *             other tvbuffs.
  *
- * $Id: tvbuff.c,v 1.7 2000/11/12 00:59:09 guy Exp $
+ * $Id: tvbuff.c,v 1.8 2000/11/13 07:19:35 guy Exp $
  *
  * Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
  *
@@ -1468,3 +1468,13 @@ tvb_find_line_end_unquoted(tvbuff_t *tvb, gint offset, int len,
        }
        return linelen;
 }
+
+/*
+ * Format a bunch of data from a tvbuff as bytes, returning a pointer
+ * to the string with the formatted data.
+ */
+gchar *
+tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len)
+{
+       return bytes_to_str(tvb_get_ptr(tvb, offset, len), len);
+}
index 43b32c4074c645a332f4bd63ca7c0340ddbea345..5d43a0b4c477fe98c36f181431d75dda57f49059 100644 (file)
@@ -9,7 +9,7 @@
  *             the data of a backing tvbuff, or can be a composite of
  *             other tvbuffs.
  *
- * $Id: tvbuff.h,v 1.5 2000/11/11 19:55:48 guy Exp $
+ * $Id: tvbuff.h,v 1.6 2000/11/13 07:19:37 guy Exp $
  *
  * Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
  *
@@ -325,6 +325,12 @@ gint tvb_strneql(tvbuff_t *tvb, gint offset, const guint8 *str, gint size);
 /* Call strncasecmp after checking if enough chars left, otherwise return -1 */
 gint tvb_strncaseeql(tvbuff_t *tvb, gint offset, const guint8 *str, gint size);
 
+/*
+ * Format a bunch of data from a tvbuff as bytes, returning a pointer
+ * to the string with the formatted data.
+ */
+gchar *tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len);
+
 /************** END OF ACCESSORS ****************/
 
 /* Sets pd and offset so that tvbuff's can be used with code
index fe56cc5144afe37512953f12d4ca3ecd3a473496..d32ba746965c0bb978e434fc53211297bb3f788e 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-aarp.c
  * Routines for Appletalk ARP packet disassembly
  *
- * $Id: packet-aarp.c,v 1.23 2000/11/13 04:26:53 guy Exp $
+ * $Id: packet-aarp.c,v 1.24 2000/11/13 07:18:37 guy Exp $
  *
  * Simon Wilkinson <sxw@dcs.ed.ac.uk>
  *
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <glib.h>
 #include "packet.h"
+#include "strutil.h"
 #include "etypes.h"
 
 static int proto_aarp = -1;
index 85edad04e6081f23d09b2377758ad073cbbc07cb..84c7239ee845a5eb3b670d15cdaf095e49f1b89f 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-arp.c
  * Routines for ARP packet disassembly
  *
- * $Id: packet-arp.c,v 1.33 2000/08/13 14:07:58 deniel Exp $
+ * $Id: packet-arp.c,v 1.34 2000/11/13 07:18:38 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -33,6 +33,7 @@
 
 #include <glib.h>
 #include "packet.h"
+#include "strutil.h"
 #include "resolv.h"
 #include "packet-arp.h"
 #include "etypes.h"
@@ -278,7 +279,7 @@ arphrdtype_to_str(guint16 hwtype, const char *fmt) {
 #define MIN_ATMARP_HEADER_SIZE 12
 
 static void
-dissect_atm_number(const u_char *pd, int offset, int tl, int hf_e164,
+dissect_atm_number(tvbuff_t *tvb, int offset, int tl, int hf_e164,
     int hf_nsap, proto_tree *tree)
 {
        int len = tl & ATMARP_LEN_MASK;
@@ -286,76 +287,78 @@ dissect_atm_number(const u_char *pd, int offset, int tl, int hf_e164,
        proto_tree *nsap_tree;
 
        if (tl & ATMARP_IS_E164)
-               proto_tree_add_string(tree, hf_e164, NullTVB, offset, len, &pd[offset]);
+               proto_tree_add_item(tree, hf_e164, tvb, offset, len, FALSE);
        else {
-               ti = proto_tree_add_bytes(tree, hf_nsap, NullTVB, offset, len,
-                   &pd[offset]);
+               ti = proto_tree_add_item(tree, hf_nsap, tvb, offset, len, FALSE);
                if (len >= 20) {
                        nsap_tree = proto_item_add_subtree(ti, ett_atmarp_nsap);
-                       dissect_atm_nsap(pd, offset, len, nsap_tree);
+                       dissect_atm_nsap(tvb, offset, len, nsap_tree);
                }
        }
 }
 
 void
-dissect_atm_nsap(const u_char *pd, int offset, int len, proto_tree *tree)
+dissect_atm_nsap(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
 {
-       switch (pd[offset]) {
+       guint8 afi;
+
+       afi = tvb_get_guint8(tvb, offset);
+       switch (afi) {
 
        case 0x39:      /* DCC ATM format */
        case 0xBD:      /* DCC ATM group format */
-               proto_tree_add_text(tree, NullTVB, offset + 0, 3,
+               proto_tree_add_text(tree, tvb, offset + 0, 3,
                    "Data Country Code%s: 0x%04X",
-                   (pd[offset] == 0xBD) ? " (group)" : "",
-                   pntohs(&pd[offset + 1]));
-               proto_tree_add_text(tree, NullTVB, offset + 3, 10,
+                   (afi == 0xBD) ? " (group)" : "",
+                   tvb_get_ntohs(tvb, offset + 1));
+               proto_tree_add_text(tree, tvb, offset + 3, 10,
                    "High Order DSP: %s",
-                   bytes_to_str(&pd[offset + 3], 10));
-               proto_tree_add_text(tree, NullTVB, offset + 13, 6,
+                   tvb_bytes_to_str(tvb, offset + 3, 10));
+               proto_tree_add_text(tree, tvb, offset + 13, 6,
                    "End System Identifier: %s",
-                   bytes_to_str(&pd[offset + 13], 6));
-               proto_tree_add_text(tree, NullTVB, offset + 19, 1,
-                   "Selector: 0x%02X", pd[offset + 19]);
+                   tvb_bytes_to_str(tvb, offset + 13, 6));
+               proto_tree_add_text(tree, tvb, offset + 19, 1,
+                   "Selector: 0x%02X", tvb_get_guint8(tvb, offset + 19));
                break;
 
        case 0x47:      /* ICD ATM format */
        case 0xC5:      /* ICD ATM group format */
-               proto_tree_add_text(tree, NullTVB, offset + 0, 3,
+               proto_tree_add_text(tree, tvb, offset + 0, 3,
                    "International Code Designator%s: 0x%04X",
-                   (pd[offset] == 0xC5) ? " (group)" : "",
-                   pntohs(&pd[offset + 1]));
-               proto_tree_add_text(tree, NullTVB, offset + 3, 10,
+                   (afi == 0xC5) ? " (group)" : "",
+                   tvb_get_ntohs(tvb, offset + 1));
+               proto_tree_add_text(tree, tvb, offset + 3, 10,
                    "High Order DSP: %s",
-                   bytes_to_str(&pd[offset + 3], 10));
-               proto_tree_add_text(tree, NullTVB, offset + 13, 6,
+                   tvb_bytes_to_str(tvb, offset + 3, 10));
+               proto_tree_add_text(tree, tvb, offset + 13, 6,
                    "End System Identifier: %s",
-                   bytes_to_str(&pd[offset + 13], 6));
-               proto_tree_add_text(tree, NullTVB, offset + 19, 1,
-                   "Selector: 0x%02X", pd[offset + 19]);
+                   tvb_bytes_to_str(tvb, offset + 13, 6));
+               proto_tree_add_text(tree, tvb, offset + 19, 1,
+                   "Selector: 0x%02X", tvb_get_guint8(tvb, offset + 19));
                break;
 
        case 0x45:      /* E.164 ATM format */
        case 0xC3:      /* E.164 ATM group format */
-               proto_tree_add_text(tree, NullTVB, offset + 0, 9,
+               proto_tree_add_text(tree, tvb, offset + 0, 9,
                    "E.164 ISDN%s: %s",
-                   (pd[offset] == 0xC3) ? " (group)" : "",
-                   bytes_to_str(&pd[offset + 1], 8));
-               proto_tree_add_text(tree, NullTVB, offset + 9, 4,
+                   (afi == 0xC3) ? " (group)" : "",
+                   tvb_bytes_to_str(tvb, offset + 1, 8));
+               proto_tree_add_text(tree, tvb, offset + 9, 4,
                    "High Order DSP: %s",
-                   bytes_to_str(&pd[offset + 3], 10));
-               proto_tree_add_text(tree, NullTVB, offset + 13, 6,
+                   tvb_bytes_to_str(tvb, offset + 3, 10));
+               proto_tree_add_text(tree, tvb, offset + 13, 6,
                    "End System Identifier: %s",
-                   bytes_to_str(&pd[offset + 13], 6));
-               proto_tree_add_text(tree, NullTVB, offset + 19, 1,
-                   "Selector: 0x%02X", pd[offset + 19]);
+                   tvb_bytes_to_str(tvb, offset + 13, 6));
+               proto_tree_add_text(tree, tvb, offset + 19, 1,
+                   "Selector: 0x%02X", tvb_get_guint8(tvb, offset + 19));
                break;
 
        default:
-               proto_tree_add_text(tree, NullTVB, offset, 1,
-                   "Unknown AFI: 0x%02X", pd[offset]);
-               proto_tree_add_text(tree, NullTVB, offset + 1, len - 1,
+               proto_tree_add_text(tree, tvb, offset, 1,
+                   "Unknown AFI: 0x%02X", afi);
+               proto_tree_add_text(tree, tvb, offset + 1, len - 1,
                    "Rest of address: %s",
-                   bytes_to_str(&pd[offset + 1], len - 1));
+                   tvb_bytes_to_str(tvb, offset + 1, len - 1));
                break;
        }
 }
@@ -364,7 +367,7 @@ dissect_atm_nsap(const u_char *pd, int offset, int len, proto_tree *tree)
  * RFC 2225 ATMARP - it's just like ARP, except where it isn't.
  */
 static void
-dissect_atmarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_atmarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
   guint16     ar_hrd;
   guint16     ar_pro;
@@ -385,95 +388,113 @@ dissect_atmarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
   gchar       *op_str;
   int         sha_offset, ssa_offset, spa_offset;
   int         tha_offset, tsa_offset, tpa_offset;
+  guint8      *sha_val, *ssa_val, *spa_val;
+  guint8      *tha_val, *tsa_val, *tpa_val;
   gchar       *sha_str, *ssa_str, *spa_str;
   gchar       *tha_str, *tsa_str, *tpa_str;
 
-  if (!BYTES_ARE_IN_FRAME(offset, MIN_ATMARP_HEADER_SIZE)) {
-    old_dissect_data(pd, offset, fd, tree);
-    return;
-  }
+  CHECK_DISPLAY_AS_DATA(proto_arp, tvb, pinfo, tree);
+
+  pinfo->current_proto = "ATMARP";
 
-  ar_hrd = pntohs(&pd[offset + ATM_AR_HRD]);
-  ar_pro = pntohs(&pd[offset + ATM_AR_PRO]);
-  ar_shtl = (guint8) pd[offset + ATM_AR_SHTL];
+  ar_hrd = tvb_get_ntohs(tvb, ATM_AR_HRD);
+  ar_pro = tvb_get_ntohs(tvb, ATM_AR_PRO);
+  ar_shtl = tvb_get_guint8(tvb, ATM_AR_SHTL);
   ar_sht = ar_shtl & ATMARP_IS_E164;
   ar_shl = ar_shtl & ATMARP_LEN_MASK;
-  ar_ssl = (guint8) pd[offset + ATM_AR_SSL];
-  ar_op  = pntohs(&pd[offset + AR_OP]);
-  ar_spln = (guint8) pd[offset + ATM_AR_SPLN];
-  ar_thtl = (guint8) pd[offset + ATM_AR_THTL];
+  ar_ssl = tvb_get_guint8(tvb, ATM_AR_SSL);
+  ar_op  = tvb_get_ntohs(tvb, AR_OP);
+  ar_spln = tvb_get_guint8(tvb, ATM_AR_SPLN);
+  ar_thtl = tvb_get_guint8(tvb, ATM_AR_THTL);
   ar_tht = ar_thtl & ATMARP_IS_E164;
   ar_thl = ar_thtl & ATMARP_LEN_MASK;
-  ar_tsl = (guint8) pd[offset + ATM_AR_TSL];
-  ar_tpln = (guint8) pd[offset + ATM_AR_TPLN];
+  ar_tsl = tvb_get_guint8(tvb, ATM_AR_TSL);
+  ar_tpln = tvb_get_guint8(tvb, ATM_AR_TPLN);
 
   tot_len = MIN_ATMARP_HEADER_SIZE + ar_shtl + ar_ssl + ar_spln +
                                ar_thtl + ar_tsl + ar_tpln;
-  if (!BYTES_ARE_IN_FRAME(offset, tot_len)) {
-    old_dissect_data(pd, offset, fd, tree);
-    return;
-  }
 
   /* Extract the addresses.  */
-  sha_offset = offset + MIN_ATMARP_HEADER_SIZE;
-  if (ar_shl != 0)
-    sha_str = atmarpnum_to_str((guint8 *) &pd[sha_offset], ar_shtl);
-  else
+  sha_offset = MIN_ATMARP_HEADER_SIZE;
+  if (ar_shl != 0) {
+    sha_val = tvb_get_ptr(tvb, sha_offset, ar_shl);
+    sha_str = atmarpnum_to_str(sha_val, ar_shtl);
+  } else {
+    sha_val = NULL;
     sha_str = "<No address>";
+  }
+
   ssa_offset = sha_offset + ar_shl;
-  if (ar_ssl != 0)
-    ssa_str = atmarpsubaddr_to_str((guint8 *) &pd[ssa_offset], ar_ssl);
-  else
+  if (ar_ssl != 0) {
+    ssa_val = tvb_get_ptr(tvb, ssa_offset, ar_ssl);
+    ssa_str = atmarpsubaddr_to_str(ssa_val, ar_ssl);
+  } else {
+    ssa_val = NULL;
     ssa_str = NULL;
+  }
+
   spa_offset = ssa_offset + ar_ssl;
-  spa_str = arpproaddr_to_str((guint8 *) &pd[spa_offset], ar_spln, ar_pro);
+  spa_val = tvb_get_ptr(tvb, spa_offset, ar_spln);
+  spa_str = arpproaddr_to_str(spa_val, ar_spln, ar_pro);
+
   tha_offset = spa_offset + ar_spln;
-  if (ar_thl != 0)
-    tha_str = atmarpnum_to_str((guint8 *) &pd[tha_offset], ar_thtl);
-  else
+  if (ar_thl != 0) {
+    tha_val = tvb_get_ptr(tvb, tha_offset, ar_thl);
+    tha_str = atmarpnum_to_str(tha_val, ar_thtl);
+  } else {
+    tha_val = NULL;
     tha_str = "<No address>";
+  }
+
   tsa_offset = tha_offset + ar_thl;
-  if (ar_tsl != 0)
-    tsa_str = atmarpsubaddr_to_str((guint8 *) &pd[tsa_offset], ar_tsl);
-  else
+  if (ar_tsl != 0) {
+    tsa_val = tvb_get_ptr(tvb, tsa_offset, ar_tsl);
+    tsa_str = atmarpsubaddr_to_str(tsa_val, ar_tsl);
+  } else {
+    tsa_val = NULL;
     tsa_str = NULL;
+  }
+
   tpa_offset = tsa_offset + ar_tsl;
-  tpa_str = arpproaddr_to_str((guint8 *) &pd[tpa_offset], ar_tpln, ar_pro);
+  tpa_val = tvb_get_ptr(tvb, tpa_offset, ar_tpln);
+  tpa_str = arpproaddr_to_str(tpa_val, ar_tpln, ar_pro);
   
-  if (check_col(fd, COL_PROTOCOL)) {
+  if (check_col(pinfo->fd, COL_PROTOCOL)) {
     switch (ar_op) {
 
     case ARPOP_REQUEST:
     case ARPOP_REPLY:
     case ATMARPOP_NAK:
     default:
-      col_add_str(fd, COL_PROTOCOL, "ATMARP");
+      col_add_str(pinfo->fd, COL_PROTOCOL, "ATMARP");
       break;
 
     case ARPOP_RREQUEST:
     case ARPOP_RREPLY:
-      col_add_str(fd, COL_PROTOCOL, "ATMRARP");
+      col_add_str(pinfo->fd, COL_PROTOCOL, "ATMRARP");
       break;
 
     case ARPOP_IREQUEST:
     case ARPOP_IREPLY:
-      col_add_str(fd, COL_PROTOCOL, "Inverse ATMARP");
+      col_add_str(pinfo->fd, COL_PROTOCOL, "Inverse ATMARP");
       break;
     }
   }
 
-  if (check_col(fd, COL_INFO)) {
+  if (check_col(pinfo->fd, COL_INFO)) {
     switch (ar_op) {
       case ARPOP_REQUEST:
-        col_add_fstr(fd, COL_INFO, "Who has %s?  Tell %s", tpa_str, spa_str);
+        col_add_fstr(pinfo->fd, COL_INFO, "Who has %s?  Tell %s",
+               tpa_str, spa_str);
         break;
       case ARPOP_REPLY:
-        col_add_fstr(fd, COL_INFO, "%s is at %s%s%s", spa_str, sha_str,
+        col_add_fstr(pinfo->fd, COL_INFO, "%s is at %s%s%s", spa_str, sha_str,
                ((ssa_str != NULL) ? "," : ""),
                ((ssa_str != NULL) ? ssa_str : ""));
         break;
       case ARPOP_IREQUEST:
-        col_add_fstr(fd, COL_INFO, "Who is %s%s%s?  Tell %s%s%s", tha_str,
+        col_add_fstr(pinfo->fd, COL_INFO, "Who is %s%s%s?  Tell %s%s%s",
+               tha_str,
                ((tsa_str != NULL) ? "," : ""),
                ((tsa_str != NULL) ? tsa_str : ""),
                sha_str,
@@ -481,76 +502,68 @@ dissect_atmarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
                ((ssa_str != NULL) ? ssa_str : ""));
         break;
       case ARPOP_IREPLY:
-        col_add_fstr(fd, COL_INFO, "%s%s%s is at %s", sha_str,
+        col_add_fstr(pinfo->fd, COL_INFO, "%s%s%s is at %s",
+               sha_str,
                ((ssa_str != NULL) ? "," : ""),
                ((ssa_str != NULL) ? ssa_str : ""),
                spa_str);
         break;
       case ATMARPOP_NAK:
-        col_add_fstr(fd, COL_INFO, "I don't know where %s is", spa_str);
+        col_add_fstr(pinfo->fd, COL_INFO, "I don't know where %s is", spa_str);
         break;
       default:
-        col_add_fstr(fd, COL_INFO, "Unknown ATMARP opcode 0x%04x", ar_op);
+        col_add_fstr(pinfo->fd, COL_INFO, "Unknown ATMARP opcode 0x%04x", ar_op);
         break;
     }
   }
 
   if (tree) {
     if ((op_str = match_strval(ar_op, atmop_vals)))
-      ti = proto_tree_add_protocol_format(tree, proto_arp, NullTVB, offset, tot_len,
+      ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len,
                                        "ATM Address Resolution Protocol (%s)", 
                                        op_str);
     else
-      ti = proto_tree_add_protocol_format(tree, proto_arp, NullTVB, offset, tot_len,
+      ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len,
                                      "ATM Address Resolution Protocol (opcode 0x%04x)", ar_op);
     arp_tree = proto_item_add_subtree(ti, ett_arp);
-    proto_tree_add_uint(arp_tree, hf_arp_hard_type, NullTVB, offset + ATM_AR_HRD, 2,
-                              ar_hrd);
-    proto_tree_add_uint(arp_tree, hf_arp_proto_type, NullTVB, offset + ATM_AR_PRO, 2,
-                              ar_pro);
-    proto_tree_add_uint(arp_tree, hf_atmarp_shtl, NullTVB, offset + ATM_AR_SHTL, 1,
-                              ar_shtl);
-    proto_tree_add_uint(arp_tree, hf_atmarp_ssl, NullTVB, offset + ATM_AR_SSL, 1,
-                              ar_ssl);
-    proto_tree_add_uint(arp_tree, hf_arp_opcode, NullTVB, offset + AR_OP,  2,
-                              ar_op);
-    proto_tree_add_uint(arp_tree, hf_atmarp_spln, NullTVB, offset + ATM_AR_SPLN, 1,
-                              ar_spln);
-    proto_tree_add_uint(arp_tree, hf_atmarp_thtl, NullTVB, offset + ATM_AR_THTL, 1,
-                              ar_thtl);
-    proto_tree_add_uint(arp_tree, hf_atmarp_tsl, NullTVB, offset + ATM_AR_TSL, 1,
-                              ar_tsl);
-    proto_tree_add_uint(arp_tree, hf_atmarp_tpln, NullTVB, offset + ATM_AR_TPLN, 1,
-                              ar_tpln);
+    proto_tree_add_uint(arp_tree, hf_arp_hard_type, tvb, ATM_AR_HRD, 2, ar_hrd);
+    proto_tree_add_uint(arp_tree, hf_arp_proto_type, tvb, ATM_AR_PRO, 2,ar_pro);
+    proto_tree_add_uint(arp_tree, hf_atmarp_shtl, tvb, ATM_AR_SHTL, 1, ar_shtl);
+    proto_tree_add_uint(arp_tree, hf_atmarp_ssl, tvb, ATM_AR_SSL, 1, ar_ssl);
+    proto_tree_add_uint(arp_tree, hf_arp_opcode, tvb, AR_OP,  2, ar_op);
+    proto_tree_add_uint(arp_tree, hf_atmarp_spln, tvb, ATM_AR_SPLN, 1, ar_spln);
+    proto_tree_add_uint(arp_tree, hf_atmarp_thtl, tvb, ATM_AR_THTL, 1, ar_thtl);
+    proto_tree_add_uint(arp_tree, hf_atmarp_tsl, tvb, ATM_AR_TSL, 1, ar_tsl);
+    proto_tree_add_uint(arp_tree, hf_atmarp_tpln, tvb, ATM_AR_TPLN, 1, ar_tpln);
     if (ar_shl != 0)
-      dissect_atm_number(pd, sha_offset, ar_shtl, hf_atmarp_src_atm_num_e164,
+      dissect_atm_number(tvb, sha_offset, ar_shtl, hf_atmarp_src_atm_num_e164,
                               hf_atmarp_src_atm_num_nsap, arp_tree);
     if (ar_ssl != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_atmarp_src_atm_subaddr, NullTVB, ssa_offset,
+      proto_tree_add_bytes_format(arp_tree, hf_atmarp_src_atm_subaddr, tvb, ssa_offset,
                               ar_ssl,
-                              &pd[ssa_offset],
+                              ssa_val,
                               "Sender ATM subaddress: %s", ssa_str);
     if (ar_spln != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_arp_src_proto, NullTVB, spa_offset, ar_spln,
-                              &pd[spa_offset],
+      proto_tree_add_bytes_format(arp_tree, hf_arp_src_proto, tvb, spa_offset, ar_spln,
+                              spa_val,
                               "Sender protocol address: %s", spa_str);
     if (ar_thl != 0)
-      dissect_atm_number(pd, tha_offset, ar_thtl, hf_atmarp_dst_atm_num_e164,
+      dissect_atm_number(tvb, tha_offset, ar_thtl, hf_atmarp_dst_atm_num_e164,
                               hf_atmarp_dst_atm_num_nsap, arp_tree);
     if (ar_tsl != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_atmarp_dst_atm_subaddr, NullTVB, tsa_offset,
+      proto_tree_add_bytes_format(arp_tree, hf_atmarp_dst_atm_subaddr, tvb, tsa_offset,
                               ar_tsl,
-                              &pd[tsa_offset],
+                              tsa_val,
                               "Target ATM subaddress: %s", tsa_str);
     if (ar_tpln != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_arp_dst_proto, NullTVB, tpa_offset, ar_tpln,
-                              &pd[tpa_offset],
+      proto_tree_add_bytes_format(arp_tree, hf_arp_dst_proto, tvb, tpa_offset, ar_tpln,
+                              tpa_val,
                               "Target protocol address: %s", tpa_str);
   }
 }
 
 static void
-dissect_arp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
   guint16     ar_hrd;
   guint16     ar_pro;
@@ -562,80 +575,81 @@ dissect_arp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
   proto_item  *ti;
   gchar       *op_str;
   int         sha_offset, spa_offset, tha_offset, tpa_offset;
+  guint8      *sha_val, *spa_val, *tha_val, *tpa_val;
   gchar       *sha_str, *spa_str, *tha_str, *tpa_str;
 
-  OLD_CHECK_DISPLAY_AS_DATA(proto_arp, pd, offset, fd, tree);
+  CHECK_DISPLAY_AS_DATA(proto_arp, tvb, pinfo, tree);
 
-  if (!BYTES_ARE_IN_FRAME(offset, MIN_ARP_HEADER_SIZE)) {
-    old_dissect_data(pd, offset, fd, tree);
-    return;
-  }
+  pinfo->current_proto = "ARP";
 
-  ar_hrd = pntohs(&pd[offset + AR_HRD]);
+  ar_hrd = tvb_get_ntohs(tvb, AR_HRD);
   if (ar_hrd == ARPHRD_ATM2225) {
-    dissect_atmarp(pd, offset, fd, tree);
+    dissect_atmarp(tvb, pinfo, tree);
     return;
   }
-  ar_pro = pntohs(&pd[offset + AR_PRO]);
-  ar_hln = (guint8) pd[offset + AR_HLN];
-  ar_pln = (guint8) pd[offset + AR_PLN];
-  ar_op  = pntohs(&pd[offset + AR_OP]);
+  ar_pro = tvb_get_ntohs(tvb, AR_PRO);
+  ar_hln = tvb_get_guint8(tvb, AR_HLN);
+  ar_pln = tvb_get_guint8(tvb, AR_PLN);
+  ar_op  = tvb_get_ntohs(tvb, AR_OP);
 
   tot_len = MIN_ARP_HEADER_SIZE + ar_hln*2 + ar_pln*2;
-  if (!BYTES_ARE_IN_FRAME(offset, tot_len)) {
-    old_dissect_data(pd, offset, fd, tree);
-    return;
-  }
 
   /* Extract the addresses.  */
-  sha_offset = offset + MIN_ARP_HEADER_SIZE;
-  sha_str = arphrdaddr_to_str((guint8 *) &pd[sha_offset], ar_hln, ar_hrd);
+  sha_offset = MIN_ARP_HEADER_SIZE;
+  sha_val = tvb_get_ptr(tvb, sha_offset, ar_hln);
+  sha_str = arphrdaddr_to_str(sha_val, ar_hln, ar_hrd);
+
   spa_offset = sha_offset + ar_hln;
-  spa_str = arpproaddr_to_str((guint8 *) &pd[spa_offset], ar_pln, ar_pro);
+  spa_val = tvb_get_ptr(tvb, spa_offset, ar_pln);
+  spa_str = arpproaddr_to_str(spa_val, ar_pln, ar_pro);
+
   tha_offset = spa_offset + ar_pln;
-  tha_str = arphrdaddr_to_str((guint8 *) &pd[tha_offset], ar_hln, ar_hrd);
+  tha_val = tvb_get_ptr(tvb, tha_offset, ar_hln);
+  tha_str = arphrdaddr_to_str(tha_val, ar_hln, ar_hrd);
+
   tpa_offset = tha_offset + ar_hln;
-  tpa_str = arpproaddr_to_str((guint8 *) &pd[tpa_offset], ar_pln, ar_pro);
+  tpa_val = tvb_get_ptr(tvb, tpa_offset, ar_pln);
+  tpa_str = arpproaddr_to_str(tpa_val, ar_pln, ar_pro);
   
-  if (check_col(fd, COL_PROTOCOL)) {
+  if (check_col(pinfo->fd, COL_PROTOCOL)) {
     switch (ar_op) {
 
     case ARPOP_REQUEST:
     case ARPOP_REPLY:
     default:
-      col_add_str(fd, COL_PROTOCOL, "ARP");
+      col_add_str(pinfo->fd, COL_PROTOCOL, "ARP");
       break;
 
     case ARPOP_RREQUEST:
     case ARPOP_RREPLY:
-      col_add_str(fd, COL_PROTOCOL, "RARP");
+      col_add_str(pinfo->fd, COL_PROTOCOL, "RARP");
       break;
 
     case ARPOP_IREQUEST:
     case ARPOP_IREPLY:
-      col_add_str(fd, COL_PROTOCOL, "Inverse ARP");
+      col_add_str(pinfo->fd, COL_PROTOCOL, "Inverse ARP");
       break;
     }
   }
 
-  if (check_col(fd, COL_INFO)) {
+  if (check_col(pinfo->fd, COL_INFO)) {
     switch (ar_op) {
       case ARPOP_REQUEST:
-        col_add_fstr(fd, COL_INFO, "Who has %s?  Tell %s", tpa_str, spa_str);
+        col_add_fstr(pinfo->fd, COL_INFO, "Who has %s?  Tell %s", tpa_str, spa_str);
         break;
       case ARPOP_REPLY:
-        col_add_fstr(fd, COL_INFO, "%s is at %s", spa_str, sha_str);
+        col_add_fstr(pinfo->fd, COL_INFO, "%s is at %s", spa_str, sha_str);
         break;
       case ARPOP_RREQUEST:
       case ARPOP_IREQUEST:
-        col_add_fstr(fd, COL_INFO, "Who is %s?  Tell %s", tha_str, sha_str);
+        col_add_fstr(pinfo->fd, COL_INFO, "Who is %s?  Tell %s", tha_str, sha_str);
         break;
       case ARPOP_RREPLY:
       case ARPOP_IREPLY:
-        col_add_fstr(fd, COL_INFO, "%s is at %s", sha_str, spa_str);
+        col_add_fstr(pinfo->fd, COL_INFO, "%s is at %s", sha_str, spa_str);
         break;
       default:
-        col_add_fstr(fd, COL_INFO, "Unknown ARP opcode 0x%04x", ar_op);
+        col_add_fstr(pinfo->fd, COL_INFO, "Unknown ARP opcode 0x%04x", ar_op);
         break;
     }
   }
@@ -649,49 +663,44 @@ dissect_arp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 
     /* add sender address in all cases */
 
-    memcpy(&ip, &pd[spa_offset], sizeof(ip));
-    add_ether_byip(ip, &pd[sha_offset]);
+    tvb_memcpy(tvb, (guint8 *)&ip, spa_offset, sizeof(ip));
+    add_ether_byip(ip, tvb_get_ptr(tvb, sha_offset, 6));
     
     if (ar_op == ARPOP_REQUEST) {
       /* add destination address */
-      memcpy(&ip, &pd[tpa_offset], sizeof(ip));
-      add_ether_byip(ip, &pd[tha_offset]);
+      tvb_memcpy(tvb, (guint8 *)&ip, tpa_offset, sizeof(ip));
+      add_ether_byip(ip, tvb_get_ptr(tvb, tha_offset, 6));
     }
   }
 
   if (tree) {
     if ((op_str = match_strval(ar_op, op_vals)))
-      ti = proto_tree_add_protocol_format(tree, proto_arp, NullTVB, offset, tot_len,
+      ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len,
                                        "Address Resolution Protocol (%s)", op_str);
     else
-      ti = proto_tree_add_protocol_format(tree, proto_arp, NullTVB, offset, tot_len,
+      ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len,
                                      "Address Resolution Protocol (opcode 0x%04x)", ar_op);
     arp_tree = proto_item_add_subtree(ti, ett_arp);
-    proto_tree_add_uint(arp_tree, hf_arp_hard_type, NullTVB, offset + AR_HRD, 2,
-                              ar_hrd);
-    proto_tree_add_uint(arp_tree, hf_arp_proto_type, NullTVB, offset + AR_PRO, 2,
-                              ar_pro);
-    proto_tree_add_uint(arp_tree, hf_arp_hard_size, NullTVB, offset + AR_HLN, 1,
-                              ar_hln);
-    proto_tree_add_uint(arp_tree, hf_arp_proto_size, NullTVB, offset + AR_PLN, 1,
-                              ar_pln);
-    proto_tree_add_uint(arp_tree, hf_arp_opcode, NullTVB, offset + AR_OP,  2,
-                              ar_op);
+    proto_tree_add_uint(arp_tree, hf_arp_hard_type, tvb, AR_HRD, 2, ar_hrd);
+    proto_tree_add_uint(arp_tree, hf_arp_proto_type, tvb, AR_PRO, 2, ar_pro);
+    proto_tree_add_uint(arp_tree, hf_arp_hard_size, tvb, AR_HLN, 1, ar_hln);
+    proto_tree_add_uint(arp_tree, hf_arp_proto_size, tvb, AR_PLN, 1, ar_pln);
+    proto_tree_add_uint(arp_tree, hf_arp_opcode, tvb, AR_OP,  2, ar_op);
     if (ar_hln != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_arp_src_ether, NullTVB, sha_offset, ar_hln,
-                              &pd[sha_offset],
+      proto_tree_add_bytes_format(arp_tree, hf_arp_src_ether, tvb, sha_offset, ar_hln,
+                              sha_val,
                               "Sender hardware address: %s", sha_str);
     if (ar_pln != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_arp_src_proto, NullTVB, spa_offset, ar_pln,
-                              &pd[spa_offset],
+      proto_tree_add_bytes_format(arp_tree, hf_arp_src_proto, tvb, spa_offset, ar_pln,
+                              spa_val,
                               "Sender protocol address: %s", spa_str);
     if (ar_hln != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_arp_dst_ether, NullTVB, tha_offset, ar_hln,
-                              &pd[tha_offset],
+      proto_tree_add_bytes_format(arp_tree, hf_arp_dst_ether, tvb, tha_offset, ar_hln,
+                              tha_val,
                               "Target hardware address: %s", tha_str);
     if (ar_pln != 0)
-      proto_tree_add_bytes_format(arp_tree, hf_arp_dst_proto, NullTVB, tpa_offset, ar_pln,
-                              &pd[tpa_offset],
+      proto_tree_add_bytes_format(arp_tree, hf_arp_dst_proto, tvb, tpa_offset, ar_pln,
+                              tpa_val,
                               "Target protocol address: %s", tpa_str);
   }
 }
@@ -818,6 +827,6 @@ proto_register_arp(void)
 void
 proto_reg_handoff_arp(void)
 {
-       old_dissector_add("ethertype", ETHERTYPE_ARP, dissect_arp);
-       old_dissector_add("ethertype", ETHERTYPE_REVARP, dissect_arp);
+  dissector_add("ethertype", ETHERTYPE_ARP, dissect_arp);
+  dissector_add("ethertype", ETHERTYPE_REVARP, dissect_arp);
 }
index 6da1857cb9a19b83dda5e776886089436b790232..ce44a2c7a2fd46c2af31d940561eac8884e415fc 100644 (file)
@@ -2,7 +2,7 @@
  * Definitions of routines for ARP packet disassembly that are used
  * elsewhere
  *
- * $Id: packet-arp.h,v 1.3 2000/04/16 22:59:36 guy Exp $
+ * $Id: packet-arp.h,v 1.4 2000/11/13 07:18:40 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -30,6 +30,6 @@
 gchar *arphrdaddr_to_str(guint8 *ad, int ad_len, guint16 type);
 gchar *arphrdtype_to_str(guint16 hwtype, const char *fmt);
 
-void dissect_atm_nsap(const u_char *pd, int offset, int len, proto_tree *tree);
+void dissect_atm_nsap(tvbuff_t *tvb, int offset, int len, proto_tree *tree);
 
 #endif /* packet-atm.h */
index 24b733172e7b2016e5f2175e812de3ae88f02379..cb11f4ce342c769a73f4dcb412fc501257929669 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-atm.c
  * Routines for ATM packet disassembly
  *
- * $Id: packet-atm.c,v 1.24 2000/08/13 14:08:02 deniel Exp $
+ * $Id: packet-atm.c,v 1.25 2000/11/13 07:18:42 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -328,7 +328,7 @@ dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     offset += 8;
 
     proto_tree_add_text(lane_tree, tvb, offset, 20, "Source ATM Address: %s",
-                       bytes_to_str(tvb_get_ptr(tvb, offset, 20), 20));
+                       tvb_bytes_to_str(tvb, offset, 20));
     offset += 20;
 
     proto_tree_add_text(lane_tree, tvb, offset, 1, "LAN type: %s",
@@ -350,11 +350,11 @@ dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     offset += 1;
 
     proto_tree_add_text(lane_tree, tvb, offset, 20, "Target ATM Address: %s",
-                       bytes_to_str(tvb_get_ptr(tvb, offset, 20), 20));
+                       tvb_bytes_to_str(tvb, offset, 20));
     offset += 20;
 
     proto_tree_add_text(lane_tree, tvb, offset, 32, "ELAN name: %s",
-                       bytes_to_str(tvb_get_ptr(tvb, offset, 32), 32));
+                       tvb_bytes_to_str(tvb, offset, 32));
     offset += 32;
 
     while (num_tlvs != 0) {
index 70a02f22c2ea503f5fd12e97f46f4f6c5f1f89a1..79fa8196f1a98adbb5801236dee8403d825eb4b4 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for the disassembly of the "Cisco Discovery Protocol"
  * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
  *
- * $Id: packet-cdp.c,v 1.25 2000/08/13 14:08:04 deniel Exp $
+ * $Id: packet-cdp.c,v 1.26 2000/11/13 07:18:44 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -35,6 +35,7 @@
 
 #include <glib.h>
 #include "packet.h"
+#include "strutil.h"
 #include "nlpid.h"
 
 /*
index a265b439b2e0dbd8c637cd11b971662f832d2307..378d2de541d666cab11fbbe2064e8a94368d8924 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Guy Harris <guy@alum.mit.edu>
  *
- * $Id: packet-ipp.c,v 1.13 2000/11/09 10:56:32 guy Exp $
+ * $Id: packet-ipp.c,v 1.14 2000/11/13 07:18:46 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -40,6 +40,7 @@
 
 #include <glib.h>
 #include "packet.h"
+#include "strutil.h"
 #include "packet-http.h"
 
 static int proto_ipp = -1;
index b573f2d5a67e8538d1e780e261de8d0a82d5aaed..4f30658fa9c55173865b8a50695ef9bd3eff01dc 100644 (file)
@@ -3,7 +3,7 @@
  * Wes Hardaker (c) 2000
  * wjhardaker@ucdavis.edu
  *
- * $Id: packet-kerberos.c,v 1.4 2000/09/06 19:05:41 gram Exp $
+ * $Id: packet-kerberos.c,v 1.5 2000/11/13 07:18:48 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -40,6 +40,8 @@
 
 #include "packet.h"
 
+#include "strutil.h"
+
 #include "asn1.h"
 
 #include "packet-kerberos.h"
index 7a6c93fa02cc4f9abc5560d29d0fae0a817f1bb0..17f623f837aab1d77bdf2acaf18f719b28c8ec1c 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for nfs dissection
  * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de>
  *
- * $Id: packet-nfs.c,v 1.37 2000/08/27 02:03:31 guy Exp $
+ * $Id: packet-nfs.c,v 1.38 2000/11/13 07:18:50 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -416,7 +416,7 @@ dissect_fhandle_data_LINUX_NFSD_LE(tvbuff_t* tvb, proto_tree *tree, int fhlen)
 
                hash_item = proto_tree_add_text(tree, tvb, 4, hashlen + 1,
                                "hash path: %s",
-                               bytes_to_str(tvb_get_ptr(tvb,5,hashlen),hashlen));
+                               tvb_bytes_to_str(tvb,5,hashlen));
                if (hash_item) {
                        hash_tree = proto_item_add_subtree(hash_item, 
                                        ett_nfs_fh_hp);
@@ -425,7 +425,7 @@ dissect_fhandle_data_LINUX_NFSD_LE(tvbuff_t* tvb, proto_tree *tree, int fhlen)
                                        hf_nfs_fh_hp_len, tvb, 4, 1, hashlen);
                                proto_tree_add_text(hash_tree, tvb, 5, hashlen,
                                        "key: %s",
-                                       bytes_to_str(tvb_get_ptr(tvb,5,hashlen),hashlen));
+                                       tvb_bytes_to_str(tvb,5,hashlen));
                        }
                }
        }
@@ -454,7 +454,7 @@ dissect_fhandle_data_unknown(tvbuff_t *tvb, proto_tree *tree, int fhlen)
                                        "%s%s",
                                        first_line ? "data: " :
                                                     "      ",
-                                       bytes_to_str(tvb_get_ptr(tvb,offset,sublen),sublen));
+                                       tvb_bytes_to_str(tvb,offset,sublen));
                bytes_left -= sublen;
                offset += sublen;
                first_line = FALSE;
index ead13c81db659b939c399bb7ca0721ac5e8e409b..56ff590c4e1016d99665ea97b2f957e97e535f5e 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for Q.2931 frame disassembly
  * Guy Harris <guy@alum.mit.edu>
  *
- * $Id: packet-q2931.c,v 1.11 2000/08/13 14:08:42 deniel Exp $
+ * $Id: packet-q2931.c,v 1.12 2000/11/13 07:18:53 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -363,7 +363,7 @@ dissect_q2931_aal_parameters_ie(tvbuff_t *tvb, int offset, int len,
                        len = 4;
                proto_tree_add_text(tree, tvb, offset, len,
                    "User defined AAL information: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                return;
        }
 
@@ -1153,7 +1153,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
                case Q2931_REJ_USER_SPECIFIC:
                        proto_tree_add_text(tree, tvb, offset, len,
                            "User specific diagnostic: %s",
-                           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                           tvb_bytes_to_str(tvb, offset, len));
                        break;
 
                case Q2931_REJ_IE_MISSING:
@@ -1173,7 +1173,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
                default:
                        proto_tree_add_text(tree, tvb, offset, len,
                            "Diagnostic: %s",
-                           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                           tvb_bytes_to_str(tvb, offset, len));
                        break;
                }
                break;
@@ -1249,7 +1249,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
        default:
                proto_tree_add_text(tree, tvb, offset, len,
                    "Diagnostics: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
        }
 }
 
@@ -1385,17 +1385,17 @@ dissect_q2931_number_ie(tvbuff_t *tvb, int offset, int len,
                if (len < 20) {
                        proto_tree_add_text(tree, tvb, offset, len,
                            "Number (too short): %s",
-                           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                           tvb_bytes_to_str(tvb, offset, len));
                        return;
                }
                ti = proto_tree_add_text(tree, tvb, offset, len, "Number");
                nsap_tree = proto_item_add_subtree(ti, ett_q2931_nsap);
-               dissect_atm_nsap(tvb_get_ptr(tvb, 0, -1), offset, len, nsap_tree);
+               dissect_atm_nsap(tvb, offset, len, nsap_tree);
                break;
 
        default:
                proto_tree_add_text(tree, tvb, offset, len, "Number: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, 0, -1), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                break;
        }
 }
@@ -1439,7 +1439,7 @@ dissect_q2931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
        if (len == 0)
                return;
        proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
-           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+           tvb_bytes_to_str(tvb, offset, len));
 }
 
 /*
@@ -1965,7 +1965,7 @@ dissect_q2931_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
                 * dump it as data and be done with it.
                 */
                proto_tree_add_text(ie_tree, tvb, offset + 4,  len,
-                   "Data: %s", bytes_to_str(tvb_get_ptr(tvb, offset + 4, len), len));
+                   "Data: %s", tvb_bytes_to_str(tvb, offset + 4, len));
        }
 }
 
index aabd1c19da01d09ca5267bbaa0b06225b4b348f0..7f940d100cd81d87863328fbfccebe98ce7d3578 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for Q.931 frame disassembly
  * Guy Harris <guy@alum.mit.edu>
  *
- * $Id: packet-q931.c,v 1.19 2000/10/19 07:01:32 guy Exp $
+ * $Id: packet-q931.c,v 1.20 2000/11/13 07:18:56 guy Exp $
  *
  * Modified by Andreas Sikkema for possible use with H.323
  *
@@ -38,6 +38,7 @@
 #include <glib.h>
 #include <string.h>
 #include "packet.h"
+#include "strutil.h"
 #include "nlpid.h"
 #include "packet-q931.h"
 
@@ -581,7 +582,7 @@ dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
                 */
                proto_tree_add_text(tree, tvb, offset,
                    len, "Data: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                return;
        }
        proto_tree_add_text(tree, tvb, offset, 1,
@@ -1036,7 +1037,7 @@ dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
                 */
                proto_tree_add_text(tree, tvb, offset,
                    len, "Data: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                return;
        }
        proto_tree_add_text(tree, tvb, offset, 1,
@@ -1072,7 +1073,7 @@ dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
                return;
        proto_tree_add_text(tree, tvb, offset, len,
            "Diagnostics: %s",
-           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+           tvb_bytes_to_str(tvb, offset, len));
 }
 
 /*
@@ -1129,7 +1130,7 @@ dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
                 */
                proto_tree_add_text(tree, tvb, offset,
                    len, "Data: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                return;
        }
        proto_tree_add_text(tree, tvb, offset, 1,
@@ -1249,7 +1250,7 @@ dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
                         */
                        proto_tree_add_text(tree, tvb, offset,
                            len, "Data: %s",
-                           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                           tvb_bytes_to_str(tvb, offset, len));
                        return;
                }
                proto_tree_add_text(tree, tvb, offset, 1,
@@ -1301,7 +1302,7 @@ dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
                 */
                proto_tree_add_text(tree, tvb, offset,
                    len, "Data: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                return;
        }
        proto_tree_add_text(tree, tvb, offset, 1,
@@ -1391,7 +1392,7 @@ dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
                return;
        proto_tree_add_text(tree, tvb, offset,
            len, "Network-specific facility specification: %s",
-           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+           tvb_bytes_to_str(tvb, offset, len));
 }
 
 /*
@@ -1913,7 +1914,7 @@ dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
        if (len == 0)
                return;
        proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
-           bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+           tvb_bytes_to_str(tvb, offset, len));
 }
 
 /*
@@ -1995,7 +1996,7 @@ dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
                 */
                proto_tree_add_text(tree, tvb, offset,
                    len, "Data: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                return;
        }
 
@@ -2074,7 +2075,7 @@ dissect_q931_user_user_ie(tvbuff_t *tvb, int offset, int len,
 
        default:
                proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
-                   bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
+                   tvb_bytes_to_str(tvb, offset, len));
                break;
        }
 }
index 49c37b2e41b6ed7eeda2f56777b4ea78c107c2b1..40ffb672a05b2087bf83208582ee23eb617bd647 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for SNMP (simple network management protocol)
  * D.Jorand (c) 1998
  *
- * $Id: packet-snmp.c,v 1.51 2000/10/21 18:52:17 guy Exp $
+ * $Id: packet-snmp.c,v 1.52 2000/11/13 07:18:59 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -54,6 +54,7 @@
 #include <glib.h>
 
 #include "packet.h"
+#include "strutil.h"
 #include "conversation.h"
 #include "etypes.h"
 #include "packet-ipx.h"