# 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>
DISSECTOR_SOURCES = \
packet-aarp.c \
- packet-aarp.h \
packet-afs.c \
packet-afs.h \
packet-arp.c \
packet-dns.h \
packet-eth.c \
packet-eth.h \
+ packet-ethertype.c \
packet-fddi.c \
packet-fddi.h \
packet-ftp.c \
dfilter-scanner.l \
dfilter.c \
dfilter.h \
- ethertype.c \
etypes.h \
follow.c \
follow.h \
## 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
packet-dhis.obj \
packet-dns.obj \
packet-eth.obj \
+ packet-ethertype.obj \
packet-fddi.obj \
packet-ftp.obj \
packet-giop.obj \
dfilter-grammar.obj \
dfilter-scanner.obj \
dfilter.obj \
- ethertype.obj \
follow.obj \
getopt.obj \
ipproto.obj \
/* 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>
*
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);
+}
+++ /dev/null
-/* 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 *);
/* 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>
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);
+}
/* 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>
*
#include <glib.h>
#include "packet.h"
#include "packet-atalk.h"
+#include "etypes.h"
static int proto_ddp = -1;
static int hf_ddp_hopcount = -1;
proto_register_subtree_array(ett, array_length(ett));
}
+
+void
+proto_reg_handoff_atalk(void)
+{
+ dissector_add("ethertype", ETHERTYPE_ATALK, dissect_ddp);
+}
/* 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>
*
#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" },
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");
+}
/* 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>
# include "snprintf.h"
#endif
+#include "etypes.h"
#include "packet-gre.h"
#include "packet-ip.h"
#include "packet-ipsec.h"
proto_register_subtree_array(ett, array_length(ett));
}
+void
+proto_reg_handoff_ip(void)
+{
+ dissector_add("ethertype", ETHERTYPE_IP, dissect_ip);
+}
+
void
proto_register_icmp(void)
{
/* 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>
#include <string.h>
#include <stdio.h>
#include <glib.h>
+#include "etypes.h"
#include "packet.h"
#include "packet-icmpv6.h"
#include "packet-ip.h"
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);
+}
* 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>
#include <stdio.h>
#include <glib.h>
+#include "etypes.h"
#include "packet.h"
#include "packet-ipx.h"
#include "packet-nbipx.h"
proto_reg_handoff_ipx(void)
{
dissector_add("udp.port", UDP_PORT_IPX, dissect_ipx);
+ dissector_add("ethertype", ETHERTYPE_IPX, dissect_ipx);
}
*
* (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>
#endif
#include <glib.h>
+#include "etypes.h"
#include "packet.h"
#include "packet-mpls.h"
#include "packet-ip.h"
proto_register_subtree_array(ett, array_length(ett));
}
+void
+proto_reg_handoff_mpls(void)
+{
+ dissector_add("ethertype", ETHERTYPE_MPLS, dissect_mpls);
+}
/* 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>
#endif
#include <glib.h>
+#include "etypes.h"
#include "packet.h"
#include "packet-ppp.h"
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);
+}
* 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>
#include <glib.h>
#include "packet.h"
+#include "etypes.h"
#if defined(HAVE_UCD_SNMP_SNMP_H) || defined(HAVE_SNMP_SNMP_H)
/*
{
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);
}
/* 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>
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");
}
/* 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>
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");
}
/* 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>
*
#endif
#include <glib.h>
+#include "etypes.h"
#include "packet.h"
#include "packet-vines.h"
proto_register_subtree_array(ett, array_length(ett));
}
+
+void
+proto_reg_handoff_vines(void)
+{
+ dissector_add("ethertype", ETHERTYPE_VINES, dissect_vines);
+}
/* 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>
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);
+}
* 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>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
+#include "etypes.h"
#include "packet.h"
#include "packet-ip.h"
#include "packet-osi.h"
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);
+}
/* 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>
/*********************** 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 */
}
-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 */
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;
}
-
/* 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>
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);
/* 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>
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 *
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);
}
/* 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>
};
-/* types for sub-dissector lookup */
-typedef GHashTable* dissector_table_t;
-
/* information describing a header field */
typedef struct header_field_info {
char *name;
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;
/* 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);