1 /* 2 * Copyright 2006 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. The Berkeley software License Agreement 9 * specifies the terms and conditions for redistribution. 10 */ 11 12 #ifndef _NETINET_ARP_H 13 #define _NETINET_ARP_H 14 15 #pragma ident "%Z%%M% %I% %E% SMI" 16 17 #include <sys/types.h> 18 #include <sys/ethernet.h> 19 #include <sys/socket.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /* 26 * Address Resolution Protocol. 27 * 28 * See RFC 826 for protocol description. ARP packets are variable 29 * in size; the arphdr structure defines the fixed-length portion. 30 * Protocol type values are the same as those for 10 Mb/s Ethernet. 31 * It is followed by the variable-sized fields ar_sha, arp_spa, 32 * arp_tha and arp_tpa in that order, according to the lengths 33 * specified. Field names used correspond to RFC 826. 34 */ 35 struct arphdr { 36 ushort_t ar_hrd; /* format of hardware address */ 37 #define ARPHRD_ETHER 1 /* ethernet hardware address */ 38 #define ARPHRD_IEEE802 6 /* IEEE 802 hardware address */ 39 #define ARPHRD_IB 32 /* IPoIB hardware address */ 40 ushort_t ar_pro; /* format of protocol address */ 41 uchar_t ar_hln; /* length of hardware address */ 42 uchar_t ar_pln; /* length of protocol address */ 43 ushort_t ar_op; /* one of: */ 44 #define ARPOP_REQUEST 1 /* request to resolve address */ 45 #define ARPOP_REPLY 2 /* response to previous request */ 46 #define REVARP_REQUEST 3 /* Reverse ARP request */ 47 #define REVARP_REPLY 4 /* Reverse ARP reply */ 48 /* 49 * The remaining fields are variable in size, 50 * according to the sizes above, and are defined 51 * as appropriate for specific hardware/protocol 52 * combinations. (E.g., see <netinet/if_ether.h>.) 53 */ 54 #ifdef notdef 55 uchar_t ar_sha[]; /* sender hardware address */ 56 uchar_t ar_spa[]; /* sender protocol address */ 57 uchar_t ar_tha[]; /* target hardware address */ 58 uchar_t ar_tpa[]; /* target protocol address */ 59 #endif /* notdef */ 60 }; 61 62 /* Maximum hardware and protocol address length */ 63 #define ARP_MAX_ADDR_LEN 255 64 65 /* 66 * Ethernet Address Resolution Protocol. 67 * 68 * See RFC 826 for protocol description. Structure below is adapted 69 * to resolving internet addresses. Field names used correspond to 70 * RFC 826. 71 */ 72 struct ether_arp { 73 struct arphdr ea_hdr; /* fixed-size header */ 74 struct ether_addr arp_sha; /* sender hardware address */ 75 uchar_t arp_spa[4]; /* sender protocol address */ 76 struct ether_addr arp_tha; /* target hardware address */ 77 uchar_t arp_tpa[4]; /* target protocol address */ 78 }; 79 #define arp_hrd ea_hdr.ar_hrd 80 #define arp_pro ea_hdr.ar_pro 81 #define arp_hln ea_hdr.ar_hln 82 #define arp_pln ea_hdr.ar_pln 83 #define arp_op ea_hdr.ar_op 84 85 /* 86 * ARP ioctl request 87 */ 88 struct arpreq { 89 struct sockaddr arp_pa; /* protocol address */ 90 struct sockaddr arp_ha; /* hardware address */ 91 int arp_flags; /* flags */ 92 }; 93 /* arp_flags field values */ 94 #define ATF_INUSE 0x01 /* entry in use */ 95 #define ATF_COM 0x02 /* completed entry (enaddr valid) */ 96 #define ATF_PERM 0x04 /* permanent entry */ 97 #define ATF_PUBL 0x08 /* publish entry (respond for other host) */ 98 #define ATF_USETRAILERS 0x10 /* has requested trailers */ 99 #define ATF_AUTHORITY 0x20 /* hardware address is authoritative */ 100 101 #ifdef __cplusplus 102 } 103 #endif 104 105 #endif /* _NETINET_ARP_H */ 106