17c478bd9Sstevel@tonic-gate /* 2*69bb4bb4Scarlsonj * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * Copyright (c) 1982, 1986 Regents of the University of California. 87c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 97c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 107c478bd9Sstevel@tonic-gate */ 117c478bd9Sstevel@tonic-gate 127c478bd9Sstevel@tonic-gate #ifndef _NETINET_ARP_H 137c478bd9Sstevel@tonic-gate #define _NETINET_ARP_H 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 17*69bb4bb4Scarlsonj #include <sys/types.h> 18*69bb4bb4Scarlsonj #include <sys/ethernet.h> 19*69bb4bb4Scarlsonj #include <sys/socket.h> 20*69bb4bb4Scarlsonj 217c478bd9Sstevel@tonic-gate #ifdef __cplusplus 227c478bd9Sstevel@tonic-gate extern "C" { 237c478bd9Sstevel@tonic-gate #endif 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate * Address Resolution Protocol. 277c478bd9Sstevel@tonic-gate * 287c478bd9Sstevel@tonic-gate * See RFC 826 for protocol description. ARP packets are variable 297c478bd9Sstevel@tonic-gate * in size; the arphdr structure defines the fixed-length portion. 307c478bd9Sstevel@tonic-gate * Protocol type values are the same as those for 10 Mb/s Ethernet. 317c478bd9Sstevel@tonic-gate * It is followed by the variable-sized fields ar_sha, arp_spa, 327c478bd9Sstevel@tonic-gate * arp_tha and arp_tpa in that order, according to the lengths 337c478bd9Sstevel@tonic-gate * specified. Field names used correspond to RFC 826. 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate struct arphdr { 367c478bd9Sstevel@tonic-gate ushort_t ar_hrd; /* format of hardware address */ 377c478bd9Sstevel@tonic-gate #define ARPHRD_ETHER 1 /* ethernet hardware address */ 38*69bb4bb4Scarlsonj #define ARPHRD_IEEE802 6 /* IEEE 802 hardware address */ 397c478bd9Sstevel@tonic-gate #define ARPHRD_IB 32 /* IPoIB hardware address */ 407c478bd9Sstevel@tonic-gate ushort_t ar_pro; /* format of protocol address */ 417c478bd9Sstevel@tonic-gate uchar_t ar_hln; /* length of hardware address */ 427c478bd9Sstevel@tonic-gate uchar_t ar_pln; /* length of protocol address */ 437c478bd9Sstevel@tonic-gate ushort_t ar_op; /* one of: */ 447c478bd9Sstevel@tonic-gate #define ARPOP_REQUEST 1 /* request to resolve address */ 457c478bd9Sstevel@tonic-gate #define ARPOP_REPLY 2 /* response to previous request */ 467c478bd9Sstevel@tonic-gate #define REVARP_REQUEST 3 /* Reverse ARP request */ 477c478bd9Sstevel@tonic-gate #define REVARP_REPLY 4 /* Reverse ARP reply */ 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * The remaining fields are variable in size, 507c478bd9Sstevel@tonic-gate * according to the sizes above, and are defined 517c478bd9Sstevel@tonic-gate * as appropriate for specific hardware/protocol 527c478bd9Sstevel@tonic-gate * combinations. (E.g., see <netinet/if_ether.h>.) 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #ifdef notdef 557c478bd9Sstevel@tonic-gate uchar_t ar_sha[]; /* sender hardware address */ 567c478bd9Sstevel@tonic-gate uchar_t ar_spa[]; /* sender protocol address */ 577c478bd9Sstevel@tonic-gate uchar_t ar_tha[]; /* target hardware address */ 587c478bd9Sstevel@tonic-gate uchar_t ar_tpa[]; /* target protocol address */ 597c478bd9Sstevel@tonic-gate #endif /* notdef */ 607c478bd9Sstevel@tonic-gate }; 617c478bd9Sstevel@tonic-gate 62*69bb4bb4Scarlsonj /* Maximum hardware and protocol address length */ 63*69bb4bb4Scarlsonj #define ARP_MAX_ADDR_LEN 255 64*69bb4bb4Scarlsonj 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Ethernet Address Resolution Protocol. 677c478bd9Sstevel@tonic-gate * 687c478bd9Sstevel@tonic-gate * See RFC 826 for protocol description. Structure below is adapted 697c478bd9Sstevel@tonic-gate * to resolving internet addresses. Field names used correspond to 707c478bd9Sstevel@tonic-gate * RFC 826. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate struct ether_arp { 737c478bd9Sstevel@tonic-gate struct arphdr ea_hdr; /* fixed-size header */ 747c478bd9Sstevel@tonic-gate struct ether_addr arp_sha; /* sender hardware address */ 757c478bd9Sstevel@tonic-gate uchar_t arp_spa[4]; /* sender protocol address */ 767c478bd9Sstevel@tonic-gate struct ether_addr arp_tha; /* target hardware address */ 777c478bd9Sstevel@tonic-gate uchar_t arp_tpa[4]; /* target protocol address */ 787c478bd9Sstevel@tonic-gate }; 797c478bd9Sstevel@tonic-gate #define arp_hrd ea_hdr.ar_hrd 807c478bd9Sstevel@tonic-gate #define arp_pro ea_hdr.ar_pro 817c478bd9Sstevel@tonic-gate #define arp_hln ea_hdr.ar_hln 827c478bd9Sstevel@tonic-gate #define arp_pln ea_hdr.ar_pln 837c478bd9Sstevel@tonic-gate #define arp_op ea_hdr.ar_op 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * ARP ioctl request 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate struct arpreq { 897c478bd9Sstevel@tonic-gate struct sockaddr arp_pa; /* protocol address */ 907c478bd9Sstevel@tonic-gate struct sockaddr arp_ha; /* hardware address */ 917c478bd9Sstevel@tonic-gate int arp_flags; /* flags */ 927c478bd9Sstevel@tonic-gate }; 93*69bb4bb4Scarlsonj /* arp_flags field values */ 947c478bd9Sstevel@tonic-gate #define ATF_INUSE 0x01 /* entry in use */ 957c478bd9Sstevel@tonic-gate #define ATF_COM 0x02 /* completed entry (enaddr valid) */ 967c478bd9Sstevel@tonic-gate #define ATF_PERM 0x04 /* permanent entry */ 977c478bd9Sstevel@tonic-gate #define ATF_PUBL 0x08 /* publish entry (respond for other host) */ 987c478bd9Sstevel@tonic-gate #define ATF_USETRAILERS 0x10 /* has requested trailers */ 99*69bb4bb4Scarlsonj #define ATF_AUTHORITY 0x20 /* hardware address is authoritative */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1027c478bd9Sstevel@tonic-gate } 1037c478bd9Sstevel@tonic-gate #endif 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #endif /* _NETINET_ARP_H */ 106