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