From 4179944c14ac8026099f6416fa80421a29c673b8 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 16 Apr 2000 21:37:07 +0000 Subject: Register a "ppp.protocol" dissector table for PPP, and have dissectors for protocols that run inside PPP register themselves with it using "dissector_add()". svn path=/trunk/; revision=1869 --- Makefile.am | 3 ++- packet-atalk.c | 4 +++- packet-ip.c | 4 +++- packet-ipv6.c | 4 +++- packet-ipx.c | 4 +++- packet-ppp.c | 57 ++++++++++++++++----------------------------------------- packet-vines.c | 17 +++++++++++++---- packet-vines.h | 9 +-------- ppptypes.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 97 insertions(+), 58 deletions(-) create mode 100644 ppptypes.h diff --git a/Makefile.am b/Makefile.am index 245910c5a3..ce01635634 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Ethereal # -# $Id: Makefile.am,v 1.185 2000/04/15 22:11:07 guy Exp $ +# $Id: Makefile.am,v 1.186 2000/04/16 21:37:02 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs @@ -262,6 +262,7 @@ ETHEREAL_COMMON_SOURCES = \ packet.h \ plugins.c \ plugins.h \ + ppptypes.h \ prefs.c \ prefs.h \ print.c \ diff --git a/packet-atalk.c b/packet-atalk.c index e07046630d..b599f84837 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.32 2000/04/13 18:18:44 gram Exp $ + * $Id: packet-atalk.c,v 1.33 2000/04/16 21:37:03 guy Exp $ * * Simon Wilkinson * @@ -36,6 +36,7 @@ #include "packet.h" #include "packet-atalk.h" #include "etypes.h" +#include "ppptypes.h" static int proto_ddp = -1; static int hf_ddp_hopcount = -1; @@ -561,4 +562,5 @@ void proto_reg_handoff_atalk(void) { dissector_add("ethertype", ETHERTYPE_ATALK, dissect_ddp); + dissector_add("ppp.protocol", PPP_AT, dissect_ddp); } diff --git a/packet-ip.c b/packet-ip.c index 3fac5a22d7..a23d4894af 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.79 2000/04/13 18:18:45 gram Exp $ + * $Id: packet-ip.c,v 1.80 2000/04/16 21:37:03 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -51,6 +51,7 @@ #endif #include "etypes.h" +#include "ppptypes.h" #include "packet-gre.h" #include "packet-ip.h" #include "packet-ipsec.h" @@ -1521,6 +1522,7 @@ void proto_reg_handoff_ip(void) { dissector_add("ethertype", ETHERTYPE_IP, dissect_ip); + dissector_add("ppp.protocol", PPP_IP, dissect_ip); } void diff --git a/packet-ipv6.c b/packet-ipv6.c index 7a58a5426e..06f0b97feb 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.32 2000/04/13 18:18:46 gram Exp $ + * $Id: packet-ipv6.c,v 1.33 2000/04/16 21:37:04 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -43,6 +43,7 @@ #include #include #include "etypes.h" +#include "ppptypes.h" #include "packet.h" #include "packet-icmpv6.h" #include "packet-ip.h" @@ -476,4 +477,5 @@ void proto_reg_handoff_ipv6(void) { dissector_add("ethertype", ETHERTYPE_IPv6, dissect_ipv6); + dissector_add("ppp.protocol", PPP_IPV6, dissect_ipv6); } diff --git a/packet-ipx.c b/packet-ipx.c index f09c2af008..50d0772c5f 100644 --- a/packet-ipx.c +++ b/packet-ipx.c @@ -2,7 +2,7 @@ * Routines for NetWare's IPX * Gilbert Ramirez * - * $Id: packet-ipx.c,v 1.53 2000/04/13 18:18:47 gram Exp $ + * $Id: packet-ipx.c,v 1.54 2000/04/16 21:37:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -35,6 +35,7 @@ #include #include #include "etypes.h" +#include "ppptypes.h" #include "packet.h" #include "packet-ipx.h" #include "packet-nbipx.h" @@ -975,4 +976,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); } diff --git a/packet-ppp.c b/packet-ppp.c index a8ee8b6912..d312a91aa1 100644 --- a/packet-ppp.c +++ b/packet-ppp.c @@ -1,7 +1,7 @@ /* packet-ppp.c * Routines for ppp packet disassembly * - * $Id: packet-ppp.c,v 1.30 2000/03/27 17:53:19 gram Exp $ + * $Id: packet-ppp.c,v 1.31 2000/04/16 21:37:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -34,6 +34,7 @@ #include #include "packet.h" +#include "ppptypes.h" #include "packet-atalk.h" #include "packet-ip.h" #include "packet-ipv6.h" @@ -60,6 +61,8 @@ static gint ett_lcp_callback_opt = -1; static gint ett_lcp_multilink_ep_disc_opt = -1; static gint ett_lcp_internationalization_opt = -1; +static dissector_table_t subdissector_table; + static int proto_mp = -1; static int hf_mp_frag_first = -1; static int hf_mp_frag_last = -1; @@ -76,31 +79,6 @@ typedef struct _e_ppphdr { guint16 ppp_prot; } e_ppphdr; - -/* Protocol types, from Linux "ppp_defs.h" and - - http://www.isi.edu/in-notes/iana/assignments/ppp-numbers - - */ -#define PPP_IP 0x21 /* Internet Protocol */ -#define PPP_AT 0x29 /* AppleTalk Protocol */ -#define PPP_IPX 0x2b /* IPX protocol */ -#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ -#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ -#define PPP_VINES 0x35 /* Banyan Vines */ -#define PPP_MP 0x3d /* Multilink PPP */ -#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ -#define PPP_COMP 0xfd /* compressed packet */ -#define PPP_IPCP 0x8021 /* IP Control Protocol */ -#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ -#define PPP_IPXCP 0x802b /* IPX Control Protocol */ -#define PPP_CCP 0x80fd /* Compression Control Protocol */ -#define PPP_LCP 0xc021 /* Link Control Protocol */ -#define PPP_PAP 0xc023 /* Password Authentication Protocol */ -#define PPP_LQR 0xc025 /* Link Quality Report protocol */ -#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ -#define PPP_CBCP 0xc029 /* Callback Control Protocol */ - static const value_string ppp_vals[] = { {PPP_IP, "IP" }, {PPP_AT, "Appletalk" }, @@ -1007,25 +985,19 @@ dissect_ppp_stuff( const u_char *pd, int offset, frame_data *fd, } offset += proto_len; - switch (ppp_prot) { - case PPP_IP: - dissect_ip(pd, offset, fd, tree); - return TRUE; - case PPP_AT: - dissect_ddp(pd, offset, fd, tree); - return TRUE; - case PPP_IPX: - dissect_ipx(pd, offset, fd, tree); - return TRUE; - case PPP_VINES: - dissect_vines(pd, offset, fd, tree); + /* do lookup with the subdissector table */ + if (dissector_try_port(subdissector_table, ppp_prot, pd, offset, fd, tree)) return TRUE; + + /* XXX - make "dissect_lcp()" and "dissect_ipcp()", have them just + call "dissect_cp()", and register them as well? + + We can't do that for "dissect_mp()", though, as it takes an additional + argument. */ + switch (ppp_prot) { case PPP_MP: dissect_mp(pd, offset, fd, tree, fh_tree); return TRUE; - case PPP_IPV6: - dissect_ipv6(pd, offset, fd, tree); - return TRUE; case PPP_LCP: dissect_cp(pd, offset, "L", "Link", ett_lcp, lcp_vals, ett_lcp_options, lcp_opts, N_LCP_OPTS, fd, tree); @@ -1195,6 +1167,9 @@ proto_register_ppp(void) proto_ppp = proto_register_protocol("Point-to-Point Protocol", "ppp"); /* proto_register_field_array(proto_ppp, hf, array_length(hf));*/ proto_register_subtree_array(ett, array_length(ett)); + +/* subdissector code */ + subdissector_table = register_dissector_table("ppp.protocol"); } void diff --git a/packet-vines.c b/packet-vines.c index ba7d499d8c..3128811118 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.13 2000/04/13 18:18:52 gram Exp $ + * $Id: packet-vines.c,v 1.14 2000/04/16 21:37:06 guy Exp $ * * Don Lafontaine * @@ -38,6 +38,7 @@ #include #include "etypes.h" +#include "ppptypes.h" #include "packet.h" #include "packet-vines.h" @@ -45,14 +46,21 @@ static gint ett_vines = -1; static gint ett_vines_frp = -1; static gint ett_vines_spp = -1; +#if 0 +static void dissect_vines_arp(const u_char *, int, frame_data *, proto_tree *); +static void dissect_vines_icp(const u_char *, int, frame_data *, proto_tree *); +static void dissect_vines_ipc(const u_char *, int, frame_data *, proto_tree *); +static void dissect_vines_rtp(const u_char *, int, frame_data *, proto_tree *); +#endif +static void dissect_vines_spp(const u_char *, int, frame_data *, proto_tree *); +static void dissect_vines(const u_char *, int, frame_data *, proto_tree *); + void capture_vines(const u_char *pd, int offset, packet_counts *ld) { ld->vines++; } - - /* AFAIK Vines FRP (Fragmentation Protocol) is used on all media except Ethernet * and TR (and probably FDDI) - Fragmentation on these media types is not possible * FIXME: Do we need to use this header with PPP too? @@ -126,7 +134,7 @@ vines_addr_to_str(const guint8 *addrp) return cur; } -void +static void dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { e_vip viph; @@ -345,4 +353,5 @@ void proto_reg_handoff_vines(void) { dissector_add("ethertype", ETHERTYPE_VINES, dissect_vines); + dissector_add("ppp.protocol", PPP_VINES, dissect_vines); } diff --git a/packet-vines.h b/packet-vines.h index baf1579765..ec0fb9c88a 100644 --- a/packet-vines.h +++ b/packet-vines.h @@ -1,7 +1,7 @@ /* packet-vines.h * Definitions for packet disassembly structures and routines * - * $Id: packet-vines.h,v 1.4 2000/02/15 21:03:25 gram Exp $ + * $Id: packet-vines.h,v 1.5 2000/04/16 21:37:07 guy Exp $ * * Don Lafontaine * @@ -39,14 +39,7 @@ #define __PACKETVINES_H__ void capture_vines(const u_char *, int, packet_counts *); -void dissect_vines(const u_char *, int, frame_data *, proto_tree *); -void dissect_vines_arp(const u_char *, int, frame_data *, proto_tree *); void dissect_vines_frp(const u_char *, int, frame_data *, proto_tree *); -void dissect_vines_icp(const u_char *, int, frame_data *, proto_tree *); -void dissect_vines_ipc(const u_char *, int, frame_data *, proto_tree *); -void dissect_vines_rtp(const u_char *, int, frame_data *, proto_tree *); -void dissect_vines_spp(const u_char *, int, frame_data *, proto_tree *); - /* VINES IP structs and definitions */ diff --git a/ppptypes.h b/ppptypes.h new file mode 100644 index 0000000000..c98f9c7b57 --- /dev/null +++ b/ppptypes.h @@ -0,0 +1,53 @@ +/* ppptypes.h + * Defines PPP packet types. + * + * $Id: ppptypes.h,v 1.1 2000/04/16 21:37:07 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs + * 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 __PPPTYPES_H__ +#define __PPPTYPES_H__ + +/* Protocol types, from Linux "ppp_defs.h" and + + http://www.isi.edu/in-notes/iana/assignments/ppp-numbers + + */ +#define PPP_IP 0x21 /* Internet Protocol */ +#define PPP_AT 0x29 /* AppleTalk Protocol */ +#define PPP_IPX 0x2b /* IPX protocol */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_VINES 0x35 /* Banyan Vines */ +#define PPP_MP 0x3d /* Multilink PPP */ +#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ +#define PPP_COMP 0xfd /* compressed packet */ +#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ +#define PPP_IPXCP 0x802b /* IPX Control Protocol */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_LQR 0xc025 /* Link Quality Report protocol */ +#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ +#define PPP_CBCP 0xc029 /* Callback Control Protocol */ + +#endif /* ppptypes.h */ -- cgit v1.2.1