2 * Copyright (c) 1982, 1986 Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
13 #ifndef _netinet_if_ether_h
14 #define _netinet_if_ether_h
16 #pragma ident "%Z%%M% %I% %E% SMI"
19 * The following include is for compatibility with SunOS 3.x and
20 * 4.3bsd. Newly written programs should include it separately.
22 #include <net/if_arp.h>
25 * Ethernet address - 6 octets
28 u_char ether_addr_octet
[6];
32 * Structure of a 10Mb/s Ethernet header.
35 struct ether_addr ether_dhost
;
36 struct ether_addr ether_shost
;
40 #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
41 #define ETHERTYPE_IP 0x0800 /* IP protocol */
42 #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
43 #define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */
46 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
47 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
48 * by an ETHER type (as given above) and then the (variable-length) header.
50 #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
51 #define ETHERTYPE_NTRAILER 16
54 #define ETHERMIN (60-14)
57 * Ethernet Address Resolution Protocol.
59 * See RFC 826 for protocol description. Structure below is adapted
60 * to resolving internet addresses. Field names used correspond to
64 struct arphdr ea_hdr
; /* fixed-size header */
65 struct ether_addr arp_sha
; /* sender hardware address */
66 u_char arp_spa
[4]; /* sender protocol address */
67 struct ether_addr arp_tha
; /* target hardware address */
68 u_char arp_tpa
[4]; /* target protocol address */
70 #define arp_hrd ea_hdr.ar_hrd
71 #define arp_pro ea_hdr.ar_pro
72 #define arp_hln ea_hdr.ar_hln
73 #define arp_pln ea_hdr.ar_pln
74 #define arp_op ea_hdr.ar_op
77 * multicast address structure
79 * Keep a reference count for each multicast address so
80 * addresses loaded into chip are unique.
83 struct ether_addr mc_enaddr
; /* multicast address */
84 u_short mc_count
; /* reference count */
86 #define MCADDRMAX 64 /* multicast addr table length */
87 #define MCCOUNTMAX 4096 /* multicast addr max reference count */
90 * Structure shared between the ethernet driver modules and
91 * the address resolution code. For example, each ec_softc or il_softc
92 * begins with this structure.
94 * The structure contains a pointer to an array of multicast addresses.
95 * This pointer is NULL until the first successful SIOCADDMULTI ioctl
96 * is issued for the interface.
99 struct ifnet ac_if
; /* network-visible interface */
100 struct ether_addr ac_enaddr
; /* ethernet hardware address */
101 struct in_addr ac_ipaddr
; /* copy of ip address- XXX */
102 struct mcaddr
*ac_mcaddr
; /* table of multicast addrs */
103 u_short ac_nmcaddr
; /* count of M/C addrs in use */
104 struct in_addr ac_lastip
; /* cache of last ARP lookup */
105 struct ether_addr ac_lastarp
; /* result of the last ARP */
109 * Internet to ethernet address resolution table.
112 struct in_addr at_iaddr
; /* internet address */
114 struct ether_addr atu_enaddr
; /* ethernet address */
115 long atu_tvsec
; /* timestamp if incomplete */
117 u_char at_timer
; /* minutes since last reference */
118 u_char at_flags
; /* flags */
119 struct mbuf
*at_hold
; /* last packet until resolved/timeout */
122 # define at_enaddr at_union.atu_enaddr
123 # define at_tvsec at_union.atu_tvsec
126 * Compare two Ethernet addresses - assumes that the two given
127 * pointers can be referenced as shorts. On architectures
128 * where this is not the case, use bcmp instead. Note that like
129 * bcmp, we return zero if they are the SAME.
131 #define ether_cmp(a,b) ( ((short *)b)[2] != ((short *)a)[2] || \
132 ((short *)b)[1] != ((short *)a)[1] || ((short *)b)[0] != ((short *)a)[0] )
135 * Copy Ethernet addresses from a to b - assumes that the two given
136 * pointers can be referenced as shorts. On architectures
137 * where this is not the case, use bcopy instead.
139 #define ether_copy(a,b) { ((short *)b)[0]=((short *)a)[0]; \
140 ((short *)b)[1]=((short *)a)[1]; ((short *)b)[2]=((short *)a)[2]; }
143 * Copy IP addresses from a to b - assumes that the two given
144 * pointers can be referenced as shorts. On architectures
145 * where this is not the case, use bcopy instead.
147 #define ip_copy(a,b) { ((short *)b)[0]=((short *)a)[0]; \
148 ((short *)b)[1]=((short *)a)[1]; }
150 #endif /* !_netinet_if_ether_h */