Back to index

glibc  2.9
ethernet.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /* Based on the FreeBSD version of this file. Curiously, that file
00020    lacks a copyright in the header. */
00021 
00022 #ifndef __NET_ETHERNET_H
00023 #define __NET_ETHERNET_H 1
00024 
00025 #include <sys/cdefs.h>
00026 #include <sys/types.h>
00027 #include <net/if_ether.h>     /* IEEE 802.3 Ethernet constants */
00028 
00029 __BEGIN_DECLS
00030 
00031 /* This is a name for the 48 bit ethernet address available on many
00032    systems.  */
00033 struct ether_addr
00034 {
00035   u_int8_t ether_addr_octet[ETH_ALEN];
00036 };
00037 
00038 /* 10Mb/s ethernet header */
00039 struct ether_header
00040 {
00041   u_int8_t  ether_dhost[ETH_ALEN]; /* destination eth addr     */
00042   u_int8_t  ether_shost[ETH_ALEN]; /* source ether addr */
00043   u_int16_t ether_type;                    /* packet type ID field    */
00044 };
00045 
00046 /* Ethernet protocol ID's */
00047 #define       ETHERTYPE_PUP        0x0200          /* Xerox PUP */
00048 #define       ETHERTYPE_IP         0x0800        /* IP */
00049 #define       ETHERTYPE_ARP        0x0806        /* Address resolution */
00050 #define       ETHERTYPE_REVARP     0x8035        /* Reverse ARP */
00051 
00052 #define       ETHER_ADDR_LEN       ETH_ALEN                 /* size of ethernet addr */
00053 #define       ETHER_TYPE_LEN       2                        /* bytes in type field */
00054 #define       ETHER_CRC_LEN 4                        /* bytes in CRC field */
00055 #define       ETHER_HDR_LEN ETH_HLEN                 /* total octets in header */
00056 #define       ETHER_MIN_LEN (ETH_ZLEN + ETH_CRC_LEN) /* min packet length */
00057 #define       ETHER_MAX_LEN (ETH_FRAME_LEN + ETH_CRC_LEN) /* max packet length */
00058 
00059 /* make sure ethenet length is valid */
00060 #define       ETHER_IS_VALID_LEN(foo)     \
00061        ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
00062 
00063 /*
00064  * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
00065  * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
00066  * by an ETHER type (as given above) and then the (variable-length) header.
00067  */
00068 #define       ETHERTYPE_TRAIL             0x1000        /* Trailer packet */
00069 #define       ETHERTYPE_NTRAILER   16
00070 
00071 #define       ETHERMTU      ETH_DATA_LEN
00072 #define       ETHERMIN      (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
00073 
00074 __END_DECLS
00075 
00076 #endif /* net/ethernet.h */