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