diff options
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | Makefile.nmake | 4 | ||||
-rw-r--r-- | packet-aarp.c | 8 | ||||
-rw-r--r-- | packet-aarp.h | 26 | ||||
-rw-r--r-- | packet-arp.c | 9 | ||||
-rw-r--r-- | packet-atalk.c | 9 | ||||
-rw-r--r-- | packet-ethertype.c (renamed from ethertype.c) | 118 | ||||
-rw-r--r-- | packet-ip.c | 9 | ||||
-rw-r--r-- | packet-ipv6.c | 9 | ||||
-rw-r--r-- | packet-ipx.c | 4 | ||||
-rw-r--r-- | packet-mpls.c | 8 | ||||
-rw-r--r-- | packet-pppoe.c | 9 | ||||
-rw-r--r-- | packet-snmp.c | 4 | ||||
-rw-r--r-- | packet-tcp.c | 4 | ||||
-rw-r--r-- | packet-udp.c | 4 | ||||
-rw-r--r-- | packet-vines.c | 9 | ||||
-rw-r--r-- | packet-vlan.c | 8 | ||||
-rw-r--r-- | packet-x25.c | 9 | ||||
-rw-r--r-- | packet.c | 53 | ||||
-rw-r--r-- | packet.h | 5 | ||||
-rw-r--r-- | proto.c | 19 | ||||
-rw-r--r-- | proto.h | 9 |
22 files changed, 179 insertions, 163 deletions
diff --git a/Makefile.am b/Makefile.am index b3dbfa6ab5..03cc08a341 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.181 2000/04/12 22:53:13 guy Exp $ +# $Id: Makefile.am,v 1.182 2000/04/13 18:18:41 gram Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@zing.org> @@ -34,7 +34,6 @@ YFLAGS=-d -p dfilter_ DISSECTOR_SOURCES = \ packet-aarp.c \ - packet-aarp.h \ packet-afs.c \ packet-afs.h \ packet-arp.c \ @@ -66,6 +65,7 @@ DISSECTOR_SOURCES = \ packet-dns.h \ packet-eth.c \ packet-eth.h \ + packet-ethertype.c \ packet-fddi.c \ packet-fddi.h \ packet-ftp.c \ @@ -243,7 +243,6 @@ ETHEREAL_COMMON_SOURCES = \ dfilter-scanner.l \ dfilter.c \ dfilter.h \ - ethertype.c \ etypes.h \ follow.c \ follow.h \ diff --git a/Makefile.nmake b/Makefile.nmake index 587a828f21..779b49e44c 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: nmake -f makefile.nmake # -# $Id: Makefile.nmake,v 1.25 2000/04/13 11:11:37 gram Exp $ +# $Id: Makefile.nmake,v 1.26 2000/04/13 18:18:42 gram Exp $ include config.nmake @@ -36,6 +36,7 @@ DISSECTOR_OBJECTS = \ packet-dhis.obj \ packet-dns.obj \ packet-eth.obj \ + packet-ethertype.obj \ packet-fddi.obj \ packet-ftp.obj \ packet-giop.obj \ @@ -140,7 +141,6 @@ ETHEREAL_COMMON_OBJECTS = \ dfilter-grammar.obj \ dfilter-scanner.obj \ dfilter.obj \ - ethertype.obj \ follow.obj \ getopt.obj \ ipproto.obj \ diff --git a/packet-aarp.c b/packet-aarp.c index f12149aeb8..8190707d42 100644 --- a/packet-aarp.c +++ b/packet-aarp.c @@ -1,7 +1,7 @@ /* packet-aarp.c * Routines for Appletalk ARP packet disassembly * - * $Id: packet-aarp.c,v 1.17 2000/03/12 04:47:33 gram Exp $ + * $Id: packet-aarp.c,v 1.18 2000/04/13 18:18:43 gram Exp $ * * Simon Wilkinson <sxw@dcs.ed.ac.uk> * @@ -283,3 +283,9 @@ proto_register_aarp(void) proto_register_field_array(proto_aarp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_aarp(void) +{ + dissector_add("ethertype", ETHERTYPE_AARP, dissect_aarp); +} diff --git a/packet-aarp.h b/packet-aarp.h deleted file mode 100644 index 83def70f47..0000000000 --- a/packet-aarp.h +++ /dev/null @@ -1,26 +0,0 @@ -/* packet-aarp.h - * - * $Id: packet-aarp.h,v 1.1 2000/02/15 21:01:56 gram 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. - */ - - -void dissect_aarp(const u_char *, int, frame_data *, proto_tree *); diff --git a/packet-arp.c b/packet-arp.c index cce1e92028..57513c91df 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.26 2000/03/12 04:47:34 gram Exp $ + * $Id: packet-arp.c,v 1.27 2000/04/13 18:18:43 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -792,3 +792,10 @@ proto_register_arp(void) proto_register_field_array(proto_arp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_arp(void) +{ + dissector_add("ethertype", ETHERTYPE_ARP, dissect_arp); + dissector_add("ethertype", ETHERTYPE_REVARP, dissect_arp); +} diff --git a/packet-atalk.c b/packet-atalk.c index 824d5f68e9..e07046630d 100644 --- a/packet-atalk.c +++ b/packet-atalk.c @@ -1,7 +1,7 @@ /* packet-atalk.c * Routines for Appletalk packet disassembly (DDP, currently). * - * $Id: packet-atalk.c,v 1.31 2000/03/12 04:47:35 gram Exp $ + * $Id: packet-atalk.c,v 1.32 2000/04/13 18:18:44 gram Exp $ * * Simon Wilkinson <sxw@dcs.ed.ac.uk> * @@ -35,6 +35,7 @@ #include <glib.h> #include "packet.h" #include "packet-atalk.h" +#include "etypes.h" static int proto_ddp = -1; static int hf_ddp_hopcount = -1; @@ -555,3 +556,9 @@ proto_register_atalk(void) proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_atalk(void) +{ + dissector_add("ethertype", ETHERTYPE_ATALK, dissect_ddp); +} diff --git a/ethertype.c b/packet-ethertype.c index 93344ec03b..6a4fb20a49 100644 --- a/ethertype.c +++ b/packet-ethertype.c @@ -1,8 +1,7 @@ /* ethertype.c * Routines for calling the right protocol for the ethertype. - * This is called by both packet-eth.c (Ethernet II) and packet-llc.c (SNAP) * - * $Id: ethertype.c,v 1.28 2000/03/09 18:31:50 ashokn Exp $ + * $Id: packet-ethertype.c,v 1.1 2000/04/13 18:18:45 gram Exp $ * * Gilbert Ramirez <gram@xiexie.org> * @@ -37,18 +36,8 @@ #include <glib.h> #include "packet.h" #include "etypes.h" -#include "packet-aarp.h" -#include "packet-arp.h" -#include "packet-atalk.h" -#include "packet-ip.h" -#include "packet-ipv6.h" -#include "packet-ipx.h" -#include "packet-pppoe.h" -#include "packet-snmp.h" -#include "packet-vines.h" -#include "packet-vlan.h" -#include "packet-x25.h" -#include "packet-mpls.h" + +static dissector_table_t ethertype_dissector_table; const value_string etype_vals[] = { {ETHERTYPE_IP, "IP" }, @@ -97,62 +86,51 @@ ethertype(guint16 etype, int offset, const u_char *pd, frame_data *fd, proto_tree *tree, proto_tree *fh_tree, int item_id) { - if (tree) { - proto_tree_add_item(fh_tree, item_id, offset - 2, 2, etype); - } - switch (etype) { - case ETHERTYPE_IP: - dissect_ip(pd, offset, fd, tree); - break; - case ETHERTYPE_IPv6: - dissect_ipv6(pd, offset, fd, tree); - break; - case ETHERTYPE_X25L3: - dissect_x25(pd, offset, fd, tree); - break; - case ETHERTYPE_ARP: - dissect_arp(pd, offset, fd, tree); - break; - case ETHERTYPE_REVARP: - dissect_arp(pd, offset, fd, tree); - break; - case ETHERTYPE_ATALK: - dissect_ddp(pd, offset, fd, tree); - break; - case ETHERTYPE_AARP: - dissect_aarp(pd, offset, fd, tree); - break; - case ETHERTYPE_IPX: - dissect_ipx(pd, offset, fd, tree); - break; - case ETHERTYPE_VINES: - dissect_vines(pd, offset, fd, tree); - break; - case ETHERTYPE_LOOP: - dissect_data(pd, offset, fd, tree); - if (check_col(fd, COL_PROTOCOL)) { col_add_fstr(fd, COL_PROTOCOL, "LOOP"); } - break; - case ETHERTYPE_PPPOED: - dissect_pppoed(pd, offset, fd, tree); - break; - case ETHERTYPE_PPPOES: - dissect_pppoes(pd, offset, fd, tree); - break; - case ETHERTYPE_VLAN: - dissect_vlan(pd, offset, fd, tree); - break; - case ETHERTYPE_SNMP: - dissect_snmp(pd, offset, fd, tree); - break; - case ETHERTYPE_MPLS: - dissect_mpls(pd, offset, fd, tree); - break; - default: - dissect_data(pd, offset, fd, tree); - if (check_col(fd, COL_PROTOCOL)) { col_add_fstr(fd, COL_PROTOCOL, "0x%04x", etype); } - break; - } -} + dissector_t sub_dissector; + char *description; + + /* Add to proto_tree */ + if (tree) { + proto_tree_add_item(fh_tree, item_id, offset - 2, 2, etype); + } + + /* Look for sub-dissector */ + sub_dissector = dissector_lookup( ethertype_dissector_table, etype ); + + if (sub_dissector) { + /* Call sub-dissector */ + sub_dissector(pd, offset, fd, tree); + } + else { + /* Label rest of packet as "Data" */ + dissect_data(pd, offset, fd, tree); + /* Label protocol */ + switch(etype) { + case ETHERTYPE_LOOP: + if (check_col(fd, COL_PROTOCOL)) { + col_add_fstr(fd, COL_PROTOCOL, "LOOP"); + } + break; + default: + if (check_col(fd, COL_PROTOCOL)) { + col_add_fstr(fd, COL_PROTOCOL, "0x%04x", etype); + } + break; + } + if (check_col(fd, COL_INFO)) { + description = match_strval(etype, etype_vals); + if (description) { + col_add_fstr(fd, COL_INFO, "%s", description); + } + } + } +} +void +proto_register_ethertype(void) +{ + /* subdissector code */ + ethertype_dissector_table = register_dissector_table("ethertype"); +} diff --git a/packet-ip.c b/packet-ip.c index c285a58148..3fac5a22d7 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.78 2000/03/21 05:15:12 guy Exp $ + * $Id: packet-ip.c,v 1.79 2000/04/13 18:18:45 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -50,6 +50,7 @@ # include "snprintf.h" #endif +#include "etypes.h" #include "packet-gre.h" #include "packet-ip.h" #include "packet-ipsec.h" @@ -1517,6 +1518,12 @@ proto_register_ip(void) } void +proto_reg_handoff_ip(void) +{ + dissector_add("ethertype", ETHERTYPE_IP, dissect_ip); +} + +void proto_register_icmp(void) { static hf_register_info hf[] = { diff --git a/packet-ipv6.c b/packet-ipv6.c index b93f3cc2bc..7a58a5426e 100644 --- a/packet-ipv6.c +++ b/packet-ipv6.c @@ -1,7 +1,7 @@ /* packet-ipv6.c * Routines for IPv6 packet disassembly * - * $Id: packet-ipv6.c,v 1.31 2000/03/21 04:15:04 guy Exp $ + * $Id: packet-ipv6.c,v 1.32 2000/04/13 18:18:46 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -42,6 +42,7 @@ #include <string.h> #include <stdio.h> #include <glib.h> +#include "etypes.h" #include "packet.h" #include "packet-icmpv6.h" #include "packet-ip.h" @@ -470,3 +471,9 @@ proto_register_ipv6(void) proto_register_field_array(proto_ipv6, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_ipv6(void) +{ + dissector_add("ethertype", ETHERTYPE_IPv6, dissect_ipv6); +} diff --git a/packet-ipx.c b/packet-ipx.c index 0e6df2638a..f09c2af008 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.52 2000/04/08 07:07:21 guy Exp $ + * $Id: packet-ipx.c,v 1.53 2000/04/13 18:18:47 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -34,6 +34,7 @@ #include <stdio.h> #include <glib.h> +#include "etypes.h" #include "packet.h" #include "packet-ipx.h" #include "packet-nbipx.h" @@ -973,4 +974,5 @@ void proto_reg_handoff_ipx(void) { dissector_add("udp.port", UDP_PORT_IPX, dissect_ipx); + dissector_add("ethertype", ETHERTYPE_IPX, dissect_ipx); } diff --git a/packet-mpls.c b/packet-mpls.c index 028d4b7ac8..7c9cd5bbc3 100644 --- a/packet-mpls.c +++ b/packet-mpls.c @@ -3,7 +3,7 @@ * * (c) Copyright Ashok Narayanan <ashokn@cisco.com> * - * $Id: packet-mpls.c,v 1.3 2000/03/20 22:52:44 gram Exp $ + * $Id: packet-mpls.c,v 1.4 2000/04/13 18:18:48 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -43,6 +43,7 @@ #endif #include <glib.h> +#include "etypes.h" #include "packet.h" #include "packet-mpls.h" #include "packet-ip.h" @@ -190,3 +191,8 @@ proto_register_mpls(void) proto_register_subtree_array(ett, array_length(ett)); } +void +proto_reg_handoff_mpls(void) +{ + dissector_add("ethertype", ETHERTYPE_MPLS, dissect_mpls); +} diff --git a/packet-pppoe.c b/packet-pppoe.c index ff1161250c..af15049757 100644 --- a/packet-pppoe.c +++ b/packet-pppoe.c @@ -1,7 +1,7 @@ /* packet-arp.c * Routines for ARP packet disassembly * - * $Id: packet-pppoe.c,v 1.5 2000/02/15 21:02:54 gram Exp $ + * $Id: packet-pppoe.c,v 1.6 2000/04/13 18:18:48 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -32,6 +32,7 @@ #endif #include <glib.h> +#include "etypes.h" #include "packet.h" #include "packet-ppp.h" @@ -247,3 +248,9 @@ proto_register_pppoed(void) proto_register_subtree_array(ett, array_length(ett)); } +void +proto_reg_handoff_pppoe(void) +{ + dissector_add("ethertype", ETHERTYPE_PPPOED, dissect_pppoed); + dissector_add("ethertype", ETHERTYPE_PPPOES, dissect_pppoes); +} diff --git a/packet-snmp.c b/packet-snmp.c index c816e3426b..b72e42426e 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -2,7 +2,7 @@ * Routines for SNMP (simple network management protocol) * D.Jorand (c) 1998 * - * $Id: packet-snmp.c,v 1.27 2000/04/08 07:07:36 guy Exp $ + * $Id: packet-snmp.c,v 1.28 2000/04/13 18:18:48 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -50,6 +50,7 @@ #include <glib.h> #include "packet.h" +#include "etypes.h" #if defined(HAVE_UCD_SNMP_SNMP_H) || defined(HAVE_SNMP_SNMP_H) /* @@ -1185,4 +1186,5 @@ proto_reg_handoff_snmp(void) { dissector_add("udp.port", UDP_PORT_SNMP, dissect_snmp); dissector_add("udp.port", UDP_PORT_SNMP_TRAP, dissect_snmp); + dissector_add("ethertype", ETHERTYPE_SNMP, dissect_snmp); } diff --git a/packet-tcp.c b/packet-tcp.c index b06a58092c..ecf39355cb 100644 --- a/packet-tcp.c +++ b/packet-tcp.c @@ -1,7 +1,7 @@ /* packet-tcp.c * Routines for TCP packet disassembly * - * $Id: packet-tcp.c,v 1.67 2000/04/12 22:53:15 guy Exp $ + * $Id: packet-tcp.c,v 1.68 2000/04/13 18:18:49 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -636,5 +636,5 @@ proto_register_tcp(void) proto_register_subtree_array(ett, array_length(ett)); /* subdissector code */ - subdissector_table = register_dissector_table(hf_tcp_port); + subdissector_table = register_dissector_table("tcp.port"); } diff --git a/packet-udp.c b/packet-udp.c index ca22c9f972..079b19f442 100644 --- a/packet-udp.c +++ b/packet-udp.c @@ -1,7 +1,7 @@ /* packet-udp.c * Routines for UDP packet disassembly * - * $Id: packet-udp.c,v 1.60 2000/04/12 22:53:16 guy Exp $ + * $Id: packet-udp.c,v 1.61 2000/04/13 18:18:50 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -246,5 +246,5 @@ proto_register_udp(void) proto_register_subtree_array(ett, array_length(ett)); /* subdissector code */ - udp_dissector_table = register_dissector_table(hf_udp_port); + udp_dissector_table = register_dissector_table("udp.port"); } diff --git a/packet-vines.c b/packet-vines.c index b1d35e04c5..ba7d499d8c 100644 --- a/packet-vines.c +++ b/packet-vines.c @@ -1,7 +1,7 @@ /* packet-vines.c * Routines for Banyan VINES protocol packet disassembly * - * $Id: packet-vines.c,v 1.12 2000/01/23 08:55:37 guy Exp $ + * $Id: packet-vines.c,v 1.13 2000/04/13 18:18:52 gram Exp $ * * Don Lafontaine <lafont02@cn.ca> * @@ -37,6 +37,7 @@ #endif #include <glib.h> +#include "etypes.h" #include "packet.h" #include "packet-vines.h" @@ -339,3 +340,9 @@ proto_register_vines(void) proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_vines(void) +{ + dissector_add("ethertype", ETHERTYPE_VINES, dissect_vines); +} diff --git a/packet-vlan.c b/packet-vlan.c index f6215eb9c2..6096ff40e6 100644 --- a/packet-vlan.c +++ b/packet-vlan.c @@ -1,7 +1,7 @@ /* packet-vlan.c * Routines for VLAN 802.1Q ethernet header disassembly * - * $Id: packet-vlan.c,v 1.8 2000/02/15 21:03:25 gram Exp $ + * $Id: packet-vlan.c,v 1.9 2000/04/13 18:18:52 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -133,3 +133,9 @@ proto_register_vlan(void) proto_register_field_array(proto_vlan, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } + +void +proto_reg_handoff_vlan(void) +{ + dissector_add("ethertype", ETHERTYPE_VLAN, dissect_vlan); +} diff --git a/packet-x25.c b/packet-x25.c index e6ece02fa8..51141f7969 100644 --- a/packet-x25.c +++ b/packet-x25.c @@ -2,7 +2,7 @@ * Routines for x25 packet disassembly * Olivier Abad <abad@daba.dhis.net> * - * $Id: packet-x25.c,v 1.22 2000/03/12 04:47:51 gram Exp $ + * $Id: packet-x25.c,v 1.23 2000/04/13 18:18:53 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -36,6 +36,7 @@ #include <glib.h> #include <stdlib.h> #include <string.h> +#include "etypes.h" #include "packet.h" #include "packet-ip.h" #include "packet-osi.h" @@ -1978,3 +1979,9 @@ proto_register_x25(void) proto_register_subtree_array(ett, array_length(ett)); register_init_routine(&reinit_x25_hashtable); } + +void +proto_reg_handoff_x25(void) +{ + dissector_add("ethertype", ETHERTYPE_X25L3, dissect_x25); +} @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.74 2000/04/04 16:33:57 gram Exp $ + * $Id: packet.c,v 1.75 2000/04/13 18:18:54 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -1266,15 +1266,27 @@ proto_register_frame(void) /*********************** code added for sub-dissector lookup *********************/ -dissector_t dissector_lookup( dissector_table_t table, guint32 pattern) { +static GHashTable *dissector_tables = NULL; -/* lookup a dissector based upon pattern. */ +/* Finds a dissector table by field name. */ +static dissector_table_t +find_dissector_table(const char *name) +{ + g_assert(dissector_tables); + return g_hash_table_lookup( dissector_tables, name ); +} +dissector_t +dissector_lookup( dissector_table_t table, guint32 pattern) +{ + /* lookup a dissector based upon pattern. */ return g_hash_table_lookup( table, GUINT_TO_POINTER( pattern)); } -void dissector_add( char *name, guint32 pattern, dissector_t dissector) { +void +dissector_add( char *name, guint32 pattern, dissector_t dissector) +{ /* add an entry, lookup the dissector table for the specified field name, */ /* if a valid table found, add the subdissector */ @@ -1290,7 +1302,9 @@ void dissector_add( char *name, guint32 pattern, dissector_t dissector) { } -void dissector_delete( char *name, guint32 pattern, dissector_t dissector) { +void +dissector_delete( char *name, guint32 pattern, dissector_t dissector) +{ /* delete the entry for this dissector at this pattern */ @@ -1327,20 +1341,23 @@ dissector_try_port(dissector_table_t sub_dissectors, guint32 port, return FALSE; } -dissector_table_t register_dissector_table( int id){ - -/* Create and register the dissector array for this field; returns */ -/* a pointer to the dissector table. */ +dissector_table_t +register_dissector_table(const char *name) +{ + dissector_table_t sub_dissectors; -/* NOTE: currently use the g_direct_XXX functions so all the hashing is done */ -/* by glib and we don't have to create hashing or comparison funtcions. */ - + /* Create our hash-of-hashes if it doesn't already exist */ + if (!dissector_tables) { + dissector_tables = g_hash_table_new( g_str_hash, g_str_equal ); + g_assert(dissector_tables); + } - header_field_info *hfinfo = proto_registrar_get_nth(id); + /* Make sure the registration is unique */ + g_assert(!g_hash_table_lookup( dissector_tables, name )); - g_assert( hfinfo); - - hfinfo->sub_dissectors = g_hash_table_new( g_direct_hash, g_direct_equal); - return hfinfo->sub_dissectors; + /* Create and register the dissector array for this field; returns */ + /* a pointer to the dissector table. */ + sub_dissectors = g_hash_table_new( g_direct_hash, g_direct_equal ); + g_hash_table_insert( dissector_tables, (gpointer)name, (gpointer) sub_dissectors ); + return sub_dissectors; } - @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.179 2000/04/04 07:02:57 guy Exp $ + * $Id: packet.h,v 1.180 2000/04/13 18:18:54 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -210,12 +210,13 @@ typedef struct true_false_string { char *false_string; } true_false_string; +typedef GHashTable* dissector_table_t; /* types for sub-dissector lookup */ typedef void (*dissector_t)(const u_char *, int, frame_data *, proto_tree *); /* a protocol uses the function to register its sub-dissector table */ -dissector_table_t register_dissector_table( int proto_id); +dissector_table_t register_dissector_table(const char *name); /* dissector lookup routine. called by protocol dissector to find a sub-dissector */ dissector_t dissector_lookup( dissector_table_t table, guint32 pattern); @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.61 2000/04/11 16:07:40 gram Exp $ + * $Id: proto.c,v 1.62 2000/04/13 18:18:55 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -260,21 +260,6 @@ proto_registrar_get_nth(int hfindex) return g_ptr_array_index(gpa_hfinfo, hfindex); } -/* Finds a dissector table by field name. */ -dissector_table_t -find_dissector_table(const char *name) -{ - header_field_info *hfinfo; - int i, len; - - len = gpa_hfinfo->len; - for (i = 0; i < len ; i++) { - hfinfo = proto_registrar_get_nth(i); - if (strcmp(name, hfinfo->abbrev) == 0) - return hfinfo->sub_dissectors; - } - return NULL; -} /* Add a node with no text */ proto_item * @@ -949,8 +934,6 @@ proto_register_protocol(char *name, char *abbrev) hfinfo->blurb = ""; hfinfo->parent = -1; /* this field differentiates protos and fields */ - hfinfo->sub_dissectors = NULL; /* clear sub-dissector table pointer */ - return proto_register_field_init(hfinfo, hfinfo->parent); } @@ -1,7 +1,7 @@ /* proto.h * Definitions for protocol display * - * $Id: proto.h,v 1.27 2000/04/04 02:34:40 gram Exp $ + * $Id: proto.h,v 1.28 2000/04/13 18:18:56 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -90,9 +90,6 @@ enum { }; -/* types for sub-dissector lookup */ -typedef GHashTable* dissector_table_t; - /* information describing a header field */ typedef struct header_field_info { char *name; @@ -106,7 +103,6 @@ typedef struct header_field_info { int id; /* assigned by registration function, not programmer */ int parent; /* parent protocol */ int bitshift; /* bits to shift */ - dissector_table_t sub_dissectors; /* sub-dissector table pointer */ } header_field_info; @@ -342,9 +338,6 @@ char* proto_registrar_get_abbrev(int n); /* get the header field information based upon a field or protocol id */ struct header_field_info* proto_registrar_get_nth(int hfindex); -/* get the dissector table based upon a field or protocol name */ -dissector_table_t find_dissector_table(const char *name); - /* Returns enum ftenum for item # n */ int proto_registrar_get_ftype(int n); |