1998-09-16 02:39:15 +00:00
|
|
|
/* packet-eth.c
|
|
|
|
* Routines for ethernet packet disassembly
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1998-09-16 02:39:15 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2007-01-20 16:46:42 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1998-09-16 02:39:15 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <glib.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
#include <epan/exceptions.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2005-09-17 00:02:31 +00:00
|
|
|
#include <epan/etypes.h>
|
2004-08-06 19:57:49 +00:00
|
|
|
#include <epan/addr_resolv.h>
|
2013-09-05 01:39:35 +00:00
|
|
|
#include <epan/expert.h>
|
2013-11-09 15:44:29 +00:00
|
|
|
#include <wsutil/pint.h>
|
2000-05-19 05:29:44 +00:00
|
|
|
#include "packet-eth.h"
|
2001-02-08 07:08:05 +00:00
|
|
|
#include "packet-ieee8023.h"
|
2000-02-15 21:06:58 +00:00
|
|
|
#include "packet-ipx.h"
|
|
|
|
#include "packet-isl.h"
|
|
|
|
#include "packet-llc.h"
|
2010-11-20 18:14:30 +00:00
|
|
|
#include "packet-sll.h"
|
2011-05-10 17:40:29 +00:00
|
|
|
#include "packet-usb.h"
|
2011-08-31 09:00:54 +00:00
|
|
|
#include <epan/crc32-tvb.h>
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2013-03-17 09:11:21 +00:00
|
|
|
void proto_register_eth(void);
|
|
|
|
void proto_reg_handoff_eth(void);
|
|
|
|
|
2009-05-20 22:50:30 +00:00
|
|
|
/* Assume all packets have an FCS */
|
2011-12-06 23:07:55 +00:00
|
|
|
static gboolean eth_assume_padding = TRUE;
|
2013-06-01 09:05:56 +00:00
|
|
|
static guint eth_trailer_length = 0;
|
2009-05-20 22:50:30 +00:00
|
|
|
static gboolean eth_assume_fcs = FALSE;
|
2011-11-02 11:01:57 +00:00
|
|
|
static gboolean eth_check_fcs = TRUE;
|
2004-11-24 06:04:43 +00:00
|
|
|
/* Interpret packets as FW1 monitor file packets if they look as if they are */
|
2002-08-08 09:28:11 +00:00
|
|
|
static gboolean eth_interpret_as_fw1_monitor = FALSE;
|
2009-01-18 12:08:56 +00:00
|
|
|
/* Preference settings defining conditions for which the CCSDS dissector is called */
|
|
|
|
static gboolean ccsds_heuristic_length = FALSE;
|
|
|
|
static gboolean ccsds_heuristic_version = FALSE;
|
|
|
|
static gboolean ccsds_heuristic_header = FALSE;
|
|
|
|
static gboolean ccsds_heuristic_bit = FALSE;
|
2002-08-08 09:28:11 +00:00
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
/* protocols and header fields */
|
1999-07-29 05:47:07 +00:00
|
|
|
static int proto_eth = -1;
|
|
|
|
static int hf_eth_dst = -1;
|
2013-09-03 21:20:59 +00:00
|
|
|
static int hf_eth_dst_resolved = -1;
|
1999-07-29 05:47:07 +00:00
|
|
|
static int hf_eth_src = -1;
|
2013-09-03 21:20:59 +00:00
|
|
|
static int hf_eth_src_resolved = -1;
|
1999-07-29 05:47:07 +00:00
|
|
|
static int hf_eth_len = -1;
|
|
|
|
static int hf_eth_type = -1;
|
2011-06-29 16:05:56 +00:00
|
|
|
static int hf_eth_invalid_lentype = -1;
|
2000-03-20 21:21:33 +00:00
|
|
|
static int hf_eth_addr = -1;
|
2013-09-03 21:20:59 +00:00
|
|
|
static int hf_eth_addr_resolved = -1;
|
2006-08-25 21:33:23 +00:00
|
|
|
static int hf_eth_lg = -1;
|
2011-06-29 16:05:56 +00:00
|
|
|
static int hf_eth_ig = -1;
|
2011-12-06 23:07:55 +00:00
|
|
|
static int hf_eth_padding = -1;
|
2000-05-17 03:05:39 +00:00
|
|
|
static int hf_eth_trailer = -1;
|
2011-11-02 11:01:57 +00:00
|
|
|
static int hf_eth_fcs = -1;
|
|
|
|
static int hf_eth_fcs_good = -1;
|
|
|
|
static int hf_eth_fcs_bad = -1;
|
1999-07-07 22:52:57 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint ett_ieee8023 = -1;
|
|
|
|
static gint ett_ether2 = -1;
|
2011-06-29 16:05:56 +00:00
|
|
|
static gint ett_ether = -1;
|
2006-02-23 09:54:08 +00:00
|
|
|
static gint ett_addr = -1;
|
2011-11-02 11:01:57 +00:00
|
|
|
static gint ett_eth_fcs = -1;
|
1999-11-16 11:44:20 +00:00
|
|
|
|
2013-05-26 03:29:07 +00:00
|
|
|
static expert_field ei_eth_invalid_lentype = EI_INIT;
|
|
|
|
static expert_field ei_eth_src_not_group = EI_INIT;
|
|
|
|
static expert_field ei_eth_fcs_bad = EI_INIT;
|
2013-09-05 01:39:35 +00:00
|
|
|
static expert_field ei_eth_len = EI_INIT;
|
2013-05-26 03:29:07 +00:00
|
|
|
|
2002-08-08 09:28:11 +00:00
|
|
|
static dissector_handle_t fw1_handle;
|
2013-11-20 02:28:14 +00:00
|
|
|
static dissector_handle_t ethertype_handle;
|
2011-06-29 16:05:56 +00:00
|
|
|
static dissector_handle_t data_handle;
|
2004-02-03 23:19:54 +00:00
|
|
|
static heur_dissector_list_t heur_subdissector_list;
|
2007-12-16 00:35:34 +00:00
|
|
|
static heur_dissector_list_t eth_trailer_subdissector_list;
|
Tvbuffify the CDP, CGMP, ISL, and VTP dissectors.
Add a new subdissector table in the LLC dissector for protocol IDs with
a Cisco OUI, and register the CDP, CGMP, and VTMP dissectors in that
table, rather than calling them via a switch statement.
Register the ISL dissector by name, and have the Ethernet dissector call
it via a handle.
Fix the handling of the checksum field in the CDP dissector.
The strings in CDP are counted, not null-terminated; treat them as such.
Fix the handling of the encapsulated frame CRC, and the encapsulated
frame, in the ISL dissector, at least for Ethernet frames; it may not be
correct for encapsulated Token Ring frames.
svn path=/trunk/; revision=2792
2000-12-28 09:49:09 +00:00
|
|
|
|
2003-01-22 01:18:03 +00:00
|
|
|
static int eth_tap = -1;
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
#define ETH_HEADER_SIZE 14
|
1999-08-18 00:57:54 +00:00
|
|
|
|
2006-08-25 21:33:23 +00:00
|
|
|
static const true_false_string ig_tfs = {
|
2011-06-29 16:05:56 +00:00
|
|
|
"Group address (multicast/broadcast)",
|
|
|
|
"Individual address (unicast)"
|
2006-02-23 09:54:08 +00:00
|
|
|
};
|
2006-08-25 21:33:23 +00:00
|
|
|
static const true_false_string lg_tfs = {
|
2011-06-29 16:05:56 +00:00
|
|
|
"Locally administered address (this is NOT the factory default)",
|
|
|
|
"Globally unique address (factory default)"
|
2006-02-23 09:54:08 +00:00
|
|
|
};
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
/* These are the Netware-ish names for the different Ethernet frame types.
|
2011-06-29 16:05:56 +00:00
|
|
|
EthernetII: The ethernet with a Type field instead of a length field
|
|
|
|
Ethernet802.2: An 802.3 header followed by an 802.2 header
|
|
|
|
Ethernet802.3: A raw 802.3 packet. IPX/SPX can be the only payload.
|
|
|
|
There's no 802.2 hdr in this.
|
|
|
|
EthernetSNAP: Basically 802.2, just with 802.2SNAP. For our purposes,
|
|
|
|
there's no difference between 802.2 and 802.2SNAP, since we just
|
|
|
|
pass it down to the LLC dissector. -- Gilbert
|
1998-09-16 02:39:15 +00:00
|
|
|
*/
|
2011-06-29 16:05:56 +00:00
|
|
|
#define ETHERNET_II 0
|
|
|
|
#define ETHERNET_802_2 1
|
|
|
|
#define ETHERNET_802_3 2
|
|
|
|
#define ETHERNET_SNAP 3
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-02-09 00:35:38 +00:00
|
|
|
void
|
2002-08-02 23:36:07 +00:00
|
|
|
capture_eth(const guchar *pd, int offset, int len, packet_counts *ld)
|
2000-01-23 08:55:37 +00:00
|
|
|
{
|
2011-06-29 16:05:56 +00:00
|
|
|
guint16 etype, length;
|
|
|
|
int ethhdr_type; /* the type of ethernet frame */
|
1999-09-15 06:26:42 +00:00
|
|
|
|
2001-11-20 21:59:18 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(offset, len, ETH_HEADER_SIZE)) {
|
1999-09-15 06:26:42 +00:00
|
|
|
ld->other++;
|
|
|
|
return;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2013-11-29 18:59:06 +00:00
|
|
|
etype = pntoh16(&pd[offset+12]);
|
1999-02-09 00:35:38 +00:00
|
|
|
|
2004-11-03 20:20:45 +00:00
|
|
|
if (etype <= IEEE_802_3_MAX_LEN) {
|
|
|
|
/* Oh, yuck. Cisco ISL frames require special interpretation of the
|
|
|
|
destination address field; fortunately, they can be recognized by
|
|
|
|
checking the first 5 octets of the destination address, which are
|
|
|
|
01-00-0C-00-00 or 0C-00-0C-00-00 for ISL frames. */
|
|
|
|
if ((pd[offset] == 0x01 || pd[offset] == 0x0C) && pd[offset+1] == 0x00
|
|
|
|
&& pd[offset+2] == 0x0C && pd[offset+3] == 0x00
|
2011-06-29 16:05:56 +00:00
|
|
|
&& pd[offset+4] == 0x00) {
|
2004-11-03 20:20:45 +00:00
|
|
|
capture_isl(pd, offset, len, ld);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-22 06:26:36 +00:00
|
|
|
/*
|
|
|
|
* If the type/length field is <= the maximum 802.3 length,
|
|
|
|
* and is not zero, this is an 802.3 frame, and it's a length
|
|
|
|
* field; it might be an Novell "raw 802.3" frame, with no
|
|
|
|
* 802.2 LLC header, or it might be a frame with an 802.2 LLC
|
|
|
|
* header.
|
|
|
|
*
|
2011-06-29 16:05:56 +00:00
|
|
|
* If the type/length field is >= the minimum Ethernet II length,
|
2003-01-22 06:26:36 +00:00
|
|
|
* this is an Ethernet II frame, and it's a type field.
|
|
|
|
*
|
2011-06-29 16:05:56 +00:00
|
|
|
* If the type/length field is > maximum 802.3 length and < minimum
|
|
|
|
* Ethernet II length, then this is an invalid packet.
|
|
|
|
*
|
2003-01-22 06:26:36 +00:00
|
|
|
* If the type/length field is zero (ETHERTYPE_UNK), this is
|
|
|
|
* a frame used internally by the Cisco MDS switch to contain
|
|
|
|
* Fibre Channel ("Vegas"). We treat that as an Ethernet II
|
|
|
|
* frame; the dissector for those frames registers itself with
|
|
|
|
* an ethernet type of ETHERTYPE_UNK.
|
|
|
|
*/
|
2011-06-29 16:05:56 +00:00
|
|
|
if (etype > IEEE_802_3_MAX_LEN && etype < ETHERNET_II_MIN_LEN) {
|
2011-06-29 17:22:18 +00:00
|
|
|
ld->other++;
|
2011-06-29 16:05:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-22 06:26:36 +00:00
|
|
|
if (etype <= IEEE_802_3_MAX_LEN && etype != ETHERTYPE_UNK) {
|
2000-01-23 08:55:37 +00:00
|
|
|
length = etype;
|
1999-02-09 00:35:38 +00:00
|
|
|
|
2000-01-23 08:55:37 +00:00
|
|
|
/* Is there an 802.2 layer? I can tell by looking at the first 2
|
|
|
|
bytes after the 802.3 header. If they are 0xffff, then what
|
|
|
|
follows the 802.3 header is an IPX payload, meaning no 802.2.
|
|
|
|
(IPX/SPX is they only thing that can be contained inside a
|
|
|
|
straight 802.3 packet). A non-0xffff value means that there's an
|
|
|
|
802.2 layer inside the 802.3 layer */
|
|
|
|
if (pd[offset+14] == 0xff && pd[offset+15] == 0xff) {
|
1999-02-09 00:35:38 +00:00
|
|
|
ethhdr_type = ETHERNET_802_3;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ethhdr_type = ETHERNET_802_2;
|
|
|
|
}
|
2000-01-23 08:55:37 +00:00
|
|
|
|
|
|
|
/* Convert the LLC length from the 802.3 header to a total
|
2000-01-24 01:15:37 +00:00
|
|
|
frame length, by adding in the size of any data that preceded
|
|
|
|
the Ethernet header, and adding in the Ethernet header size,
|
|
|
|
and set the payload and captured-payload lengths to the minima
|
2000-01-23 08:55:37 +00:00
|
|
|
of the total length and the frame lengths. */
|
2000-01-24 01:15:37 +00:00
|
|
|
length += offset + ETH_HEADER_SIZE;
|
2001-11-20 22:29:07 +00:00
|
|
|
if (len > length)
|
|
|
|
len = length;
|
1999-02-09 00:35:38 +00:00
|
|
|
} else {
|
|
|
|
ethhdr_type = ETHERNET_II;
|
|
|
|
}
|
2000-01-23 08:55:37 +00:00
|
|
|
offset += ETH_HEADER_SIZE;
|
1999-02-09 00:35:38 +00:00
|
|
|
|
|
|
|
switch (ethhdr_type) {
|
|
|
|
case ETHERNET_802_3:
|
2002-04-24 06:03:34 +00:00
|
|
|
capture_ipx(ld);
|
1999-02-09 00:35:38 +00:00
|
|
|
break;
|
|
|
|
case ETHERNET_802_2:
|
2001-11-20 21:59:18 +00:00
|
|
|
capture_llc(pd, offset, len, ld);
|
1999-02-09 00:35:38 +00:00
|
|
|
break;
|
|
|
|
case ETHERNET_II:
|
2001-11-20 21:59:18 +00:00
|
|
|
capture_ethertype(etype, pd, offset, len, ld);
|
1999-02-09 00:35:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-07 21:53:40 +00:00
|
|
|
static gboolean check_is_802_2(tvbuff_t *tvb, int fcs_len);
|
2007-11-10 17:06:49 +00:00
|
|
|
|
2013-06-01 09:05:56 +00:00
|
|
|
static proto_tree *
|
2005-04-11 08:43:51 +00:00
|
|
|
dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
|
2011-06-29 16:05:56 +00:00
|
|
|
int fcs_len)
|
2000-01-24 01:15:37 +00:00
|
|
|
{
|
2011-09-23 11:01:13 +00:00
|
|
|
proto_item *ti = NULL;
|
2011-06-29 16:05:56 +00:00
|
|
|
eth_hdr *ehdr;
|
|
|
|
gboolean is_802_2;
|
|
|
|
proto_tree *fh_tree = NULL;
|
|
|
|
const guint8 *src_addr, *dst_addr;
|
|
|
|
static eth_hdr ehdrs[4];
|
|
|
|
static int ehdr_num=0;
|
|
|
|
proto_tree *tree;
|
|
|
|
proto_item *addr_item;
|
|
|
|
proto_tree *addr_tree=NULL;
|
2013-11-20 02:28:14 +00:00
|
|
|
ethertype_data_t ethertype_data;
|
2003-08-23 09:09:35 +00:00
|
|
|
|
|
|
|
ehdr_num++;
|
|
|
|
if(ehdr_num>=4){
|
|
|
|
ehdr_num=0;
|
|
|
|
}
|
|
|
|
ehdr=&ehdrs[ehdr_num];
|
|
|
|
|
2005-04-11 08:43:51 +00:00
|
|
|
tree=parent_tree;
|
2000-05-15 06:22:07 +00:00
|
|
|
|
2009-07-22 21:33:47 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Ethernet");
|
Generalize the "ip_src" and "ip_dst" members of the "packet_info"
structure to "dl_src"/"dl_dst", "net_src"/"net_dst", and "src"/"dst"
addresses, where an address is an address type, an address length in
bytes, and a pointer to that many bytes.
"dl_{src,dst}" are the link-layer source/destination; "net_{src,dst}"
are the network-layer source/destination; "{src,dst}" are the
source/destination from the highest of those two layers that we have in
the packet.
Add a port type to "packet_info" as well, specifying whether it's a TCP
or UDP port.
Don't set the address and port columns in the dissector functions; just
set the address and port members of the "packet_info" structure. Set
the columns in "fill_in_columns()"; this means that if we're showing
COL_{DEF,RES,UNRES}_SRC" or "COL_{DEF,RES,UNRES}_DST", we only generate
the string from "src" or "dst", we don't generate a string for the
link-layer address and then overwrite it with a string for the
network-layer address (generating those strings costs CPU).
Add support for "conversations", where a "conversation" is (at present)
a source and destination address and a source and destination port. (In
the future, we may support "conversations" above the transport layer,
e.g. a TFTP conversation, where the first packet goes from the client to
the TFTP server port, but the reply comes back from a different port,
and all subsequent packets go between the client address/port and the
server address/new port, or an NFS conversation, which might include
lock manager, status monitor, and mount packets, as well as NFS
packets.)
Currently, all we support is a call that takes the source and
destination address/port pairs, looks them up in a hash table, and:
if nothing is found, creates a new entry in the hash table, and
assigns it a unique 32-bit conversation ID, and returns that
conversation ID;
if an entry is found, returns its conversation ID.
Use that in the SMB and AFS code to keep track of individual SMB or AFS
conversations. We need to match up requests and replies, as, for
certain replies, the operation code for the request to which it's a
reply doesn't show up in the reply - you have to find the request with a
matching transaction ID. Transaction IDs are per-conversation, so the
hash table for requests should include a conversation ID and transaction
ID as the key.
This allows SMB and AFS decoders to handle IPv4 or IPv6 addresses
transparently (and should allow the SMB decoder to handle NetBIOS atop
other protocols as well, if the source and destination address and port
values in the "packet_info" structure are set appropriately).
In the "Follow TCP Connection" code, check to make sure that the
addresses are IPv4 addressses; ultimately, that code should be changed
to use the conversation code instead, which will let it handle IPv6
transparently.
svn path=/trunk/; revision=909
1999-10-22 07:18:23 +00:00
|
|
|
|
2003-08-23 09:09:35 +00:00
|
|
|
src_addr=tvb_get_ptr(tvb, 6, 6);
|
2011-06-29 16:05:56 +00:00
|
|
|
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src_addr);
|
|
|
|
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src_addr);
|
|
|
|
SET_ADDRESS(&ehdr->src, AT_ETHER, 6, src_addr);
|
2003-08-23 09:09:35 +00:00
|
|
|
dst_addr=tvb_get_ptr(tvb, 0, 6);
|
2011-06-29 16:05:56 +00:00
|
|
|
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst_addr);
|
|
|
|
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst_addr);
|
|
|
|
SET_ADDRESS(&ehdr->dst, AT_ETHER, 6, dst_addr);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2003-08-23 09:09:35 +00:00
|
|
|
ehdr->type = tvb_get_ntohs(tvb, 12);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2007-09-28 05:50:19 +00:00
|
|
|
tap_queue_packet(eth_tap, pinfo, ehdr);
|
|
|
|
|
2004-02-03 23:19:54 +00:00
|
|
|
/*
|
|
|
|
* In case the packet is a non-Ethernet packet inside
|
|
|
|
* Ethernet framing, allow heuristic dissectors to take
|
|
|
|
* a first look before we assume that it's actually an
|
|
|
|
* Ethernet packet.
|
|
|
|
*/
|
2012-09-11 08:26:48 +00:00
|
|
|
if (dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, parent_tree, NULL))
|
2013-06-01 09:05:56 +00:00
|
|
|
return fh_tree;
|
2004-02-03 23:19:54 +00:00
|
|
|
|
2004-11-03 20:20:45 +00:00
|
|
|
if (ehdr->type <= IEEE_802_3_MAX_LEN) {
|
|
|
|
/* Oh, yuck. Cisco ISL frames require special interpretation of the
|
|
|
|
destination address field; fortunately, they can be recognized by
|
|
|
|
checking the first 5 octets of the destination address, which are
|
|
|
|
01-00-0C-00-00 for ISL frames. */
|
2011-06-29 16:05:56 +00:00
|
|
|
if ((tvb_get_guint8(tvb, 0) == 0x01 ||
|
|
|
|
tvb_get_guint8(tvb, 0) == 0x0C) &&
|
|
|
|
tvb_get_guint8(tvb, 1) == 0x00 &&
|
|
|
|
tvb_get_guint8(tvb, 2) == 0x0C &&
|
|
|
|
tvb_get_guint8(tvb, 3) == 0x00 &&
|
|
|
|
tvb_get_guint8(tvb, 4) == 0x00) {
|
2005-04-11 08:43:51 +00:00
|
|
|
dissect_isl(tvb, pinfo, parent_tree, fcs_len);
|
2013-06-01 09:05:56 +00:00
|
|
|
return fh_tree;
|
2004-11-03 20:20:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-22 06:26:36 +00:00
|
|
|
/*
|
|
|
|
* If the type/length field is <= the maximum 802.3 length,
|
|
|
|
* and is not zero, this is an 802.3 frame, and it's a length
|
|
|
|
* field; it might be an Novell "raw 802.3" frame, with no
|
|
|
|
* 802.2 LLC header, or it might be a frame with an 802.2 LLC
|
|
|
|
* header.
|
|
|
|
*
|
2011-06-29 16:05:56 +00:00
|
|
|
* If the type/length field is >= the minimum Ethernet II length,
|
2003-01-22 06:26:36 +00:00
|
|
|
* this is an Ethernet II frame, and it's a type field.
|
|
|
|
*
|
2011-06-29 16:05:56 +00:00
|
|
|
* If the type/length field is > maximum 802.3 length and < minimum
|
|
|
|
* Ethernet II length, then this is an invalid packet.
|
|
|
|
*
|
2003-01-22 06:26:36 +00:00
|
|
|
* If the type/length field is zero (ETHERTYPE_UNK), this is
|
|
|
|
* a frame used internally by the Cisco MDS switch to contain
|
|
|
|
* Fibre Channel ("Vegas"). We treat that as an Ethernet II
|
|
|
|
* frame; the dissector for those frames registers itself with
|
|
|
|
* an ethernet type of ETHERTYPE_UNK.
|
|
|
|
*/
|
2011-06-29 16:05:56 +00:00
|
|
|
if (ehdr->type > IEEE_802_3_MAX_LEN && ehdr->type < ETHERNET_II_MIN_LEN) {
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO,
|
|
|
|
"Ethernet Unknown: Invalid length/type: 0x%04x (%d)",
|
|
|
|
ehdr->type, ehdr->type);
|
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_eth, tvb, 0, ETH_HEADER_SIZE,
|
|
|
|
"Ethernet Unknown, Src: %s (%s), Dst: %s (%s)",
|
|
|
|
get_ether_name(src_addr), ether_to_str(src_addr),
|
|
|
|
get_ether_name(dst_addr), ether_to_str(dst_addr));
|
|
|
|
fh_tree = proto_item_add_subtree(ti, ett_ether);
|
|
|
|
addr_item = proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
|
|
|
|
if (addr_item)
|
|
|
|
addr_tree = proto_item_add_subtree(addr_item, ett_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_dst_resolved, tvb, 0, 6,
|
|
|
|
get_ether_name(dst_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-06-29 16:05:56 +00:00
|
|
|
proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_addr_resolved, tvb, 0, 6,
|
|
|
|
get_ether_name(dst_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 0, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 0, 3, ENC_BIG_ENDIAN);
|
2011-06-29 16:05:56 +00:00
|
|
|
|
|
|
|
addr_item = proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
|
|
|
|
if (addr_item)
|
|
|
|
addr_tree = proto_item_add_subtree(addr_item, ett_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_src_resolved, tvb, 6, 6,
|
|
|
|
get_ether_name(src_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-06-29 16:05:56 +00:00
|
|
|
proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 6, 6, src_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_addr_resolved, tvb, 6, 6,
|
|
|
|
get_ether_name(src_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 6, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 6, 3, ENC_BIG_ENDIAN);
|
2011-06-29 16:05:56 +00:00
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
ti = proto_tree_add_item(fh_tree, hf_eth_invalid_lentype, tvb, 12, 2, ENC_BIG_ENDIAN);
|
2013-09-09 00:44:09 +00:00
|
|
|
expert_add_info_format(pinfo, ti, &ei_eth_invalid_lentype,
|
2011-06-29 16:05:56 +00:00
|
|
|
"Invalid length/type: 0x%04x (%d)", ehdr->type, ehdr->type);
|
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, 14);
|
|
|
|
call_dissector(data_handle, next_tvb, pinfo, parent_tree);
|
2013-06-01 09:05:56 +00:00
|
|
|
return fh_tree;
|
2011-06-29 16:05:56 +00:00
|
|
|
}
|
|
|
|
|
2003-08-23 09:09:35 +00:00
|
|
|
if (ehdr->type <= IEEE_802_3_MAX_LEN && ehdr->type != ETHERTYPE_UNK) {
|
2000-05-16 06:21:33 +00:00
|
|
|
|
2009-08-07 21:53:40 +00:00
|
|
|
is_802_2 = check_is_802_2(tvb, fcs_len);
|
1998-09-27 22:12:47 +00:00
|
|
|
|
2009-07-22 21:33:47 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "IEEE 802.3 Ethernet %s",
|
2011-06-29 16:05:56 +00:00
|
|
|
(is_802_2 ? "" : "Raw "));
|
1998-09-16 02:39:15 +00:00
|
|
|
if (tree) {
|
2001-01-18 07:44:41 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_eth, tvb, 0, ETH_HEADER_SIZE,
|
2011-06-29 16:05:56 +00:00
|
|
|
"IEEE 802.3 Ethernet %s", (is_802_2 ? "" : "Raw "));
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2001-01-18 07:44:41 +00:00
|
|
|
fh_tree = proto_item_add_subtree(ti, ett_ieee8023);
|
2003-08-23 09:09:35 +00:00
|
|
|
}
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2005-04-11 08:43:51 +00:00
|
|
|
/* if IP is not referenced from any filters we dont need to worry about
|
|
|
|
generating any tree items. We must do this after we created the actual
|
|
|
|
protocol above so that proto hier stat still works though.
|
|
|
|
*/
|
|
|
|
if(!proto_field_is_referenced(parent_tree, proto_eth)){
|
|
|
|
tree=NULL;
|
|
|
|
fh_tree=NULL;
|
|
|
|
}
|
|
|
|
|
2006-02-23 09:54:08 +00:00
|
|
|
addr_item=proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
|
|
|
|
if(addr_item){
|
|
|
|
addr_tree = proto_item_add_subtree(addr_item, ett_addr);
|
|
|
|
}
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_dst_resolved, tvb, 0, 6,
|
|
|
|
get_ether_name(dst_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2006-02-23 09:54:08 +00:00
|
|
|
proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_addr_resolved, tvb, 0, 6,
|
|
|
|
get_ether_name(dst_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 0, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 0, 3, ENC_BIG_ENDIAN);
|
2000-03-20 21:21:33 +00:00
|
|
|
|
2006-02-23 09:54:08 +00:00
|
|
|
addr_item=proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
|
|
|
|
if(addr_item){
|
|
|
|
addr_tree = proto_item_add_subtree(addr_item, ett_addr);
|
|
|
|
}
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_src_resolved, tvb, 6, 6,
|
|
|
|
get_ether_name(src_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2006-02-23 09:54:08 +00:00
|
|
|
proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 6, 6, src_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_addr_resolved, tvb, 6, 6,
|
|
|
|
get_ether_name(src_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 6, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 6, 3, ENC_BIG_ENDIAN);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
dissect_802_3(ehdr->type, is_802_2, tvb, ETH_HEADER_SIZE, pinfo,
|
2013-09-05 01:39:35 +00:00
|
|
|
parent_tree, fh_tree, hf_eth_len, hf_eth_trailer, &ei_eth_len, fcs_len);
|
1998-09-27 22:12:47 +00:00
|
|
|
} else {
|
2002-08-08 09:28:11 +00:00
|
|
|
if (eth_interpret_as_fw1_monitor) {
|
2011-06-29 16:05:56 +00:00
|
|
|
if ((dst_addr[0] == 'i') || (dst_addr[0] == 'I') ||
|
|
|
|
(dst_addr[0] == 'o') || (dst_addr[0] == 'O')) {
|
|
|
|
call_dissector(fw1_handle, tvb, pinfo, parent_tree);
|
2013-06-01 09:05:56 +00:00
|
|
|
return fh_tree;
|
2011-06-29 16:05:56 +00:00
|
|
|
}
|
2002-08-08 09:28:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 19:28:07 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "Ethernet II");
|
2005-04-11 08:43:51 +00:00
|
|
|
if (parent_tree) {
|
2011-06-29 16:05:56 +00:00
|
|
|
if (PTREE_DATA(parent_tree)->visible) {
|
2011-09-23 14:39:23 +00:00
|
|
|
ti = proto_tree_add_protocol_format(parent_tree, proto_eth, tvb, 0, ETH_HEADER_SIZE,
|
2011-09-23 14:47:18 +00:00
|
|
|
"Ethernet II, Src: %s (%s), Dst: %s (%s)",
|
2011-06-29 16:05:56 +00:00
|
|
|
get_ether_name(src_addr), ether_to_str(src_addr),
|
|
|
|
get_ether_name(dst_addr), ether_to_str(dst_addr));
|
2007-11-29 06:29:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(parent_tree, proto_eth, tvb, 0, ETH_HEADER_SIZE, ENC_NA);
|
2007-11-29 06:29:20 +00:00
|
|
|
}
|
2001-01-18 07:44:41 +00:00
|
|
|
fh_tree = proto_item_add_subtree(ti, ett_ether2);
|
2003-08-23 09:09:35 +00:00
|
|
|
}
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2006-02-23 09:54:08 +00:00
|
|
|
addr_item=proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
|
|
|
|
if(addr_item){
|
|
|
|
addr_tree = proto_item_add_subtree(addr_item, ett_addr);
|
|
|
|
}
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_dst_resolved, tvb, 0, 6,
|
|
|
|
get_ether_name(dst_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2006-02-23 09:54:08 +00:00
|
|
|
proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_addr_resolved, tvb, 0, 6,
|
|
|
|
get_ether_name(dst_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 0, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 0, 3, ENC_BIG_ENDIAN);
|
2006-02-23 09:54:08 +00:00
|
|
|
|
|
|
|
addr_item=proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
|
|
|
|
if(addr_item){
|
|
|
|
addr_tree = proto_item_add_subtree(addr_item, ett_addr);
|
2010-10-17 20:28:20 +00:00
|
|
|
if (tvb_get_guint8(tvb, 6) & 0x01) {
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_add_info(pinfo, addr_item, &ei_eth_src_not_group);
|
2010-10-17 20:28:20 +00:00
|
|
|
}
|
2006-02-23 09:54:08 +00:00
|
|
|
}
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_src_resolved, tvb, 6, 6,
|
|
|
|
get_ether_name(src_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2006-02-23 09:54:08 +00:00
|
|
|
proto_tree_add_ether(addr_tree, hf_eth_addr, tvb, 6, 6, src_addr);
|
2013-09-03 21:20:59 +00:00
|
|
|
addr_item=proto_tree_add_string(addr_tree, hf_eth_addr_resolved, tvb, 6, 6,
|
|
|
|
get_ether_name(src_addr));
|
|
|
|
PROTO_ITEM_SET_GENERATED(addr_item);
|
|
|
|
PROTO_ITEM_SET_HIDDEN(addr_item);
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(addr_tree, hf_eth_lg, tvb, 6, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(addr_tree, hf_eth_ig, tvb, 6, 3, ENC_BIG_ENDIAN);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2013-11-20 02:28:14 +00:00
|
|
|
ethertype_data.etype = ehdr->type;
|
|
|
|
ethertype_data.offset_after_ethertype = ETH_HEADER_SIZE;
|
|
|
|
ethertype_data.fh_tree = fh_tree;
|
|
|
|
ethertype_data.etype_id = hf_eth_type;
|
|
|
|
ethertype_data.trailer_id = hf_eth_trailer;
|
|
|
|
ethertype_data.fcs_len = fcs_len;
|
|
|
|
|
|
|
|
call_dissector_with_data(ethertype_handle, tvb, pinfo, parent_tree, ðertype_data);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
2013-06-01 09:05:56 +00:00
|
|
|
return fh_tree;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 17:06:49 +00:00
|
|
|
/* -------------- */
|
2009-08-07 21:53:40 +00:00
|
|
|
static gboolean check_is_802_2(tvbuff_t *tvb, int fcs_len)
|
2007-11-10 17:06:49 +00:00
|
|
|
{
|
2011-06-29 16:05:56 +00:00
|
|
|
volatile gboolean is_802_2;
|
2009-08-07 21:53:40 +00:00
|
|
|
volatile int length;
|
|
|
|
gint captured_length, reported_length;
|
2011-06-29 16:05:56 +00:00
|
|
|
|
2007-11-10 17:06:49 +00:00
|
|
|
is_802_2 = TRUE;
|
|
|
|
|
|
|
|
/* Is there an 802.2 layer? I can tell by looking at the first 2
|
|
|
|
bytes after the 802.3 header. If they are 0xffff, then what
|
|
|
|
follows the 802.3 header is an IPX payload, meaning no 802.2.
|
2009-01-18 12:08:56 +00:00
|
|
|
A non-0xffff value means that there's an 802.2 layer or CCSDS
|
|
|
|
layer inside the 802.3 layer */
|
|
|
|
|
2007-11-10 17:06:49 +00:00
|
|
|
TRY {
|
2011-06-29 16:05:56 +00:00
|
|
|
if (tvb_get_ntohs(tvb, 14) == 0xffff) {
|
|
|
|
is_802_2 = FALSE;
|
|
|
|
}
|
|
|
|
/* Is this a CCSDS payload instead of an 802.2 (LLC)?
|
|
|
|
Check the conditions enabled by the user for CCSDS presence */
|
|
|
|
else if (ccsds_heuristic_length || ccsds_heuristic_version ||
|
|
|
|
ccsds_heuristic_header || ccsds_heuristic_bit) {
|
|
|
|
gboolean CCSDS_len = TRUE;
|
|
|
|
gboolean CCSDS_ver = TRUE;
|
|
|
|
gboolean CCSDS_head = TRUE;
|
|
|
|
gboolean CCSDS_bit = TRUE;
|
|
|
|
/* See if the reported payload size matches the
|
|
|
|
size contained in the CCSDS header. */
|
|
|
|
if (ccsds_heuristic_length) {
|
|
|
|
/* The following technique to account for FCS
|
|
|
|
is copied from packet-ieee8023.c dissect_802_3() */
|
|
|
|
length = tvb_get_ntohs(tvb, 12);
|
|
|
|
reported_length = tvb_reported_length_remaining(tvb, ETH_HEADER_SIZE);
|
|
|
|
if (fcs_len > 0) {
|
|
|
|
if (reported_length >= fcs_len)
|
|
|
|
reported_length -= fcs_len;
|
|
|
|
}
|
|
|
|
/* Make sure the length in the 802.3 header doesn't go past the end of
|
|
|
|
the payload. */
|
|
|
|
if (length > reported_length) {
|
|
|
|
length = reported_length;
|
|
|
|
}
|
|
|
|
/* Only allow inspection of 'length' number of bytes. */
|
|
|
|
captured_length = tvb_length_remaining(tvb, ETH_HEADER_SIZE);
|
|
|
|
if (captured_length > length)
|
|
|
|
captured_length = length;
|
|
|
|
|
|
|
|
/* Check if payload is large enough to contain a CCSDS header */
|
|
|
|
if (captured_length >= 6) {
|
|
|
|
/* Compare length to packet length contained in CCSDS header. */
|
|
|
|
if (length != 7 + tvb_get_ntohs(tvb, ETH_HEADER_SIZE + 4))
|
|
|
|
CCSDS_len = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Check if CCSDS Version number (first 3 bits of payload) is zero */
|
|
|
|
if ((ccsds_heuristic_version) && (tvb_get_bits8(tvb, 8*ETH_HEADER_SIZE, 3)!=0))
|
|
|
|
CCSDS_ver = FALSE;
|
|
|
|
/* Check if Secondary Header Flag (4th bit of payload) is set to one. */
|
|
|
|
if ((ccsds_heuristic_header) && (tvb_get_bits8(tvb, 8*ETH_HEADER_SIZE + 4, 1)!=1))
|
|
|
|
CCSDS_head = FALSE;
|
|
|
|
/* Check if spare bit (1st bit of 7th word of payload) is zero. */
|
|
|
|
if ((ccsds_heuristic_bit) && (tvb_get_bits8(tvb, 8*ETH_HEADER_SIZE + 16*6, 1)!=0))
|
|
|
|
CCSDS_bit = FALSE;
|
|
|
|
/* If all the conditions are true, don't interpret payload as an 802.2 (LLC).
|
|
|
|
* Additional check in packet-802.3.c will distinguish between
|
|
|
|
* IPX and CCSDS packets*/
|
|
|
|
if (CCSDS_len && CCSDS_ver && CCSDS_head && CCSDS_bit)
|
|
|
|
is_802_2 = FALSE;
|
|
|
|
}
|
2007-11-10 17:06:49 +00:00
|
|
|
}
|
Move show_exception() and show_reported_bounds_error() to
epan/show_exception.c, as it's used outside
epan/dissectors/packet-frame.c. Update their callers to include
<epan/show_exception.h> to get their declaration.
Add a CATCH_NONFATAL_ERRORS macro that catches all exceptions that, if
there's more stuff in the packet to dissect after the dissector call
that threw the exception, doesn't mean you shouldn't go ahead and
dissect that stuff. Use it in all those cases, including ones where
BoundsError was inappropriately being caught (you want those passed up
to the top level, so that the packet is reported as having been cut
short in the capture process).
Add a CATCH_BOUNDS_ERRORS macro that catches all exceptions that
correspond to running past the end of the data for a tvbuff; use it
rather than explicitly catching those exceptions individually, and
rather than just catching all exceptions (the only place that
DissectorError should be caught, for example, is at the top level, so
dissector bugs show up in the protocol tree).
Don't catch and then immediately rethrow exceptions without doing
anything else; just let the exceptions go up to the final catcher.
Use show_exception() to report non-fatal errors, rather than doing it
yourself.
If a dissector is called from Lua, catch all non-fatal errors and use
show_exception() to report them rather than catching only
ReportedBoundsError and adding a proto_malformed item.
Don't catch exceptions when constructing a trailer tvbuff in
packet-ieee8023.c - just construct it after the payload has been
dissected, and let whatever exceptions that throws be handled at the top
level.
Avoid some TRY/CATCH/ENDTRY cases by using checks such as
tvb_bytes_exist() before even looking in the tvbuff.
svn path=/trunk/; revision=47924
2013-02-27 22:43:54 +00:00
|
|
|
CATCH_BOUNDS_ERRORS {
|
2011-06-29 16:05:56 +00:00
|
|
|
; /* do nothing */
|
2007-11-10 17:06:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
ENDTRY;
|
|
|
|
return is_802_2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-21 21:05:30 +00:00
|
|
|
/*
|
|
|
|
* Add an Ethernet trailer - which, for some captures, might be the FCS
|
|
|
|
* rather than a pad-to-60-bytes trailer.
|
2003-10-01 07:11:49 +00:00
|
|
|
*
|
|
|
|
* If fcs_len is 0, we assume the frame has no FCS; if it's 4, we assume
|
|
|
|
* it has an FCS; if it's anything else (such as -1, which means "maybe
|
|
|
|
* it does, maybe it doesn't"), we try to infer whether it has an FCS.
|
2003-08-21 21:05:30 +00:00
|
|
|
*/
|
|
|
|
void
|
2011-06-29 16:05:56 +00:00
|
|
|
add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
|
|
|
|
int trailer_id, tvbuff_t *tvb, tvbuff_t *trailer_tvb, int fcs_len)
|
2003-08-21 21:05:30 +00:00
|
|
|
{
|
2011-12-10 05:33:48 +00:00
|
|
|
/* If there're some bytes left over, it could be a combination of:
|
2011-12-06 23:07:55 +00:00
|
|
|
- padding to meet the minimum 64 byte frame length
|
2011-12-10 05:33:48 +00:00
|
|
|
- an FCS, if present (if fcs_len is 0, we know it's not present;
|
|
|
|
if fcs_len is 4, we know it's present; if fcs_len is -1, we
|
|
|
|
need some heuristics to determine whether it's present)
|
|
|
|
- information inserted by TAPs or other network monitoring equipment.
|
2013-09-03 21:20:59 +00:00
|
|
|
|
2011-12-10 05:33:48 +00:00
|
|
|
If we don't know whether the FCS is present, then, if we don't have a
|
|
|
|
network monitoring trailer, and if the Ethernet frame was claimed to
|
|
|
|
have had 64 or more bytes - i.e., it was at least an FCS worth of data
|
|
|
|
longer than the minimum payload size - we could assume the last 4 bytes
|
|
|
|
of the trailer are an FCS. */
|
2011-11-02 11:01:57 +00:00
|
|
|
proto_item *item;
|
|
|
|
proto_tree *checksum_tree;
|
|
|
|
|
2013-10-21 17:31:22 +00:00
|
|
|
if (trailer_tvb) {
|
2003-08-26 04:34:26 +00:00
|
|
|
guint trailer_length, trailer_reported_length;
|
2011-12-06 23:07:55 +00:00
|
|
|
guint padding_length = 0;
|
2003-08-21 21:05:30 +00:00
|
|
|
gboolean has_fcs = FALSE;
|
2011-12-06 23:07:55 +00:00
|
|
|
tvbuff_t *real_trailer_tvb;
|
2007-12-16 00:35:34 +00:00
|
|
|
|
2003-08-21 21:05:30 +00:00
|
|
|
trailer_length = tvb_length(trailer_tvb);
|
2003-08-26 04:34:26 +00:00
|
|
|
trailer_reported_length = tvb_reported_length(trailer_tvb);
|
2007-12-16 00:35:34 +00:00
|
|
|
|
2013-09-03 21:20:59 +00:00
|
|
|
/* There can not have been padding when the length of the frame (including the
|
2011-12-06 23:07:55 +00:00
|
|
|
trailer) is less than 60 bytes. */
|
|
|
|
if (eth_assume_padding && pinfo->fd->pkt_len>=60) {
|
|
|
|
/* Calculate the amount of padding needed for a minimum sized frame */
|
|
|
|
if ( (pinfo->fd->pkt_len - trailer_reported_length) < 60 )
|
|
|
|
padding_length = 60 - (pinfo->fd->pkt_len - trailer_reported_length);
|
|
|
|
|
2013-09-03 21:20:59 +00:00
|
|
|
/* Add the padding to the tree, unless it should be treated as
|
|
|
|
part of the trailer and therefor be handed over to (one of)
|
2011-12-06 23:07:55 +00:00
|
|
|
the ethernet-trailer dissectors */
|
|
|
|
if (padding_length > 0) {
|
|
|
|
tvb_ensure_bytes_exist(tvb, 0, padding_length);
|
|
|
|
proto_tree_add_item(fh_tree, hf_eth_padding, trailer_tvb, 0,
|
2012-05-07 19:47:15 +00:00
|
|
|
padding_length, ENC_NA);
|
2011-12-06 23:07:55 +00:00
|
|
|
trailer_length -= padding_length;
|
|
|
|
trailer_reported_length -= padding_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-01 07:11:49 +00:00
|
|
|
if (fcs_len != 0) {
|
|
|
|
/* If fcs_len is 4, we assume we definitely have an FCS.
|
|
|
|
Otherwise, then, if the frame is big enough that, if we
|
|
|
|
have a trailer, it probably inclues an FCS, and we have
|
|
|
|
enough space in the trailer for the FCS, we assume we
|
|
|
|
have an FCS.
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
"Big enough" means 64 bytes or more; any frame that big
|
|
|
|
needs no trailer, as there's no need to pad an Ethernet
|
|
|
|
packet past 60 bytes.
|
2003-08-26 04:34:26 +00:00
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
The trailer must be at least 4 bytes long to have enough
|
|
|
|
space for an FCS. */
|
2003-10-01 07:11:49 +00:00
|
|
|
|
|
|
|
if (fcs_len == 4 || (tvb_reported_length(tvb) >= 64 &&
|
2011-06-29 16:05:56 +00:00
|
|
|
trailer_reported_length >= 4)) {
|
|
|
|
/* Either we know we have an FCS, or we believe we have an FCS. */
|
|
|
|
if (trailer_length < trailer_reported_length) {
|
|
|
|
/* The packet is claimed to have enough data for a 4-byte FCS,
|
|
|
|
but we didn't capture all of the packet.
|
|
|
|
Slice off the 4-byte FCS from the reported length, and
|
|
|
|
trim the captured length so it's no more than the reported
|
|
|
|
length; that will slice off what of the FCS, if any, is
|
|
|
|
in the captured packet. */
|
|
|
|
trailer_reported_length -= 4;
|
|
|
|
if (trailer_length > trailer_reported_length)
|
|
|
|
trailer_length = trailer_reported_length;
|
|
|
|
has_fcs = TRUE;
|
|
|
|
} else {
|
|
|
|
/* We captured all of the packet, including what appears to
|
|
|
|
be a 4-byte FCS. Slice it off. */
|
|
|
|
trailer_length -= 4;
|
|
|
|
trailer_reported_length -= 4;
|
|
|
|
has_fcs = TRUE;
|
|
|
|
}
|
2003-08-26 04:34:26 +00:00
|
|
|
}
|
2003-08-21 21:05:30 +00:00
|
|
|
}
|
2011-12-10 12:28:28 +00:00
|
|
|
|
|
|
|
/* Create a new tvb without the padding and/or the (assumed) fcs */
|
2013-09-03 21:20:59 +00:00
|
|
|
if (fcs_len==4)
|
2011-12-10 12:28:28 +00:00
|
|
|
real_trailer_tvb = tvb_new_subset(trailer_tvb, padding_length,
|
|
|
|
trailer_length, trailer_reported_length);
|
|
|
|
else
|
|
|
|
real_trailer_tvb = tvb_new_subset_remaining(trailer_tvb, padding_length);
|
|
|
|
|
|
|
|
/* Call all ethernet trailer dissectors to dissect the trailer if
|
|
|
|
we actually have a trailer. */
|
|
|
|
if (tvb_reported_length(real_trailer_tvb) != 0) {
|
2013-09-03 21:20:59 +00:00
|
|
|
if (dissector_try_heuristic(eth_trailer_subdissector_list,
|
2012-09-11 08:26:48 +00:00
|
|
|
real_trailer_tvb, pinfo, tree, NULL) ) {
|
2011-12-10 12:28:28 +00:00
|
|
|
/* If we're not sure that there is a FCS, all trailer data
|
2013-09-03 21:20:59 +00:00
|
|
|
has been given to the ethernet-trailer dissector, so
|
2011-12-10 12:28:28 +00:00
|
|
|
stop dissecting here */
|
2013-09-03 21:20:59 +00:00
|
|
|
if (fcs_len!=4)
|
2011-12-10 12:28:28 +00:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
/* No luck with the trailer dissectors, so just display the
|
|
|
|
extra bytes as general trailer */
|
|
|
|
if (trailer_length != 0) {
|
|
|
|
tvb_ensure_bytes_exist(tvb, 0, trailer_length);
|
|
|
|
proto_tree_add_item(fh_tree, trailer_id, real_trailer_tvb, 0,
|
2012-05-07 19:47:15 +00:00
|
|
|
trailer_length, ENC_NA);
|
2011-12-10 12:28:28 +00:00
|
|
|
}
|
|
|
|
}
|
2003-08-21 21:05:30 +00:00
|
|
|
}
|
2011-12-10 12:28:28 +00:00
|
|
|
|
2003-08-21 21:05:30 +00:00
|
|
|
if (has_fcs) {
|
2011-12-10 12:28:28 +00:00
|
|
|
guint32 sent_fcs = tvb_get_ntohl(trailer_tvb, padding_length+trailer_length);
|
2011-11-02 11:01:57 +00:00
|
|
|
if(eth_check_fcs){
|
|
|
|
guint32 fcs = crc32_802_tvb(tvb, tvb_length(tvb) - 4);
|
|
|
|
if (fcs == sent_fcs) {
|
2013-09-15 01:48:30 +00:00
|
|
|
item = proto_tree_add_uint_format_value(fh_tree, hf_eth_fcs, trailer_tvb,
|
2011-12-10 12:28:28 +00:00
|
|
|
padding_length+trailer_length, 4, sent_fcs,
|
2013-09-15 01:48:30 +00:00
|
|
|
"0x%08x [correct]", sent_fcs);
|
2011-11-02 11:01:57 +00:00
|
|
|
checksum_tree = proto_item_add_subtree(item, ett_eth_fcs);
|
2013-06-24 19:27:47 +00:00
|
|
|
item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_good, trailer_tvb,
|
|
|
|
padding_length+trailer_length, 4, TRUE);
|
2011-11-02 11:01:57 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
2013-06-24 19:27:47 +00:00
|
|
|
item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_bad, trailer_tvb,
|
|
|
|
padding_length+trailer_length, 4, FALSE);
|
2011-11-02 11:01:57 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
|
|
|
} else {
|
2013-09-15 01:48:30 +00:00
|
|
|
item = proto_tree_add_uint_format_value(fh_tree, hf_eth_fcs, trailer_tvb,
|
2011-12-10 12:28:28 +00:00
|
|
|
padding_length+trailer_length, 4, sent_fcs,
|
2013-09-15 01:48:30 +00:00
|
|
|
"0x%08x [incorrect, should be 0x%08x]",
|
2011-11-02 11:01:57 +00:00
|
|
|
sent_fcs, fcs);
|
|
|
|
checksum_tree = proto_item_add_subtree(item, ett_eth_fcs);
|
2013-06-24 19:27:47 +00:00
|
|
|
item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_good, trailer_tvb,
|
|
|
|
padding_length+trailer_length, 4, FALSE);
|
2011-11-02 11:01:57 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
2013-06-24 19:27:47 +00:00
|
|
|
item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_bad, trailer_tvb,
|
|
|
|
padding_length+trailer_length, 4, TRUE);
|
2011-11-02 11:01:57 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_add_info(pinfo, item, &ei_eth_fcs_bad);
|
2011-11-02 11:01:57 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, " [ETHERNET FRAME CHECK SEQUENCE INCORRECT]");
|
|
|
|
}
|
|
|
|
}else{
|
2013-09-15 01:48:30 +00:00
|
|
|
item = proto_tree_add_uint_format_value(fh_tree, hf_eth_fcs, trailer_tvb,
|
2011-12-10 12:28:28 +00:00
|
|
|
padding_length+trailer_length, 4, sent_fcs,
|
2013-09-15 01:48:30 +00:00
|
|
|
"0x%08x [validiation disabled]", sent_fcs);
|
2011-11-02 11:01:57 +00:00
|
|
|
checksum_tree = proto_item_add_subtree(item, ett_eth_fcs);
|
2013-06-24 19:27:47 +00:00
|
|
|
item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_good, trailer_tvb,
|
|
|
|
padding_length+trailer_length, 4, FALSE);
|
2011-11-02 11:01:57 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
2013-06-24 19:27:47 +00:00
|
|
|
item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_bad, trailer_tvb,
|
|
|
|
padding_length+trailer_length, 4, FALSE);
|
2011-11-02 11:01:57 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
2003-08-26 05:09:56 +00:00
|
|
|
}
|
2007-09-25 19:30:26 +00:00
|
|
|
trailer_length += 4;
|
2003-08-21 21:05:30 +00:00
|
|
|
}
|
2011-12-10 12:28:28 +00:00
|
|
|
proto_tree_set_appendix(fh_tree, tvb, tvb_length(tvb) - padding_length - trailer_length, padding_length + trailer_length);
|
2003-08-21 21:05:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-01 07:11:49 +00:00
|
|
|
/* Called for the Ethernet Wiretap encapsulation type; pass the FCS length
|
2009-05-20 22:50:30 +00:00
|
|
|
reported to us, or, if the "assume_fcs" preference is set, pass 4. */
|
2003-10-01 07:11:49 +00:00
|
|
|
static void
|
|
|
|
dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2013-06-01 09:05:56 +00:00
|
|
|
proto_tree *fh_tree;
|
|
|
|
|
|
|
|
/* Some devices slice the packet and add their own trailer before
|
2013-09-03 21:20:59 +00:00
|
|
|
putting the frame on the network. Make sure these packets get
|
2013-10-21 17:31:22 +00:00
|
|
|
a proper trailer (even though the sliced frame might not
|
|
|
|
properly dissect. */
|
2013-06-01 09:05:56 +00:00
|
|
|
if ( (eth_trailer_length > 0) && (eth_trailer_length < tvb_length(tvb)) ) {
|
|
|
|
tvbuff_t *next_tvb;
|
2013-10-21 17:31:22 +00:00
|
|
|
guint total_trailer_length;
|
2013-06-01 09:05:56 +00:00
|
|
|
|
2013-10-21 17:31:22 +00:00
|
|
|
total_trailer_length = eth_trailer_length + (eth_assume_fcs ? 4 : 0);
|
2013-06-01 09:05:56 +00:00
|
|
|
|
2013-10-21 17:31:22 +00:00
|
|
|
/* Dissect the tvb up to, but not including the trailer */
|
2013-06-01 09:05:56 +00:00
|
|
|
next_tvb = tvb_new_subset(tvb, 0,
|
|
|
|
tvb_length(tvb) - total_trailer_length,
|
2013-10-21 17:31:22 +00:00
|
|
|
tvb_reported_length(tvb) - total_trailer_length);
|
2013-06-01 09:05:56 +00:00
|
|
|
fh_tree = dissect_eth_common(next_tvb, pinfo, tree, 0);
|
|
|
|
|
2013-10-21 17:31:22 +00:00
|
|
|
/* Now handle the ethernet trailer and optional FCS */
|
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, tvb_length(tvb) - total_trailer_length);
|
|
|
|
add_ethernet_trailer(pinfo, tree, fh_tree, hf_eth_trailer, tvb, next_tvb,
|
|
|
|
eth_assume_fcs ? 4 : pinfo->pseudo_header->eth.fcs_len);
|
2013-06-01 09:05:56 +00:00
|
|
|
} else {
|
|
|
|
dissect_eth_common(tvb, pinfo, tree, eth_assume_fcs ? 4 : pinfo->pseudo_header->eth.fcs_len);
|
|
|
|
}
|
2003-10-01 07:11:49 +00:00
|
|
|
}
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
/* Called by other dissectors This one's for encapsulated Ethernet
|
|
|
|
packets that don't include an FCS. */
|
2003-10-01 07:11:49 +00:00
|
|
|
static void
|
2004-11-24 09:13:52 +00:00
|
|
|
dissect_eth_withoutfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
2003-10-01 07:11:49 +00:00
|
|
|
{
|
|
|
|
dissect_eth_common(tvb, pinfo, tree, 0);
|
|
|
|
}
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
/* ...and this one's for encapsulated packets that do. */
|
|
|
|
static void
|
|
|
|
dissect_eth_withfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
dissect_eth_common(tvb, pinfo, tree, 4);
|
|
|
|
}
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
void
|
|
|
|
proto_register_eth(void)
|
|
|
|
{
|
2011-06-29 16:05:56 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
|
|
|
|
{ &hf_eth_dst,
|
|
|
|
{ "Destination", "eth.dst", FT_ETHER, BASE_NONE, NULL, 0x0,
|
|
|
|
"Destination Hardware Address", HFILL }},
|
|
|
|
|
2013-09-03 21:20:59 +00:00
|
|
|
{ &hf_eth_dst_resolved,
|
|
|
|
{ "Destination (resolved)", "eth.dst_resolved", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0, "Destination Hardware Address (resolved)", HFILL }},
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
{ &hf_eth_src,
|
|
|
|
{ "Source", "eth.src", FT_ETHER, BASE_NONE, NULL, 0x0,
|
|
|
|
"Source Hardware Address", HFILL }},
|
|
|
|
|
2013-09-03 21:20:59 +00:00
|
|
|
{ &hf_eth_src_resolved,
|
|
|
|
{ "Source (resolved)", "eth.src_resolved", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0, "Source Hardware Address (resolved)", HFILL }},
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
{ &hf_eth_len,
|
|
|
|
{ "Length", "eth.len", FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
/* registered here but handled in packet-ethertype.c */
|
|
|
|
{ &hf_eth_type,
|
|
|
|
{ "Type", "eth.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
|
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_eth_invalid_lentype,
|
|
|
|
{ "Invalid length/type", "eth.invalid_lentype", FT_UINT16, BASE_HEX_DEC,
|
|
|
|
NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_eth_addr,
|
|
|
|
{ "Address", "eth.addr", FT_ETHER, BASE_NONE, NULL, 0x0,
|
|
|
|
"Source or Destination Hardware Address", HFILL }},
|
|
|
|
|
2013-09-03 21:20:59 +00:00
|
|
|
{ &hf_eth_addr_resolved,
|
|
|
|
{ "Address (resolved)", "eth.addr_resolved", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0, "Source or Destination Hardware Address (resolved)",
|
|
|
|
HFILL }},
|
|
|
|
|
2011-12-06 23:07:55 +00:00
|
|
|
{ &hf_eth_padding,
|
|
|
|
{ "Padding", "eth.padding", FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
"Ethernet Padding", HFILL }},
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
{ &hf_eth_trailer,
|
|
|
|
{ "Trailer", "eth.trailer", FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
"Ethernet Trailer or Checksum", HFILL }},
|
|
|
|
|
2011-11-02 11:01:57 +00:00
|
|
|
{ &hf_eth_fcs,
|
2013-06-24 19:00:55 +00:00
|
|
|
{ "Frame check sequence", "eth.fcs", FT_UINT32, BASE_HEX, NULL, 0x0,
|
2011-11-02 11:01:57 +00:00
|
|
|
"Ethernet checksum", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_eth_fcs_good,
|
|
|
|
{ "FCS Good", "eth.fcs_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_eth_fcs_bad,
|
|
|
|
{ "FCS Bad", "eth.fcs_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"True: checksum doesn't matche packet content; False: does match content or not checked", HFILL }},
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
{ &hf_eth_lg,
|
|
|
|
{ "LG bit", "eth.lg", FT_BOOLEAN, 24,
|
|
|
|
TFS(&lg_tfs), 0x020000,
|
|
|
|
"Specifies if this is a locally administered or globally unique (IEEE assigned) address", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_eth_ig,
|
|
|
|
{ "IG bit", "eth.ig", FT_BOOLEAN, 24,
|
|
|
|
TFS(&ig_tfs), 0x010000,
|
|
|
|
"Specifies if this is an individual (unicast) or group (broadcast/multicast) address", HFILL }}
|
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_ieee8023,
|
|
|
|
&ett_ether2,
|
|
|
|
&ett_ether,
|
2011-11-02 11:01:57 +00:00
|
|
|
&ett_addr,
|
|
|
|
&ett_eth_fcs
|
2011-06-29 16:05:56 +00:00
|
|
|
};
|
2013-05-26 03:29:07 +00:00
|
|
|
|
|
|
|
static ei_register_info ei[] = {
|
2013-07-06 02:53:45 +00:00
|
|
|
{ &ei_eth_invalid_lentype, { "eth.invalid_lentype", PI_PROTOCOL, PI_WARN, "Invalid length/type", EXPFILL }},
|
|
|
|
{ &ei_eth_src_not_group, { "eth.src_not_group", PI_PROTOCOL, PI_WARN, "Source MAC must not be a group address: IEEE 802.3-2002, Section 3.2.3(b)", EXPFILL }},
|
2013-07-08 18:49:42 +00:00
|
|
|
{ &ei_eth_fcs_bad, { "eth.fcs_bad.expert", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
|
2013-09-05 01:39:35 +00:00
|
|
|
{ &ei_eth_len, { "eth.len.past_end", PI_MALFORMED, PI_ERROR, "Length field value goes past the end of the payload", EXPFILL }},
|
2013-05-26 03:29:07 +00:00
|
|
|
};
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
module_t *eth_module;
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_module_t* expert_eth;
|
2011-06-29 16:05:56 +00:00
|
|
|
|
|
|
|
proto_eth = proto_register_protocol("Ethernet", "Ethernet", "eth");
|
|
|
|
proto_register_field_array(proto_eth, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_eth = expert_register_protocol(proto_eth);
|
|
|
|
expert_register_field_array(expert_eth, ei, array_length(ei));
|
2011-06-29 16:05:56 +00:00
|
|
|
|
|
|
|
/* subdissector code */
|
|
|
|
register_heur_dissector_list("eth", &heur_subdissector_list);
|
|
|
|
register_heur_dissector_list("eth.trailer", ð_trailer_subdissector_list);
|
|
|
|
|
|
|
|
/* Register configuration preferences */
|
|
|
|
eth_module = prefs_register_protocol(proto_eth, NULL);
|
|
|
|
|
2011-12-06 23:07:55 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "assume_padding",
|
|
|
|
"Assume short frames which include a trailer contain padding",
|
|
|
|
"Some devices add trailing data to frames. When this setting is checked "
|
|
|
|
"the Ethernet dissector will assume there has been added padding to the "
|
|
|
|
"frame before the trailer was added. Uncheck if a device added a trailer "
|
|
|
|
"before the frame was padded.",
|
|
|
|
ð_assume_padding);
|
|
|
|
|
2013-06-01 09:05:56 +00:00
|
|
|
prefs_register_uint_preference(eth_module, "trailer_length",
|
|
|
|
"Fixed ethernet trailer length",
|
|
|
|
"Some TAPs add a fixed length ethernet trailer at the end "
|
|
|
|
"of the frame, but before the (optional) FCS. Make sure it "
|
|
|
|
"gets interpreted correctly.",
|
|
|
|
10, ð_trailer_length);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "assume_fcs",
|
|
|
|
"Assume packets have FCS",
|
|
|
|
"Some Ethernet adapters and drivers include the FCS at the end of a packet, others do not. "
|
|
|
|
"The Ethernet dissector attempts to guess whether a captured packet has an FCS, "
|
|
|
|
"but it cannot always guess correctly.",
|
|
|
|
ð_assume_fcs);
|
|
|
|
|
2011-11-02 11:01:57 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "check_fcs",
|
|
|
|
"Validate the Ethernet checksum if possible",
|
|
|
|
"Whether to validate the Frame Check Sequence",
|
|
|
|
ð_check_fcs);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "interpret_as_fw1_monitor",
|
2004-11-24 06:04:43 +00:00
|
|
|
"Attempt to interpret as FireWall-1 monitor file",
|
|
|
|
"Whether packets should be interpreted as coming from CheckPoint FireWall-1 monitor file if they look as if they do",
|
2002-08-08 09:28:11 +00:00
|
|
|
ð_interpret_as_fw1_monitor);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_static_text_preference(eth_module, "ccsds_heuristic",
|
2010-04-25 17:34:32 +00:00
|
|
|
"These are the conditions to match a payload against in order to determine if this\n"
|
|
|
|
"is a CCSDS (Consultative Committee for Space Data Systems) packet within\n"
|
|
|
|
"an 802.3 packet. A packet is considered as a possible CCSDS packet only if\n"
|
|
|
|
"one or more of the conditions are checked.",
|
2009-01-18 12:08:56 +00:00
|
|
|
"Describe the conditions that must be true for the CCSDS dissector to be called");
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "ccsds_heuristic_length",
|
2009-01-18 12:08:56 +00:00
|
|
|
"CCSDS Length in header matches payload size",
|
|
|
|
"Set the condition that must be true for the CCSDS dissector to be called",
|
|
|
|
&ccsds_heuristic_length);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "ccsds_heuristic_version",
|
2009-01-18 12:08:56 +00:00
|
|
|
"CCSDS Version # is zero",
|
|
|
|
"Set the condition that must be true for the CCSDS dissector to be called",
|
|
|
|
&ccsds_heuristic_version);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "ccsds_heuristic_header",
|
2009-01-18 12:08:56 +00:00
|
|
|
"CCSDS Secondary Header Flag is set",
|
|
|
|
"Set the condition that must be true for the CCSDS dissector to be called",
|
|
|
|
&ccsds_heuristic_header);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
prefs_register_bool_preference(eth_module, "ccsds_heuristic_bit",
|
2009-01-18 12:08:56 +00:00
|
|
|
"CCSDS Spare bit is cleared",
|
|
|
|
"Set the condition that must be true for the CCSDS dissector to be called",
|
|
|
|
&ccsds_heuristic_bit);
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
register_dissector("eth_withoutfcs", dissect_eth_withoutfcs, proto_eth);
|
|
|
|
register_dissector("eth_withfcs", dissect_eth_withfcs, proto_eth);
|
|
|
|
register_dissector("eth", dissect_eth_maybefcs, proto_eth);
|
|
|
|
eth_tap = register_tap("eth");
|
1999-07-07 22:52:57 +00:00
|
|
|
}
|
2000-11-29 05:16:15 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_eth(void)
|
|
|
|
{
|
2011-06-29 16:05:56 +00:00
|
|
|
dissector_handle_t eth_maybefcs_handle, eth_withoutfcs_handle;
|
|
|
|
|
|
|
|
/* Get a handle for the Firewall-1 dissector. */
|
|
|
|
fw1_handle = find_dissector("fw1");
|
|
|
|
|
2013-11-20 02:28:14 +00:00
|
|
|
/* Get a handle for the ethertype dissector. */
|
|
|
|
ethertype_handle = find_dissector("ethertype");
|
|
|
|
|
2011-06-29 16:05:56 +00:00
|
|
|
/* Get a handle for the generic data dissector. */
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
|
|
|
|
eth_maybefcs_handle = find_dissector("eth");
|
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_ETHERNET, eth_maybefcs_handle);
|
|
|
|
|
|
|
|
eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
|
|
|
|
dissector_add_uint("ethertype", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle);
|
2013-09-11 21:37:58 +00:00
|
|
|
dissector_add_uint("chdlc.protocol", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle);
|
2011-06-29 16:05:56 +00:00
|
|
|
dissector_add_uint("gre.proto", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle);
|
|
|
|
|
|
|
|
dissector_add_uint("sll.ltype", LINUX_SLL_P_ETHERNET, eth_withoutfcs_handle);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is to handle the output for the Cisco CMTS "cable intercept"
|
|
|
|
* command - it encapsulates Ethernet frames in UDP packets, but
|
|
|
|
* the UDP port is user-defined.
|
|
|
|
*/
|
|
|
|
dissector_add_handle("udp.port", eth_withoutfcs_handle);
|
2000-11-29 05:16:15 +00:00
|
|
|
}
|