1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright 2005 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. The Berkeley software License Agreement 9*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 10*7c478bd9Sstevel@tonic-gate */ 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate #ifndef _NET_IF_H 13*7c478bd9Sstevel@tonic-gate #define _NET_IF_H 14*7c478bd9Sstevel@tonic-gate 15*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 16*7c478bd9Sstevel@tonic-gate /* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86 */ 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 19*7c478bd9Sstevel@tonic-gate 20*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 21*7c478bd9Sstevel@tonic-gate #include <sys/socket.h> 22*7c478bd9Sstevel@tonic-gate #include <netinet/in.h> 23*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 24*7c478bd9Sstevel@tonic-gate #include <sys/types32.h> 25*7c478bd9Sstevel@tonic-gate #endif 26*7c478bd9Sstevel@tonic-gate #endif 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 29*7c478bd9Sstevel@tonic-gate extern "C" { 30*7c478bd9Sstevel@tonic-gate #endif 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Structures defining a network interface, providing a packet 34*7c478bd9Sstevel@tonic-gate * transport mechanism (ala level 0 of the PUP protocols). 35*7c478bd9Sstevel@tonic-gate * 36*7c478bd9Sstevel@tonic-gate * Each interface accepts output datagrams of a specified maximum 37*7c478bd9Sstevel@tonic-gate * length, and provides higher level routines with input datagrams 38*7c478bd9Sstevel@tonic-gate * received from its medium. 39*7c478bd9Sstevel@tonic-gate * 40*7c478bd9Sstevel@tonic-gate * Output occurs when the routine if_output is called, with three parameters: 41*7c478bd9Sstevel@tonic-gate * (*ifp->if_output)(ifp, m, dst) 42*7c478bd9Sstevel@tonic-gate * Here m is the mbuf chain to be sent and dst is the destination address. 43*7c478bd9Sstevel@tonic-gate * The output routine encapsulates the supplied datagram if necessary, 44*7c478bd9Sstevel@tonic-gate * and then transmits it on its medium. 45*7c478bd9Sstevel@tonic-gate * 46*7c478bd9Sstevel@tonic-gate * On input, each interface unwraps the data received by it, and either 47*7c478bd9Sstevel@tonic-gate * places it on the input queue of a internetwork datagram routine 48*7c478bd9Sstevel@tonic-gate * and posts the associated software interrupt, or passes the datagram to a raw 49*7c478bd9Sstevel@tonic-gate * packet input routine. 50*7c478bd9Sstevel@tonic-gate * 51*7c478bd9Sstevel@tonic-gate * Routines exist for locating interfaces by their addresses 52*7c478bd9Sstevel@tonic-gate * or for locating a interface on a certain network, as well as more general 53*7c478bd9Sstevel@tonic-gate * routing and gateway routines maintaining information used to locate 54*7c478bd9Sstevel@tonic-gate * interfaces. These routines live in the files if.c and route.c 55*7c478bd9Sstevel@tonic-gate */ 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* 60*7c478bd9Sstevel@tonic-gate * Structure defining a queue for a network interface. 61*7c478bd9Sstevel@tonic-gate * 62*7c478bd9Sstevel@tonic-gate * (Would like to call this struct ``if'', but C isn't PL/1.) 63*7c478bd9Sstevel@tonic-gate */ 64*7c478bd9Sstevel@tonic-gate struct ifnet { 65*7c478bd9Sstevel@tonic-gate char *if_name; /* name, e.g. ``en'' or ``lo'' */ 66*7c478bd9Sstevel@tonic-gate short if_unit; /* sub-unit for lower level driver */ 67*7c478bd9Sstevel@tonic-gate short if_mtu; /* maximum transmission unit */ 68*7c478bd9Sstevel@tonic-gate short if_flags; /* up/down, broadcast, etc. */ 69*7c478bd9Sstevel@tonic-gate short if_timer; /* time 'til if_watchdog called */ 70*7c478bd9Sstevel@tonic-gate ushort_t if_promisc; /* net # of requests for promisc mode */ 71*7c478bd9Sstevel@tonic-gate int if_metric; /* routing metric (external only) */ 72*7c478bd9Sstevel@tonic-gate struct ifaddr *if_addrlist; /* linked list of addresses per if */ 73*7c478bd9Sstevel@tonic-gate struct ifqueue { 74*7c478bd9Sstevel@tonic-gate struct mbuf *ifq_head; 75*7c478bd9Sstevel@tonic-gate struct mbuf *ifq_tail; 76*7c478bd9Sstevel@tonic-gate int ifq_len; 77*7c478bd9Sstevel@tonic-gate int ifq_maxlen; 78*7c478bd9Sstevel@tonic-gate int ifq_drops; 79*7c478bd9Sstevel@tonic-gate } if_snd; /* output queue */ 80*7c478bd9Sstevel@tonic-gate /* procedure handles */ 81*7c478bd9Sstevel@tonic-gate int (*if_init)(); /* init routine */ 82*7c478bd9Sstevel@tonic-gate int (*if_output)(); /* output routine */ 83*7c478bd9Sstevel@tonic-gate int (*if_ioctl)(); /* ioctl routine */ 84*7c478bd9Sstevel@tonic-gate int (*if_reset)(); /* bus reset routine */ 85*7c478bd9Sstevel@tonic-gate int (*if_watchdog)(); /* timer routine */ 86*7c478bd9Sstevel@tonic-gate /* generic interface statistics */ 87*7c478bd9Sstevel@tonic-gate int if_ipackets; /* packets received on interface */ 88*7c478bd9Sstevel@tonic-gate int if_ierrors; /* input errors on interface */ 89*7c478bd9Sstevel@tonic-gate int if_opackets; /* packets sent on interface */ 90*7c478bd9Sstevel@tonic-gate int if_oerrors; /* output errors on interface */ 91*7c478bd9Sstevel@tonic-gate int if_collisions; /* collisions on csma interfaces */ 92*7c478bd9Sstevel@tonic-gate /* end statistics */ 93*7c478bd9Sstevel@tonic-gate struct ifnet *if_next; 94*7c478bd9Sstevel@tonic-gate struct ifnet *if_upper; /* next layer up */ 95*7c478bd9Sstevel@tonic-gate struct ifnet *if_lower; /* next layer down */ 96*7c478bd9Sstevel@tonic-gate int (*if_input)(); /* input routine */ 97*7c478bd9Sstevel@tonic-gate int (*if_ctlin)(); /* control input routine */ 98*7c478bd9Sstevel@tonic-gate int (*if_ctlout)(); /* control output routine */ 99*7c478bd9Sstevel@tonic-gate struct map *if_memmap; /* rmap for interface specific memory */ 100*7c478bd9Sstevel@tonic-gate }; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* 103*7c478bd9Sstevel@tonic-gate * NOTE : These flags are not directly used within IP. 104*7c478bd9Sstevel@tonic-gate * ip_if.h has definitions derived from this which is used within IP. 105*7c478bd9Sstevel@tonic-gate * If you define a flag here, you need to define one in ip_if.h before 106*7c478bd9Sstevel@tonic-gate * using the new flag in IP. Don't use these flags directly in IP. 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate #define IFF_UP 0x0000000001 /* interface is up */ 109*7c478bd9Sstevel@tonic-gate #define IFF_BROADCAST 0x0000000002 /* broadcast address valid */ 110*7c478bd9Sstevel@tonic-gate #define IFF_DEBUG 0x0000000004 /* turn on debugging */ 111*7c478bd9Sstevel@tonic-gate #define IFF_LOOPBACK 0x0000000008 /* is a loopback net */ 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate #define IFF_POINTOPOINT 0x0000000010 /* interface is point-to-point link */ 114*7c478bd9Sstevel@tonic-gate #define IFF_NOTRAILERS 0x0000000020 /* avoid use of trailers */ 115*7c478bd9Sstevel@tonic-gate #define IFF_RUNNING 0x0000000040 /* resources allocated */ 116*7c478bd9Sstevel@tonic-gate #define IFF_NOARP 0x0000000080 /* no address resolution protocol */ 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate #define IFF_PROMISC 0x0000000100 /* receive all packets */ 119*7c478bd9Sstevel@tonic-gate #define IFF_ALLMULTI 0x0000000200 /* receive all multicast packets */ 120*7c478bd9Sstevel@tonic-gate #define IFF_INTELLIGENT 0x0000000400 /* protocol code on board */ 121*7c478bd9Sstevel@tonic-gate #define IFF_MULTICAST 0x0000000800 /* supports multicast */ 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate #define IFF_MULTI_BCAST 0x0000001000 /* multicast using broadcast address */ 124*7c478bd9Sstevel@tonic-gate #define IFF_UNNUMBERED 0x0000002000 /* non-unique address */ 125*7c478bd9Sstevel@tonic-gate #define IFF_DHCPRUNNING 0x0000004000 /* DHCP controls this interface */ 126*7c478bd9Sstevel@tonic-gate #define IFF_PRIVATE 0x0000008000 /* do not advertise */ 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate /* 129*7c478bd9Sstevel@tonic-gate * The following flags can't be grabbed or altered by SIOC[GS]IFFLAGS. 130*7c478bd9Sstevel@tonic-gate * Should use SIOC[GS]LIFFLAGS which has a larger flags field. 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate #define IFF_NOXMIT 0x0000010000 /* Do not transmit packets */ 133*7c478bd9Sstevel@tonic-gate #define IFF_NOLOCAL 0x0000020000 /* No address - just on-link subnet */ 134*7c478bd9Sstevel@tonic-gate #define IFF_DEPRECATED 0x0000040000 /* interface address deprecated */ 135*7c478bd9Sstevel@tonic-gate #define IFF_ADDRCONF 0x0000080000 /* address from stateless addrconf */ 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate #define IFF_ROUTER 0x0000100000 /* router on this interface */ 138*7c478bd9Sstevel@tonic-gate #define IFF_NONUD 0x0000200000 /* No NUD on this interface */ 139*7c478bd9Sstevel@tonic-gate #define IFF_ANYCAST 0x0000400000 /* Anycast address */ 140*7c478bd9Sstevel@tonic-gate #define IFF_NORTEXCH 0x0000800000 /* Do not exchange routing info */ 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #define IFF_IPV4 0x0001000000 /* IPv4 interface */ 143*7c478bd9Sstevel@tonic-gate #define IFF_IPV6 0x0002000000 /* IPv6 interface */ 144*7c478bd9Sstevel@tonic-gate #define IFF_MIPRUNNING 0x0004000000 /* Mobile IP controls this interface */ 145*7c478bd9Sstevel@tonic-gate #define IFF_NOFAILOVER 0x0008000000 /* Don't failover on NIC failure */ 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate #define IFF_FAILED 0x0010000000 /* NIC has failed */ 148*7c478bd9Sstevel@tonic-gate #define IFF_STANDBY 0x0020000000 /* Standby NIC to be used on failures */ 149*7c478bd9Sstevel@tonic-gate #define IFF_INACTIVE 0x0040000000 /* Standby active or not ? */ 150*7c478bd9Sstevel@tonic-gate #define IFF_OFFLINE 0x0080000000 /* NIC has been offlined */ 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate /* 153*7c478bd9Sstevel@tonic-gate * The IFF_XRESOLV flag is an evolving interface and is subject 154*7c478bd9Sstevel@tonic-gate * to change without notice. 155*7c478bd9Sstevel@tonic-gate */ 156*7c478bd9Sstevel@tonic-gate #define IFF_XRESOLV 0x0100000000 /* IPv6 external resolver */ 157*7c478bd9Sstevel@tonic-gate #define IFF_COS_ENABLED 0x0200000000 /* If interface supports CoS marking */ 158*7c478bd9Sstevel@tonic-gate #define IFF_PREFERRED 0x0400000000 /* Prefer as source address */ 159*7c478bd9Sstevel@tonic-gate #define IFF_TEMPORARY 0x0800000000 /* RFC3041 */ 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate #define IFF_FIXEDMTU 0x1000000000 /* MTU manually set with SIOCSLIFMTU */ 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate #define IFF_VIRTUAL 0x2000000000 /* Does not send or receive packets */ 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate /* 166*7c478bd9Sstevel@tonic-gate * The IFF_MULTICAST flag indicates that the network can support the 167*7c478bd9Sstevel@tonic-gate * transmission and reception of higher-level (e.g., IP) multicast packets. 168*7c478bd9Sstevel@tonic-gate * It is independent of hardware support for multicasting; for example, 169*7c478bd9Sstevel@tonic-gate * point-to-point links or pure broadcast networks may well support 170*7c478bd9Sstevel@tonic-gate * higher-level multicasts. 171*7c478bd9Sstevel@tonic-gate */ 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* flags set internally only: */ 174*7c478bd9Sstevel@tonic-gate #define IFF_CANTCHANGE \ 175*7c478bd9Sstevel@tonic-gate (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_PROMISC | \ 176*7c478bd9Sstevel@tonic-gate IFF_MULTICAST | IFF_MULTI_BCAST | IFF_UNNUMBERED | IFF_IPV4 | \ 177*7c478bd9Sstevel@tonic-gate IFF_IPV6 | IFF_INACTIVE | IFF_FIXEDMTU | IFF_VIRTUAL | \ 178*7c478bd9Sstevel@tonic-gate IFF_LOOPBACK | IFF_ALLMULTI) 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate /* 181*7c478bd9Sstevel@tonic-gate * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) 182*7c478bd9Sstevel@tonic-gate * input routines have queues of messages stored on ifqueue structures 183*7c478bd9Sstevel@tonic-gate * (defined above). Entries are added to and deleted from these structures 184*7c478bd9Sstevel@tonic-gate * by these macros, which should be called with ipl raised to splimp(). 185*7c478bd9Sstevel@tonic-gate */ 186*7c478bd9Sstevel@tonic-gate #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) 187*7c478bd9Sstevel@tonic-gate #define IF_DROP(ifq) ((ifq)->ifq_drops++) 188*7c478bd9Sstevel@tonic-gate #define IF_ENQUEUE(ifq, m) { \ 189*7c478bd9Sstevel@tonic-gate (m)->m_act = 0; \ 190*7c478bd9Sstevel@tonic-gate if ((ifq)->ifq_tail == 0) \ 191*7c478bd9Sstevel@tonic-gate (ifq)->ifq_head = m; \ 192*7c478bd9Sstevel@tonic-gate else \ 193*7c478bd9Sstevel@tonic-gate (ifq)->ifq_tail->m_act = m; \ 194*7c478bd9Sstevel@tonic-gate (ifq)->ifq_tail = m; \ 195*7c478bd9Sstevel@tonic-gate (ifq)->ifq_len++; \ 196*7c478bd9Sstevel@tonic-gate } 197*7c478bd9Sstevel@tonic-gate #define IF_PREPEND(ifq, m) { \ 198*7c478bd9Sstevel@tonic-gate (m)->m_act = (ifq)->ifq_head; \ 199*7c478bd9Sstevel@tonic-gate if ((ifq)->ifq_tail == 0) \ 200*7c478bd9Sstevel@tonic-gate (ifq)->ifq_tail = (m); \ 201*7c478bd9Sstevel@tonic-gate (ifq)->ifq_head = (m); \ 202*7c478bd9Sstevel@tonic-gate (ifq)->ifq_len++; \ 203*7c478bd9Sstevel@tonic-gate } 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate /* 206*7c478bd9Sstevel@tonic-gate * Packets destined for level-1 protocol input routines 207*7c478bd9Sstevel@tonic-gate * have a pointer to the receiving interface prepended to the data. 208*7c478bd9Sstevel@tonic-gate * IF_DEQUEUEIF extracts and returns this pointer when dequeuing the packet. 209*7c478bd9Sstevel@tonic-gate * IF_ADJ should be used otherwise to adjust for its presence. 210*7c478bd9Sstevel@tonic-gate */ 211*7c478bd9Sstevel@tonic-gate #define IF_ADJ(m) { \ 212*7c478bd9Sstevel@tonic-gate (m)->m_off += sizeof (struct ifnet *); \ 213*7c478bd9Sstevel@tonic-gate (m)->m_len -= sizeof (struct ifnet *); \ 214*7c478bd9Sstevel@tonic-gate if ((m)->m_len == 0) { \ 215*7c478bd9Sstevel@tonic-gate struct mbuf *n; \ 216*7c478bd9Sstevel@tonic-gate MFREE((m), n); \ 217*7c478bd9Sstevel@tonic-gate (m) = n; \ 218*7c478bd9Sstevel@tonic-gate } \ 219*7c478bd9Sstevel@tonic-gate } 220*7c478bd9Sstevel@tonic-gate #define IF_DEQUEUEIF(ifq, m, ifp) { \ 221*7c478bd9Sstevel@tonic-gate (m) = (ifq)->ifq_head; \ 222*7c478bd9Sstevel@tonic-gate if (m) { \ 223*7c478bd9Sstevel@tonic-gate if (((ifq)->ifq_head = (m)->m_act) == 0) \ 224*7c478bd9Sstevel@tonic-gate (ifq)->ifq_tail = 0; \ 225*7c478bd9Sstevel@tonic-gate (m)->m_act = 0; \ 226*7c478bd9Sstevel@tonic-gate (ifq)->ifq_len--; \ 227*7c478bd9Sstevel@tonic-gate (ifp) = *(mtod((m), struct ifnet **)); \ 228*7c478bd9Sstevel@tonic-gate IF_ADJ(m); \ 229*7c478bd9Sstevel@tonic-gate } \ 230*7c478bd9Sstevel@tonic-gate } 231*7c478bd9Sstevel@tonic-gate #define IF_DEQUEUE(ifq, m) { \ 232*7c478bd9Sstevel@tonic-gate (m) = (ifq)->ifq_head; \ 233*7c478bd9Sstevel@tonic-gate if (m) { \ 234*7c478bd9Sstevel@tonic-gate if (((ifq)->ifq_head = (m)->m_act) == 0) \ 235*7c478bd9Sstevel@tonic-gate (ifq)->ifq_tail = 0; \ 236*7c478bd9Sstevel@tonic-gate (m)->m_act = 0; \ 237*7c478bd9Sstevel@tonic-gate (ifq)->ifq_len--; \ 238*7c478bd9Sstevel@tonic-gate } \ 239*7c478bd9Sstevel@tonic-gate } 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate #define IFQ_MAXLEN 50 242*7c478bd9Sstevel@tonic-gate #define IFNET_SLOWHZ 1 /* granularity is 1 second */ 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate /* 245*7c478bd9Sstevel@tonic-gate * The ifaddr structure contains information about one address 246*7c478bd9Sstevel@tonic-gate * of an interface. They are maintained by the different address families, 247*7c478bd9Sstevel@tonic-gate * are allocated and attached when an address is set, and are linked 248*7c478bd9Sstevel@tonic-gate * together so all addresses for an interface can be located. 249*7c478bd9Sstevel@tonic-gate */ 250*7c478bd9Sstevel@tonic-gate struct ifaddr { 251*7c478bd9Sstevel@tonic-gate struct sockaddr ifa_addr; /* address of interface */ 252*7c478bd9Sstevel@tonic-gate union { 253*7c478bd9Sstevel@tonic-gate struct sockaddr ifu_broadaddr; 254*7c478bd9Sstevel@tonic-gate struct sockaddr ifu_dstaddr; 255*7c478bd9Sstevel@tonic-gate } ifa_ifu; 256*7c478bd9Sstevel@tonic-gate #define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ 257*7c478bd9Sstevel@tonic-gate #define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */ 258*7c478bd9Sstevel@tonic-gate struct ifnet *ifa_ifp; /* back-pointer to interface */ 259*7c478bd9Sstevel@tonic-gate struct ifaddr *ifa_next; /* next address for interface */ 260*7c478bd9Sstevel@tonic-gate }; 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate /* 263*7c478bd9Sstevel@tonic-gate * For SIOCLIF*ND ioctls. 264*7c478bd9Sstevel@tonic-gate * 265*7c478bd9Sstevel@tonic-gate * The lnr_state_* fields use the ND_* neighbor reachability states. 266*7c478bd9Sstevel@tonic-gate * The 3 different fields are for use with SIOCLIFSETND to cover the cases 267*7c478bd9Sstevel@tonic-gate * when 268*7c478bd9Sstevel@tonic-gate * A new entry is created 269*7c478bd9Sstevel@tonic-gate * The entry already exists and the link-layer address is the same 270*7c478bd9Sstevel@tonic-gate * The entry already exists and the link-layer address differs 271*7c478bd9Sstevel@tonic-gate * 272*7c478bd9Sstevel@tonic-gate * Use ND_UNCHANGED and ND_ISROUTER_UNCHANGED to not change any state. 273*7c478bd9Sstevel@tonic-gate */ 274*7c478bd9Sstevel@tonic-gate #define ND_MAX_HDW_LEN 64 275*7c478bd9Sstevel@tonic-gate typedef struct lif_nd_req { 276*7c478bd9Sstevel@tonic-gate struct sockaddr_storage lnr_addr; 277*7c478bd9Sstevel@tonic-gate uint8_t lnr_state_create; /* When creating */ 278*7c478bd9Sstevel@tonic-gate uint8_t lnr_state_same_lla; /* Update same addr */ 279*7c478bd9Sstevel@tonic-gate uint8_t lnr_state_diff_lla; /* Update w/ diff. */ 280*7c478bd9Sstevel@tonic-gate int lnr_hdw_len; 281*7c478bd9Sstevel@tonic-gate int lnr_flags; /* See below */ 282*7c478bd9Sstevel@tonic-gate /* padding because ia32 "long long"s are only 4-byte aligned. */ 283*7c478bd9Sstevel@tonic-gate int lnr_pad0; 284*7c478bd9Sstevel@tonic-gate char lnr_hdw_addr[ND_MAX_HDW_LEN]; 285*7c478bd9Sstevel@tonic-gate } lif_nd_req_t; 286*7c478bd9Sstevel@tonic-gate 287*7c478bd9Sstevel@tonic-gate /* 288*7c478bd9Sstevel@tonic-gate * Neighbor reachability states 289*7c478bd9Sstevel@tonic-gate * Used with SIOCLIF*ND ioctls. 290*7c478bd9Sstevel@tonic-gate */ 291*7c478bd9Sstevel@tonic-gate #define ND_UNCHANGED 0 /* For ioctls that don't modify state */ 292*7c478bd9Sstevel@tonic-gate #define ND_INCOMPLETE 1 /* addr resolution in progress */ 293*7c478bd9Sstevel@tonic-gate #define ND_REACHABLE 2 /* have recently been reachable */ 294*7c478bd9Sstevel@tonic-gate #define ND_STALE 3 /* may be unreachable, don't do anything */ 295*7c478bd9Sstevel@tonic-gate #define ND_DELAY 4 /* wait for upper layer hint */ 296*7c478bd9Sstevel@tonic-gate #define ND_PROBE 5 /* send probes */ 297*7c478bd9Sstevel@tonic-gate #define ND_UNREACHABLE 6 /* delete this route */ 298*7c478bd9Sstevel@tonic-gate 299*7c478bd9Sstevel@tonic-gate #define ND_STATE_VALID_MIN 0 300*7c478bd9Sstevel@tonic-gate #define ND_STATE_VALID_MAX 6 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate /* 303*7c478bd9Sstevel@tonic-gate * lnr_flags value of lif_nd_req. 304*7c478bd9Sstevel@tonic-gate * Used with SIOCLIF*ND ioctls. 305*7c478bd9Sstevel@tonic-gate */ 306*7c478bd9Sstevel@tonic-gate #define NDF_ISROUTER_ON 0x1 307*7c478bd9Sstevel@tonic-gate #define NDF_ISROUTER_OFF 0x2 308*7c478bd9Sstevel@tonic-gate #define NDF_ANYCAST_ON 0x4 309*7c478bd9Sstevel@tonic-gate #define NDF_ANYCAST_OFF 0x8 310*7c478bd9Sstevel@tonic-gate #define NDF_PROXY_ON 0x10 311*7c478bd9Sstevel@tonic-gate #define NDF_PROXY_OFF 0x20 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate /* For SIOC[GS]LIFLNKINFO */ 314*7c478bd9Sstevel@tonic-gate typedef struct lif_ifinfo_req { 315*7c478bd9Sstevel@tonic-gate uint8_t lir_maxhops; 316*7c478bd9Sstevel@tonic-gate uint32_t lir_reachtime; /* Reachable time in msec */ 317*7c478bd9Sstevel@tonic-gate uint32_t lir_reachretrans; /* Retransmission timer msec */ 318*7c478bd9Sstevel@tonic-gate uint32_t lir_maxmtu; 319*7c478bd9Sstevel@tonic-gate } lif_ifinfo_req_t; 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 322*7c478bd9Sstevel@tonic-gate 323*7c478bd9Sstevel@tonic-gate /* 324*7c478bd9Sstevel@tonic-gate * Maximum lengths of interface name and IPMP group name; these are the same 325*7c478bd9Sstevel@tonic-gate * for historical reasons. Note that the actual maximum length of a name is 326*7c478bd9Sstevel@tonic-gate * one byte less than these constants since the kernel always sets the final 327*7c478bd9Sstevel@tonic-gate * byte of lifr_name and lifr_groupname to NUL. 328*7c478bd9Sstevel@tonic-gate */ 329*7c478bd9Sstevel@tonic-gate #define _LIFNAMSIZ 32 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate #define LIFNAMSIZ _LIFNAMSIZ 334*7c478bd9Sstevel@tonic-gate #define LIFGRNAMSIZ LIFNAMSIZ 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate /* 337*7c478bd9Sstevel@tonic-gate * Interface request structure used for socket 338*7c478bd9Sstevel@tonic-gate * ioctl's. All interface ioctl's must have parameter 339*7c478bd9Sstevel@tonic-gate * definitions which begin with ifr_name. The 340*7c478bd9Sstevel@tonic-gate * remainder may be interface specific. 341*7c478bd9Sstevel@tonic-gate * Note: This data structure uses 64bit type uint64_t which is not 342*7c478bd9Sstevel@tonic-gate * a valid type for strict ANSI/ISO C compilation for ILP32. 343*7c478bd9Sstevel@tonic-gate * Applications with ioctls using this structure that insist on 344*7c478bd9Sstevel@tonic-gate * building with strict ANSI/ISO C (-Xc) will need to be LP64. 345*7c478bd9Sstevel@tonic-gate */ 346*7c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE) 347*7c478bd9Sstevel@tonic-gate struct lifreq { 348*7c478bd9Sstevel@tonic-gate char lifr_name[LIFNAMSIZ]; /* if name, e.g. "en0" */ 349*7c478bd9Sstevel@tonic-gate union { 350*7c478bd9Sstevel@tonic-gate int lifru_addrlen; /* for subnet/token etc */ 351*7c478bd9Sstevel@tonic-gate uint_t lifru_ppa; /* SIOCSLIFNAME */ 352*7c478bd9Sstevel@tonic-gate } lifr_lifru1; 353*7c478bd9Sstevel@tonic-gate #define lifr_addrlen lifr_lifru1.lifru_addrlen 354*7c478bd9Sstevel@tonic-gate #define lifr_ppa lifr_lifru1.lifru_ppa /* Driver's ppa */ 355*7c478bd9Sstevel@tonic-gate uint_t lifr_movetoindex; /* FAILOVER/FAILBACK ifindex */ 356*7c478bd9Sstevel@tonic-gate union { 357*7c478bd9Sstevel@tonic-gate struct sockaddr_storage lifru_addr; 358*7c478bd9Sstevel@tonic-gate struct sockaddr_storage lifru_dstaddr; 359*7c478bd9Sstevel@tonic-gate struct sockaddr_storage lifru_broadaddr; 360*7c478bd9Sstevel@tonic-gate struct sockaddr_storage lifru_token; /* With lifr_addrlen */ 361*7c478bd9Sstevel@tonic-gate struct sockaddr_storage lifru_subnet; /* With lifr_addrlen */ 362*7c478bd9Sstevel@tonic-gate int lifru_index; /* interface index */ 363*7c478bd9Sstevel@tonic-gate uint64_t lifru_flags; /* Flags for SIOC?LIFFLAGS */ 364*7c478bd9Sstevel@tonic-gate int lifru_metric; 365*7c478bd9Sstevel@tonic-gate uint_t lifru_mtu; 366*7c478bd9Sstevel@tonic-gate char lifru_data[1]; /* interface dependent data */ 367*7c478bd9Sstevel@tonic-gate char lifru_enaddr[6]; 368*7c478bd9Sstevel@tonic-gate int lif_muxid[2]; /* mux id's for arp and ip */ 369*7c478bd9Sstevel@tonic-gate struct lif_nd_req lifru_nd_req; 370*7c478bd9Sstevel@tonic-gate struct lif_ifinfo_req lifru_ifinfo_req; 371*7c478bd9Sstevel@tonic-gate char lifru_groupname[LIFGRNAMSIZ]; /* SIOC[GS]LIFGROUPNAME */ 372*7c478bd9Sstevel@tonic-gate uint_t lifru_delay; /* SIOC[GS]LIFNOTIFYDELAY */ 373*7c478bd9Sstevel@tonic-gate zoneid_t lifru_zoneid; /* SIOC[GS]LIFZONE */ 374*7c478bd9Sstevel@tonic-gate } lifr_lifru; 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate #define lifr_addr lifr_lifru.lifru_addr /* address */ 377*7c478bd9Sstevel@tonic-gate #define lifr_dstaddr lifr_lifru.lifru_dstaddr /* other end of p-to-p link */ 378*7c478bd9Sstevel@tonic-gate #define lifr_broadaddr lifr_lifru.lifru_broadaddr /* broadcast address */ 379*7c478bd9Sstevel@tonic-gate #define lifr_token lifr_lifru.lifru_token /* address token */ 380*7c478bd9Sstevel@tonic-gate #define lifr_subnet lifr_lifru.lifru_subnet /* subnet prefix */ 381*7c478bd9Sstevel@tonic-gate #define lifr_index lifr_lifru.lifru_index /* interface index */ 382*7c478bd9Sstevel@tonic-gate #define lifr_flags lifr_lifru.lifru_flags /* flags */ 383*7c478bd9Sstevel@tonic-gate #define lifr_metric lifr_lifru.lifru_metric /* metric */ 384*7c478bd9Sstevel@tonic-gate #define lifr_mtu lifr_lifru.lifru_mtu /* mtu */ 385*7c478bd9Sstevel@tonic-gate #define lifr_data lifr_lifru.lifru_data /* for use by interface */ 386*7c478bd9Sstevel@tonic-gate #define lifr_enaddr lifr_lifru.lifru_enaddr /* ethernet address */ 387*7c478bd9Sstevel@tonic-gate #define lifr_index lifr_lifru.lifru_index /* interface index */ 388*7c478bd9Sstevel@tonic-gate #define lifr_ip_muxid lifr_lifru.lif_muxid[0] 389*7c478bd9Sstevel@tonic-gate #define lifr_arp_muxid lifr_lifru.lif_muxid[1] 390*7c478bd9Sstevel@tonic-gate #define lifr_nd lifr_lifru.lifru_nd_req /* SIOCLIF*ND */ 391*7c478bd9Sstevel@tonic-gate #define lifr_ifinfo lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */ 392*7c478bd9Sstevel@tonic-gate #define lifr_groupname lifr_lifru.lifru_groupname 393*7c478bd9Sstevel@tonic-gate #define lifr_delay lifr_lifru.lifru_delay 394*7c478bd9Sstevel@tonic-gate #define lifr_zoneid lifr_lifru.lifru_zoneid 395*7c478bd9Sstevel@tonic-gate }; 396*7c478bd9Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */ 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate /* 399*7c478bd9Sstevel@tonic-gate * Argument structure for SIOCT* address testing ioctls. 400*7c478bd9Sstevel@tonic-gate */ 401*7c478bd9Sstevel@tonic-gate struct sioc_addrreq { 402*7c478bd9Sstevel@tonic-gate struct sockaddr_storage sa_addr; /* Address to test */ 403*7c478bd9Sstevel@tonic-gate int sa_res; /* Result - 0/1 */ 404*7c478bd9Sstevel@tonic-gate int sa_pad; 405*7c478bd9Sstevel@tonic-gate }; 406*7c478bd9Sstevel@tonic-gate 407*7c478bd9Sstevel@tonic-gate /* 408*7c478bd9Sstevel@tonic-gate * Argument structure used by mrouted to get src-grp pkt counts using 409*7c478bd9Sstevel@tonic-gate * SIOCGETLSGCNT. See <netinet/ip_mroute.h>. 410*7c478bd9Sstevel@tonic-gate */ 411*7c478bd9Sstevel@tonic-gate struct sioc_lsg_req { 412*7c478bd9Sstevel@tonic-gate struct sockaddr_storage slr_src; 413*7c478bd9Sstevel@tonic-gate struct sockaddr_storage slr_grp; 414*7c478bd9Sstevel@tonic-gate uint_t slr_pktcnt; 415*7c478bd9Sstevel@tonic-gate uint_t slr_bytecnt; 416*7c478bd9Sstevel@tonic-gate uint_t slr_wrong_if; 417*7c478bd9Sstevel@tonic-gate uint_t slr_pad; 418*7c478bd9Sstevel@tonic-gate }; 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate /* 421*7c478bd9Sstevel@tonic-gate * OBSOLETE: Replaced by struct lifreq. Supported for compatibility. 422*7c478bd9Sstevel@tonic-gate * 423*7c478bd9Sstevel@tonic-gate * Interface request structure used for socket 424*7c478bd9Sstevel@tonic-gate * ioctl's. All interface ioctl's must have parameter 425*7c478bd9Sstevel@tonic-gate * definitions which begin with ifr_name. The 426*7c478bd9Sstevel@tonic-gate * remainder may be interface specific. 427*7c478bd9Sstevel@tonic-gate */ 428*7c478bd9Sstevel@tonic-gate struct ifreq { 429*7c478bd9Sstevel@tonic-gate #define IFNAMSIZ 16 430*7c478bd9Sstevel@tonic-gate char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 431*7c478bd9Sstevel@tonic-gate union { 432*7c478bd9Sstevel@tonic-gate struct sockaddr ifru_addr; 433*7c478bd9Sstevel@tonic-gate struct sockaddr ifru_dstaddr; 434*7c478bd9Sstevel@tonic-gate char ifru_oname[IFNAMSIZ]; /* other if name */ 435*7c478bd9Sstevel@tonic-gate struct sockaddr ifru_broadaddr; 436*7c478bd9Sstevel@tonic-gate int ifru_index; /* interface index */ 437*7c478bd9Sstevel@tonic-gate short ifru_flags; 438*7c478bd9Sstevel@tonic-gate int ifru_metric; 439*7c478bd9Sstevel@tonic-gate char ifru_data[1]; /* interface dependent data */ 440*7c478bd9Sstevel@tonic-gate char ifru_enaddr[6]; 441*7c478bd9Sstevel@tonic-gate int if_muxid[2]; /* mux id's for arp and ip */ 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate /* Struct for flags/ppa */ 444*7c478bd9Sstevel@tonic-gate struct ifr_ppaflags { 445*7c478bd9Sstevel@tonic-gate short ifrup_flags; /* Space of ifru_flags. */ 446*7c478bd9Sstevel@tonic-gate short ifrup_filler; 447*7c478bd9Sstevel@tonic-gate uint_t ifrup_ppa; 448*7c478bd9Sstevel@tonic-gate } ifru_ppaflags; 449*7c478bd9Sstevel@tonic-gate 450*7c478bd9Sstevel@tonic-gate /* Struct for FDDI ioctl's */ 451*7c478bd9Sstevel@tonic-gate struct ifr_dnld_reqs { 452*7c478bd9Sstevel@tonic-gate uint32_t v_addr; 453*7c478bd9Sstevel@tonic-gate uint32_t m_addr; 454*7c478bd9Sstevel@tonic-gate uint32_t ex_addr; 455*7c478bd9Sstevel@tonic-gate uint32_t size; 456*7c478bd9Sstevel@tonic-gate } ifru_dnld_req; 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate /* Struct for FDDI stats */ 459*7c478bd9Sstevel@tonic-gate struct ifr_fddi_stats { 460*7c478bd9Sstevel@tonic-gate uint32_t stat_size; 461*7c478bd9Sstevel@tonic-gate uint32_t fddi_stats; 462*7c478bd9Sstevel@tonic-gate } ifru_fddi_stat; 463*7c478bd9Sstevel@tonic-gate 464*7c478bd9Sstevel@tonic-gate struct ifr_netmapents { 465*7c478bd9Sstevel@tonic-gate uint32_t map_ent_size, /* size of netmap structure */ 466*7c478bd9Sstevel@tonic-gate entry_number; /* index into netmap list */ 467*7c478bd9Sstevel@tonic-gate uint32_t fddi_map_ent; /* pointer to user structure */ 468*7c478bd9Sstevel@tonic-gate } ifru_netmapent; 469*7c478bd9Sstevel@tonic-gate 470*7c478bd9Sstevel@tonic-gate /* Field for generic ioctl for fddi */ 471*7c478bd9Sstevel@tonic-gate 472*7c478bd9Sstevel@tonic-gate struct ifr_fddi_gen_struct { 473*7c478bd9Sstevel@tonic-gate uint32_t ifru_fddi_gioctl; /* field for gen ioctl */ 474*7c478bd9Sstevel@tonic-gate uint32_t ifru_fddi_gaddr; /* Generic ptr to a field */ 475*7c478bd9Sstevel@tonic-gate } ifru_fddi_gstruct; 476*7c478bd9Sstevel@tonic-gate 477*7c478bd9Sstevel@tonic-gate } ifr_ifru; 478*7c478bd9Sstevel@tonic-gate 479*7c478bd9Sstevel@tonic-gate #define ifr_addr ifr_ifru.ifru_addr /* address */ 480*7c478bd9Sstevel@tonic-gate #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ 481*7c478bd9Sstevel@tonic-gate #define ifr_oname ifr_ifru.ifru_oname /* other if name */ 482*7c478bd9Sstevel@tonic-gate #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ 483*7c478bd9Sstevel@tonic-gate #define ifr_flags ifr_ifru.ifru_flags /* flags */ 484*7c478bd9Sstevel@tonic-gate #define ifr_metric ifr_ifru.ifru_metric /* metric */ 485*7c478bd9Sstevel@tonic-gate #define ifr_data ifr_ifru.ifru_data /* for use by interface */ 486*7c478bd9Sstevel@tonic-gate #define ifr_enaddr ifr_ifru.ifru_enaddr /* ethernet address */ 487*7c478bd9Sstevel@tonic-gate #define ifr_index ifr_ifru.ifru_index /* interface index */ 488*7c478bd9Sstevel@tonic-gate /* For setting ppa */ 489*7c478bd9Sstevel@tonic-gate #define ifr_ppa ifr_ifru.ifru_ppaflags.ifrup_ppa 490*7c478bd9Sstevel@tonic-gate 491*7c478bd9Sstevel@tonic-gate /* FDDI specific */ 492*7c478bd9Sstevel@tonic-gate #define ifr_dnld_req ifr_ifru.ifru_dnld_req 493*7c478bd9Sstevel@tonic-gate #define ifr_fddi_stat ifr_ifru.ifru_fddi_stat 494*7c478bd9Sstevel@tonic-gate #define ifr_fddi_netmap ifr_ifru.ifru_netmapent /* FDDI network map entries */ 495*7c478bd9Sstevel@tonic-gate #define ifr_fddi_gstruct ifr_ifru.ifru_fddi_gstruct 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate #define ifr_ip_muxid ifr_ifru.if_muxid[0] 498*7c478bd9Sstevel@tonic-gate #define ifr_arp_muxid ifr_ifru.if_muxid[1] 499*7c478bd9Sstevel@tonic-gate }; 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate /* Used by SIOCGLIFNUM. Uses same flags as in struct lifconf */ 502*7c478bd9Sstevel@tonic-gate struct lifnum { 503*7c478bd9Sstevel@tonic-gate sa_family_t lifn_family; 504*7c478bd9Sstevel@tonic-gate int lifn_flags; /* request specific interfaces */ 505*7c478bd9Sstevel@tonic-gate int lifn_count; /* Result */ 506*7c478bd9Sstevel@tonic-gate }; 507*7c478bd9Sstevel@tonic-gate 508*7c478bd9Sstevel@tonic-gate /* 509*7c478bd9Sstevel@tonic-gate * Structure used in SIOCGLIFCONF request. 510*7c478bd9Sstevel@tonic-gate * Used to retrieve interface configuration 511*7c478bd9Sstevel@tonic-gate * for machine (useful for programs which 512*7c478bd9Sstevel@tonic-gate * must know all networks accessible) for a given address family. 513*7c478bd9Sstevel@tonic-gate * Using AF_UNSPEC will retrieve all address families. 514*7c478bd9Sstevel@tonic-gate */ 515*7c478bd9Sstevel@tonic-gate struct lifconf { 516*7c478bd9Sstevel@tonic-gate sa_family_t lifc_family; 517*7c478bd9Sstevel@tonic-gate int lifc_flags; /* request specific interfaces */ 518*7c478bd9Sstevel@tonic-gate int lifc_len; /* size of associated buffer */ 519*7c478bd9Sstevel@tonic-gate union { 520*7c478bd9Sstevel@tonic-gate caddr_t lifcu_buf; 521*7c478bd9Sstevel@tonic-gate struct lifreq *lifcu_req; 522*7c478bd9Sstevel@tonic-gate } lifc_lifcu; 523*7c478bd9Sstevel@tonic-gate #define lifc_buf lifc_lifcu.lifcu_buf /* buffer address */ 524*7c478bd9Sstevel@tonic-gate #define lifc_req lifc_lifcu.lifcu_req /* array of structures returned */ 525*7c478bd9Sstevel@tonic-gate }; 526*7c478bd9Sstevel@tonic-gate 527*7c478bd9Sstevel@tonic-gate /* 528*7c478bd9Sstevel@tonic-gate * Structure used in SIOCGLIFSRCOF to get the interface 529*7c478bd9Sstevel@tonic-gate * configuration list for those interfaces that use an address 530*7c478bd9Sstevel@tonic-gate * hosted on the interface (set in lifs_ifindex), as the source 531*7c478bd9Sstevel@tonic-gate * address. 532*7c478bd9Sstevel@tonic-gate */ 533*7c478bd9Sstevel@tonic-gate struct lifsrcof { 534*7c478bd9Sstevel@tonic-gate uint_t lifs_ifindex; /* interface of interest */ 535*7c478bd9Sstevel@tonic-gate size_t lifs_maxlen; /* size of buffer: input */ 536*7c478bd9Sstevel@tonic-gate size_t lifs_len; /* size of buffer: output */ 537*7c478bd9Sstevel@tonic-gate union { 538*7c478bd9Sstevel@tonic-gate caddr_t lifsu_buf; 539*7c478bd9Sstevel@tonic-gate struct lifreq *lifsu_req; 540*7c478bd9Sstevel@tonic-gate } lifs_lifsu; 541*7c478bd9Sstevel@tonic-gate #define lifs_buf lifs_lifsu.lifsu_buf /* buffer address */ 542*7c478bd9Sstevel@tonic-gate #define lifs_req lifs_lifsu.lifsu_req /* array returned */ 543*7c478bd9Sstevel@tonic-gate }; 544*7c478bd9Sstevel@tonic-gate 545*7c478bd9Sstevel@tonic-gate /* Flags */ 546*7c478bd9Sstevel@tonic-gate #define LIFC_NOXMIT 0x01 /* Include IFF_NOXMIT interfaces */ 547*7c478bd9Sstevel@tonic-gate #define LIFC_EXTERNAL_SOURCE 0x02 /* Exclude the interfaces which can't */ 548*7c478bd9Sstevel@tonic-gate /* be used to communicate outside the */ 549*7c478bd9Sstevel@tonic-gate /* node (exclude interfaces which are */ 550*7c478bd9Sstevel@tonic-gate /* IFF_NOXMIT, IFF_NOLOCAL, */ 551*7c478bd9Sstevel@tonic-gate /* IFF_LOOPBACK, IFF_DEPRECATED, or */ 552*7c478bd9Sstevel@tonic-gate /* not IFF_UP). Has priority over */ 553*7c478bd9Sstevel@tonic-gate /* LIFC_NOXMIT. */ 554*7c478bd9Sstevel@tonic-gate #define LIFC_TEMPORARY 0x04 /* Include IFF_TEMPORARY interfaces */ 555*7c478bd9Sstevel@tonic-gate #define LIFC_ALLZONES 0x08 /* Include all zones */ 556*7c478bd9Sstevel@tonic-gate /* (must be issued from global zone) */ 557*7c478bd9Sstevel@tonic-gate 558*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 559*7c478bd9Sstevel@tonic-gate 560*7c478bd9Sstevel@tonic-gate struct lifconf32 { 561*7c478bd9Sstevel@tonic-gate sa_family_t lifc_family; 562*7c478bd9Sstevel@tonic-gate int lifc_flags; /* request specific interfaces */ 563*7c478bd9Sstevel@tonic-gate int32_t lifc_len; /* size of associated buffer */ 564*7c478bd9Sstevel@tonic-gate union { 565*7c478bd9Sstevel@tonic-gate caddr32_t lifcu_buf; 566*7c478bd9Sstevel@tonic-gate caddr32_t lifcu_req; 567*7c478bd9Sstevel@tonic-gate } lifc_lifcu; 568*7c478bd9Sstevel@tonic-gate }; 569*7c478bd9Sstevel@tonic-gate 570*7c478bd9Sstevel@tonic-gate struct lifsrcof32 { 571*7c478bd9Sstevel@tonic-gate uint_t lifs_ifindex; /* interface of interest */ 572*7c478bd9Sstevel@tonic-gate size32_t lifs_maxlen; /* size of buffer: input */ 573*7c478bd9Sstevel@tonic-gate size32_t lifs_len; /* size of buffer: output */ 574*7c478bd9Sstevel@tonic-gate union { 575*7c478bd9Sstevel@tonic-gate caddr32_t lifsu_buf; 576*7c478bd9Sstevel@tonic-gate caddr32_t lifsu_req; 577*7c478bd9Sstevel@tonic-gate } lifs_lifsu; 578*7c478bd9Sstevel@tonic-gate }; 579*7c478bd9Sstevel@tonic-gate 580*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 581*7c478bd9Sstevel@tonic-gate 582*7c478bd9Sstevel@tonic-gate /* 583*7c478bd9Sstevel@tonic-gate * OBSOLETE: Structure used in SIOCGIFCONF request. 584*7c478bd9Sstevel@tonic-gate * Used to retrieve interface configuration 585*7c478bd9Sstevel@tonic-gate * for machine (useful for programs which 586*7c478bd9Sstevel@tonic-gate * must know all networks accessible). 587*7c478bd9Sstevel@tonic-gate */ 588*7c478bd9Sstevel@tonic-gate struct ifconf { 589*7c478bd9Sstevel@tonic-gate int ifc_len; /* size of associated buffer */ 590*7c478bd9Sstevel@tonic-gate union { 591*7c478bd9Sstevel@tonic-gate caddr_t ifcu_buf; 592*7c478bd9Sstevel@tonic-gate struct ifreq *ifcu_req; 593*7c478bd9Sstevel@tonic-gate } ifc_ifcu; 594*7c478bd9Sstevel@tonic-gate #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ 595*7c478bd9Sstevel@tonic-gate #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ 596*7c478bd9Sstevel@tonic-gate }; 597*7c478bd9Sstevel@tonic-gate 598*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 599*7c478bd9Sstevel@tonic-gate 600*7c478bd9Sstevel@tonic-gate struct ifconf32 { 601*7c478bd9Sstevel@tonic-gate int32_t ifc_len; /* size of associated buffer */ 602*7c478bd9Sstevel@tonic-gate union { 603*7c478bd9Sstevel@tonic-gate caddr32_t ifcu_buf; 604*7c478bd9Sstevel@tonic-gate caddr32_t ifcu_req; 605*7c478bd9Sstevel@tonic-gate } ifc_ifcu; 606*7c478bd9Sstevel@tonic-gate }; 607*7c478bd9Sstevel@tonic-gate 608*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 609*7c478bd9Sstevel@tonic-gate 610*7c478bd9Sstevel@tonic-gate typedef struct if_data { 611*7c478bd9Sstevel@tonic-gate /* generic interface information */ 612*7c478bd9Sstevel@tonic-gate uchar_t ifi_type; /* ethernet, tokenring, etc */ 613*7c478bd9Sstevel@tonic-gate uchar_t ifi_addrlen; /* media address length */ 614*7c478bd9Sstevel@tonic-gate uchar_t ifi_hdrlen; /* media header length */ 615*7c478bd9Sstevel@tonic-gate uint_t ifi_mtu; /* maximum transmission unit */ 616*7c478bd9Sstevel@tonic-gate uint_t ifi_metric; /* routing metric (external only) */ 617*7c478bd9Sstevel@tonic-gate uint_t ifi_baudrate; /* linespeed */ 618*7c478bd9Sstevel@tonic-gate /* volatile statistics */ 619*7c478bd9Sstevel@tonic-gate uint_t ifi_ipackets; /* packets received on interface */ 620*7c478bd9Sstevel@tonic-gate uint_t ifi_ierrors; /* input errors on interface */ 621*7c478bd9Sstevel@tonic-gate uint_t ifi_opackets; /* packets sent on interface */ 622*7c478bd9Sstevel@tonic-gate uint_t ifi_oerrors; /* output errors on interface */ 623*7c478bd9Sstevel@tonic-gate uint_t ifi_collisions; /* collisions on csma interfaces */ 624*7c478bd9Sstevel@tonic-gate uint_t ifi_ibytes; /* total number of octets received */ 625*7c478bd9Sstevel@tonic-gate uint_t ifi_obytes; /* total number of octets sent */ 626*7c478bd9Sstevel@tonic-gate uint_t ifi_imcasts; /* packets received via multicast */ 627*7c478bd9Sstevel@tonic-gate uint_t ifi_omcasts; /* packets sent via multicast */ 628*7c478bd9Sstevel@tonic-gate uint_t ifi_iqdrops; /* dropped on input, this interface */ 629*7c478bd9Sstevel@tonic-gate uint_t ifi_noproto; /* destined for unsupported protocol */ 630*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 631*7c478bd9Sstevel@tonic-gate struct timeval32 ifi_lastchange; /* last updated */ 632*7c478bd9Sstevel@tonic-gate #else 633*7c478bd9Sstevel@tonic-gate struct timeval ifi_lastchange; /* last updated */ 634*7c478bd9Sstevel@tonic-gate #endif 635*7c478bd9Sstevel@tonic-gate } if_data_t; 636*7c478bd9Sstevel@tonic-gate 637*7c478bd9Sstevel@tonic-gate /* 638*7c478bd9Sstevel@tonic-gate * Message format for use in obtaining information about interfaces 639*7c478bd9Sstevel@tonic-gate * from the routing socket 640*7c478bd9Sstevel@tonic-gate */ 641*7c478bd9Sstevel@tonic-gate typedef struct if_msghdr { 642*7c478bd9Sstevel@tonic-gate ushort_t ifm_msglen; /* to skip over non-understood messages */ 643*7c478bd9Sstevel@tonic-gate uchar_t ifm_version; /* future binary compatibility */ 644*7c478bd9Sstevel@tonic-gate uchar_t ifm_type; /* message type */ 645*7c478bd9Sstevel@tonic-gate int ifm_addrs; /* like rtm_addrs */ 646*7c478bd9Sstevel@tonic-gate int ifm_flags; /* value of if_flags */ 647*7c478bd9Sstevel@tonic-gate ushort_t ifm_index; /* index for associated ifp */ 648*7c478bd9Sstevel@tonic-gate struct if_data ifm_data; /* statistics and other data about if */ 649*7c478bd9Sstevel@tonic-gate } if_msghdr_t; 650*7c478bd9Sstevel@tonic-gate 651*7c478bd9Sstevel@tonic-gate /* 652*7c478bd9Sstevel@tonic-gate * Message format for use in obtaining information about interface addresses 653*7c478bd9Sstevel@tonic-gate * from the routing socket 654*7c478bd9Sstevel@tonic-gate */ 655*7c478bd9Sstevel@tonic-gate typedef struct ifa_msghdr { 656*7c478bd9Sstevel@tonic-gate ushort_t ifam_msglen; /* to skip over non-understood messages */ 657*7c478bd9Sstevel@tonic-gate uchar_t ifam_version; /* future binary compatibility */ 658*7c478bd9Sstevel@tonic-gate uchar_t ifam_type; /* message type */ 659*7c478bd9Sstevel@tonic-gate int ifam_addrs; /* like rtm_addrs */ 660*7c478bd9Sstevel@tonic-gate int ifam_flags; /* route flags */ 661*7c478bd9Sstevel@tonic-gate ushort_t ifam_index; /* index for associated ifp */ 662*7c478bd9Sstevel@tonic-gate int ifam_metric; /* value of ipif_metric */ 663*7c478bd9Sstevel@tonic-gate } ifa_msghdr_t; 664*7c478bd9Sstevel@tonic-gate 665*7c478bd9Sstevel@tonic-gate /* currently tunnels only support IPv4 or IPv6 */ 666*7c478bd9Sstevel@tonic-gate enum ifta_proto { 667*7c478bd9Sstevel@tonic-gate IFTAP_INVALID, 668*7c478bd9Sstevel@tonic-gate IFTAP_IPV4, 669*7c478bd9Sstevel@tonic-gate IFTAP_IPV6 670*7c478bd9Sstevel@tonic-gate }; 671*7c478bd9Sstevel@tonic-gate 672*7c478bd9Sstevel@tonic-gate #define IFTUN_SECINFOLEN 8 /* In units of 32-bit words. */ 673*7c478bd9Sstevel@tonic-gate #define IFTUN_VERSION 1 /* Current version number. */ 674*7c478bd9Sstevel@tonic-gate 675*7c478bd9Sstevel@tonic-gate /* 676*7c478bd9Sstevel@tonic-gate * Used by tunneling module to get/set a tunnel parameters using 677*7c478bd9Sstevel@tonic-gate * SIOCTUN[SG]PARAM. 678*7c478bd9Sstevel@tonic-gate * 679*7c478bd9Sstevel@tonic-gate * There is a version number and an array of uint32_t at the end of this 680*7c478bd9Sstevel@tonic-gate * ioctl because in a perfect world, the ipsec_req_t would be inside 681*7c478bd9Sstevel@tonic-gate * tun_addreq. Since this file is independent of IP (and IPsec), I have to 682*7c478bd9Sstevel@tonic-gate * just leave room there, and have the appropriate handlers deal with the 683*7c478bd9Sstevel@tonic-gate * security information. 684*7c478bd9Sstevel@tonic-gate * 685*7c478bd9Sstevel@tonic-gate * In the future, the sockaddr types and the ta_vers could be used together 686*7c478bd9Sstevel@tonic-gate * to determine the nature of the security information that is at the end 687*7c478bd9Sstevel@tonic-gate * of this ioctl. 688*7c478bd9Sstevel@tonic-gate */ 689*7c478bd9Sstevel@tonic-gate struct iftun_req { 690*7c478bd9Sstevel@tonic-gate char ifta_lifr_name[LIFNAMSIZ]; /* if name */ 691*7c478bd9Sstevel@tonic-gate struct sockaddr_storage ifta_saddr; /* source address */ 692*7c478bd9Sstevel@tonic-gate struct sockaddr_storage ifta_daddr; /* destination address */ 693*7c478bd9Sstevel@tonic-gate uint_t ifta_flags; /* See below */ 694*7c478bd9Sstevel@tonic-gate /* IP version information is read only */ 695*7c478bd9Sstevel@tonic-gate enum ifta_proto ifta_upper; /* IP version above tunnel */ 696*7c478bd9Sstevel@tonic-gate enum ifta_proto ifta_lower; /* IP version below tunnel */ 697*7c478bd9Sstevel@tonic-gate uint_t ifta_vers; /* Version number */ 698*7c478bd9Sstevel@tonic-gate uint32_t ifta_secinfo[IFTUN_SECINFOLEN]; /* Security prefs. */ 699*7c478bd9Sstevel@tonic-gate int16_t ifta_encap_lim; /* Encapsulation limit */ 700*7c478bd9Sstevel@tonic-gate uint8_t ifta_hop_limit; /* Hop limit */ 701*7c478bd9Sstevel@tonic-gate uint8_t ifta_spare0; /* Pad to 64-bit boundary */ 702*7c478bd9Sstevel@tonic-gate uint32_t ifta_spare1; 703*7c478bd9Sstevel@tonic-gate }; 704*7c478bd9Sstevel@tonic-gate 705*7c478bd9Sstevel@tonic-gate /* ifta_flags are set to indicate which members are valid */ 706*7c478bd9Sstevel@tonic-gate #define IFTUN_SRC 0x01 707*7c478bd9Sstevel@tonic-gate #define IFTUN_DST 0x02 708*7c478bd9Sstevel@tonic-gate #define IFTUN_SECURITY 0x04 /* Pay attention to secinfo */ 709*7c478bd9Sstevel@tonic-gate #define IFTUN_ENCAP 0x08 /* Pay attention to encap */ 710*7c478bd9Sstevel@tonic-gate #define IFTUN_HOPLIMIT 0x10 /* Pay attention to hoplimit */ 711*7c478bd9Sstevel@tonic-gate 712*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */ 713*7c478bd9Sstevel@tonic-gate 714*7c478bd9Sstevel@tonic-gate /* 715*7c478bd9Sstevel@tonic-gate * The if_nameindex structure holds the interface index value about 716*7c478bd9Sstevel@tonic-gate * a single interface. An array of this structure is used to return 717*7c478bd9Sstevel@tonic-gate * all interfaces and indexes. 718*7c478bd9Sstevel@tonic-gate */ 719*7c478bd9Sstevel@tonic-gate struct if_nameindex { 720*7c478bd9Sstevel@tonic-gate unsigned if_index; /* positive interface index */ 721*7c478bd9Sstevel@tonic-gate char *if_name; /* if name, e.g. "en0" */ 722*7c478bd9Sstevel@tonic-gate }; 723*7c478bd9Sstevel@tonic-gate 724*7c478bd9Sstevel@tonic-gate /* Interface index identification API definitions */ 725*7c478bd9Sstevel@tonic-gate extern unsigned if_nametoindex(const char *); 726*7c478bd9Sstevel@tonic-gate extern char *if_indextoname(unsigned, char *); 727*7c478bd9Sstevel@tonic-gate extern struct if_nameindex *if_nameindex(void); 728*7c478bd9Sstevel@tonic-gate extern void if_freenameindex(struct if_nameindex *); 729*7c478bd9Sstevel@tonic-gate 730*7c478bd9Sstevel@tonic-gate #define IF_NAMESIZE _LIFNAMSIZ 731*7c478bd9Sstevel@tonic-gate 732*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 733*7c478bd9Sstevel@tonic-gate } 734*7c478bd9Sstevel@tonic-gate #endif 735*7c478bd9Sstevel@tonic-gate 736*7c478bd9Sstevel@tonic-gate #endif /* _NET_IF_H */ 737