10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (c) 1982, 1986 Regents of the University of California. 30Sstevel@tonic-gate * All rights reserved. 40Sstevel@tonic-gate * 50Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 60Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given 70Sstevel@tonic-gate * to the University of California at Berkeley. The name of the University 80Sstevel@tonic-gate * may not be used to endorse or promote products derived from this 90Sstevel@tonic-gate * software without specific prior written permission. This software 100Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty. 110Sstevel@tonic-gate */ 120Sstevel@tonic-gate 13*722Smuffin #ifndef _netinet_if_ether_h 14*722Smuffin #define _netinet_if_ether_h 150Sstevel@tonic-gate 16*722Smuffin #pragma ident "%Z%%M% %I% %E% SMI" 170Sstevel@tonic-gate 180Sstevel@tonic-gate /* 190Sstevel@tonic-gate * The following include is for compatibility with SunOS 3.x and 200Sstevel@tonic-gate * 4.3bsd. Newly written programs should include it separately. 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate #include <net/if_arp.h> 230Sstevel@tonic-gate 240Sstevel@tonic-gate /* 250Sstevel@tonic-gate * Ethernet address - 6 octets 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate struct ether_addr { 280Sstevel@tonic-gate u_char ether_addr_octet[6]; 290Sstevel@tonic-gate }; 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * Structure of a 10Mb/s Ethernet header. 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate struct ether_header { 350Sstevel@tonic-gate struct ether_addr ether_dhost; 360Sstevel@tonic-gate struct ether_addr ether_shost; 370Sstevel@tonic-gate u_short ether_type; 380Sstevel@tonic-gate }; 390Sstevel@tonic-gate 400Sstevel@tonic-gate #define ETHERTYPE_PUP 0x0200 /* PUP protocol */ 410Sstevel@tonic-gate #define ETHERTYPE_IP 0x0800 /* IP protocol */ 420Sstevel@tonic-gate #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ 430Sstevel@tonic-gate #define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have 470Sstevel@tonic-gate * (type-ETHERTYPE_TRAIL)*512 bytes of data followed 480Sstevel@tonic-gate * by an ETHER type (as given above) and then the (variable-length) header. 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ 510Sstevel@tonic-gate #define ETHERTYPE_NTRAILER 16 520Sstevel@tonic-gate 530Sstevel@tonic-gate #define ETHERMTU 1500 540Sstevel@tonic-gate #define ETHERMIN (60-14) 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * Ethernet Address Resolution Protocol. 580Sstevel@tonic-gate * 590Sstevel@tonic-gate * See RFC 826 for protocol description. Structure below is adapted 600Sstevel@tonic-gate * to resolving internet addresses. Field names used correspond to 610Sstevel@tonic-gate * RFC 826. 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate struct ether_arp { 640Sstevel@tonic-gate struct arphdr ea_hdr; /* fixed-size header */ 650Sstevel@tonic-gate struct ether_addr arp_sha; /* sender hardware address */ 660Sstevel@tonic-gate u_char arp_spa[4]; /* sender protocol address */ 670Sstevel@tonic-gate struct ether_addr arp_tha; /* target hardware address */ 680Sstevel@tonic-gate u_char arp_tpa[4]; /* target protocol address */ 690Sstevel@tonic-gate }; 700Sstevel@tonic-gate #define arp_hrd ea_hdr.ar_hrd 710Sstevel@tonic-gate #define arp_pro ea_hdr.ar_pro 720Sstevel@tonic-gate #define arp_hln ea_hdr.ar_hln 730Sstevel@tonic-gate #define arp_pln ea_hdr.ar_pln 740Sstevel@tonic-gate #define arp_op ea_hdr.ar_op 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * multicast address structure 780Sstevel@tonic-gate * 790Sstevel@tonic-gate * Keep a reference count for each multicast address so 800Sstevel@tonic-gate * addresses loaded into chip are unique. 810Sstevel@tonic-gate */ 820Sstevel@tonic-gate struct mcaddr { 830Sstevel@tonic-gate struct ether_addr mc_enaddr; /* multicast address */ 840Sstevel@tonic-gate u_short mc_count; /* reference count */ 850Sstevel@tonic-gate }; 860Sstevel@tonic-gate #define MCADDRMAX 64 /* multicast addr table length */ 870Sstevel@tonic-gate #define MCCOUNTMAX 4096 /* multicast addr max reference count */ 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 900Sstevel@tonic-gate * Structure shared between the ethernet driver modules and 910Sstevel@tonic-gate * the address resolution code. For example, each ec_softc or il_softc 920Sstevel@tonic-gate * begins with this structure. 930Sstevel@tonic-gate * 940Sstevel@tonic-gate * The structure contains a pointer to an array of multicast addresses. 950Sstevel@tonic-gate * This pointer is NULL until the first successful SIOCADDMULTI ioctl 960Sstevel@tonic-gate * is issued for the interface. 970Sstevel@tonic-gate */ 980Sstevel@tonic-gate struct arpcom { 990Sstevel@tonic-gate struct ifnet ac_if; /* network-visible interface */ 1000Sstevel@tonic-gate struct ether_addr ac_enaddr; /* ethernet hardware address */ 1010Sstevel@tonic-gate struct in_addr ac_ipaddr; /* copy of ip address- XXX */ 1020Sstevel@tonic-gate struct mcaddr *ac_mcaddr; /* table of multicast addrs */ 1030Sstevel@tonic-gate u_short ac_nmcaddr; /* count of M/C addrs in use */ 1040Sstevel@tonic-gate struct in_addr ac_lastip; /* cache of last ARP lookup */ 1050Sstevel@tonic-gate struct ether_addr ac_lastarp; /* result of the last ARP */ 1060Sstevel@tonic-gate }; 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* 1090Sstevel@tonic-gate * Internet to ethernet address resolution table. 1100Sstevel@tonic-gate */ 1110Sstevel@tonic-gate struct arptab { 1120Sstevel@tonic-gate struct in_addr at_iaddr; /* internet address */ 1130Sstevel@tonic-gate union { 1140Sstevel@tonic-gate struct ether_addr atu_enaddr; /* ethernet address */ 1150Sstevel@tonic-gate long atu_tvsec; /* timestamp if incomplete */ 1160Sstevel@tonic-gate } at_union; 1170Sstevel@tonic-gate u_char at_timer; /* minutes since last reference */ 1180Sstevel@tonic-gate u_char at_flags; /* flags */ 1190Sstevel@tonic-gate struct mbuf *at_hold; /* last packet until resolved/timeout */ 1200Sstevel@tonic-gate }; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate # define at_enaddr at_union.atu_enaddr 1230Sstevel@tonic-gate # define at_tvsec at_union.atu_tvsec 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate /* 1260Sstevel@tonic-gate * Compare two Ethernet addresses - assumes that the two given 1270Sstevel@tonic-gate * pointers can be referenced as shorts. On architectures 1280Sstevel@tonic-gate * where this is not the case, use bcmp instead. Note that like 1290Sstevel@tonic-gate * bcmp, we return zero if they are the SAME. 1300Sstevel@tonic-gate */ 1310Sstevel@tonic-gate #define ether_cmp(a,b) ( ((short *)b)[2] != ((short *)a)[2] || \ 1320Sstevel@tonic-gate ((short *)b)[1] != ((short *)a)[1] || ((short *)b)[0] != ((short *)a)[0] ) 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate /* 1350Sstevel@tonic-gate * Copy Ethernet addresses from a to b - assumes that the two given 1360Sstevel@tonic-gate * pointers can be referenced as shorts. On architectures 1370Sstevel@tonic-gate * where this is not the case, use bcopy instead. 1380Sstevel@tonic-gate */ 1390Sstevel@tonic-gate #define ether_copy(a,b) { ((short *)b)[0]=((short *)a)[0]; \ 1400Sstevel@tonic-gate ((short *)b)[1]=((short *)a)[1]; ((short *)b)[2]=((short *)a)[2]; } 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate /* 1430Sstevel@tonic-gate * Copy IP addresses from a to b - assumes that the two given 1440Sstevel@tonic-gate * pointers can be referenced as shorts. On architectures 1450Sstevel@tonic-gate * where this is not the case, use bcopy instead. 1460Sstevel@tonic-gate */ 1470Sstevel@tonic-gate #define ip_copy(a,b) { ((short *)b)[0]=((short *)a)[0]; \ 1480Sstevel@tonic-gate ((short *)b)[1]=((short *)a)[1]; } 1490Sstevel@tonic-gate 150*722Smuffin #endif /* !_netinet_if_ether_h */ 151