diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-09-03 06:27:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-09-03 06:27:03 +0000 |
commit | 172159397390fbb6467b41d32aed46da7d7b4288 (patch) | |
tree | 1e1adaa5cd9633b607ae536e1a5529c9bb0786aa | |
parent | e076cb925f3d61ab5ab72580b8a36f153ce2e9d5 (diff) | |
download | wireshark-172159397390fbb6467b41d32aed46da7d7b4288.tar.gz wireshark-172159397390fbb6467b41d32aed46da7d7b4288.tar.bz2 wireshark-172159397390fbb6467b41d32aed46da7d7b4288.zip |
Fix up the API for adding support for new OUI's to the LLC dissector.
Use that API to create the table for the Cisco OUI 00:00:0C.
svn path=/trunk/; revision=8351
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | Makefile.nmake | 3 | ||||
-rw-r--r-- | packet-cisco-oui.c | 55 | ||||
-rw-r--r-- | packet-llc.c | 65 | ||||
-rw-r--r-- | packet-llc.h | 6 |
5 files changed, 88 insertions, 44 deletions
diff --git a/Makefile.am b/Makefile.am index f0ba7d9692..d38e4d1431 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.618 2003/09/03 05:39:21 guy Exp $ +# $Id: Makefile.am,v 1.619 2003/09/03 06:27:03 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -112,6 +112,7 @@ DISSECTOR_SRC = \ packet-cdp.c \ packet-cgmp.c \ packet-chdlc.c \ + packet-cisco-oui.c \ packet-clearcase.c \ packet-clip.c \ packet-clnp.c \ diff --git a/Makefile.nmake b/Makefile.nmake index e7e603759f..a6c6279157 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake # -# $Id: Makefile.nmake,v 1.331 2003/09/03 05:39:21 guy Exp $ +# $Id: Makefile.nmake,v 1.332 2003/09/03 06:27:03 guy Exp $ include config.nmake include <win32.mak> @@ -53,6 +53,7 @@ DISSECTOR_SRC = \ packet-cdp.c \ packet-cgmp.c \ packet-chdlc.c \ + packet-cisco-oui.c \ packet-clearcase.c \ packet-clip.c \ packet-clnp.c \ diff --git a/packet-cisco-oui.c b/packet-cisco-oui.c new file mode 100644 index 0000000000..449a10e0d3 --- /dev/null +++ b/packet-cisco-oui.c @@ -0,0 +1,55 @@ +/* packet-cisco-oui.c + * Register an LLC dissector table for Cisco's OUI 00:00:0c + * + * $Id: packet-cisco-oui.c,v 1.1 2003/09/03 06:27:03 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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. + */ + +#include "config.h" + +#include <epan/packet.h> +#include "packet-llc.h" +#include "oui.h" + +static int hf_llc_cisco_pid = -1; + +static const value_string cisco_pid_vals[] = { + { 0x0102, "DRIP" }, + { 0x2000, "CDP" }, + { 0x2001, "CGMP" }, + { 0x2003, "VTP" }, + { 0, NULL } +}; + +/* + * NOTE: there's no dissector here, just registration routines to set + * up the dissector table for the Cisco OUI. + */ +void +proto_register_cisco_oui(void) +{ + static hf_register_info hf = { + &hf_llc_cisco_pid, + { "PID", "llc.cisco_pid", FT_UINT16, BASE_HEX, + VALS(cisco_pid_vals), 0x0, "", HFILL }, + }; + + llc_add_oui(OUI_CISCO, "llc.cisco_pid", "Cisco OUI PID", &hf); +} diff --git a/packet-llc.c b/packet-llc.c index c930997f5c..e32fc34ac4 100644 --- a/packet-llc.c +++ b/packet-llc.c @@ -2,7 +2,7 @@ * Routines for IEEE 802.2 LLC layer * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: packet-llc.c,v 1.113 2003/09/02 19:18:52 guy Exp $ + * $Id: packet-llc.c,v 1.114 2003/09/03 06:27:03 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -65,7 +65,6 @@ static gint ett_llc = -1; static gint ett_llc_ctrl = -1; static dissector_table_t subdissector_table; -static dissector_table_t cisco_subdissector_table; static dissector_table_t xid_subdissector_table; static dissector_table_t nortel_subdissector_table; @@ -173,41 +172,40 @@ http://www.cisco.com/univercd/cc/td/doc/product/software/ios113ed/113ed_cr/ibm_r }; /* - * Hash table for translating OUIs to a dissector table/field ID pair; + * Hash table for translating OUIs to a dissector table/field info pair; * the dissector table maps PID values to dissectors, and the field * corresponds to the PID for that OUI. */ typedef struct { dissector_table_t table; - int field_id; + hf_register_info *field_info; } oui_info_t; -static GHashTable *oui_dissector_tables = NULL; +static GHashTable *oui_info_table = NULL; /* - * Add an entry for a new OID. + * Add an entry for a new OUI. */ void -llc_add_oid(guint32 oid, const char *table_name, char *table_ui_name, - int field_id) +llc_add_oui(guint32 oui, const char *table_name, char *table_ui_name, + hf_register_info *hf_item) { oui_info_t *new_info; new_info = g_malloc(sizeof (oui_info_t)); new_info->table = register_dissector_table(table_name, table_ui_name, FT_UINT16, BASE_HEX); - new_info->field_id = field_id; + new_info->field_info = hf_item; /* * Create the hash table for OUI information, if it doesn't * already exist. */ - if (oui_dissector_tables == NULL) { - oui_dissector_tables = g_hash_table_new(g_direct_hash, + if (oui_info_table == NULL) { + oui_info_table = g_hash_table_new(g_direct_hash, g_direct_equal); } - g_hash_table_insert(oui_dissector_tables, (gpointer)oid, - new_info->table); + g_hash_table_insert(oui_info_table, (gpointer)oui, new_info); } void @@ -514,27 +512,6 @@ dissect_snap(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, } break; - case OUI_CISCO: - /* So are all CDP packets LLC packets - with an OUI of OUI_CISCO and a - protocol ID of 0x2000, or - are some of them raw or encapsulated - Ethernet? */ - if (tree) { - proto_tree_add_uint(snap_tree, hf_pid, tvb, offset+3, 2, - etype); - } - next_tvb = tvb_new_subset(tvb, offset+5, -1, -1); - if (XDLC_IS_INFORMATION(control)) { - /* do lookup with the subdissector table */ - /* for future reference, 0x0102 is Cisco DRIP */ - if (!dissector_try_port(cisco_subdissector_table, - etype, next_tvb, pinfo, tree)) - call_dissector(data_handle,next_tvb, pinfo, tree); - } else - call_dissector(data_handle,next_tvb, pinfo, tree); - break; - case OUI_CABLE_BPDU: /* DOCSIS cable modem spanning tree BPDU */ if (tree) { proto_tree_add_uint(snap_tree, hf_pid, tvb, offset+3, 2, @@ -566,13 +543,12 @@ dissect_snap(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, /* * Do we have information for this OUI? */ - oui_info = g_hash_table_lookup(oui_dissector_tables, - (gpointer)oui); + oui_info = g_hash_table_lookup(oui_info_table, (gpointer)oui); if (oui_info != NULL) { /* * Yes - use it. */ - hf = oui_info->field_id; + hf = *oui_info->field_info->p_id; subdissector_table = oui_info->table; } else { /* @@ -652,8 +628,6 @@ proto_register_llc(void) /* subdissector code */ subdissector_table = register_dissector_table("llc.dsap", "LLC SAP", FT_UINT8, BASE_HEX); - cisco_subdissector_table = register_dissector_table("llc.cisco_pid", - "Cisco OUI PID", FT_UINT16, BASE_HEX); xid_subdissector_table = register_dissector_table("llc.xid_dsap", "LLC XID SAP", FT_UINT8, BASE_HEX); nortel_subdissector_table = register_dissector_table("llc.nortel_pid", @@ -662,6 +636,14 @@ proto_register_llc(void) register_dissector("llc", dissect_llc, proto_llc); } +static void +register_hf(gpointer key _U_, gpointer value, gpointer user_data _U_) +{ + oui_info_t *info = value; + + proto_register_field_array(proto_llc, info->field_info, 1); +} + void proto_reg_handoff_llc(void) { @@ -695,4 +677,9 @@ proto_reg_handoff_llc(void) * apparently. */ dissector_add("arcnet.protocol_id", ARCNET_PROTO_BACNET, llc_handle); + + /* + * Register all the fields for PIDs for various OUIs. + */ + g_hash_table_foreach(oui_info_table, register_hf, NULL); } diff --git a/packet-llc.h b/packet-llc.h index 7cad2b5786..948d6ad092 100644 --- a/packet-llc.h +++ b/packet-llc.h @@ -1,6 +1,6 @@ /* packet-llc.h * - * $Id: packet-llc.h,v 1.10 2003/08/28 01:29:16 guy Exp $ + * $Id: packet-llc.h,v 1.11 2003/09/03 06:27:03 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -30,9 +30,9 @@ void dissect_snap(tvbuff_t *, int, packet_info *, proto_tree *, proto_tree *, int, int, int, int, int); /* - * Add an entry for a new OID. + * Add an entry for a new OUI. */ -void llc_add_oid(guint32, const char *, char *, int); +void llc_add_oui(guint32, const char *, char *, hf_register_info *); extern const value_string sap_vals[]; |