2 * Routines for calling the right protocol for the ethertype.
4 * $Id: packet-ethertype.c,v 1.9 2000/11/18 10:38:24 guy Exp $
6 * Gilbert Ramirez <gram@xiexie.org>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@zing.org>
10 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
38 #include "packet-ip.h"
39 #include "packet-ipx.h"
40 #include "packet-vlan.h"
41 #include "packet-vines.h"
44 static dissector_table_t ethertype_dissector_table;
46 const value_string etype_vals[] = {
47 {ETHERTYPE_IP, "IP" },
48 {ETHERTYPE_IPv6, "IPv6" },
49 {ETHERTYPE_X25L3, "X.25 Layer 3" },
50 {ETHERTYPE_ARP, "ARP" },
51 {ETHERTYPE_REVARP, "RARP" },
52 {ETHERTYPE_DEC_LB, "DEC LanBridge" },
53 {ETHERTYPE_ATALK, "Appletalk" },
54 {ETHERTYPE_AARP, "AARP" },
55 {ETHERTYPE_IPX, "Netware IPX/SPX" },
56 {ETHERTYPE_VINES, "Vines" },
57 {ETHERTYPE_TRAIN, "Netmon Train" },
58 {ETHERTYPE_LOOP, "Loopback" }, /* Ethernet Loopback */
59 {ETHERTYPE_PPPOED, "PPPoE Discovery" },
60 {ETHERTYPE_PPPOES, "PPPoE Session" },
61 {ETHERTYPE_VLAN, "802.1Q Virtual LAN" },
62 {ETHERTYPE_MPLS, "MPLS label switched packet" },
63 {ETHERTYPE_MPLS_MULTI, "MPLS multicast label switched packet" },
64 {ETHERTYPE_3C_NBP_DGRAM, "3Com NBP Datagram" },
65 {ETHERTYPE_DEC, "DEC proto" },
66 {ETHERTYPE_DNA_DL, "DEC DNA Dump/Load" },
67 {ETHERTYPE_DNA_RC, "DEC DNA Remote Console" },
68 {ETHERTYPE_DNA_RT, "DEC DNA Routing" },
69 {ETHERTYPE_LAT, "DEC LAT" },
70 {ETHERTYPE_DEC_DIAG, "DEC Diagnostics" },
71 {ETHERTYPE_DEC_CUST, "DEC Customer use" },
72 {ETHERTYPE_DEC_SCA, "DEC LAVC/SCA" },
76 capture_ethertype(guint16 etype, int offset,
77 const u_char *pd, packet_counts *ld)
81 capture_ip(pd, offset, ld);
84 capture_ipx(pd, offset, ld);
87 capture_vlan(pd, offset, ld);
90 capture_vines(pd, offset, ld);
99 ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype, packet_info *pinfo,
100 proto_tree *tree, proto_tree *fh_tree, int item_id)
105 /* Add to proto_tree */
107 proto_tree_add_uint(fh_tree, item_id, tvb, offset_after_etype - 2, 2, etype);
110 /* Tvbuff for the payload after the Ethernet type. */
111 next_tvb = tvb_new_subset(tvb, offset_after_etype, -1, -1);
113 /* Look for sub-dissector */
114 if (!dissector_try_port(ethertype_dissector_table, etype,
115 next_tvb, pinfo, tree)) {
116 /* No sub-dissector found.
117 Label rest of packet as "Data" */
118 dissect_data(next_tvb, 0, pinfo, tree);
124 if (check_col(pinfo->fd, COL_PROTOCOL)) {
125 col_add_fstr(pinfo->fd, COL_PROTOCOL, "LOOP");
129 if (check_col(pinfo->fd, COL_PROTOCOL)) {
130 col_add_fstr(pinfo->fd, COL_PROTOCOL, "0x%04x", etype);
134 if (check_col(pinfo->fd, COL_INFO)) {
135 description = match_strval(etype, etype_vals);
137 col_add_fstr(pinfo->fd, COL_INFO, "%s", description);
142 /* Return the length of that tvbuff; the subdissector may have
143 reduced the length to a value specified by a length field
144 in its header, meaning what remains is padding. */
145 return tvb_reported_length(next_tvb);
150 proto_register_ethertype(void)
152 /* subdissector code */
153 ethertype_dissector_table = register_dissector_table("ethertype");