175115Sfenner/*- 275115Sfenner * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 375115Sfenner * The Regents of the University of California. All rights reserved. 475115Sfenner * 575115Sfenner * This code is derived from the Stanford/CMU enet packet filter, 675115Sfenner * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7127668Sbms * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 875115Sfenner * Berkeley Laboratory. 975115Sfenner * 1075115Sfenner * Redistribution and use in source and binary forms, with or without 1175115Sfenner * modification, are permitted provided that the following conditions 1275115Sfenner * are met: 1375115Sfenner * 1. Redistributions of source code must retain the above copyright 1475115Sfenner * notice, this list of conditions and the following disclaimer. 1575115Sfenner * 2. Redistributions in binary form must reproduce the above copyright 1675115Sfenner * notice, this list of conditions and the following disclaimer in the 1775115Sfenner * documentation and/or other materials provided with the distribution. 1875115Sfenner * 3. All advertising materials mentioning features or use of this software 1975115Sfenner * must display the following acknowledgement: 2075115Sfenner * This product includes software developed by the University of 2175115Sfenner * California, Berkeley and its contributors. 2275115Sfenner * 4. Neither the name of the University nor the names of its contributors 2375115Sfenner * may be used to endorse or promote products derived from this software 2475115Sfenner * without specific prior written permission. 2575115Sfenner * 2675115Sfenner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2775115Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2875115Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2975115Sfenner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3075115Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3175115Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3275115Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3375115Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3475115Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3575115Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3675115Sfenner * SUCH DAMAGE. 3775115Sfenner * 38214478Srpaulo * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.8 2008-05-30 01:37:41 guy Exp $ (LBL) 3975115Sfenner */ 4075115Sfenner 4175115Sfenner/* 4275115Sfenner * For captures on Linux cooked sockets, we construct a fake header 4375115Sfenner * that includes: 4475115Sfenner * 4575115Sfenner * a 2-byte "packet type" which is one of: 4675115Sfenner * 4775115Sfenner * LINUX_SLL_HOST packet was sent to us 4875115Sfenner * LINUX_SLL_BROADCAST packet was broadcast 4975115Sfenner * LINUX_SLL_MULTICAST packet was multicast 5075115Sfenner * LINUX_SLL_OTHERHOST packet was sent to somebody else 5175115Sfenner * LINUX_SLL_OUTGOING packet was sent *by* us; 5275115Sfenner * 5375115Sfenner * a 2-byte Ethernet protocol field; 5475115Sfenner * 5575115Sfenner * a 2-byte link-layer type; 5675115Sfenner * 5775115Sfenner * a 2-byte link-layer address length; 5875115Sfenner * 5975115Sfenner * an 8-byte source link-layer address, whose actual length is 6075115Sfenner * specified by the previous value. 6175115Sfenner * 6275115Sfenner * All fields except for the link-layer address are in network byte order. 6375115Sfenner * 6475115Sfenner * DO NOT change the layout of this structure, or change any of the 6575115Sfenner * LINUX_SLL_ values below. If you must change the link-layer header 6675115Sfenner * for a "cooked" Linux capture, introduce a new DLT_ type (ask 67190207Srpaulo * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it 68190207Srpaulo * a value that collides with a value already being used), and use the 6975115Sfenner * new header in captures of that type, so that programs that can 7075115Sfenner * handle DLT_LINUX_SLL captures will continue to handle them correctly 7175115Sfenner * without any change, and so that capture files with different headers 7275115Sfenner * can be told apart and programs that read them can dissect the 7375115Sfenner * packets in them. 7475115Sfenner * 7575115Sfenner * This structure, and the #defines below, must be the same in the 7675115Sfenner * libpcap and tcpdump versions of "sll.h". 7775115Sfenner */ 7875115Sfenner 7975115Sfenner/* 8075115Sfenner * A DLT_LINUX_SLL fake link-layer header. 8175115Sfenner */ 8275115Sfenner#define SLL_HDR_LEN 16 /* total header length */ 8375115Sfenner#define SLL_ADDRLEN 8 /* length of address field */ 8475115Sfenner 8575115Sfennerstruct sll_header { 8675115Sfenner u_int16_t sll_pkttype; /* packet type */ 8775115Sfenner u_int16_t sll_hatype; /* link-layer address type */ 8875115Sfenner u_int16_t sll_halen; /* link-layer address length */ 8975115Sfenner u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ 9075115Sfenner u_int16_t sll_protocol; /* protocol */ 9175115Sfenner}; 9275115Sfenner 9375115Sfenner/* 9475115Sfenner * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the 9575115Sfenner * PACKET_ values on Linux, but are defined here so that they're 9675115Sfenner * available even on systems other than Linux, and so that they 9775115Sfenner * don't change even if the PACKET_ values change. 9875115Sfenner */ 9975115Sfenner#define LINUX_SLL_HOST 0 10075115Sfenner#define LINUX_SLL_BROADCAST 1 10175115Sfenner#define LINUX_SLL_MULTICAST 2 10275115Sfenner#define LINUX_SLL_OTHERHOST 3 10375115Sfenner#define LINUX_SLL_OUTGOING 4 10475115Sfenner 10575115Sfenner/* 10675115Sfenner * The LINUX_SLL_ values for "sll_protocol"; these correspond to the 10775115Sfenner * ETH_P_ values on Linux, but are defined here so that they're 10875115Sfenner * available even on systems other than Linux. We assume, for now, 10975115Sfenner * that the ETH_P_ values won't change in Linux; if they do, then: 11075115Sfenner * 11175115Sfenner * if we don't translate them in "pcap-linux.c", capture files 11275115Sfenner * won't necessarily be readable if captured on a system that 11375115Sfenner * defines ETH_P_ values that don't match these values; 11475115Sfenner * 11575115Sfenner * if we do translate them in "pcap-linux.c", that makes life 11675115Sfenner * unpleasant for the BPF code generator, as the values you test 11775115Sfenner * for in the kernel aren't the values that you test for when 11875115Sfenner * reading a capture file, so the fixup code run on BPF programs 11975115Sfenner * handed to the kernel ends up having to do more work. 12075115Sfenner * 12175115Sfenner * Add other values here as necessary, for handling packet types that 12275115Sfenner * might show up on non-Ethernet, non-802.x networks. (Not all the ones 12375115Sfenner * in the Linux "if_ether.h" will, I suspect, actually show up in 12475115Sfenner * captures.) 12575115Sfenner */ 12675115Sfenner#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */ 12775115Sfenner#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */ 128