diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-04-17 00:32:43 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-04-17 00:32:43 +0000 |
commit | 0ba3e2b233c719f12627694f562c4974f8ecbfe2 (patch) | |
tree | beec035095e135d72c17c3cdee265524a117611f | |
parent | 83a275737e3a5c00e3b81ef2f6e91d89bb559368 (diff) | |
download | wireshark-0ba3e2b233c719f12627694f562c4974f8ecbfe2.tar.gz wireshark-0ba3e2b233c719f12627694f562c4974f8ecbfe2.tar.bz2 wireshark-0ba3e2b233c719f12627694f562c4974f8ecbfe2.zip |
Register a "llc.dsap" dissector table for 802.2 LLC, and have dissectors
for protocols that run inside 802.2 LLC register themselves with it
using "dissector_add()".
Make various dissectors static if they can be, and remove from header
files declarations of those dissectors.
svn path=/trunk/; revision=1872
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | llcsaps.h | 56 | ||||
-rw-r--r-- | packet-bpdu.c | 9 | ||||
-rw-r--r-- | packet-ip.c | 4 | ||||
-rw-r--r-- | packet-ipx.c | 4 | ||||
-rw-r--r-- | packet-llc.c | 128 | ||||
-rw-r--r-- | packet-netbios.c | 11 | ||||
-rw-r--r-- | packet-netbios.h | 3 | ||||
-rw-r--r-- | packet-osi.c | 10 | ||||
-rw-r--r-- | packet-sna.c | 11 | ||||
-rw-r--r-- | packet-sna.h | 4 |
11 files changed, 147 insertions, 96 deletions
diff --git a/Makefile.am b/Makefile.am index 18ee68df6d..397cffd9a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.188 2000/04/16 22:59:35 guy Exp $ +# $Id: Makefile.am,v 1.189 2000/04/17 00:32:36 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@zing.org> @@ -251,6 +251,7 @@ ETHEREAL_COMMON_SOURCES = \ ipproto.c \ ipv4.c \ ipv4.h \ + llcsaps.h \ nlpid.h \ oui.h \ packet.c \ diff --git a/llcsaps.h b/llcsaps.h new file mode 100644 index 0000000000..5cc8f051c1 --- /dev/null +++ b/llcsaps.h @@ -0,0 +1,56 @@ +/* llcsaps.h + * Defines LLC SAP values. + * + * $Id: llcsaps.h,v 1.1 2000/04/17 00:32:37 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 __LLCSAPS_H__ +#define __LLCSAPS_H__ + +#define SAP_NULL 0x00 +#define SAP_LLC_SLMGMT 0x02 +#define SAP_SNA_PATHCTRL 0x04 +#define SAP_IP 0x06 +#define SAP_SNA1 0x08 +#define SAP_SNA2 0x0C +#define SAP_PROWAY_NM_INIT 0x0E +#define SAP_TI 0x18 +#define SAP_BPDU 0x42 +#define SAP_RS511 0x4E +#define SAP_XNS 0x80 +#define SAP_NESTAR 0x86 +#define SAP_PROWAY_ASLM 0x8E +#define SAP_ARP 0x98 +#define SAP_SNAP 0xAA +#define SAP_ARP 0x98 +#define SAP_VINES1 0xBA +#define SAP_VINES2 0xBC +#define SAP_NETWARE 0xE0 +#define SAP_NETBIOS 0xF0 +#define SAP_IBMNM 0xF4 +#define SAP_RPL1 0xF8 +#define SAP_UB 0xFA +#define SAP_RPL2 0xFC +#define SAP_OSINL 0xFE +#define SAP_GLOBAL 0xFF + +#endif /* llcsaps.h */ diff --git a/packet-bpdu.c b/packet-bpdu.c index 1db910270a..b2da00a988 100644 --- a/packet-bpdu.c +++ b/packet-bpdu.c @@ -1,7 +1,7 @@ /* packet-bpdu.c * Routines for BPDU (Spanning Tree Protocol) disassembly * - * $Id: packet-bpdu.c,v 1.8 2000/03/12 04:47:36 gram Exp $ + * $Id: packet-bpdu.c,v 1.9 2000/04/17 00:32:37 guy Exp $ * * Copyright 1999 Christophe Tronche <ch.tronche@computer.org> * @@ -41,6 +41,7 @@ #include <string.h> #include <glib.h> #include "packet.h" +#include "llcsaps.h" #include "resolv.h" /* Offsets of fields within a BPDU */ @@ -262,3 +263,9 @@ proto_register_bpdu(void) proto_register_field_array(proto_bpdu, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_bpdu(void) +{ + dissector_add("llc.dsap", SAP_BPDU, dissect_bpdu); +} diff --git a/packet-ip.c b/packet-ip.c index f74031c814..11c91b9288 100644 --- a/packet-ip.c +++ b/packet-ip.c @@ -1,7 +1,7 @@ /* packet-ip.c * Routines for IP and miscellaneous IP protocol packet disassembly * - * $Id: packet-ip.c,v 1.81 2000/04/16 22:46:19 guy Exp $ + * $Id: packet-ip.c,v 1.82 2000/04/17 00:32:38 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -52,6 +52,7 @@ #include "etypes.h" #include "ppptypes.h" +#include "llcsaps.h" #include "packet-ip.h" #include "packet-ipsec.h" @@ -1486,6 +1487,7 @@ proto_reg_handoff_ip(void) dissector_add("ethertype", ETHERTYPE_IP, dissect_ip); dissector_add("ppp.protocol", PPP_IP, dissect_ip); dissector_add("ip.proto", IP_PROTO_IPV4, dissect_ip); + dissector_add("llc.dsap", SAP_IP, dissect_ip); } void diff --git a/packet-ipx.c b/packet-ipx.c index 50d0772c5f..01f6cc5a85 100644 --- a/packet-ipx.c +++ b/packet-ipx.c @@ -2,7 +2,7 @@ * Routines for NetWare's IPX * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-ipx.c,v 1.54 2000/04/16 21:37:05 guy Exp $ + * $Id: packet-ipx.c,v 1.55 2000/04/17 00:32:39 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -36,6 +36,7 @@ #include <glib.h> #include "etypes.h" #include "ppptypes.h" +#include "llcsaps.h" #include "packet.h" #include "packet-ipx.h" #include "packet-nbipx.h" @@ -977,4 +978,5 @@ proto_reg_handoff_ipx(void) dissector_add("udp.port", UDP_PORT_IPX, dissect_ipx); dissector_add("ethertype", ETHERTYPE_IPX, dissect_ipx); dissector_add("ppp.protocol", PPP_IPX, dissect_ipx); + dissector_add("llc.dsap", SAP_NETWARE, dissect_ipx); } diff --git a/packet-llc.c b/packet-llc.c index 732f0ecc12..dc1948e3bc 100644 --- a/packet-llc.c +++ b/packet-llc.c @@ -2,7 +2,7 @@ * Routines for IEEE 802.2 LLC layer * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-llc.c,v 1.54 2000/04/13 02:36:35 guy Exp $ + * $Id: packet-llc.c,v 1.55 2000/04/17 00:32:39 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -37,6 +37,7 @@ #include "oui.h" #include "xdlc.h" #include "etypes.h" +#include "llcsaps.h" #include "packet-bpdu.h" #include "packet-cdp.h" #include "packet-cgmp.h" @@ -60,16 +61,17 @@ static int hf_llc_pid = -1; static gint ett_llc = -1; static gint ett_llc_ctrl = -1; +static dissector_table_t subdissector_table; + typedef void (capture_func_t)(const u_char *, int, packet_counts *); -typedef void (dissect_func_t)(const u_char *, int, frame_data *, proto_tree *); -/* The SAP info is split into two tables, one value_string table and one table of sap_info. This is - * so that the value_string can be used in the header field registration. +/* The SAP info is split into two tables, one value_string table and one + * table of sap_info. This is so that the value_string can be used in the + * header field registration. */ struct sap_info { guint8 sap; capture_func_t *capture_func; - dissect_func_t *dissect_func; }; /* @@ -97,8 +99,6 @@ struct sap_info { */ #define SAP_MASK 0xFE -#define SAP_SNAP 0xAA - /* * These are for SSAP and DSAP, wth last bit always zero. * XXX - some DSAPs come in separate "individual" and "group" versions, @@ -107,64 +107,45 @@ struct sap_info { * the ISO Network Layer Protocol, 0xFF is the Global LSAP. */ static const value_string sap_vals[] = { - { 0x00, "NULL LSAP" }, - { 0x02, "LLC Sub-Layer Management" }, - { 0x04, "SNA Path Control" }, - { 0x06, "TCP/IP" }, - { 0x08, "SNA" }, - { 0x0C, "SNA" }, - { 0x0E, "PROWAY (IEC955) Network Management and Initialization" }, - { 0x18, "Texas Instruments" }, - { 0x42, "Spanning Tree BPDU" }, - { 0x4E, "EIA RS-511 Manufacturing Message Service" }, + { SAP_NULL, "NULL LSAP" }, + { SAP_LLC_SLMGMT, "LLC Sub-Layer Management" }, + { SAP_SNA_PATHCTRL, "SNA Path Control" }, + { SAP_IP, "TCP/IP" }, + { SAP_SNA1, "SNA" }, + { SAP_SNA2, "SNA" }, + { SAP_PROWAY_NM_INIT, "PROWAY (IEC955) Network Management and Initialization" }, + { SAP_TI, "Texas Instruments" }, + { SAP_BPDU, "Spanning Tree BPDU" }, + { SAP_RS511, "EIA RS-511 Manufacturing Message Service" }, #if 0 /* XXX - setting the group bit makes this 0x7F; is that just a group version of this? */ - { 0x7E, "ISO 8208 (X.25 over 802.2 Type 2)" }, + { 0x7E, "ISO 8208 (X.25 over 802.2 Type 2)" }, #endif - { 0x7F, "ISO 802.2" }, - { 0x80, "XNS" }, - { 0x86, "Nestar" }, - { 0x8E, "PROWAY (IEC955) Active Station List Maintenance" }, - { 0x98, "ARP" }, /* XXX - hand to "dissect_arp()"? */ - { SAP_SNAP, "SNAP" }, - { 0xBA, "Banyan Vines" }, - { 0xBC, "Banyan Vines" }, - { 0xE0, "NetWare" }, - { 0xF0, "NetBIOS" }, - { 0xF4, "IBM Net Management" }, - { 0xF8, "Remote Program Load" }, - { 0xFA, "Ungermann-Bass" }, - { 0xFC, "Remote Program Load" }, - { 0xFE, "ISO Network Layer" }, - { 0xFF, "Global LSAP" }, - { 0x00, NULL } + { 0x7F, "ISO 802.2" }, + { SAP_XNS, "XNS" }, + { SAP_NESTAR, "Nestar" }, + { SAP_PROWAY_ASLM, "PROWAY (IEC955) Active Station List Maintenance" }, + { SAP_ARP, "ARP" }, /* XXX - hand to "dissect_arp()"? */ + { SAP_SNAP, "SNAP" }, + { SAP_VINES1, "Banyan Vines" }, + { SAP_VINES2, "Banyan Vines" }, + { SAP_NETWARE, "NetWare" }, + { SAP_NETBIOS, "NetBIOS" }, + { SAP_IBMNM, "IBM Net Management" }, + { SAP_RPL1, "Remote Program Load" }, + { SAP_UB, "Ungermann-Bass" }, + { SAP_RPL2, "Remote Program Load" }, + { SAP_OSINL, "ISO Network Layer" }, + { SAP_GLOBAL, "Global LSAP" }, + { 0x00, NULL } }; static struct sap_info saps[] = { - { 0x00, NULL, NULL }, - { 0x02, NULL, NULL }, - { 0x03, NULL, NULL }, - { 0x04, NULL, dissect_sna }, - { 0x05, NULL, NULL }, - { 0x06, capture_ip, dissect_ip }, - { 0x08, NULL, NULL }, - { 0x0C, NULL, NULL }, - { 0x42, NULL, dissect_bpdu }, - { 0x7F, NULL, NULL }, - { 0x80, NULL, NULL }, - { SAP_SNAP, NULL, NULL }, - { 0xBA, NULL, NULL }, - { 0xBC, NULL, NULL }, - { 0xE0, capture_ipx, dissect_ipx }, - { 0xF0, capture_netbios, dissect_netbios }, - { 0xF4, NULL, NULL }, - { 0xF5, NULL, NULL }, - { 0xF8, NULL, NULL }, - { 0xFC, NULL, NULL }, - { 0xFE, NULL, dissect_osi }, - { 0xFF, NULL, NULL }, - { 0x00, NULL, NULL} + { SAP_IP, capture_ip }, + { SAP_NETWARE, capture_ipx }, + { SAP_NETBIOS, capture_netbios }, + { 0x00, NULL} }; /* @@ -204,22 +185,6 @@ sap_capture_func(u_char sap) { return NULL; } -static dissect_func_t * -sap_dissect_func(u_char sap) { - int i=0; - - /* look for the second record where sap == 0, which should - * be the last record - */ - while (saps[i].sap > 0 || i == 0) { - if (saps[i].sap == sap) { - return saps[i].dissect_func; - } - i++; - } - return &dissect_data; -} - void capture_llc(const u_char *pd, int offset, packet_counts *ld) { @@ -308,7 +273,7 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { int llc_header_len; guint32 oui; guint16 etype; - dissect_func_t *dissect; + guint8 dsap; if (!BYTES_ARE_IN_FRAME(offset, 2)) { dissect_data(pd, offset, fd, tree); @@ -459,15 +424,13 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { } if (XDLC_IS_INFORMATION(control)) { - dissect = sap_dissect_func(pd[offset]); - /* non-SNAP */ + dsap = pd[offset]; offset += llc_header_len; - if (dissect) { - dissect(pd, offset, fd, tree); - } - else { + /* do lookup with the subdissector table */ + if (!dissector_try_port(subdissector_table, dsap, + pd, offset, fd, tree)) { dissect_data(pd, offset, fd, tree); } } else { @@ -525,4 +488,7 @@ proto_register_llc(void) proto_llc = proto_register_protocol ("Logical-Link Control", "llc" ); proto_register_field_array(proto_llc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + +/* subdissector code */ + subdissector_table = register_dissector_table("llc.dsap"); } diff --git a/packet-netbios.c b/packet-netbios.c index ffb4269018..5b92ef4829 100644 --- a/packet-netbios.c +++ b/packet-netbios.c @@ -5,7 +5,7 @@ * * derived from the packet-nbns.c * - * $Id: packet-netbios.c,v 1.17 2000/03/07 05:20:54 guy Exp $ + * $Id: packet-netbios.c,v 1.18 2000/04/17 00:32:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -40,6 +40,7 @@ #include <glib.h> #include "packet.h" +#include "llcsaps.h" #include "packet-netbios.h" #include "packet-smb.h" @@ -960,7 +961,7 @@ void (*dissect_netb[])(const u_char *, int, frame_data *, proto_tree *) = { }; -void dissect_netbios(const u_char *pd, int offset, frame_data *fd, +static void dissect_netbios(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { @@ -1081,3 +1082,9 @@ void proto_register_netbios(void) proto_netbios = proto_register_protocol("NetBIOS", "netbios"); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_netbios(void) +{ + dissector_add("llc.dsap", SAP_NETBIOS, dissect_netbios); +} diff --git a/packet-netbios.h b/packet-netbios.h index 45b99d7e67..f0d16ed86e 100644 --- a/packet-netbios.h +++ b/packet-netbios.h @@ -5,7 +5,7 @@ * * derived from the packet-nbns.c * - * $Id: packet-netbios.h,v 1.5 2000/02/15 21:02:42 gram Exp $ + * $Id: packet-netbios.h,v 1.6 2000/04/17 00:32:41 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -31,7 +31,6 @@ #define NETBIOS_NAME_LEN 16 void capture_netbios(const u_char *, int, packet_counts *); -void dissect_netbios(const u_char *, int, frame_data *, proto_tree *); extern int process_netbios_name(const u_char *name_ptr, char *name_ret); extern int get_netbios_name(const u_char *data_ptr, int offset, diff --git a/packet-osi.c b/packet-osi.c index c0b1f73deb..29c55544f3 100644 --- a/packet-osi.c +++ b/packet-osi.c @@ -2,7 +2,7 @@ * Routines for ISO/OSI network and transport protocol packet disassembly * Main entrance point and common functions * - * $Id: packet-osi.c,v 1.31 2000/04/16 09:10:52 deniel Exp $ + * $Id: packet-osi.c,v 1.32 2000/04/17 00:32:41 guy Exp $ * Laurent Deniel <deniel@worldnet.fr> * Ralf Schneider <Ralf.Schneider@t-online.de> * @@ -40,7 +40,7 @@ #include <ctype.h> #include <glib.h> #include "packet.h" -#include "packet-h1.h" +#include "llcsaps.h" #include "nlpid.h" #include "packet-osi.h" #include "packet-clnp.h" @@ -259,3 +259,9 @@ void dissect_osi(const u_char *pd, int offset, frame_data *fd, break; } } /* dissect_osi */ + +void +proto_reg_handoff_osi(void) +{ + dissector_add("llc.dsap", SAP_OSINL, dissect_osi); +} diff --git a/packet-sna.c b/packet-sna.c index 26d1f05416..9fb1f2976b 100644 --- a/packet-sna.c +++ b/packet-sna.c @@ -2,7 +2,7 @@ * Routines for SNA * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-sna.c,v 1.13 2000/04/13 20:39:14 gram Exp $ + * $Id: packet-sna.c,v 1.14 2000/04/17 00:32:42 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -34,6 +34,7 @@ #include <glib.h> #include "packet.h" +#include "llcsaps.h" #include "packet-sna.h" /* @@ -301,7 +302,7 @@ static int dissect_fid5 (const u_char*, int, frame_data*, proto_tree*); static int dissect_fidf (const u_char*, int, frame_data*, proto_tree*); static void dissect_rh (const u_char*, int, frame_data*, proto_tree*); -void +static void dissect_sna(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { proto_tree *sna_tree = NULL, *th_tree = NULL, *rh_tree = NULL; @@ -1201,3 +1202,9 @@ proto_register_sna(void) proto_register_field_array(proto_sna, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_sna(void) +{ + dissector_add("llc.dsap", SAP_SNA_PATHCTRL, dissect_sna); +} diff --git a/packet-sna.h b/packet-sna.h index 71d3921c2f..aa18ac3b65 100644 --- a/packet-sna.h +++ b/packet-sna.h @@ -1,7 +1,7 @@ /* packet-sna.h * Definitions for SNA dissection. * - * $Id: packet-sna.h,v 1.2 2000/02/15 21:03:10 gram Exp $ + * $Id: packet-sna.h,v 1.3 2000/04/17 00:32:43 guy Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,5 +33,3 @@ struct sna_fid_type_4_addr { * Routine to take an SNA FID Type 4 address and generate a string. */ extern gchar *sna_fid_type_4_addr_to_str(const struct sna_fid_type_4_addr *addrp); - -void dissect_sna(const u_char *, int, frame_data *, proto_tree *); |