aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--packet-arp.c160
-rw-r--r--packet-arp.h35
-rw-r--r--packet-bootp.c3
-rw-r--r--packet-q2931.c64
-rw-r--r--packet.h6
6 files changed, 184 insertions, 87 deletions
diff --git a/Makefile.am b/Makefile.am
index 6253165c3c..534efb89b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.117 1999/11/25 10:01:15 guy Exp $
+# $Id: Makefile.am,v 1.118 1999/11/27 04:48:12 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -36,6 +36,7 @@ DISSECTOR_SOURCES = \
packet-afs.c \
packet-afs.h \
packet-arp.c \
+ packet-arp.h \
packet-ascend.c\
packet-atalk.c \
packet-atalk.h \
diff --git a/packet-arp.c b/packet-arp.c
index d85f5691df..1bd9545e74 100644
--- a/packet-arp.c
+++ b/packet-arp.c
@@ -1,7 +1,7 @@
/* packet-arp.c
* Routines for ARP packet disassembly
*
- * $Id: packet-arp.c,v 1.23 1999/11/27 04:01:43 guy Exp $
+ * $Id: packet-arp.c,v 1.24 1999/11/27 04:48:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -33,6 +33,7 @@
#include <glib.h>
#include "packet.h"
+#include "packet-arp.h"
#include "etypes.h"
static int proto_arp = -1;
@@ -51,12 +52,15 @@ static int hf_arp_src_ether = -1;
static int hf_arp_src_proto = -1;
static int hf_arp_dst_ether = -1;
static int hf_arp_dst_proto = -1;
-static int hf_atmarp_src_atm_num = -1;
+static int hf_atmarp_src_atm_num_e164 = -1;
+static int hf_atmarp_src_atm_num_nsap = -1;
static int hf_atmarp_src_atm_subaddr = -1;
-static int hf_atmarp_dst_atm_num = -1;
+static int hf_atmarp_dst_atm_num_e164 = -1;
+static int hf_atmarp_dst_atm_num_nsap = -1;
static int hf_atmarp_dst_atm_subaddr = -1;
static gint ett_arp = -1;
+static gint ett_atmarp_nsap = -1;
/* Definitions taken from Linux "linux/if_arp.h" header file, and from
@@ -164,18 +168,44 @@ arpproaddr_to_str(guint8 *ad, int ad_len, guint16 type)
return bytes_to_str(ad, ad_len);
}
+#define N_ATMARPNUM_TO_STR_STRINGS 2
+#define MAX_E164_STR_LEN 20
static gchar *
atmarpnum_to_str(guint8 *ad, int ad_tl)
{
- int ad_len = ad_tl & ATMARP_LEN_MASK;
+ int ad_len = ad_tl & ATMARP_LEN_MASK;
+ static gchar str[N_ATMARPNUM_TO_STR_STRINGS][MAX_E164_STR_LEN+3+1];
+ static int cur_idx;
+ gchar *cur;
if (ad_len == 0)
return "<No address>";
- /*
- * XXX - break down into subcomponents.
- */
- return bytes_to_str(ad, ad_len);
+ if (ad_tl & ATMARP_IS_E164) {
+ /*
+ * I'm assuming this means it's an ASCII (IA5) string.
+ */
+ cur_idx++;
+ if (cur_idx >= N_ATMARPNUM_TO_STR_STRINGS)
+ cur_idx = 0;
+ cur = &str[cur_idx][0];
+ if (ad_len > MAX_E164_STR_LEN) {
+ /* Can't show it all. */
+ memcpy(cur, ad, MAX_E164_STR_LEN);
+ strcpy(&cur[MAX_E164_STR_LEN], "...");
+ } else {
+ memcpy(cur, ad, ad_len);
+ cur[ad_len + 1] = '\0';
+ }
+ return cur;
+ } else {
+ /*
+ * NSAP.
+ *
+ * XXX - break down into subcomponents.
+ */
+ return bytes_to_str(ad, ad_len);
+ }
}
static gchar *
@@ -246,6 +276,89 @@ arphrdtype_to_str(guint16 hwtype, const char *fmt) {
#define ATM_AR_TPLN 11
#define MIN_ATMARP_HEADER_SIZE 12
+static void
+dissect_atm_number(const u_char *pd, int offset, int tl, int hf_e164,
+ int hf_nsap, proto_tree *tree)
+{
+ int len = tl & ATMARP_LEN_MASK;
+ proto_item *ti;
+ proto_tree *nsap_tree;
+
+ if (tl & ATMARP_IS_E164)
+ proto_tree_add_item(tree, hf_e164, offset, len, &pd[offset]);
+ else {
+ ti = proto_tree_add_item(tree, hf_nsap, offset, len,
+ &pd[offset]);
+ if (len >= 20) {
+ nsap_tree = proto_item_add_subtree(ti, ett_atmarp_nsap);
+ dissect_atm_nsap(pd, offset, len, nsap_tree);
+ }
+ }
+}
+
+void
+dissect_atm_nsap(const u_char *pd, int offset, int len, proto_tree *tree)
+{
+ switch (pd[offset]) {
+
+ case 0x39: /* DCC ATM format */
+ case 0xBD: /* DCC ATM group format */
+ proto_tree_add_text(tree, offset + 0, 3,
+ "Data Country Code%s: 0x%04X",
+ (pd[offset] == 0xBD) ? " (group)" : "",
+ pntohs(&pd[offset + 1]));
+ proto_tree_add_text(tree, offset + 3, 10,
+ "High Order DSP: %s",
+ bytes_to_str(&pd[offset + 3], 10));
+ proto_tree_add_text(tree, offset + 13, 6,
+ "End System Identifier: %s",
+ bytes_to_str(&pd[offset + 13], 6));
+ proto_tree_add_text(tree, offset + 19, 1,
+ "Selector: 0x%02X", pd[offset + 19]);
+ break;
+
+ case 0x47: /* ICD ATM format */
+ case 0xC5: /* ICD ATM group format */
+ proto_tree_add_text(tree, offset + 0, 3,
+ "International Code Designator%s: 0x%04X",
+ (pd[offset] == 0xC5) ? " (group)" : "",
+ pntohs(&pd[offset + 1]));
+ proto_tree_add_text(tree, offset + 3, 10,
+ "High Order DSP: %s",
+ bytes_to_str(&pd[offset + 3], 10));
+ proto_tree_add_text(tree, offset + 13, 6,
+ "End System Identifier: %s",
+ bytes_to_str(&pd[offset + 13], 6));
+ proto_tree_add_text(tree, offset + 19, 1,
+ "Selector: 0x%02X", pd[offset + 19]);
+ break;
+
+ case 0x45: /* E.164 ATM format */
+ case 0xC3: /* E.164 ATM group format */
+ proto_tree_add_text(tree, offset + 0, 9,
+ "E.164 ISDN%s: %s",
+ (pd[offset] == 0xC3) ? " (group)" : "",
+ bytes_to_str(&pd[offset + 1], 8));
+ proto_tree_add_text(tree, offset + 9, 4,
+ "High Order DSP: %s",
+ bytes_to_str(&pd[offset + 3], 10));
+ proto_tree_add_text(tree, offset + 13, 6,
+ "End System Identifier: %s",
+ bytes_to_str(&pd[offset + 13], 6));
+ proto_tree_add_text(tree, offset + 19, 1,
+ "Selector: 0x%02X", pd[offset + 19]);
+ break;
+
+ default:
+ proto_tree_add_text(tree, offset, 1,
+ "Unknown AFI: 0x%02X", pd[offset]);
+ proto_tree_add_text(tree, offset + 1, len - 1,
+ "Rest of address: %s",
+ bytes_to_str(&pd[offset + 1], len - 1));
+ break;
+ }
+}
+
/*
* RFC 2225 ATMARP - it's just like ARP, except where it isn't.
*/
@@ -409,10 +522,8 @@ dissect_atmarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_item(arp_tree, hf_atmarp_tpln, offset + ATM_AR_TPLN, 1,
ar_tpln);
if (ar_shl != 0)
- proto_tree_add_item_format(arp_tree, hf_atmarp_src_atm_num, sha_offset,
- ar_shl,
- &pd[sha_offset],
- "Sender ATM number: %s", sha_str);
+ dissect_atm_number(pd, 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_item_format(arp_tree, hf_atmarp_src_atm_subaddr, ssa_offset,
ar_ssl,
@@ -423,10 +534,8 @@ dissect_atmarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
&pd[spa_offset],
"Sender protocol address: %s", spa_str);
if (ar_thl != 0)
- proto_tree_add_item_format(arp_tree, hf_atmarp_dst_atm_num, tha_offset,
- ar_thl,
- &pd[tha_offset],
- "Target ATM number: %s", tha_str);
+ dissect_atm_number(pd, 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_item_format(arp_tree, hf_atmarp_dst_atm_subaddr, tsa_offset,
ar_tsl,
@@ -630,8 +739,13 @@ proto_register_arp(void)
FT_BYTES, BASE_NONE, NULL, 0x0,
"" }},
- { &hf_atmarp_src_atm_num,
- { "Sender ATM number", "arp.src.atm_num",
+ { &hf_atmarp_src_atm_num_e164,
+ { "Sender ATM number (E.164)", "arp.src.atm_num_e164",
+ FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+
+ { &hf_atmarp_src_atm_num_nsap,
+ { "Sender ATM number (NSAP)", "arp.src.atm_num_nsap",
FT_BYTES, BASE_NONE, NULL, 0x0,
"" }},
@@ -650,8 +764,13 @@ proto_register_arp(void)
FT_BYTES, BASE_NONE, NULL, 0x0,
"" }},
- { &hf_atmarp_dst_atm_num,
- { "Target ATM number", "arp.dst.atm_num",
+ { &hf_atmarp_dst_atm_num_e164,
+ { "Target ATM number (E.164)", "arp.dst.atm_num_e164",
+ FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+
+ { &hf_atmarp_dst_atm_num_nsap,
+ { "Target ATM number (NSAP)", "arp.dst.atm_num_nsap",
FT_BYTES, BASE_NONE, NULL, 0x0,
"" }},
@@ -667,6 +786,7 @@ proto_register_arp(void)
};
static gint *ett[] = {
&ett_arp,
+ &ett_atmarp_nsap,
};
proto_arp = proto_register_protocol("Address Resolution Protocol", "arp");
diff --git a/packet-arp.h b/packet-arp.h
new file mode 100644
index 0000000000..ac32d16b24
--- /dev/null
+++ b/packet-arp.h
@@ -0,0 +1,35 @@
+/* packet-arp.h
+ * Definitions of routines for ARP packet disassembly that are used
+ * elsewhere
+ *
+ * $Id: packet-arp.h,v 1.1 1999/11/27 04:48:12 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998 Gerald Combs
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PACKET_ARP_H__
+#define __PACKET_ARP_H__
+
+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);
+
+#endif /* packet-atm.h */
diff --git a/packet-bootp.c b/packet-bootp.c
index 6455b7f548..e49d3e5ea3 100644
--- a/packet-bootp.c
+++ b/packet-bootp.c
@@ -2,7 +2,7 @@
* Routines for BOOTP/DHCP packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-bootp.c,v 1.22 1999/11/16 11:42:27 guy Exp $
+ * $Id: packet-bootp.c,v 1.23 1999/11/27 04:48:12 guy Exp $
*
* The information used comes from:
* RFC 2132: DHCP Options and BOOTP Vendor Extensions
@@ -39,6 +39,7 @@
#include <glib.h>
#include "packet.h"
+#include "packet-arp.h"
static int proto_bootp = -1;
static int hf_bootp_type = -1;
diff --git a/packet-q2931.c b/packet-q2931.c
index 7db0fef375..52ab8fd553 100644
--- a/packet-q2931.c
+++ b/packet-q2931.c
@@ -2,7 +2,7 @@
* Routines for Q.2931 frame disassembly
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-q2931.c,v 1.4 1999/11/27 02:14:38 guy Exp $
+ * $Id: packet-q2931.c,v 1.5 1999/11/27 04:48:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -37,6 +37,7 @@
#include <string.h>
#include "packet.h"
#include "packet-q931.h"
+#include "packet-arp.h"
/*
* See
@@ -45,7 +46,7 @@
*
* for some information on Q.2931, although, alas, not the actual message
* type and information element values - those I got from the FreeBSD 3.2
- * ATM code.
+ * ATM code, and from Q.2931 (and Q.931) itself.
*/
static int proto_q2931 = -1;
@@ -1381,64 +1382,7 @@ dissect_q2931_number_ie(const u_char *pd, int offset, int len,
}
ti = proto_tree_add_text(tree, offset, len, "Number");
nsap_tree = proto_item_add_subtree(ti, ett_q2931_nsap);
- switch (pd[offset]) {
-
- case 0x39: /* DCC ATM format */
- case 0xBD: /* DCC ATM group format */
- proto_tree_add_text(nsap_tree, offset + 0, 3,
- "Data Country Code%s: 0x%04X",
- (pd[offset] == 0xBD) ? " (group)" : "",
- pntohs(&pd[offset + 1]));
- proto_tree_add_text(nsap_tree, offset + 3, 10,
- "High Order DSP: %s",
- bytes_to_str(&pd[offset + 3], 10));
- proto_tree_add_text(nsap_tree, offset + 13, 6,
- "End System Identifier: %s",
- bytes_to_str(&pd[offset + 13], 6));
- proto_tree_add_text(nsap_tree, offset + 19, 1,
- "Selector: 0x%02X", pd[offset + 19]);
- break;
-
- case 0x47: /* ICD ATM format */
- case 0xC5: /* ICD ATM group format */
- proto_tree_add_text(nsap_tree, offset + 0, 3,
- "International Code Designator%s: 0x%04X",
- (pd[offset] == 0xC5) ? " (group)" : "",
- pntohs(&pd[offset + 1]));
- proto_tree_add_text(nsap_tree, offset + 3, 10,
- "High Order DSP: %s",
- bytes_to_str(&pd[offset + 3], 10));
- proto_tree_add_text(nsap_tree, offset + 13, 6,
- "End System Identifier: %s",
- bytes_to_str(&pd[offset + 13], 6));
- proto_tree_add_text(nsap_tree, offset + 19, 1,
- "Selector: 0x%02X", pd[offset + 19]);
- break;
-
- case 0x45: /* E.164 ATM format */
- case 0xC3: /* E.164 ATM group format */
- proto_tree_add_text(nsap_tree, offset + 0, 9,
- "E.164 ISDN%s: %s",
- (pd[offset] == 0xC3) ? " (group)" : "",
- bytes_to_str(&pd[offset + 1], 8));
- proto_tree_add_text(nsap_tree, offset + 9, 4,
- "High Order DSP: %s",
- bytes_to_str(&pd[offset + 3], 10));
- proto_tree_add_text(nsap_tree, offset + 13, 6,
- "End System Identifier: %s",
- bytes_to_str(&pd[offset + 13], 6));
- proto_tree_add_text(nsap_tree, offset + 19, 1,
- "Selector: 0x%02X", pd[offset + 19]);
- break;
-
- default:
- proto_tree_add_text(nsap_tree, offset, 1,
- "Unknown AFI: 0x%02X", pd[offset]);
- proto_tree_add_text(nsap_tree, offset + 1, len - 1,
- "Rest of address: %s",
- bytes_to_str(&pd[offset + 1], len - 1));
- break;
- }
+ dissect_atm_nsap(pd, offset, len, nsap_tree);
break;
default:
diff --git a/packet.h b/packet.h
index 86d951a1ac..5ea204c93c 100644
--- a/packet.h
+++ b/packet.h
@@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.151 1999/11/23 17:09:58 gram Exp $
+ * $Id: packet.h,v 1.152 1999/11/27 04:48:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -428,10 +428,6 @@ void ethertype(guint16 etype, int offset,
proto_tree *fh_tree, int item_id);
extern const value_string etype_vals[];
-/* These functions are in packet-arp.c */
-gchar *arphrdaddr_to_str(guint8 *ad, int ad_len, guint16 type);
-gchar *arphrdtype_to_str(guint16 hwtype, const char *fmt);
-
/* ipproto.c */
extern const char *ipprotostr(int proto);