Blame sysdeps/unix/sysv/linux/net/ethernet.h

Packit 6c4009
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/* Based on the FreeBSD version of this file. Curiously, that file
Packit 6c4009
   lacks a copyright in the header. */
Packit 6c4009
Packit 6c4009
#ifndef __NET_ETHERNET_H
Packit 6c4009
#define __NET_ETHERNET_H 1
Packit 6c4009
Packit 6c4009
#include <sys/types.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
Packit 6c4009
#include <linux/if_ether.h>     /* IEEE 802.3 Ethernet constants */
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* This is a name for the 48 bit ethernet address available on many
Packit 6c4009
   systems.  */
Packit 6c4009
struct ether_addr
Packit 6c4009
{
Packit 6c4009
  uint8_t ether_addr_octet[ETH_ALEN];
Packit 6c4009
} __attribute__ ((__packed__));
Packit 6c4009
Packit 6c4009
/* 10Mb/s ethernet header */
Packit 6c4009
struct ether_header
Packit 6c4009
{
Packit 6c4009
  uint8_t  ether_dhost[ETH_ALEN];	/* destination eth addr	*/
Packit 6c4009
  uint8_t  ether_shost[ETH_ALEN];	/* source ether addr	*/
Packit 6c4009
  uint16_t ether_type;		        /* packet type ID field	*/
Packit 6c4009
} __attribute__ ((__packed__));
Packit 6c4009
Packit 6c4009
/* Ethernet protocol ID's */
Packit 6c4009
#define	ETHERTYPE_PUP		0x0200          /* Xerox PUP */
Packit 6c4009
#define ETHERTYPE_SPRITE	0x0500		/* Sprite */
Packit 6c4009
#define	ETHERTYPE_IP		0x0800		/* IP */
Packit 6c4009
#define	ETHERTYPE_ARP		0x0806		/* Address resolution */
Packit 6c4009
#define	ETHERTYPE_REVARP	0x8035		/* Reverse ARP */
Packit 6c4009
#define ETHERTYPE_AT		0x809B		/* AppleTalk protocol */
Packit 6c4009
#define ETHERTYPE_AARP		0x80F3		/* AppleTalk ARP */
Packit 6c4009
#define	ETHERTYPE_VLAN		0x8100		/* IEEE 802.1Q VLAN tagging */
Packit 6c4009
#define ETHERTYPE_IPX		0x8137		/* IPX */
Packit 6c4009
#define	ETHERTYPE_IPV6		0x86dd		/* IP protocol version 6 */
Packit 6c4009
#define ETHERTYPE_LOOPBACK	0x9000		/* used to test interfaces */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define	ETHER_ADDR_LEN	ETH_ALEN                 /* size of ethernet addr */
Packit 6c4009
#define	ETHER_TYPE_LEN	2                        /* bytes in type field */
Packit 6c4009
#define	ETHER_CRC_LEN	4                        /* bytes in CRC field */
Packit 6c4009
#define	ETHER_HDR_LEN	ETH_HLEN                 /* total octets in header */
Packit 6c4009
#define	ETHER_MIN_LEN	(ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */
Packit 6c4009
#define	ETHER_MAX_LEN	(ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */
Packit 6c4009
Packit 6c4009
/* make sure ethenet length is valid */
Packit 6c4009
#define	ETHER_IS_VALID_LEN(foo)	\
Packit 6c4009
	((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
Packit 6c4009
 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
Packit 6c4009
 * by an ETHER type (as given above) and then the (variable-length) header.
Packit 6c4009
 */
Packit 6c4009
#define	ETHERTYPE_TRAIL		0x1000		/* Trailer packet */
Packit 6c4009
#define	ETHERTYPE_NTRAILER	16
Packit 6c4009
Packit 6c4009
#define	ETHERMTU	ETH_DATA_LEN
Packit 6c4009
#define	ETHERMIN	(ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif	/* net/ethernet.h */