|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * Fundamental constants relating to ethernet. ! 24: * ! 25: */ ! 26: ! 27: #ifndef _NET_ETHERNET_H_ ! 28: #define _NET_ETHERNET_H_ ! 29: ! 30: /* ! 31: * The number of bytes in an ethernet (MAC) address. ! 32: */ ! 33: #define ETHER_ADDR_LEN 6 ! 34: ! 35: /* ! 36: * The number of bytes in the type field. ! 37: */ ! 38: #define ETHER_TYPE_LEN 2 ! 39: ! 40: /* ! 41: * The number of bytes in the trailing CRC field. ! 42: */ ! 43: #define ETHER_CRC_LEN 4 ! 44: ! 45: /* ! 46: * The length of the combined header. ! 47: */ ! 48: #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) ! 49: ! 50: /* ! 51: * The minimum packet length. ! 52: */ ! 53: #define ETHER_MIN_LEN 64 ! 54: ! 55: /* ! 56: * The maximum packet length. ! 57: */ ! 58: #define ETHER_MAX_LEN 1518 ! 59: ! 60: /* ! 61: * A macro to validate a length with ! 62: */ ! 63: #define ETHER_IS_VALID_LEN(foo) \ ! 64: ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) ! 65: ! 66: /* ! 67: * Structure of a 10Mb/s Ethernet header. ! 68: */ ! 69: struct ether_header { ! 70: u_char ether_dhost[ETHER_ADDR_LEN]; ! 71: u_char ether_shost[ETHER_ADDR_LEN]; ! 72: u_short ether_type; ! 73: }; ! 74: ! 75: /* ! 76: * Structure of a 48-bit Ethernet address. ! 77: */ ! 78: struct ether_addr { ! 79: u_char octet[ETHER_ADDR_LEN]; ! 80: }; ! 81: ! 82: #define ether_addr_octet octet ! 83: ! 84: #define ETHERTYPE_PUP 0x0200 /* PUP protocol */ ! 85: #define ETHERTYPE_IP 0x0800 /* IP protocol */ ! 86: #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ ! 87: #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */ ! 88: #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */ ! 89: #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ ! 90: /* XXX - add more useful types here */ ! 91: ! 92: /* ! 93: * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have ! 94: * (type-ETHERTYPE_TRAIL)*512 bytes of data followed ! 95: * by an ETHER type (as given above) and then the (variable-length) header. ! 96: */ ! 97: #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ ! 98: #define ETHERTYPE_NTRAILER 16 ! 99: ! 100: #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) ! 101: #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) ! 102: ! 103: #if KERNEL ! 104: struct ether_addr *ether_aton __P((char *)); ! 105: #endif ! 106: ! 107: #if !KERNEL ! 108: #include <sys/cdefs.h> ! 109: ! 110: /* ! 111: * Ethernet address conversion/parsing routines. ! 112: */ ! 113: __BEGIN_DECLS ! 114: ! 115: int ether_hostton __P((char *, struct ether_addr *)); ! 116: int ether_line __P((char *, struct ether_addr *, char *)); ! 117: char *ether_ntoa __P((struct ether_addr *)); ! 118: int ether_ntohost __P((char *, struct ether_addr *)); ! 119: __END_DECLS ! 120: #endif /* !KERNEL */ ! 121: ! 122: #endif /* !_NET_ETHERNET_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.