ethernet.h revision 199767f8919635c4928607450d9e0abb932109ce
/*
* Fundamental constants relating to ethernet.
*
* $FreeBSD$
*
*/
#ifndef _NET_ETHERNET_H_
#define _NET_ETHERNET_H_
/*
* Some basic Ethernet constants.
*/
/*
* 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.
*/
/*
* Compute the maximum frame size based on ethertype (i.e. possible
* encapsulation) and whether or not an FCS is present.
*/
((hasfcs) ? ETHER_CRC_LEN : 0) + \
/*
* Ethernet-specific mbuf flags.
*/
/*
* 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) \
/*
* Structure of a 10Mb/s Ethernet header.
*/
struct ether_header {
} __packed;
/*
* Structure of a 48-bit Ethernet address.
*/
struct ether_addr {
} __packed;
/*
* 802.1q Virtual LAN header.
*/
struct ether_vlan_header {
} __packed;
#define EVL_VLID_MASK 0x0FFF
#define EVL_PRI_MASK 0xE000
/*
* NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields.
* However, there are some conflicts.
*/
/* 0x0101 .. 0x1FF Experimental */
/* 0x0400 Nixdorf */
/* 0x081C Symbolics Private */
/* 0x0888 - 0x088A Xyplex */
/* 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_NTRAILER 16
/* The following 3C0x types
are unregistered: */
#define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */
/* 0x6010 - 0x6014 3Com Corporation */
/* 0x7020 - 0x7029 LRT (England) (now Sintrom) */
/* 0x8042 DEC Unassigned */
/* 0x8046 - 0x8047 AT&T */
#define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */
/* 0x8065 - 0x8066 Univ. of Mass @ Amherst */
/* 0x806E - 0x8077 Landmark Graphics Corp. */
/* 0x807D - 0x807F Vitalink Communications */
/* 0x8081 - 0x8083 Counterpoint Computers */
/* 0x8088 - 0x808A Xyplex */
/* 0x809C - 0x809E Datability */
/* 0x80A3 Nixdorf */
/* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */
/* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */
/* 0x80C4 - 0x80C5 Banyan Systems */
/* 0x80C8 - 0x80CC Intergraph Corporation */
/* 0x80CD - 0x80CE Harris Corporation */
/* 0x80CF - 0x80D2 Taylor Instrument */
/* 0x80D3 - 0x80D4 Rosemount Corporation */
/* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */
/* 0x80E0 - 0x80E3 Allen-Bradley */
/* 0x80E4 - 0x80F0 Datability */
/* 0x80F4 - 0x80F5 Kinetics */
/* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */
/* 0x8107 - 0x8109 Symbolics Private */
/* 0x8132 - 0x8137 Bridge Communications */
/* 0x8139 - 0x813D KTI */
/* 0x814D - 0x814E BIIN */
/* 0x8151 - 0x8153 Qualcomm */
/* 0x815C - 0x815E Computer Protocol Pty Ltd */
/* 0x8164 - 0x8166 Charles River Data Systems */
/* 0x8182 - 0x8183 Reserved for HIPPI-6400 */
/* 0x8184 - 0x818C SGI prop. */
/* 0x819A - 0x81A3 RAD Network Devices */
/* 0x81B7 - 0x81B9 Xyplex */
/* 0x81CC - 0x81D5 Apricot Computers */
/* 0x81D6 - 0x81DD Artisoft Lantastic */
/* 0x81E6 - 0x81EF Polygon */
/* 0x81F0 - 0x81F2 Comsat Labs */
/* 0x81F3 - 0x81F5 SAIC */
/* 0x81F6 - 0x81F8 VG Analytical */
/* 0x8203 - 0x8205 QNX Software Systems Ltd. */
/* 0x8221 - 0x8222 Ascom Banking Systems */
/* 0x823E - 0x8240 Advanced Encryption Systems */
/* 0x8263 - 0x826A Charles River Data Systems */
/* 0x827F - 0x8282 Athena Programming */
/* 0x829A - 0x829B Inst Ind Info Tech */
/* 0x829C - 0x82AB Taurus Controls */
/* 0x82AC - 0x8693 Walker Richer & Quinn */
/* 0x8694 - 0x869D Idea Courier */
/* 0x869E - 0x86A1 Computer Network Tech */
/* 0x86A3 - 0x86AC Gateway Communications */
/* 0x86E0 - 0x86EF Landis & Gyr Powers */
/* 0x8700 - 0x8710 Motorola */
/* 0x873B - 0x873C Control Technology Inc. Proprietary */
#define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */
/* 0xFF00 - 0xFFOF ISC Bunker Ramo */
/*
* 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_NTRAILER 16
/*
* The ETHER_BPF_MTAP macro should be used by drivers which support hardware
* offload for VLAN tag processing. It will check the mbuf to see if it has
* M_VLANTAG set, and if it does, will pass the packet along to
* ether_vlan_mtap. This function will re-insert VLAN tags for the duration
* of the tap, so they show up properly for network analyzers.
*/
M_ASSERTVALID(_m); \
else \
} \
} while (0)
#ifdef _KERNEL
struct ifnet;
struct mbuf;
struct route;
struct sockaddr;
struct bpf_if;
extern void ether_ifdetach(struct ifnet *);
extern char *ether_sprintf(const u_int8_t *);
void *, u_int);
#else /* _KERNEL */
/*
* Ethernet address conversion/parsing routines.
*/
struct ether_addr *ether_aton(const char *);
int ether_hostton(const char *, struct ether_addr *);
int ether_line(const char *, struct ether_addr *, char *);
char *ether_ntoa(const struct ether_addr *);
char *ether_ntoa_r(const struct ether_addr *, char *);
int ether_ntohost(char *, const struct ether_addr *);
#endif /* !_KERNEL */
#endif /* !_NET_ETHERNET_H_ */