117443Sphk/* 217443Sphk * Fundamental constants relating to ethernet. 317443Sphk * 450477Speter * $FreeBSD: stable/11/sys/net/ethernet.h 369376 2021-02-25 10:13:03Z donner $ 517443Sphk * 617443Sphk */ 717443Sphk 817455Sphk#ifndef _NET_ETHERNET_H_ 9358259Spfg#define _NET_ETHERNET_H_ 1017455Sphk 1117455Sphk/* 12179036Sscf * Some basic Ethernet constants. 1317455Sphk */ 14106929Ssam#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ 15106929Ssam#define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ 16106929Ssam#define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */ 17106929Ssam#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) 18106929Ssam#define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */ 19106929Ssam#define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */ 20106929Ssam#define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */ 2117455Sphk 22106929Ssam#define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */ 2317455Sphk/* 24106929Ssam * Mbuf adjust factor to force 32-bit alignment of IP header. 25106929Ssam * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a 26106929Ssam * receive so the upper layers get the IP header properly aligned 27106929Ssam * past the 14-byte Ethernet header. 2817455Sphk */ 29106929Ssam#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ 3017455Sphk 3117455Sphk/* 32106929Ssam * Compute the maximum frame size based on ethertype (i.e. possible 33106929Ssam * encapsulation) and whether or not an FCS is present. 3417455Sphk */ 35106929Ssam#define ETHER_MAX_FRAME(ifp, etype, hasfcs) \ 36106929Ssam ((ifp)->if_mtu + ETHER_HDR_LEN + \ 37106929Ssam ((hasfcs) ? ETHER_CRC_LEN : 0) + \ 38106929Ssam (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0)) 3917455Sphk 4017455Sphk/* 41106929Ssam * Ethernet-specific mbuf flags. 4217455Sphk */ 43106929Ssam#define M_HASFCS M_PROTO5 /* FCS included at end of frame */ 4417455Sphk 4517455Sphk/* 46106929Ssam * Ethernet CRC32 polynomials (big- and little-endian verions). 4717455Sphk */ 48106929Ssam#define ETHER_CRC_POLY_LE 0xedb88320 49106929Ssam#define ETHER_CRC_POLY_BE 0x04c11db6 5017455Sphk 5117455Sphk/* 5217455Sphk * A macro to validate a length with 5317455Sphk */ 5417455Sphk#define ETHER_IS_VALID_LEN(foo) \ 5517455Sphk ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) 5617455Sphk 5717455Sphk/* 5817455Sphk * Structure of a 10Mb/s Ethernet header. 5917455Sphk */ 60165724Scsjpstruct ether_header { 6117455Sphk u_char ether_dhost[ETHER_ADDR_LEN]; 6217455Sphk u_char ether_shost[ETHER_ADDR_LEN]; 6317455Sphk u_short ether_type; 64164381Ssam} __packed; 6517455Sphk 6617455Sphk/* 6717455Sphk * Structure of a 48-bit Ethernet address. 6817455Sphk */ 69165724Scsjpstruct ether_addr { 7017455Sphk u_char octet[ETHER_ADDR_LEN]; 71164785Simp} __packed; 7217455Sphk 73106929Ssam#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ 74338937Sjpaetzel#define ETHER_IS_BROADCAST(addr) \ 75338937Sjpaetzel (((addr)[0] & (addr)[1] & (addr)[2] & \ 76338937Sjpaetzel (addr)[3] & (addr)[4] & (addr)[5]) == 0xff) 77106929Ssam 78103024Ssobomax/* 79274374Sglebius * 802.1q Virtual LAN header. 80274374Sglebius */ 81274374Sglebiusstruct ether_vlan_header { 82274374Sglebius uint8_t evl_dhost[ETHER_ADDR_LEN]; 83274374Sglebius uint8_t evl_shost[ETHER_ADDR_LEN]; 84274374Sglebius uint16_t evl_encap_proto; 85274374Sglebius uint16_t evl_tag; 86274374Sglebius uint16_t evl_proto; 87274374Sglebius} __packed; 88274374Sglebius 89274374Sglebius#define EVL_VLID_MASK 0x0FFF 90274374Sglebius#define EVL_PRI_MASK 0xE000 91274374Sglebius#define EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK) 92274374Sglebius#define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7) 93274374Sglebius#define EVL_CFIOFTAG(tag) (((tag) >> 12) & 1) 94274374Sglebius#define EVL_MAKETAG(vlid, pri, cfi) \ 95318604Ssephe ((((((pri) & 7) << 1) | ((cfi) & 1)) << 12) | ((vlid) & EVL_VLID_MASK)) 96274374Sglebius 97274374Sglebius/* 98358259Spfg * Ethernet protocol types. 99358259Spfg * 100358259Spfg * A public list is available from the IEEE Registration Authority: 101358259Spfg * https://standards.ieee.org/products-services/regauth/ 102358259Spfg * 103103024Ssobomax * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. 104103024Ssobomax * However, there are some conflicts. 105103024Ssobomax */ 106103024Ssobomax 107103024Ssobomax#define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */ 108103024Ssobomax /* 0x0101 .. 0x1FF Experimental */ 109103024Ssobomax#define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */ 110103024Ssobomax#define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */ 111103024Ssobomax#define ETHERTYPE_SPRITE 0x0500 /* ??? */ 112103024Ssobomax /* 0x0400 Nixdorf */ 113103024Ssobomax#define ETHERTYPE_NS 0x0600 /* XNS */ 114103024Ssobomax#define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */ 115103024Ssobomax#define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */ 116103024Ssobomax#define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */ 11721260Swollman#define ETHERTYPE_IP 0x0800 /* IP protocol */ 118103024Ssobomax#define ETHERTYPE_X75 0x0801 /* X.75 Internet */ 119103024Ssobomax#define ETHERTYPE_NBS 0x0802 /* NBS Internet */ 120103024Ssobomax#define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */ 121103024Ssobomax#define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */ 122103024Ssobomax#define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */ 123103024Ssobomax#define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */ 124103024Ssobomax#define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */ 125103024Ssobomax#define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */ 126103024Ssobomax /* 0x081C Symbolics Private */ 127103024Ssobomax /* 0x0888 - 0x088A Xyplex */ 128103024Ssobomax#define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */ 129103024Ssobomax#define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */ 130103024Ssobomax#define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */ 131103024Ssobomax#define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */ 132103024Ssobomax#define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */ 133103024Ssobomax#define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */ 13421260Swollman 135103024Ssobomax/* 0x1000 - 0x100F Berkeley Trailer */ 13621260Swollman/* 13721260Swollman * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have 13821260Swollman * (type-ETHERTYPE_TRAIL)*512 bytes of data followed 13921260Swollman * by an ETHER type (as given above) and then the (variable-length) header. 14021260Swollman */ 141103024Ssobomax#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ 142103024Ssobomax#define ETHERTYPE_NTRAILER 16 143103024Ssobomax 144103024Ssobomax#define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */ 145103024Ssobomax#define ETHERTYPE_VALID 0x1600 /* VALID system protocol */ 146103024Ssobomax#define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */ 147103024Ssobomax#define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */ 148103024Ssobomax 149103024Ssobomax /* The following 3C0x types 150103024Ssobomax are unregistered: */ 151103024Ssobomax#define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */ 152103024Ssobomax#define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */ 153103024Ssobomax#define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */ 154179036Sscf#define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect response not registered */ 155103024Ssobomax#define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */ 156103024Ssobomax#define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */ 157103024Ssobomax#define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */ 158103024Ssobomax#define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */ 159103024Ssobomax#define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */ 160103024Ssobomax#define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */ 161179036Sscf#define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete NetBIOS name not registered */ 162103024Ssobomax#define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */ 163103024Ssobomax#define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */ 164103024Ssobomax#define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */ 165103024Ssobomax 166103024Ssobomax#define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */ 167103024Ssobomax#define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */ 168103024Ssobomax#define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */ 169103024Ssobomax#define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */ 170103024Ssobomax#define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */ 171103024Ssobomax#define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */ 172103024Ssobomax#define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */ 173103024Ssobomax#define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */ 174103024Ssobomax#define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */ 175103024Ssobomax#define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */ 176103024Ssobomax#define ETHERTYPE_LAT 0x6004 /* DEC LAT */ 177103024Ssobomax#define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */ 178103024Ssobomax#define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */ 179103024Ssobomax#define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */ 180103024Ssobomax#define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */ 181103024Ssobomax#define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */ 182103024Ssobomax /* 0x6010 - 0x6014 3Com Corporation */ 183103024Ssobomax#define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/ 184103024Ssobomax#define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */ 185103024Ssobomax#define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */ 186103024Ssobomax#define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */ 187103024Ssobomax#define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */ 188103024Ssobomax#define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */ 189103024Ssobomax#define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */ 190103024Ssobomax#define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */ 191103024Ssobomax#define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */ 192103024Ssobomax /* 0x7020 - 0x7029 LRT (England) (now Sintrom) */ 193103024Ssobomax#define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */ 194103024Ssobomax#define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */ 195103024Ssobomax#define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */ 196103024Ssobomax#define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */ 197103024Ssobomax#define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */ 198103024Ssobomax#define ETHERTYPE_HP 0x8005 /* HP Probe */ 199103024Ssobomax#define ETHERTYPE_NESTAR 0x8006 /* Nestar */ 200103024Ssobomax#define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */ 201103024Ssobomax#define ETHERTYPE_EXCELAN 0x8010 /* Excelan */ 202103024Ssobomax#define ETHERTYPE_SG_DIAG 0x8013 /* SGI diagnostic type */ 203103024Ssobomax#define ETHERTYPE_SG_NETGAMES 0x8014 /* SGI network games */ 204103024Ssobomax#define ETHERTYPE_SG_RESV 0x8015 /* SGI reserved type */ 205103024Ssobomax#define ETHERTYPE_SG_BOUNCE 0x8016 /* SGI bounce server */ 206103024Ssobomax#define ETHERTYPE_APOLLODOMAIN 0x8019 /* Apollo DOMAIN */ 207103024Ssobomax#define ETHERTYPE_TYMSHARE 0x802E /* Tymeshare */ 208103024Ssobomax#define ETHERTYPE_TIGAN 0x802F /* Tigan, Inc. */ 209103024Ssobomax#define ETHERTYPE_REVARP 0x8035 /* Reverse addr resolution protocol */ 210103024Ssobomax#define ETHERTYPE_AEONIC 0x8036 /* Aeonic Systems */ 211103024Ssobomax#define ETHERTYPE_IPXNEW 0x8037 /* IPX (Novell Netware?) */ 212103024Ssobomax#define ETHERTYPE_LANBRIDGE 0x8038 /* DEC LANBridge */ 213103024Ssobomax#define ETHERTYPE_DSMD 0x8039 /* DEC DSM/DDP */ 214103024Ssobomax#define ETHERTYPE_ARGONAUT 0x803A /* DEC Argonaut Console */ 215103024Ssobomax#define ETHERTYPE_VAXELN 0x803B /* DEC VAXELN */ 216103024Ssobomax#define ETHERTYPE_DECDNS 0x803C /* DEC DNS Naming Service */ 217103024Ssobomax#define ETHERTYPE_ENCRYPT 0x803D /* DEC Ethernet Encryption */ 218103024Ssobomax#define ETHERTYPE_DECDTS 0x803E /* DEC Distributed Time Service */ 219103024Ssobomax#define ETHERTYPE_DECLTM 0x803F /* DEC LAN Traffic Monitor */ 220103024Ssobomax#define ETHERTYPE_DECNETBIOS 0x8040 /* DEC PATHWORKS DECnet NETBIOS Emulation */ 221103024Ssobomax#define ETHERTYPE_DECLAST 0x8041 /* DEC Local Area System Transport */ 222103024Ssobomax /* 0x8042 DEC Unassigned */ 223103024Ssobomax#define ETHERTYPE_PLANNING 0x8044 /* Planning Research Corp. */ 224103024Ssobomax /* 0x8046 - 0x8047 AT&T */ 225103024Ssobomax#define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */ 226103024Ssobomax#define ETHERTYPE_EXPERDATA 0x8049 /* ExperData */ 227103024Ssobomax#define ETHERTYPE_VEXP 0x805B /* Stanford V Kernel exp. */ 228103024Ssobomax#define ETHERTYPE_VPROD 0x805C /* Stanford V Kernel prod. */ 229103024Ssobomax#define ETHERTYPE_ES 0x805D /* Evans & Sutherland */ 230103024Ssobomax#define ETHERTYPE_LITTLE 0x8060 /* Little Machines */ 231103024Ssobomax#define ETHERTYPE_COUNTERPOINT 0x8062 /* Counterpoint Computers */ 232103024Ssobomax /* 0x8065 - 0x8066 Univ. of Mass @ Amherst */ 233103024Ssobomax#define ETHERTYPE_VEECO 0x8067 /* Veeco Integrated Auto. */ 234103024Ssobomax#define ETHERTYPE_GENDYN 0x8068 /* General Dynamics */ 235103024Ssobomax#define ETHERTYPE_ATT 0x8069 /* AT&T */ 236103024Ssobomax#define ETHERTYPE_AUTOPHON 0x806A /* Autophon */ 237103024Ssobomax#define ETHERTYPE_COMDESIGN 0x806C /* ComDesign */ 238103024Ssobomax#define ETHERTYPE_COMPUGRAPHIC 0x806D /* Compugraphic Corporation */ 239103024Ssobomax /* 0x806E - 0x8077 Landmark Graphics Corp. */ 240103024Ssobomax#define ETHERTYPE_MATRA 0x807A /* Matra */ 241103024Ssobomax#define ETHERTYPE_DDE 0x807B /* Dansk Data Elektronik */ 242103024Ssobomax#define ETHERTYPE_MERIT 0x807C /* Merit Internodal (or Univ of Michigan?) */ 243103024Ssobomax /* 0x807D - 0x807F Vitalink Communications */ 244103024Ssobomax#define ETHERTYPE_VLTLMAN 0x8080 /* Vitalink TransLAN III Management */ 245103024Ssobomax /* 0x8081 - 0x8083 Counterpoint Computers */ 246103024Ssobomax /* 0x8088 - 0x808A Xyplex */ 247103024Ssobomax#define ETHERTYPE_ATALK 0x809B /* AppleTalk */ 248103024Ssobomax#define ETHERTYPE_AT ETHERTYPE_ATALK /* old NetBSD */ 249103024Ssobomax#define ETHERTYPE_APPLETALK ETHERTYPE_ATALK /* HP-UX */ 250103024Ssobomax /* 0x809C - 0x809E Datability */ 251103024Ssobomax#define ETHERTYPE_SPIDER 0x809F /* Spider Systems Ltd. */ 252103024Ssobomax /* 0x80A3 Nixdorf */ 253103024Ssobomax /* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */ 254103024Ssobomax /* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */ 255103024Ssobomax /* 0x80C4 - 0x80C5 Banyan Systems */ 256103024Ssobomax#define ETHERTYPE_PACER 0x80C6 /* Pacer Software */ 257103024Ssobomax#define ETHERTYPE_APPLITEK 0x80C7 /* Applitek Corporation */ 258103024Ssobomax /* 0x80C8 - 0x80CC Intergraph Corporation */ 259103024Ssobomax /* 0x80CD - 0x80CE Harris Corporation */ 260103024Ssobomax /* 0x80CF - 0x80D2 Taylor Instrument */ 261103024Ssobomax /* 0x80D3 - 0x80D4 Rosemount Corporation */ 262103024Ssobomax#define ETHERTYPE_SNA 0x80D5 /* IBM SNA Services over Ethernet */ 263103024Ssobomax#define ETHERTYPE_VARIAN 0x80DD /* Varian Associates */ 264103024Ssobomax /* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */ 265103024Ssobomax /* 0x80E0 - 0x80E3 Allen-Bradley */ 266103024Ssobomax /* 0x80E4 - 0x80F0 Datability */ 267103024Ssobomax#define ETHERTYPE_RETIX 0x80F2 /* Retix */ 268103024Ssobomax#define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ 269103024Ssobomax /* 0x80F4 - 0x80F5 Kinetics */ 270103024Ssobomax#define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ 271358259Spfg#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ 272103024Ssobomax /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ 273103024Ssobomax#define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ 274103024Ssobomax#define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ 275103024Ssobomax /* 0x8107 - 0x8109 Symbolics Private */ 276103024Ssobomax#define ETHERTYPE_TALARIS 0x812B /* Talaris */ 277103024Ssobomax#define ETHERTYPE_WATERLOO 0x8130 /* Waterloo Microsystems Inc. (XXX which?) */ 278103024Ssobomax#define ETHERTYPE_HAYES 0x8130 /* Hayes Microcomputers (XXX which?) */ 279103024Ssobomax#define ETHERTYPE_VGLAB 0x8131 /* VG Laboratory Systems */ 280103024Ssobomax /* 0x8132 - 0x8137 Bridge Communications */ 281103024Ssobomax#define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ 282103024Ssobomax#define ETHERTYPE_NOVELL 0x8138 /* Novell, Inc. */ 283103024Ssobomax /* 0x8139 - 0x813D KTI */ 284103024Ssobomax#define ETHERTYPE_MUMPS 0x813F /* M/MUMPS data sharing */ 285103024Ssobomax#define ETHERTYPE_AMOEBA 0x8145 /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */ 286103024Ssobomax#define ETHERTYPE_FLIP 0x8146 /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */ 287103024Ssobomax#define ETHERTYPE_VURESERVED 0x8147 /* Vrije Universiteit (NL) [reserved] */ 288103024Ssobomax#define ETHERTYPE_LOGICRAFT 0x8148 /* Logicraft */ 289103024Ssobomax#define ETHERTYPE_NCD 0x8149 /* Network Computing Devices */ 290103024Ssobomax#define ETHERTYPE_ALPHA 0x814A /* Alpha Micro */ 291103024Ssobomax#define ETHERTYPE_SNMP 0x814C /* SNMP over Ethernet (see RFC1089) */ 292103024Ssobomax /* 0x814D - 0x814E BIIN */ 293103024Ssobomax#define ETHERTYPE_TEC 0x814F /* Technically Elite Concepts */ 294103024Ssobomax#define ETHERTYPE_RATIONAL 0x8150 /* Rational Corp */ 295103024Ssobomax /* 0x8151 - 0x8153 Qualcomm */ 296103024Ssobomax /* 0x815C - 0x815E Computer Protocol Pty Ltd */ 297103024Ssobomax /* 0x8164 - 0x8166 Charles River Data Systems */ 298103024Ssobomax#define ETHERTYPE_XTP 0x817D /* Protocol Engines XTP */ 299103024Ssobomax#define ETHERTYPE_SGITW 0x817E /* SGI/Time Warner prop. */ 300103024Ssobomax#define ETHERTYPE_HIPPI_FP 0x8180 /* HIPPI-FP encapsulation */ 301103024Ssobomax#define ETHERTYPE_STP 0x8181 /* Scheduled Transfer STP, HIPPI-ST */ 302103024Ssobomax /* 0x8182 - 0x8183 Reserved for HIPPI-6400 */ 303103024Ssobomax /* 0x8184 - 0x818C SGI prop. */ 304103024Ssobomax#define ETHERTYPE_MOTOROLA 0x818D /* Motorola */ 305103024Ssobomax#define ETHERTYPE_NETBEUI 0x8191 /* PowerLAN NetBIOS/NetBEUI (PC) */ 306103024Ssobomax /* 0x819A - 0x81A3 RAD Network Devices */ 307103024Ssobomax /* 0x81B7 - 0x81B9 Xyplex */ 308103024Ssobomax /* 0x81CC - 0x81D5 Apricot Computers */ 309103024Ssobomax /* 0x81D6 - 0x81DD Artisoft Lantastic */ 310103024Ssobomax /* 0x81E6 - 0x81EF Polygon */ 311103024Ssobomax /* 0x81F0 - 0x81F2 Comsat Labs */ 312103024Ssobomax /* 0x81F3 - 0x81F5 SAIC */ 313103024Ssobomax /* 0x81F6 - 0x81F8 VG Analytical */ 314103024Ssobomax /* 0x8203 - 0x8205 QNX Software Systems Ltd. */ 315103024Ssobomax /* 0x8221 - 0x8222 Ascom Banking Systems */ 316103024Ssobomax /* 0x823E - 0x8240 Advanced Encryption Systems */ 317103024Ssobomax /* 0x8263 - 0x826A Charles River Data Systems */ 318103024Ssobomax /* 0x827F - 0x8282 Athena Programming */ 319103024Ssobomax /* 0x829A - 0x829B Inst Ind Info Tech */ 320103024Ssobomax /* 0x829C - 0x82AB Taurus Controls */ 321103024Ssobomax /* 0x82AC - 0x8693 Walker Richer & Quinn */ 322103024Ssobomax#define ETHERTYPE_ACCTON 0x8390 /* Accton Technologies (unregistered) */ 323103024Ssobomax#define ETHERTYPE_TALARISMC 0x852B /* Talaris multicast */ 324103024Ssobomax#define ETHERTYPE_KALPANA 0x8582 /* Kalpana */ 325103024Ssobomax /* 0x8694 - 0x869D Idea Courier */ 326103024Ssobomax /* 0x869E - 0x86A1 Computer Network Tech */ 327103024Ssobomax /* 0x86A3 - 0x86AC Gateway Communications */ 328103024Ssobomax#define ETHERTYPE_SECTRA 0x86DB /* SECTRA */ 329103024Ssobomax#define ETHERTYPE_IPV6 0x86DD /* IP protocol version 6 */ 330103024Ssobomax#define ETHERTYPE_DELTACON 0x86DE /* Delta Controls */ 331103024Ssobomax#define ETHERTYPE_ATOMIC 0x86DF /* ATOMIC */ 332103024Ssobomax /* 0x86E0 - 0x86EF Landis & Gyr Powers */ 333103024Ssobomax /* 0x8700 - 0x8710 Motorola */ 334103024Ssobomax#define ETHERTYPE_RDP 0x8739 /* Control Technology Inc. RDP Without IP */ 335103024Ssobomax#define ETHERTYPE_MICP 0x873A /* Control Technology Inc. Mcast Industrial Ctrl Proto. */ 336103024Ssobomax /* 0x873B - 0x873C Control Technology Inc. Proprietary */ 337103024Ssobomax#define ETHERTYPE_TCPCOMP 0x876B /* TCP/IP Compression (RFC1701) */ 338103024Ssobomax#define ETHERTYPE_IPAS 0x876C /* IP Autonomous Systems (RFC1701) */ 339103024Ssobomax#define ETHERTYPE_SECUREDATA 0x876D /* Secure Data (RFC1701) */ 340103024Ssobomax#define ETHERTYPE_FLOWCONTROL 0x8808 /* 802.3x flow control packet */ 341167290Sbms#define ETHERTYPE_SLOW 0x8809 /* 802.3ad link aggregation (LACP) */ 342179036Sscf#define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPoE) */ 343103024Ssobomax#define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ 344358259Spfg#define ETHERTYPE_TEST 0x8822 /* Network Conformance Testing */ 345103024Ssobomax#define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ 346103024Ssobomax#define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ 347103024Ssobomax#define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ 348103024Ssobomax#define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ 349103024Ssobomax#define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ 350103024Ssobomax#define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ 351358259Spfg#define ETHERTYPE_PAE 0x888E /* EAPOL PAE/802.1x */ 352358259Spfg#define ETHERTYPE_PROFINET 0x8892 /* PROFINET RT Protocol */ 353358259Spfg#define ETHERTYPE_AOE 0x88A2 /* ATA Protocol */ 354358259Spfg#define ETHERTYPE_ETHERCAT 0x88A4 /* EtherCat Protocol */ 355330829Sae#define ETHERTYPE_QINQ 0x88A8 /* 802.1ad VLAN stacking */ 356358259Spfg#define ETHERTYPE_POWERLINK 0x88AB /* Ethernet Powerlink (EPL) */ 357358259Spfg#define ETHERTYPE_LLDP 0x88CC /* Link Layer Discovery Protocol */ 358358259Spfg#define ETHERTYPE_SERCOS 0x88CD /* SERCOS III Protocol */ 359358259Spfg#define ETHERTYPE_MACSEC 0x88E5 /* 802.1AE MAC Security */ 360358259Spfg#define ETHERTYPE_PBB 0x88E7 /* 802.1Q Provider Backbone Bridges */ 361358259Spfg#define ETHERTYPE_FCOE 0x8906 /* Fibre Channel over Ethernet */ 362103024Ssobomax#define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ 363369376Sdonner#define ETHERTYPE_8021Q9100 0x9100 /* IEEE 802.1Q stacking (proprietary) */ 364103024Ssobomax#define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ 365103024Ssobomax#define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ 366103024Ssobomax#define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ 367103024Ssobomax#define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ 368369376Sdonner#define ETHERTYPE_8021Q9200 0x9200 /* IEEE 802.1Q stacking (proprietary) */ 369369376Sdonner#define ETHERTYPE_8021Q9300 0x9300 /* IEEE 802.1Q stacking (proprietary) */ 370103024Ssobomax#define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ 371103024Ssobomax#define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ 372103024Ssobomax#define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ 373103024Ssobomax /* 0xFF00 - 0xFFOF ISC Bunker Ramo */ 374103024Ssobomax 375103024Ssobomax#define ETHERTYPE_MAX 0xFFFF /* Maximum valid ethernet type, reserved */ 376103024Ssobomax 377103024Ssobomax/* 378103024Ssobomax * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have 379103024Ssobomax * (type-ETHERTYPE_TRAIL)*512 bytes of data followed 380103024Ssobomax * by an ETHER type (as given above) and then the (variable-length) header. 381103024Ssobomax */ 38221260Swollman#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ 38321260Swollman#define ETHERTYPE_NTRAILER 16 38421260Swollman 38521260Swollman#define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) 38621260Swollman#define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) 387106929Ssam#define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN) 388164396Scsjp/* 389164396Scsjp * The ETHER_BPF_MTAP macro should be used by drivers which support hardware 390164396Scsjp * offload for VLAN tag processing. It will check the mbuf to see if it has 391164396Scsjp * M_VLANTAG set, and if it does, will pass the packet along to 392164396Scsjp * ether_vlan_mtap. This function will re-insert VLAN tags for the duration 393164398Scsjp * of the tap, so they show up properly for network analyzers. 394164396Scsjp */ 395358259Spfg#define ETHER_BPF_MTAP(_ifp, _m) do { \ 396164396Scsjp if (bpf_peers_present((_ifp)->if_bpf)) { \ 397164396Scsjp M_ASSERTVALID(_m); \ 398164396Scsjp if (((_m)->m_flags & M_VLANTAG) != 0) \ 399164396Scsjp ether_vlan_mtap((_ifp)->if_bpf, (_m), NULL, 0); \ 400164396Scsjp else \ 401164396Scsjp bpf_mtap((_ifp)->if_bpf, (_m)); \ 402164396Scsjp } \ 403164396Scsjp} while (0) 40421260Swollman 405332991Skib/* 406332991Skib * Names for 802.1q priorities ("802.1p"). Notice that in this scheme, 407332991Skib * (0 < 1), allowing default 0-tagged traffic to take priority over background 408332991Skib * tagged traffic. 409332991Skib */ 410332991Skib#define IEEE8021Q_PCP_BK 1 /* Background (lowest) */ 411332991Skib#define IEEE8021Q_PCP_BE 0 /* Best effort (default) */ 412332991Skib#define IEEE8021Q_PCP_EE 2 /* Excellent effort */ 413332991Skib#define IEEE8021Q_PCP_CA 3 /* Critical applications */ 414332991Skib#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency */ 415332991Skib#define IEEE8021Q_PCP_VO 5 /* Video, < 10ms latency */ 416332991Skib#define IEEE8021Q_PCP_IC 6 /* Internetwork control */ 417332991Skib#define IEEE8021Q_PCP_NC 7 /* Network control (highest) */ 418332991Skib 41962143Sarchie#ifdef _KERNEL 42062143Sarchie 42162267Sarchiestruct ifnet; 42262267Sarchiestruct mbuf; 423191148Skmacystruct route; 424106929Ssamstruct sockaddr; 425164396Scsjpstruct bpf_if; 42662267Sarchie 427130015Snaddyextern uint32_t ether_crc32_le(const uint8_t *, size_t); 428130015Snaddyextern uint32_t ether_crc32_be(const uint8_t *, size_t); 429106929Ssamextern void ether_demux(struct ifnet *, struct mbuf *); 430106929Ssamextern void ether_ifattach(struct ifnet *, const u_int8_t *); 431106929Ssamextern void ether_ifdetach(struct ifnet *); 432170097Syarextern int ether_ioctl(struct ifnet *, u_long, caddr_t); 433249925Sglebiusextern int ether_output(struct ifnet *, struct mbuf *, 434249925Sglebius const struct sockaddr *, struct route *); 435106929Ssamextern int ether_output_frame(struct ifnet *, struct mbuf *); 436106929Ssamextern char *ether_sprintf(const u_int8_t *); 437164396Scsjpvoid ether_vlan_mtap(struct bpf_if *, struct mbuf *, 438164396Scsjp void *, u_int); 439172777Sthompsastruct mbuf *ether_vlanencap(struct mbuf *, uint16_t); 440332991Skibbool ether_8021q_frame(struct mbuf **mp, struct ifnet *ife, struct ifnet *p, 441332991Skib uint16_t vid, uint8_t pcp); 442346783Skevansvoid ether_gen_addr(struct ifnet *ifp, struct ether_addr *hwaddr); 44362143Sarchie 444321747Ssephe#ifdef _SYS_EVENTHANDLER_H_ 445321747Ssephe/* new ethernet interface attached event */ 446321747Ssephetypedef void (*ether_ifattach_event_handler_t)(void *, struct ifnet *); 447321747SsepheEVENTHANDLER_DECLARE(ether_ifattach_event, ether_ifattach_event_handler_t); 448321747Ssephe#endif 449321747Ssephe 45062143Sarchie#else /* _KERNEL */ 45162143Sarchie 45220681Swollman#include <sys/cdefs.h> 45320681Swollman 45420661Swpaul/* 45520661Swpaul * Ethernet address conversion/parsing routines. 45620661Swpaul */ 45720686Sbde__BEGIN_DECLS 45892725Salfredstruct ether_addr *ether_aton(const char *); 459169529Srwatsonstruct ether_addr *ether_aton_r(const char *, struct ether_addr *); 46092725Salfredint ether_hostton(const char *, struct ether_addr *); 46192725Salfredint ether_line(const char *, struct ether_addr *, char *); 46292725Salfredchar *ether_ntoa(const struct ether_addr *); 463169529Srwatsonchar *ether_ntoa_r(const struct ether_addr *, char *); 46492725Salfredint ether_ntohost(char *, const struct ether_addr *); 46520686Sbde__END_DECLS 46620686Sbde 46762143Sarchie#endif /* !_KERNEL */ 46862143Sarchie 46920686Sbde#endif /* !_NET_ETHERNET_H_ */ 470