2011-04-05 20:48:52 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2014-12-16 03:47:14 +01:00
|
|
|
|
2011-04-05 20:48:52 +02:00
|
|
|
#ifndef _NET_ETHERNET_H_
|
2014-12-16 03:47:14 +01:00
|
|
|
#define _NET_ETHERNET_H_
|
|
|
|
|
2016-05-12 22:11:28 +02:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2011-04-05 20:48:52 +02:00
|
|
|
#include <linux/if_ether.h>
|
2016-05-12 22:11:28 +02:00
|
|
|
|
|
|
|
#define ETHERTYPE_IP 0x0800
|
|
|
|
#define ETHERTYPE_ARP 0x0806
|
|
|
|
#define ETHERTYPE_REVARP 0x8035
|
|
|
|
#define ETHERTYPE_VLAN 0x8100
|
|
|
|
#define ETHERTYPE_IPX 0x8137
|
|
|
|
#define ETHERTYPE_IPV6 0x86dd
|
|
|
|
#define ETHERTYPE_LOOPBACK 0x9000
|
|
|
|
|
|
|
|
#define ETHERTYPE_TRAIL 0x1000
|
|
|
|
#define ETHERTYPE_NTRAILER 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some basic Ethernet constants.
|
|
|
|
*/
|
|
|
|
#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
|
|
|
|
#define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */
|
|
|
|
#define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */
|
|
|
|
#define ETHER_HDR_LEN ((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
|
|
|
|
#define ETHER_MIN_LEN 64 /* minimum frame length, including CRC */
|
|
|
|
#define ETHER_MAX_LEN 1518 /* maximum frame length, including CRC */
|
|
|
|
#define ETHER_MAX_LEN_JUMBO 9018 /* maximum jumbo frame len, including CRC */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ethernet address - 6 octets
|
|
|
|
* this is only used by the ethers(3) functions.
|
|
|
|
*/
|
|
|
|
struct ether_addr {
|
|
|
|
u_int8_t ether_addr_octet[ETHER_ADDR_LEN];
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure of a 10Mb/s Ethernet header.
|
|
|
|
*/
|
|
|
|
struct ether_header {
|
|
|
|
u_int8_t ether_dhost[ETHER_ADDR_LEN];
|
|
|
|
u_int8_t ether_shost[ETHER_ADDR_LEN];
|
|
|
|
u_int16_t ether_type;
|
|
|
|
} __attribute__((__packed__));
|
|
|
|
|
|
|
|
#define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN)
|
|
|
|
#define ETHERMTU (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
|
|
|
|
#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
|
2014-12-16 03:47:14 +01:00
|
|
|
|
|
|
|
#endif
|