📄 ethernet.h
字号:
/*
* Fundamental constants relating to ethernet.
*
* $FreeBSD: src/sys/net/ethernet.h,v 1.22 2002/11/14 23:28:47 sam Exp $
*
*/
#ifndef _NET_ETHERNET_H_
#define _NET_ETHERNET_H_
/*
* Somce 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 len, including CRC */
#define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */
#define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */
#define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */
/*
* Mbuf adjust factor to force 32-bit alignment of IP header.
* Drivers should do m_adj(m, ETHER_ALIGN) when setting up a
* receive so the upper layers get the IP header properly aligned
* past the 14-byte Ethernet header.
*/
#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */
/*
* Compute the maximum frame size based on ethertype (i.e. possible
* encapsulation) and whether or not an FCS is present.
*/
#define ETHER_MAX_FRAME(ifp, etype, hasfcs) \
((ifp)->if_mtu + ETHER_HDR_LEN + \
((hasfcs) ? ETHER_CRC_LEN : 0) + \
(((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0))
/*
* Ethernet-specific mbuf flags.
*/
#define M_HASFCS M_PROTO5 /* FCS included at end of frame */
/*
* Ethernet CRC32 polynomials (big- and little-endian verions).
*/
#define ETHER_CRC_POLY_LE 0xedb88320
#define ETHER_CRC_POLY_BE 0x04c11db6
/*
* A macro to validate a length with
*/
#define ETHER_IS_VALID_LEN(foo) \
((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
/*
* Structure of a 10Mb/s Ethernet header.
*/
struct ether_header {
UCHAR ether_dhost[ETHER_ADDR_LEN];
UCHAR ether_shost[ETHER_ADDR_LEN];
USHORT ether_type;
};
/*
* Structure of a 48-bit Ethernet address.
*/
struct ether_addr {
UCHAR octet[ETHER_ADDR_LEN];
};
#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
/*
* NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields.
* However, there are some conflicts.
*/
#define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */
/* 0x0101 .. 0x1FF Experimental */
#define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */
#define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */
#define ETHERTYPE_SPRITE 0x0500 /* ??? */
/* 0x0400 Nixdorf */
#define ETHERTYPE_NS 0x0600 /* XNS */
#define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */
#define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */
#define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#define ETHERTYPE_X75 0x0801 /* X.75 Internet */
#define ETHERTYPE_NBS 0x0802 /* NBS Internet */
#define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */
#define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */
#define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */
#define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */
#define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */
#define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */
/* 0x081C Symbolics Private */
/* 0x0888 - 0x088A Xyplex */
#define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */
#define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */
#define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */
#define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */
#define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */
#define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */
/* 0x1000 - 0x100F Berkeley Trailer */
/*
* The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
* (type-ETHERTYPE_TRAIL)*512 bytes of data followed
* by an ETHER type (as given above) and then the (variable-length) header.
*/
#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
#define ETHERTYPE_NTRAILER 16
#define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */
#define ETHERTYPE_VALID 0x1600 /* VALID system protocol */
#define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */
#define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */
/* The following 3C0x types
are unregistered: */
#define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */
#define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */
#define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */
#define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect repsonse not registered */
#define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */
#define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */
#define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */
#define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */
#define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */
#define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */
#define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete Netbios name not registered */
#define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */
#define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */
#define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */
#define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */
#define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */
#define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */
#define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */
#define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */
#define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */
#define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */
#define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */
#define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */
#define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */
#define ETHERTYPE_LAT 0x6004 /* DEC LAT */
#define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */
#define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */
#define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */
#define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */
#define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */
/* 0x6010 - 0x6014 3Com Corporation */
#define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/
#define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */
#define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */
#define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */
#define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */
#define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */
#define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */
#define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */
#define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */
/* 0x7020 - 0x7029 LRT (England) (now Sintrom) */
#define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */
#define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */
#define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */
#define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */
#define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */
#define ETHERTYPE_HP 0x8005 /* HP Probe */
#define ETHERTYPE_NESTAR 0x8006 /* Nestar */
#define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */
#define ETHERTYPE_EXCELAN 0x8010 /* Excelan */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -