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