1*76404edcSAsim Jamshed /*- 2*76404edcSAsim Jamshed * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3*76404edcSAsim Jamshed * The Regents of the University of California. All rights reserved. 4*76404edcSAsim Jamshed * 5*76404edcSAsim Jamshed * This code is derived from the Stanford/CMU enet packet filter, 6*76404edcSAsim Jamshed * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7*76404edcSAsim Jamshed * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 8*76404edcSAsim Jamshed * Berkeley Laboratory. 9*76404edcSAsim Jamshed * 10*76404edcSAsim Jamshed * Redistribution and use in source and binary forms, with or without 11*76404edcSAsim Jamshed * modification, are permitted provided that the following conditions 12*76404edcSAsim Jamshed * are met: 13*76404edcSAsim Jamshed * 1. Redistributions of source code must retain the above copyright 14*76404edcSAsim Jamshed * notice, this list of conditions and the following disclaimer. 15*76404edcSAsim Jamshed * 2. Redistributions in binary form must reproduce the above copyright 16*76404edcSAsim Jamshed * notice, this list of conditions and the following disclaimer in the 17*76404edcSAsim Jamshed * documentation and/or other materials provided with the distribution. 18*76404edcSAsim Jamshed * 3. All advertising materials mentioning features or use of this software 19*76404edcSAsim Jamshed * must display the following acknowledgement: 20*76404edcSAsim Jamshed * This product includes software developed by the University of 21*76404edcSAsim Jamshed * California, Berkeley and its contributors. 22*76404edcSAsim Jamshed * 4. Neither the name of the University nor the names of its contributors 23*76404edcSAsim Jamshed * may be used to endorse or promote products derived from this software 24*76404edcSAsim Jamshed * without specific prior written permission. 25*76404edcSAsim Jamshed * 26*76404edcSAsim Jamshed * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27*76404edcSAsim Jamshed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28*76404edcSAsim Jamshed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29*76404edcSAsim Jamshed * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30*76404edcSAsim Jamshed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31*76404edcSAsim Jamshed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32*76404edcSAsim Jamshed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33*76404edcSAsim Jamshed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34*76404edcSAsim Jamshed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35*76404edcSAsim Jamshed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36*76404edcSAsim Jamshed * SUCH DAMAGE. 37*76404edcSAsim Jamshed * 38*76404edcSAsim Jamshed * @(#) $Header: /usr/cvsroot/sfeng/ims/src/libraries/daq/daq/sfbpf/sll.h,v 1.3 2012/09/07 19:30:43 maltizer Exp $ (LBL) 39*76404edcSAsim Jamshed */ 40*76404edcSAsim Jamshed 41*76404edcSAsim Jamshed /* 42*76404edcSAsim Jamshed * For captures on Linux cooked sockets, we construct a fake header 43*76404edcSAsim Jamshed * that includes: 44*76404edcSAsim Jamshed * 45*76404edcSAsim Jamshed * a 2-byte "packet type" which is one of: 46*76404edcSAsim Jamshed * 47*76404edcSAsim Jamshed * LINUX_SLL_HOST packet was sent to us 48*76404edcSAsim Jamshed * LINUX_SLL_BROADCAST packet was broadcast 49*76404edcSAsim Jamshed * LINUX_SLL_MULTICAST packet was multicast 50*76404edcSAsim Jamshed * LINUX_SLL_OTHERHOST packet was sent to somebody else 51*76404edcSAsim Jamshed * LINUX_SLL_OUTGOING packet was sent *by* us; 52*76404edcSAsim Jamshed * 53*76404edcSAsim Jamshed * a 2-byte Ethernet protocol field; 54*76404edcSAsim Jamshed * 55*76404edcSAsim Jamshed * a 2-byte link-layer type; 56*76404edcSAsim Jamshed * 57*76404edcSAsim Jamshed * a 2-byte link-layer address length; 58*76404edcSAsim Jamshed * 59*76404edcSAsim Jamshed * an 8-byte source link-layer address, whose actual length is 60*76404edcSAsim Jamshed * specified by the previous value. 61*76404edcSAsim Jamshed * 62*76404edcSAsim Jamshed * All fields except for the link-layer address are in network byte order. 63*76404edcSAsim Jamshed * 64*76404edcSAsim Jamshed * DO NOT change the layout of this structure, or change any of the 65*76404edcSAsim Jamshed * LINUX_SLL_ values below. If you must change the link-layer header 66*76404edcSAsim Jamshed * for a "cooked" Linux capture, introduce a new DLT_ type (ask 67*76404edcSAsim Jamshed * "[email protected]" for one, so that you don't give it 68*76404edcSAsim Jamshed * a value that collides with a value already being used), and use the 69*76404edcSAsim Jamshed * new header in captures of that type, so that programs that can 70*76404edcSAsim Jamshed * handle DLT_LINUX_SLL captures will continue to handle them correctly 71*76404edcSAsim Jamshed * without any change, and so that capture files with different headers 72*76404edcSAsim Jamshed * can be told apart and programs that read them can dissect the 73*76404edcSAsim Jamshed * packets in them. 74*76404edcSAsim Jamshed */ 75*76404edcSAsim Jamshed 76*76404edcSAsim Jamshed #ifndef lib_pcap_sll_h 77*76404edcSAsim Jamshed #define lib_pcap_sll_h 78*76404edcSAsim Jamshed 79*76404edcSAsim Jamshed /* 80*76404edcSAsim Jamshed * A DLT_LINUX_SLL fake link-layer header. 81*76404edcSAsim Jamshed */ 82*76404edcSAsim Jamshed #define SLL_HDR_LEN 16 /* total header length */ 83*76404edcSAsim Jamshed #define SLL_ADDRLEN 8 /* length of address field */ 84*76404edcSAsim Jamshed 85*76404edcSAsim Jamshed #if defined (__SVR4) && defined (__sun) 86*76404edcSAsim Jamshed 87*76404edcSAsim Jamshed typedef uint8_t u_int8_t; 88*76404edcSAsim Jamshed typedef uint16_t u_int16_t; 89*76404edcSAsim Jamshed 90*76404edcSAsim Jamshed #endif /* defined (__SVR4) && defined (__sun) */ 91*76404edcSAsim Jamshed 92*76404edcSAsim Jamshed struct sll_header 93*76404edcSAsim Jamshed { 94*76404edcSAsim Jamshed u_int16_t sll_pkttype; /* packet type */ 95*76404edcSAsim Jamshed u_int16_t sll_hatype; /* link-layer address type */ 96*76404edcSAsim Jamshed u_int16_t sll_halen; /* link-layer address length */ 97*76404edcSAsim Jamshed u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ 98*76404edcSAsim Jamshed u_int16_t sll_protocol; /* protocol */ 99*76404edcSAsim Jamshed }; 100*76404edcSAsim Jamshed 101*76404edcSAsim Jamshed /* 102*76404edcSAsim Jamshed * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the 103*76404edcSAsim Jamshed * PACKET_ values on Linux, but are defined here so that they're 104*76404edcSAsim Jamshed * available even on systems other than Linux, and so that they 105*76404edcSAsim Jamshed * don't change even if the PACKET_ values change. 106*76404edcSAsim Jamshed */ 107*76404edcSAsim Jamshed #define LINUX_SLL_HOST 0 108*76404edcSAsim Jamshed #define LINUX_SLL_BROADCAST 1 109*76404edcSAsim Jamshed #define LINUX_SLL_MULTICAST 2 110*76404edcSAsim Jamshed #define LINUX_SLL_OTHERHOST 3 111*76404edcSAsim Jamshed #define LINUX_SLL_OUTGOING 4 112*76404edcSAsim Jamshed 113*76404edcSAsim Jamshed /* 114*76404edcSAsim Jamshed * The LINUX_SLL_ values for "sll_protocol"; these correspond to the 115*76404edcSAsim Jamshed * ETH_P_ values on Linux, but are defined here so that they're 116*76404edcSAsim Jamshed * available even on systems other than Linux. We assume, for now, 117*76404edcSAsim Jamshed * that the ETH_P_ values won't change in Linux; if they do, then: 118*76404edcSAsim Jamshed * 119*76404edcSAsim Jamshed * if we don't translate them in "pcap-linux.c", capture files 120*76404edcSAsim Jamshed * won't necessarily be readable if captured on a system that 121*76404edcSAsim Jamshed * defines ETH_P_ values that don't match these values; 122*76404edcSAsim Jamshed * 123*76404edcSAsim Jamshed * if we do translate them in "pcap-linux.c", that makes life 124*76404edcSAsim Jamshed * unpleasant for the BPF code generator, as the values you test 125*76404edcSAsim Jamshed * for in the kernel aren't the values that you test for when 126*76404edcSAsim Jamshed * reading a capture file, so the fixup code run on BPF programs 127*76404edcSAsim Jamshed * handed to the kernel ends up having to do more work. 128*76404edcSAsim Jamshed * 129*76404edcSAsim Jamshed * Add other values here as necessary, for handling packet types that 130*76404edcSAsim Jamshed * might show up on non-Ethernet, non-802.x networks. (Not all the ones 131*76404edcSAsim Jamshed * in the Linux "if_ether.h" will, I suspect, actually show up in 132*76404edcSAsim Jamshed * captures.) 133*76404edcSAsim Jamshed */ 134*76404edcSAsim Jamshed #define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */ 135*76404edcSAsim Jamshed #define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */ 136*76404edcSAsim Jamshed 137*76404edcSAsim Jamshed #endif 138