xref: /onnv-gate/usr/src/uts/common/netinet/if_ether.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*0Sstevel@tonic-gate  * Use is subject to license terms.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate /*
7*0Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
8*0Sstevel@tonic-gate  * All rights reserved.
9*0Sstevel@tonic-gate  *
10*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
11*0Sstevel@tonic-gate  * provided that this notice is preserved and that due credit is given
12*0Sstevel@tonic-gate  * to the University of California at Berkeley. The name of the University
13*0Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
14*0Sstevel@tonic-gate  * software without specific prior written permission. This software
15*0Sstevel@tonic-gate  * is provided ``as is'' without express or implied warranty.
16*0Sstevel@tonic-gate  */
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate #ifndef	_NETINET_IF_ETHER_H
19*0Sstevel@tonic-gate #define	_NETINET_IF_ETHER_H
20*0Sstevel@tonic-gate 
21*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
22*0Sstevel@tonic-gate /* if_ether.h 1.28 89/08/04 SMI; from UCB 7.2 12/7/87 */
23*0Sstevel@tonic-gate 
24*0Sstevel@tonic-gate #include <sys/ethernet.h>
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * The following include is for compatibility with SunOS 3.x and
28*0Sstevel@tonic-gate  * 4.3bsd.  Newly written programs should include it separately.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate #include <net/if_arp.h>
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate /*
37*0Sstevel@tonic-gate  * Ethernet Address Resolution Protocol.
38*0Sstevel@tonic-gate  *
39*0Sstevel@tonic-gate  * See RFC 826 for protocol description.  Structure below is adapted
40*0Sstevel@tonic-gate  * to resolving internet addresses.  Field names used correspond to
41*0Sstevel@tonic-gate  * RFC 826.
42*0Sstevel@tonic-gate  */
43*0Sstevel@tonic-gate struct	ether_arp {
44*0Sstevel@tonic-gate 	struct	arphdr ea_hdr;		/* fixed-size header */
45*0Sstevel@tonic-gate 	ether_addr_t arp_sha;		/* sender hardware address */
46*0Sstevel@tonic-gate 	uchar_t	arp_spa[4];		/* sender protocol address */
47*0Sstevel@tonic-gate 	ether_addr_t arp_tha;		/* target hardware address */
48*0Sstevel@tonic-gate 	uchar_t	arp_tpa[4];		/* target protocol address */
49*0Sstevel@tonic-gate };
50*0Sstevel@tonic-gate #define	arp_hrd	ea_hdr.ar_hrd
51*0Sstevel@tonic-gate #define	arp_pro	ea_hdr.ar_pro
52*0Sstevel@tonic-gate #define	arp_hln	ea_hdr.ar_hln
53*0Sstevel@tonic-gate #define	arp_pln	ea_hdr.ar_pln
54*0Sstevel@tonic-gate #define	arp_op	ea_hdr.ar_op
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate /*
57*0Sstevel@tonic-gate  *	multicast address structure
58*0Sstevel@tonic-gate  *
59*0Sstevel@tonic-gate  *	Keep a reference count for each multicast address so
60*0Sstevel@tonic-gate  *	addresses loaded into chip are unique.
61*0Sstevel@tonic-gate  */
62*0Sstevel@tonic-gate struct	mcaddr {
63*0Sstevel@tonic-gate 	struct	ether_addr	mc_enaddr;	/* multicast address */
64*0Sstevel@tonic-gate 	ushort_t mc_count;			/* reference count */
65*0Sstevel@tonic-gate };
66*0Sstevel@tonic-gate #define	MCADDRMAX	64		/* multicast addr table length */
67*0Sstevel@tonic-gate #define	MCCOUNTMAX	4096		/* multicast addr max reference count */
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate /*
70*0Sstevel@tonic-gate  * Structure shared between the ethernet driver modules and
71*0Sstevel@tonic-gate  * the address resolution code.  For example, each ec_softc or il_softc
72*0Sstevel@tonic-gate  * begins with this structure.
73*0Sstevel@tonic-gate  *
74*0Sstevel@tonic-gate  * The structure contains a pointer to an array of multicast addresses.
75*0Sstevel@tonic-gate  * This pointer is NULL until the first successful SIOCADDMULTI ioctl
76*0Sstevel@tonic-gate  * is issued for the interface.
77*0Sstevel@tonic-gate  */
78*0Sstevel@tonic-gate struct	arpcom {
79*0Sstevel@tonic-gate 	struct	ifnet ac_if;		/* network-visible interface */
80*0Sstevel@tonic-gate 	struct	ether_addr ac_enaddr;	/* ethernet hardware address */
81*0Sstevel@tonic-gate 	struct	in_addr ac_ipaddr;	/* copy of ip address- XXX */
82*0Sstevel@tonic-gate 	struct	mcaddr *ac_mcaddr;	/* table of multicast addrs */
83*0Sstevel@tonic-gate 	ushort_t ac_nmcaddr;		/* count of M/C addrs in use */
84*0Sstevel@tonic-gate 	struct  in_addr ac_lastip;	/* cache of last ARP lookup */
85*0Sstevel@tonic-gate 	struct	ether_addr ac_lastarp;	/* result of the last ARP */
86*0Sstevel@tonic-gate };
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /*
89*0Sstevel@tonic-gate  * Internet to ethernet address resolution table.
90*0Sstevel@tonic-gate  */
91*0Sstevel@tonic-gate struct	arptab {
92*0Sstevel@tonic-gate 	struct	in_addr at_iaddr;	/* internet address */
93*0Sstevel@tonic-gate 	union {
94*0Sstevel@tonic-gate 	    struct ether_addr atu_enaddr;	/* ethernet address */
95*0Sstevel@tonic-gate 	    long   atu_tvsec;			/* timestamp if incomplete */
96*0Sstevel@tonic-gate 	} 	at_union;
97*0Sstevel@tonic-gate 	uchar_t	at_timer;		/* minutes since last reference */
98*0Sstevel@tonic-gate 	uchar_t	at_flags;		/* flags */
99*0Sstevel@tonic-gate 	struct	mbuf *at_hold;		/* last packet until resolved/timeout */
100*0Sstevel@tonic-gate };
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate #define	at_enaddr	at_union.atu_enaddr
103*0Sstevel@tonic-gate #define	at_tvsec	at_union.atu_tvsec
104*0Sstevel@tonic-gate 
105*0Sstevel@tonic-gate /*
106*0Sstevel@tonic-gate  * Copy IP addresses from a to b - assumes that the two given
107*0Sstevel@tonic-gate  * pointers can be referenced as shorts.  On architectures
108*0Sstevel@tonic-gate  * where this is not the case, use bcopy instead.
109*0Sstevel@tonic-gate  */
110*0Sstevel@tonic-gate #if defined(__sparc) || defined(__i386) || defined(__amd64)
111*0Sstevel@tonic-gate #define	ip_copy(a, b) { ((short *)b)[0] = ((short *)a)[0]; \
112*0Sstevel@tonic-gate 	((short *)b)[1] = ((short *)a)[1]; }
113*0Sstevel@tonic-gate #else
114*0Sstevel@tonic-gate #define	ip_copy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 4))
115*0Sstevel@tonic-gate #endif
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate #ifdef	__cplusplus
118*0Sstevel@tonic-gate }
119*0Sstevel@tonic-gate #endif
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate #endif	/* _NETINET_IF_ETHER_H */
122