xref: /illumos-gate/usr/src/uts/common/net/if.h (revision 940fff4b)
17c478bd9Sstevel@tonic-gate /*
2550b6e40SSowmini Varadhan  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
37c478bd9Sstevel@tonic-gate  */
47c478bd9Sstevel@tonic-gate 
57c478bd9Sstevel@tonic-gate /*
67c478bd9Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
77c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
87c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
97c478bd9Sstevel@tonic-gate  */
107c478bd9Sstevel@tonic-gate 
117c478bd9Sstevel@tonic-gate #ifndef	_NET_IF_H
127c478bd9Sstevel@tonic-gate #define	_NET_IF_H
137c478bd9Sstevel@tonic-gate 
147c478bd9Sstevel@tonic-gate /* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86		*/
157c478bd9Sstevel@tonic-gate 
167c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
197c478bd9Sstevel@tonic-gate #include <sys/socket.h>
207c478bd9Sstevel@tonic-gate #include <netinet/in.h>
217c478bd9Sstevel@tonic-gate #if defined(_LP64)
227c478bd9Sstevel@tonic-gate #include <sys/types32.h>
237c478bd9Sstevel@tonic-gate #endif
247c478bd9Sstevel@tonic-gate #endif
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
277c478bd9Sstevel@tonic-gate extern "C" {
287c478bd9Sstevel@tonic-gate #endif
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * Structures defining a network interface, providing a packet
327c478bd9Sstevel@tonic-gate  * transport mechanism (ala level 0 of the PUP protocols).
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * Each interface accepts output datagrams of a specified maximum
357c478bd9Sstevel@tonic-gate  * length, and provides higher level routines with input datagrams
367c478bd9Sstevel@tonic-gate  * received from its medium.
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * Output occurs when the routine if_output is called, with three parameters:
397c478bd9Sstevel@tonic-gate  *	(*ifp->if_output)(ifp, m, dst)
407c478bd9Sstevel@tonic-gate  * Here m is the mbuf chain to be sent and dst is the destination address.
417c478bd9Sstevel@tonic-gate  * The output routine encapsulates the supplied datagram if necessary,
427c478bd9Sstevel@tonic-gate  * and then transmits it on its medium.
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * On input, each interface unwraps the data received by it, and either
457c478bd9Sstevel@tonic-gate  * places it on the input queue of a internetwork datagram routine
467c478bd9Sstevel@tonic-gate  * and posts the associated software interrupt, or passes the datagram to a raw
477c478bd9Sstevel@tonic-gate  * packet input routine.
487c478bd9Sstevel@tonic-gate  *
497c478bd9Sstevel@tonic-gate  * Routines exist for locating interfaces by their addresses
507c478bd9Sstevel@tonic-gate  * or for locating a interface on a certain network, as well as more general
517c478bd9Sstevel@tonic-gate  * routing and gateway routines maintaining information used to locate
527c478bd9Sstevel@tonic-gate  * interfaces.  These routines live in the files if.c and route.c
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * Structure defining a queue for a network interface.
597c478bd9Sstevel@tonic-gate  *
607c478bd9Sstevel@tonic-gate  * (Would like to call this struct ``if'', but C isn't PL/1.)
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate struct ifnet {
637c478bd9Sstevel@tonic-gate 	char	*if_name;		/* name, e.g. ``en'' or ``lo'' */
647c478bd9Sstevel@tonic-gate 	short	if_unit;		/* sub-unit for lower level driver */
657c478bd9Sstevel@tonic-gate 	short	if_mtu;			/* maximum transmission unit */
667c478bd9Sstevel@tonic-gate 	short	if_flags;		/* up/down, broadcast, etc. */
677c478bd9Sstevel@tonic-gate 	short	if_timer;		/* time 'til if_watchdog called */
687c478bd9Sstevel@tonic-gate 	ushort_t if_promisc;		/* net # of requests for promisc mode */
697c478bd9Sstevel@tonic-gate 	int	if_metric;		/* routing metric (external only) */
707c478bd9Sstevel@tonic-gate 	struct	ifaddr *if_addrlist;	/* linked list of addresses per if */
717c478bd9Sstevel@tonic-gate 	struct	ifqueue {
727c478bd9Sstevel@tonic-gate 		struct	mbuf *ifq_head;
737c478bd9Sstevel@tonic-gate 		struct	mbuf *ifq_tail;
747c478bd9Sstevel@tonic-gate 		int	ifq_len;
757c478bd9Sstevel@tonic-gate 		int	ifq_maxlen;
767c478bd9Sstevel@tonic-gate 		int	ifq_drops;
777c478bd9Sstevel@tonic-gate 	} if_snd;			/* output queue */
787c478bd9Sstevel@tonic-gate /* procedure handles */
797c478bd9Sstevel@tonic-gate 	int	(*if_init)();		/* init routine */
807c478bd9Sstevel@tonic-gate 	int	(*if_output)();		/* output routine */
817c478bd9Sstevel@tonic-gate 	int	(*if_ioctl)();		/* ioctl routine */
827c478bd9Sstevel@tonic-gate 	int	(*if_reset)();		/* bus reset routine */
837c478bd9Sstevel@tonic-gate 	int	(*if_watchdog)();	/* timer routine */
847c478bd9Sstevel@tonic-gate /* generic interface statistics */
857c478bd9Sstevel@tonic-gate 	int	if_ipackets;		/* packets received on interface */
867c478bd9Sstevel@tonic-gate 	int	if_ierrors;		/* input errors on interface */
877c478bd9Sstevel@tonic-gate 	int	if_opackets;		/* packets sent on interface */
887c478bd9Sstevel@tonic-gate 	int	if_oerrors;		/* output errors on interface */
897c478bd9Sstevel@tonic-gate 	int	if_collisions;		/* collisions on csma interfaces */
907c478bd9Sstevel@tonic-gate /* end statistics */
917c478bd9Sstevel@tonic-gate 	struct	ifnet *if_next;
927c478bd9Sstevel@tonic-gate 	struct	ifnet *if_upper;	/* next layer up */
937c478bd9Sstevel@tonic-gate 	struct	ifnet *if_lower;	/* next layer down */
947c478bd9Sstevel@tonic-gate 	int	(*if_input)();		/* input routine */
957c478bd9Sstevel@tonic-gate 	int	(*if_ctlin)();		/* control input routine */
967c478bd9Sstevel@tonic-gate 	int	(*if_ctlout)();		/* control output routine */
977c478bd9Sstevel@tonic-gate 	struct map *if_memmap;		/* rmap for interface specific memory */
987c478bd9Sstevel@tonic-gate };
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * NOTE : These flags are not directly used within IP.
1027c478bd9Sstevel@tonic-gate  * ip_if.h has definitions derived from this which is used within IP.
1037c478bd9Sstevel@tonic-gate  * If you define a flag here, you need to define one in ip_if.h before
1047c478bd9Sstevel@tonic-gate  * using the new flag in IP. Don't use these flags directly in IP.
1057c478bd9Sstevel@tonic-gate  */
106e11c3f44Smeem #define	IFF_UP		0x0000000001	/* address is up */
1077c478bd9Sstevel@tonic-gate #define	IFF_BROADCAST	0x0000000002	/* broadcast address valid */
1087c478bd9Sstevel@tonic-gate #define	IFF_DEBUG	0x0000000004	/* turn on debugging */
1097c478bd9Sstevel@tonic-gate #define	IFF_LOOPBACK	0x0000000008	/* is a loopback net */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	IFF_POINTOPOINT	0x0000000010	/* interface is point-to-point link */
1127c478bd9Sstevel@tonic-gate #define	IFF_NOTRAILERS	0x0000000020	/* avoid use of trailers */
1137c478bd9Sstevel@tonic-gate #define	IFF_RUNNING	0x0000000040	/* resources allocated */
1147c478bd9Sstevel@tonic-gate #define	IFF_NOARP	0x0000000080	/* no address resolution protocol */
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	IFF_PROMISC	0x0000000100	/* receive all packets */
1177c478bd9Sstevel@tonic-gate #define	IFF_ALLMULTI	0x0000000200	/* receive all multicast packets */
1187c478bd9Sstevel@tonic-gate #define	IFF_INTELLIGENT	0x0000000400	/* protocol code on board */
1198df01f76Smeem /*
1208df01f76Smeem  * The IFF_MULTICAST flag indicates that the network can support the
1218df01f76Smeem  * transmission and reception of higher-level (e.g., IP) multicast packets.
1228df01f76Smeem  * It is independent of hardware support for multicasting; for example,
1238df01f76Smeem  * point-to-point links or pure broadcast networks may well support
1248df01f76Smeem  * higher-level multicasts.
1258df01f76Smeem  */
1267c478bd9Sstevel@tonic-gate #define	IFF_MULTICAST	0x0000000800	/* supports multicast */
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #define	IFF_MULTI_BCAST	0x0000001000	/* multicast using broadcast address */
1297c478bd9Sstevel@tonic-gate #define	IFF_UNNUMBERED	0x0000002000	/* non-unique address */
1307c478bd9Sstevel@tonic-gate #define	IFF_DHCPRUNNING	0x0000004000	/* DHCP controls this interface */
1317c478bd9Sstevel@tonic-gate #define	IFF_PRIVATE	0x0000008000	/* do not advertise */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * The following flags can't be grabbed or altered by SIOC[GS]IFFLAGS.
1357c478bd9Sstevel@tonic-gate  * Should use SIOC[GS]LIFFLAGS which has a larger flags field.
1367c478bd9Sstevel@tonic-gate  */
1377c478bd9Sstevel@tonic-gate #define	IFF_NOXMIT	0x0000010000	/* Do not transmit packets */
1387c478bd9Sstevel@tonic-gate #define	IFF_NOLOCAL	0x0000020000	/* No address - just on-link subnet */
139e11c3f44Smeem #define	IFF_DEPRECATED	0x0000040000	/* Address is deprecated */
1407c478bd9Sstevel@tonic-gate #define	IFF_ADDRCONF	0x0000080000	/* address from stateless addrconf */
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #define	IFF_ROUTER	0x0000100000	/* router on this interface */
1437c478bd9Sstevel@tonic-gate #define	IFF_NONUD	0x0000200000	/* No NUD on this interface */
1447c478bd9Sstevel@tonic-gate #define	IFF_ANYCAST	0x0000400000	/* Anycast address */
1457c478bd9Sstevel@tonic-gate #define	IFF_NORTEXCH	0x0000800000	/* Do not exchange routing info */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #define	IFF_IPV4	0x0001000000	/* IPv4 interface */
1487c478bd9Sstevel@tonic-gate #define	IFF_IPV6	0x0002000000	/* IPv6 interface */
1491cb875aeSCathy Zhou #define	IFF_NOACCEPT	0x0004000000	/* no-accept mode VRRP ill */
150e11c3f44Smeem #define	IFF_NOFAILOVER	0x0008000000	/* in.mpathd(1M) test address */
1517c478bd9Sstevel@tonic-gate 
152e11c3f44Smeem #define	IFF_FAILED	0x0010000000	/* Interface has failed */
153e11c3f44Smeem #define	IFF_STANDBY	0x0020000000	/* Interface is a hot-spare */
154e11c3f44Smeem #define	IFF_INACTIVE	0x0040000000	/* Functioning but not used for data */
155e11c3f44Smeem #define	IFF_OFFLINE	0x0080000000	/* Interface is offline */
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate  * The IFF_XRESOLV flag is an evolving interface and is subject
1597c478bd9Sstevel@tonic-gate  * to change without notice.
1607c478bd9Sstevel@tonic-gate  */
161aee32e3dScarlsonj #define	IFF_XRESOLV	0x0100000000ll	/* IPv6 external resolver */
162aee32e3dScarlsonj #define	IFF_COS_ENABLED	0x0200000000ll	/* If interface supports CoS marking */
163aee32e3dScarlsonj #define	IFF_PREFERRED	0x0400000000ll	/* Prefer as source address */
164aee32e3dScarlsonj #define	IFF_TEMPORARY	0x0800000000ll	/* RFC3041 */
1657c478bd9Sstevel@tonic-gate 
166aee32e3dScarlsonj #define	IFF_FIXEDMTU	0x1000000000ll	/* MTU manually set with SIOCSLIFMTU */
167aee32e3dScarlsonj #define	IFF_VIRTUAL	0x2000000000ll	/* Does not send or receive packets */
16869bb4bb4Scarlsonj #define	IFF_DUPLICATE	0x4000000000ll	/* Local address already in use */
169e11c3f44Smeem #define	IFF_IPMP	0x8000000000ll	/* IPMP IP interface */
1701cb875aeSCathy Zhou #define	IFF_VRRP	0x10000000000ll	/* Managed by VRRP */
1717c478bd9Sstevel@tonic-gate 
1726e91bba0SGirish Moodalbail #define	IFF_NOLINKLOCAL	0x20000000000ll	/* No default linklocal */
173550b6e40SSowmini Varadhan #define	IFF_L3PROTECT	0x40000000000ll	/* Layer-3 protection enforced */
1746e91bba0SGirish Moodalbail 
175e11c3f44Smeem /* flags that cannot be changed by userland on any interface */
1767c478bd9Sstevel@tonic-gate #define	IFF_CANTCHANGE \
1777c478bd9Sstevel@tonic-gate 	(IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_PROMISC | \
1787c478bd9Sstevel@tonic-gate 	IFF_MULTICAST | IFF_MULTI_BCAST | IFF_UNNUMBERED | IFF_IPV4 | \
179e11c3f44Smeem 	IFF_IPV6 | IFF_IPMP | IFF_FIXEDMTU | IFF_VIRTUAL | \
1801cb875aeSCathy Zhou 	IFF_LOOPBACK | IFF_ALLMULTI | IFF_DUPLICATE | IFF_COS_ENABLED | \
181550b6e40SSowmini Varadhan 	IFF_VRRP | IFF_NOLINKLOCAL | IFF_L3PROTECT)
1827c478bd9Sstevel@tonic-gate 
183e11c3f44Smeem /* flags that cannot be changed by userland on an IPMP interface */
184e11c3f44Smeem #define	IFF_IPMP_CANTCHANGE 	IFF_FAILED
185e11c3f44Smeem 
186e11c3f44Smeem /* flags that can never be set on an IPMP interface */
187e11c3f44Smeem #define	IFF_IPMP_INVALID	(IFF_STANDBY | IFF_INACTIVE | IFF_OFFLINE | \
1881cb875aeSCathy Zhou 	IFF_NOFAILOVER | IFF_NOARP | IFF_NONUD | IFF_XRESOLV | IFF_NOACCEPT)
189e11c3f44Smeem 
1907c478bd9Sstevel@tonic-gate /*
1917c478bd9Sstevel@tonic-gate  * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
1927c478bd9Sstevel@tonic-gate  * input routines have queues of messages stored on ifqueue structures
1937c478bd9Sstevel@tonic-gate  * (defined above).  Entries are added to and deleted from these structures
1947c478bd9Sstevel@tonic-gate  * by these macros, which should be called with ipl raised to splimp().
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate #define	IF_QFULL(ifq)		((ifq)->ifq_len >= (ifq)->ifq_maxlen)
1977c478bd9Sstevel@tonic-gate #define	IF_DROP(ifq)		((ifq)->ifq_drops++)
1987c478bd9Sstevel@tonic-gate #define	IF_ENQUEUE(ifq, m) { \
1997c478bd9Sstevel@tonic-gate 	(m)->m_act = 0; \
2007c478bd9Sstevel@tonic-gate 	if ((ifq)->ifq_tail == 0) \
2017c478bd9Sstevel@tonic-gate 		(ifq)->ifq_head = m; \
2027c478bd9Sstevel@tonic-gate 	else \
2037c478bd9Sstevel@tonic-gate 		(ifq)->ifq_tail->m_act = m; \
2047c478bd9Sstevel@tonic-gate 	(ifq)->ifq_tail = m; \
2057c478bd9Sstevel@tonic-gate 	(ifq)->ifq_len++; \
2067c478bd9Sstevel@tonic-gate }
2077c478bd9Sstevel@tonic-gate #define	IF_PREPEND(ifq, m) { \
2087c478bd9Sstevel@tonic-gate 	(m)->m_act = (ifq)->ifq_head; \
2097c478bd9Sstevel@tonic-gate 	if ((ifq)->ifq_tail == 0) \
2107c478bd9Sstevel@tonic-gate 		(ifq)->ifq_tail = (m); \
2117c478bd9Sstevel@tonic-gate 	(ifq)->ifq_head = (m); \
2127c478bd9Sstevel@tonic-gate 	(ifq)->ifq_len++; \
2137c478bd9Sstevel@tonic-gate }
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate  * Packets destined for level-1 protocol input routines
2177c478bd9Sstevel@tonic-gate  * have a pointer to the receiving interface prepended to the data.
2187c478bd9Sstevel@tonic-gate  * IF_DEQUEUEIF extracts and returns this pointer when dequeuing the packet.
2197c478bd9Sstevel@tonic-gate  * IF_ADJ should be used otherwise to adjust for its presence.
2207c478bd9Sstevel@tonic-gate  */
2217c478bd9Sstevel@tonic-gate #define	IF_ADJ(m) { \
2227c478bd9Sstevel@tonic-gate 	(m)->m_off += sizeof (struct ifnet *); \
2237c478bd9Sstevel@tonic-gate 	(m)->m_len -= sizeof (struct ifnet *); \
2247c478bd9Sstevel@tonic-gate 	if ((m)->m_len == 0) { \
2257c478bd9Sstevel@tonic-gate 		struct mbuf *n; \
2267c478bd9Sstevel@tonic-gate 		MFREE((m), n); \
2277c478bd9Sstevel@tonic-gate 		(m) = n; \
2287c478bd9Sstevel@tonic-gate 	} \
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate #define	IF_DEQUEUEIF(ifq, m, ifp) { \
2317c478bd9Sstevel@tonic-gate 	(m) = (ifq)->ifq_head; \
2327c478bd9Sstevel@tonic-gate 	if (m) { \
2337c478bd9Sstevel@tonic-gate 		if (((ifq)->ifq_head = (m)->m_act) == 0) \
2347c478bd9Sstevel@tonic-gate 			(ifq)->ifq_tail = 0; \
2357c478bd9Sstevel@tonic-gate 		(m)->m_act = 0; \
2367c478bd9Sstevel@tonic-gate 		(ifq)->ifq_len--; \
2377c478bd9Sstevel@tonic-gate 		(ifp) = *(mtod((m), struct ifnet **)); \
2387c478bd9Sstevel@tonic-gate 		IF_ADJ(m); \
2397c478bd9Sstevel@tonic-gate 	} \
2407c478bd9Sstevel@tonic-gate }
2417c478bd9Sstevel@tonic-gate #define	IF_DEQUEUE(ifq, m) { \
2427c478bd9Sstevel@tonic-gate 	(m) = (ifq)->ifq_head; \
2437c478bd9Sstevel@tonic-gate 	if (m) { \
2447c478bd9Sstevel@tonic-gate 		if (((ifq)->ifq_head = (m)->m_act) == 0) \
2457c478bd9Sstevel@tonic-gate 			(ifq)->ifq_tail = 0; \
2467c478bd9Sstevel@tonic-gate 		(m)->m_act = 0; \
2477c478bd9Sstevel@tonic-gate 		(ifq)->ifq_len--; \
2487c478bd9Sstevel@tonic-gate 	} \
2497c478bd9Sstevel@tonic-gate }
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate #define	IFQ_MAXLEN	50
2527c478bd9Sstevel@tonic-gate #define	IFNET_SLOWHZ	1		/* granularity is 1 second */
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /*
2557c478bd9Sstevel@tonic-gate  * The ifaddr structure contains information about one address
2567c478bd9Sstevel@tonic-gate  * of an interface.  They are maintained by the different address families,
2577c478bd9Sstevel@tonic-gate  * are allocated and attached when an address is set, and are linked
2587c478bd9Sstevel@tonic-gate  * together so all addresses for an interface can be located.
2597c478bd9Sstevel@tonic-gate  */
2607c478bd9Sstevel@tonic-gate struct ifaddr {
2617c478bd9Sstevel@tonic-gate 	struct	sockaddr ifa_addr;	/* address of interface */
2627c478bd9Sstevel@tonic-gate 	union {
2637c478bd9Sstevel@tonic-gate 		struct	sockaddr ifu_broadaddr;
2647c478bd9Sstevel@tonic-gate 		struct	sockaddr ifu_dstaddr;
2657c478bd9Sstevel@tonic-gate 	} ifa_ifu;
2667c478bd9Sstevel@tonic-gate #define	ifa_broadaddr	ifa_ifu.ifu_broadaddr	/* broadcast address */
2677c478bd9Sstevel@tonic-gate #define	ifa_dstaddr	ifa_ifu.ifu_dstaddr	/* other end of p-to-p link */
2687c478bd9Sstevel@tonic-gate 	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
2697c478bd9Sstevel@tonic-gate 	struct	ifaddr *ifa_next;	/* next address for interface */
2707c478bd9Sstevel@tonic-gate };
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  * For SIOCLIF*ND ioctls.
2747c478bd9Sstevel@tonic-gate  *
2757c478bd9Sstevel@tonic-gate  * The lnr_state_* fields use the ND_* neighbor reachability states.
2767c478bd9Sstevel@tonic-gate  * The 3 different fields are for use with SIOCLIFSETND to cover the cases
2777c478bd9Sstevel@tonic-gate  * when
2787c478bd9Sstevel@tonic-gate  *	A new entry is created
2797c478bd9Sstevel@tonic-gate  *	The entry already exists and the link-layer address is the same
2807c478bd9Sstevel@tonic-gate  *	The entry already exists and the link-layer address differs
2817c478bd9Sstevel@tonic-gate  *
2827c478bd9Sstevel@tonic-gate  * Use ND_UNCHANGED and ND_ISROUTER_UNCHANGED to not change any state.
2837c478bd9Sstevel@tonic-gate  */
2847c478bd9Sstevel@tonic-gate #define	ND_MAX_HDW_LEN	64
2857c478bd9Sstevel@tonic-gate typedef struct lif_nd_req {
2867c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	lnr_addr;
2877c478bd9Sstevel@tonic-gate 	uint8_t			lnr_state_create;	/* When creating */
2887c478bd9Sstevel@tonic-gate 	uint8_t			lnr_state_same_lla;	/* Update same addr */
2897c478bd9Sstevel@tonic-gate 	uint8_t			lnr_state_diff_lla;	/* Update w/ diff. */
2907c478bd9Sstevel@tonic-gate 	int			lnr_hdw_len;
2917c478bd9Sstevel@tonic-gate 	int			lnr_flags;		/* See below */
2927c478bd9Sstevel@tonic-gate 	/* padding because ia32 "long long"s are only 4-byte aligned. */
2937c478bd9Sstevel@tonic-gate 	int			lnr_pad0;
2947c478bd9Sstevel@tonic-gate 	char			lnr_hdw_addr[ND_MAX_HDW_LEN];
2957c478bd9Sstevel@tonic-gate } lif_nd_req_t;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate /*
2987c478bd9Sstevel@tonic-gate  * Neighbor reachability states
2997c478bd9Sstevel@tonic-gate  * Used with SIOCLIF*ND ioctls.
3007c478bd9Sstevel@tonic-gate  */
3017c478bd9Sstevel@tonic-gate #define	ND_UNCHANGED	0	/* For ioctls that don't modify state */
3027c478bd9Sstevel@tonic-gate #define	ND_INCOMPLETE	1	/* addr resolution in progress */
3037c478bd9Sstevel@tonic-gate #define	ND_REACHABLE	2	/* have recently been reachable */
3047c478bd9Sstevel@tonic-gate #define	ND_STALE	3	/* may be unreachable, don't do anything */
3057c478bd9Sstevel@tonic-gate #define	ND_DELAY	4	/* wait for upper layer hint */
3067c478bd9Sstevel@tonic-gate #define	ND_PROBE	5	/* send probes */
3077c478bd9Sstevel@tonic-gate #define	ND_UNREACHABLE	6	/* delete this route */
308c793af95Ssangeeta #define	ND_INITIAL	7	/* ipv4: arp resolution has not been sent yet */
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate #define	ND_STATE_VALID_MIN	0
311c793af95Ssangeeta #define	ND_STATE_VALID_MAX	7
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate /*
3147c478bd9Sstevel@tonic-gate  * lnr_flags value of lif_nd_req.
3157c478bd9Sstevel@tonic-gate  * Used with SIOCLIF*ND ioctls.
3167c478bd9Sstevel@tonic-gate  */
3177c478bd9Sstevel@tonic-gate #define	NDF_ISROUTER_ON		0x1
3187c478bd9Sstevel@tonic-gate #define	NDF_ISROUTER_OFF	0x2
3197c478bd9Sstevel@tonic-gate #define	NDF_ANYCAST_ON		0x4
3207c478bd9Sstevel@tonic-gate #define	NDF_ANYCAST_OFF		0x8
3217c478bd9Sstevel@tonic-gate #define	NDF_PROXY_ON		0x10
3227c478bd9Sstevel@tonic-gate #define	NDF_PROXY_OFF		0x20
32301685f97SSowmini Varadhan /*
32401685f97SSowmini Varadhan  * the NDF_STATIC entry ensures that an NCE will not be deleted, and is
32501685f97SSowmini Varadhan  * used by non-ON applications like IPv6 test suites.
32601685f97SSowmini Varadhan  */
32701685f97SSowmini Varadhan #define	NDF_STATIC		0x40
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate /* For SIOC[GS]LIFLNKINFO */
3307c478bd9Sstevel@tonic-gate typedef struct lif_ifinfo_req {
3317c478bd9Sstevel@tonic-gate 	uint8_t		lir_maxhops;
3327c478bd9Sstevel@tonic-gate 	uint32_t	lir_reachtime;		/* Reachable time in msec */
3337c478bd9Sstevel@tonic-gate 	uint32_t	lir_reachretrans;	/* Retransmission timer msec */
3347c478bd9Sstevel@tonic-gate 	uint32_t	lir_maxmtu;
3357c478bd9Sstevel@tonic-gate } lif_ifinfo_req_t;
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /*
3407c478bd9Sstevel@tonic-gate  * Maximum lengths of interface name and IPMP group name; these are the same
3417c478bd9Sstevel@tonic-gate  * for historical reasons.  Note that the actual maximum length of a name is
3427c478bd9Sstevel@tonic-gate  * one byte less than these constants since the kernel always sets the final
3437c478bd9Sstevel@tonic-gate  * byte of lifr_name and lifr_groupname to NUL.
3447c478bd9Sstevel@tonic-gate  */
3457c478bd9Sstevel@tonic-gate #define	_LIFNAMSIZ	32
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate #define	LIFNAMSIZ	_LIFNAMSIZ
3507c478bd9Sstevel@tonic-gate #define	LIFGRNAMSIZ	LIFNAMSIZ
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate  * Interface request structure used for socket
3547c478bd9Sstevel@tonic-gate  * ioctl's.  All interface ioctl's must have parameter
3557c478bd9Sstevel@tonic-gate  * definitions which begin with ifr_name.  The
3567c478bd9Sstevel@tonic-gate  * remainder may be interface specific.
3577c478bd9Sstevel@tonic-gate  * Note: This data structure uses 64bit type uint64_t which is not
3587c478bd9Sstevel@tonic-gate  *	 a valid type for strict ANSI/ISO C compilation for ILP32.
3597c478bd9Sstevel@tonic-gate  *	 Applications with ioctls using this structure that insist on
3607c478bd9Sstevel@tonic-gate  *	 building with strict ANSI/ISO C (-Xc) will need to be LP64.
3617c478bd9Sstevel@tonic-gate  */
3627c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
3637c478bd9Sstevel@tonic-gate struct	lifreq {
3647c478bd9Sstevel@tonic-gate 	char	lifr_name[LIFNAMSIZ];		/* if name, e.g. "en0" */
3657c478bd9Sstevel@tonic-gate 	union {
3667c478bd9Sstevel@tonic-gate 		int	lifru_addrlen;		/* for subnet/token etc */
3677c478bd9Sstevel@tonic-gate 		uint_t	lifru_ppa;		/* SIOCSLIFNAME */
3687c478bd9Sstevel@tonic-gate 	} lifr_lifru1;
3697c478bd9Sstevel@tonic-gate #define	lifr_addrlen	lifr_lifru1.lifru_addrlen
3707c478bd9Sstevel@tonic-gate #define	lifr_ppa	lifr_lifru1.lifru_ppa	/* Driver's ppa */
371e11c3f44Smeem 	uint_t		lifr_type;		/* IFT_ETHER, ... */
3727c478bd9Sstevel@tonic-gate 	union {
3737c478bd9Sstevel@tonic-gate 		struct	sockaddr_storage lifru_addr;
3747c478bd9Sstevel@tonic-gate 		struct	sockaddr_storage lifru_dstaddr;
3757c478bd9Sstevel@tonic-gate 		struct	sockaddr_storage lifru_broadaddr;
3767c478bd9Sstevel@tonic-gate 		struct	sockaddr_storage lifru_token;	/* With lifr_addrlen */
3777c478bd9Sstevel@tonic-gate 		struct	sockaddr_storage lifru_subnet;	/* With lifr_addrlen */
3787c478bd9Sstevel@tonic-gate 		int	lifru_index;		/* interface index */
3797c478bd9Sstevel@tonic-gate 		uint64_t lifru_flags;		/* Flags for SIOC?LIFFLAGS */
3807c478bd9Sstevel@tonic-gate 		int	lifru_metric;
3817c478bd9Sstevel@tonic-gate 		uint_t	lifru_mtu;
3827c478bd9Sstevel@tonic-gate 		int	lif_muxid[2];		/* mux id's for arp and ip */
3837c478bd9Sstevel@tonic-gate 		struct lif_nd_req	lifru_nd_req;
3847c478bd9Sstevel@tonic-gate 		struct lif_ifinfo_req	lifru_ifinfo_req;
3857c478bd9Sstevel@tonic-gate 		char	lifru_groupname[LIFGRNAMSIZ]; /* SIOC[GS]LIFGROUPNAME */
386e11c3f44Smeem 		char	lifru_binding[LIFNAMSIZ]; /* SIOCGLIFBINDING */
3877c478bd9Sstevel@tonic-gate 		zoneid_t lifru_zoneid;		/* SIOC[GS]LIFZONE */
3886e91bba0SGirish Moodalbail 		uint_t	lifru_dadstate;		/* SIOCGLIFDADSTATE */
3897c478bd9Sstevel@tonic-gate 	} lifr_lifru;
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate #define	lifr_addr	lifr_lifru.lifru_addr	/* address */
3927c478bd9Sstevel@tonic-gate #define	lifr_dstaddr	lifr_lifru.lifru_dstaddr /* other end of p-to-p link */
3937c478bd9Sstevel@tonic-gate #define	lifr_broadaddr	lifr_lifru.lifru_broadaddr /* broadcast address */
3947c478bd9Sstevel@tonic-gate #define	lifr_token	lifr_lifru.lifru_token	/* address token */
3957c478bd9Sstevel@tonic-gate #define	lifr_subnet	lifr_lifru.lifru_subnet	/* subnet prefix */
3967c478bd9Sstevel@tonic-gate #define	lifr_index	lifr_lifru.lifru_index	/* interface index */
3977c478bd9Sstevel@tonic-gate #define	lifr_flags	lifr_lifru.lifru_flags	/* flags */
3987c478bd9Sstevel@tonic-gate #define	lifr_metric	lifr_lifru.lifru_metric	/* metric */
3997c478bd9Sstevel@tonic-gate #define	lifr_mtu	lifr_lifru.lifru_mtu	/* mtu */
4007c478bd9Sstevel@tonic-gate #define	lifr_ip_muxid	lifr_lifru.lif_muxid[0]
4017c478bd9Sstevel@tonic-gate #define	lifr_arp_muxid	lifr_lifru.lif_muxid[1]
4027c478bd9Sstevel@tonic-gate #define	lifr_nd		lifr_lifru.lifru_nd_req	/* SIOCLIF*ND */
4037c478bd9Sstevel@tonic-gate #define	lifr_ifinfo	lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */
4047c478bd9Sstevel@tonic-gate #define	lifr_groupname	lifr_lifru.lifru_groupname
405e11c3f44Smeem #define	lifr_binding	lifr_lifru.lifru_binding
4067c478bd9Sstevel@tonic-gate #define	lifr_zoneid	lifr_lifru.lifru_zoneid
4076e91bba0SGirish Moodalbail #define	lifr_dadstate	lifr_lifru.lifru_dadstate
4087c478bd9Sstevel@tonic-gate };
4097c478bd9Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate /*
4127c478bd9Sstevel@tonic-gate  * Argument structure for SIOCT* address testing ioctls.
4137c478bd9Sstevel@tonic-gate  */
4147c478bd9Sstevel@tonic-gate struct sioc_addrreq {
4157c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	sa_addr;	/* Address to test */
4167c478bd9Sstevel@tonic-gate 	int			sa_res;		/* Result - 0/1 */
4177c478bd9Sstevel@tonic-gate 	int			sa_pad;
4187c478bd9Sstevel@tonic-gate };
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate /*
4217c478bd9Sstevel@tonic-gate  * Argument structure used by mrouted to get src-grp pkt counts using
4227c478bd9Sstevel@tonic-gate  * SIOCGETLSGCNT. See <netinet/ip_mroute.h>.
4237c478bd9Sstevel@tonic-gate  */
4247c478bd9Sstevel@tonic-gate struct sioc_lsg_req {
4257c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	slr_src;
4267c478bd9Sstevel@tonic-gate 	struct sockaddr_storage	slr_grp;
4277c478bd9Sstevel@tonic-gate 	uint_t			slr_pktcnt;
4287c478bd9Sstevel@tonic-gate 	uint_t			slr_bytecnt;
4297c478bd9Sstevel@tonic-gate 	uint_t			slr_wrong_if;
4307c478bd9Sstevel@tonic-gate 	uint_t			slr_pad;
4317c478bd9Sstevel@tonic-gate };
4327c478bd9Sstevel@tonic-gate 
4336e91bba0SGirish Moodalbail /* Argument structure for SIOCGLIFDADSTATE ioctl */
4346e91bba0SGirish Moodalbail typedef enum {
4356e91bba0SGirish Moodalbail 	DAD_IN_PROGRESS	= 0x1,
4366e91bba0SGirish Moodalbail 	DAD_DONE	= 0x2
4376e91bba0SGirish Moodalbail } glif_dad_state_t;
4386e91bba0SGirish Moodalbail 
4397c478bd9Sstevel@tonic-gate /*
4407c478bd9Sstevel@tonic-gate  * OBSOLETE: Replaced by struct lifreq. Supported for compatibility.
4417c478bd9Sstevel@tonic-gate  *
4427c478bd9Sstevel@tonic-gate  * Interface request structure used for socket
4437c478bd9Sstevel@tonic-gate  * ioctl's.  All interface ioctl's must have parameter
4447c478bd9Sstevel@tonic-gate  * definitions which begin with ifr_name.  The
4457c478bd9Sstevel@tonic-gate  * remainder may be interface specific.
4467c478bd9Sstevel@tonic-gate  */
4477c478bd9Sstevel@tonic-gate struct	ifreq {
4487c478bd9Sstevel@tonic-gate #define	IFNAMSIZ	16
4497c478bd9Sstevel@tonic-gate 	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
4507c478bd9Sstevel@tonic-gate 	union {
4517c478bd9Sstevel@tonic-gate 		struct	sockaddr ifru_addr;
4527c478bd9Sstevel@tonic-gate 		struct	sockaddr ifru_dstaddr;
4537c478bd9Sstevel@tonic-gate 		char	ifru_oname[IFNAMSIZ];	/* other if name */
4547c478bd9Sstevel@tonic-gate 		struct	sockaddr ifru_broadaddr;
4557c478bd9Sstevel@tonic-gate 		int	ifru_index;		/* interface index */
4560a0e9771SDarren Reed 		uint_t	ifru_mtu;
4577c478bd9Sstevel@tonic-gate 		short	ifru_flags;
4587c478bd9Sstevel@tonic-gate 		int	ifru_metric;
4597c478bd9Sstevel@tonic-gate 		char	ifru_data[1];		/* interface dependent data */
4607c478bd9Sstevel@tonic-gate 		char	ifru_enaddr[6];
4617c478bd9Sstevel@tonic-gate 		int	if_muxid[2];		/* mux id's for arp and ip */
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate 		/* Struct for flags/ppa */
4647c478bd9Sstevel@tonic-gate 		struct ifr_ppaflags {
4657c478bd9Sstevel@tonic-gate 			short ifrup_flags;	/* Space of ifru_flags. */
4667c478bd9Sstevel@tonic-gate 			short ifrup_filler;
4677c478bd9Sstevel@tonic-gate 			uint_t ifrup_ppa;
4687c478bd9Sstevel@tonic-gate 		} ifru_ppaflags;
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate 		/* Struct for FDDI ioctl's */
4717c478bd9Sstevel@tonic-gate 		struct ifr_dnld_reqs {
4727c478bd9Sstevel@tonic-gate 			uint32_t	v_addr;
4737c478bd9Sstevel@tonic-gate 			uint32_t	m_addr;
4747c478bd9Sstevel@tonic-gate 			uint32_t	ex_addr;
4757c478bd9Sstevel@tonic-gate 			uint32_t	size;
4767c478bd9Sstevel@tonic-gate 		} ifru_dnld_req;
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate 		/* Struct for FDDI stats */
4797c478bd9Sstevel@tonic-gate 		struct ifr_fddi_stats {
4807c478bd9Sstevel@tonic-gate 			uint32_t stat_size;
4817c478bd9Sstevel@tonic-gate 			uint32_t fddi_stats;
4827c478bd9Sstevel@tonic-gate 		} ifru_fddi_stat;
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate 		struct ifr_netmapents {
4857c478bd9Sstevel@tonic-gate 			uint32_t map_ent_size,	/* size of netmap structure */
4867c478bd9Sstevel@tonic-gate 				entry_number;	/* index into netmap list */
4877c478bd9Sstevel@tonic-gate 			uint32_t fddi_map_ent;	/* pointer to user structure */
4887c478bd9Sstevel@tonic-gate 		} ifru_netmapent;
4897c478bd9Sstevel@tonic-gate 
4907c478bd9Sstevel@tonic-gate 		/* Field for generic ioctl for fddi */
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate 		struct ifr_fddi_gen_struct {
4937c478bd9Sstevel@tonic-gate 			uint32_t ifru_fddi_gioctl; /* field for gen ioctl */
4947c478bd9Sstevel@tonic-gate 			uint32_t ifru_fddi_gaddr;  /* Generic ptr to a field */
4957c478bd9Sstevel@tonic-gate 		} ifru_fddi_gstruct;
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate 	} ifr_ifru;
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
5007c478bd9Sstevel@tonic-gate #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
5017c478bd9Sstevel@tonic-gate #define	ifr_oname	ifr_ifru.ifru_oname	/* other if name */
5027c478bd9Sstevel@tonic-gate #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
5037c478bd9Sstevel@tonic-gate #define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
5047c478bd9Sstevel@tonic-gate #define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
5057c478bd9Sstevel@tonic-gate #define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
5067c478bd9Sstevel@tonic-gate #define	ifr_enaddr	ifr_ifru.ifru_enaddr	/* ethernet address */
5077c478bd9Sstevel@tonic-gate #define	ifr_index	ifr_ifru.ifru_index	/* interface index */
5080a0e9771SDarren Reed #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
5097c478bd9Sstevel@tonic-gate /* For setting ppa */
5107c478bd9Sstevel@tonic-gate #define	ifr_ppa		ifr_ifru.ifru_ppaflags.ifrup_ppa
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate /* FDDI specific */
5137c478bd9Sstevel@tonic-gate #define	ifr_dnld_req	ifr_ifru.ifru_dnld_req
5147c478bd9Sstevel@tonic-gate #define	ifr_fddi_stat	ifr_ifru.ifru_fddi_stat
5157c478bd9Sstevel@tonic-gate #define	ifr_fddi_netmap	ifr_ifru.ifru_netmapent	/* FDDI network map entries */
5167c478bd9Sstevel@tonic-gate #define	ifr_fddi_gstruct ifr_ifru.ifru_fddi_gstruct
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate #define	ifr_ip_muxid	ifr_ifru.if_muxid[0]
5197c478bd9Sstevel@tonic-gate #define	ifr_arp_muxid	ifr_ifru.if_muxid[1]
5207c478bd9Sstevel@tonic-gate };
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate /* Used by SIOCGLIFNUM. Uses same flags as in struct lifconf */
5237c478bd9Sstevel@tonic-gate struct lifnum {
5247c478bd9Sstevel@tonic-gate 	sa_family_t	lifn_family;
5257c478bd9Sstevel@tonic-gate 	int		lifn_flags;	/* request specific interfaces */
5267c478bd9Sstevel@tonic-gate 	int		lifn_count;	/* Result */
5277c478bd9Sstevel@tonic-gate };
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate /*
5307c478bd9Sstevel@tonic-gate  * Structure used in SIOCGLIFCONF request.
5317c478bd9Sstevel@tonic-gate  * Used to retrieve interface configuration
5327c478bd9Sstevel@tonic-gate  * for machine (useful for programs which
5337c478bd9Sstevel@tonic-gate  * must know all networks accessible) for a given address family.
5347c478bd9Sstevel@tonic-gate  * Using AF_UNSPEC will retrieve all address families.
5357c478bd9Sstevel@tonic-gate  */
5367c478bd9Sstevel@tonic-gate struct	lifconf {
5377c478bd9Sstevel@tonic-gate 	sa_family_t	lifc_family;
5387c478bd9Sstevel@tonic-gate 	int		lifc_flags;	/* request specific interfaces */
5397c478bd9Sstevel@tonic-gate 	int		lifc_len;	/* size of associated buffer */
5407c478bd9Sstevel@tonic-gate 	union {
5417c478bd9Sstevel@tonic-gate 		caddr_t	lifcu_buf;
5427c478bd9Sstevel@tonic-gate 		struct	lifreq *lifcu_req;
5437c478bd9Sstevel@tonic-gate 	} lifc_lifcu;
5447c478bd9Sstevel@tonic-gate #define	lifc_buf lifc_lifcu.lifcu_buf	/* buffer address */
5457c478bd9Sstevel@tonic-gate #define	lifc_req lifc_lifcu.lifcu_req	/* array of structures returned */
5467c478bd9Sstevel@tonic-gate };
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate /*
5497c478bd9Sstevel@tonic-gate  * Structure used in SIOCGLIFSRCOF to get the interface
5507c478bd9Sstevel@tonic-gate  * configuration list for those interfaces that use an address
5517c478bd9Sstevel@tonic-gate  * hosted on the interface (set in lifs_ifindex), as the source
5527c478bd9Sstevel@tonic-gate  * address.
5537c478bd9Sstevel@tonic-gate  */
5547c478bd9Sstevel@tonic-gate struct lifsrcof {
5557c478bd9Sstevel@tonic-gate 	uint_t	lifs_ifindex;	/* interface of interest */
5567c478bd9Sstevel@tonic-gate 	size_t  lifs_maxlen;	/* size of buffer: input */
5577c478bd9Sstevel@tonic-gate 	size_t  lifs_len;	/* size of buffer: output */
5587c478bd9Sstevel@tonic-gate 	union {
5597c478bd9Sstevel@tonic-gate 		caddr_t	lifsu_buf;
5607c478bd9Sstevel@tonic-gate 		struct	lifreq *lifsu_req;
5617c478bd9Sstevel@tonic-gate 	} lifs_lifsu;
5627c478bd9Sstevel@tonic-gate #define	lifs_buf lifs_lifsu.lifsu_buf /* buffer address */
5637c478bd9Sstevel@tonic-gate #define	lifs_req lifs_lifsu.lifsu_req /* array returned */
5647c478bd9Sstevel@tonic-gate };
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate /* Flags */
5677c478bd9Sstevel@tonic-gate #define	LIFC_NOXMIT	0x01		/* Include IFF_NOXMIT interfaces */
5687c478bd9Sstevel@tonic-gate #define	LIFC_EXTERNAL_SOURCE	0x02	/* Exclude the interfaces which can't */
5697c478bd9Sstevel@tonic-gate 					/* be used to communicate outside the */
5707c478bd9Sstevel@tonic-gate 					/* node (exclude interfaces which are */
5717c478bd9Sstevel@tonic-gate 					/* IFF_NOXMIT, IFF_NOLOCAL, */
5727c478bd9Sstevel@tonic-gate 					/* IFF_LOOPBACK, IFF_DEPRECATED, or */
5737c478bd9Sstevel@tonic-gate 					/* not IFF_UP). Has priority over */
5747c478bd9Sstevel@tonic-gate 					/* LIFC_NOXMIT. */
5757c478bd9Sstevel@tonic-gate #define	LIFC_TEMPORARY	0x04		/* Include IFF_TEMPORARY interfaces */
5767c478bd9Sstevel@tonic-gate #define	LIFC_ALLZONES	0x08		/* Include all zones */
5777c478bd9Sstevel@tonic-gate 					/* (must be issued from global zone) */
578e11c3f44Smeem #define	LIFC_UNDER_IPMP	0x10		/* Include underlying IPMP interfaces */
5796e91bba0SGirish Moodalbail #define	LIFC_ENABLED	0x20		/* Include only IFF_UP interfaces */
5807c478bd9Sstevel@tonic-gate 
5817c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate struct	lifconf32 {
5847c478bd9Sstevel@tonic-gate 	sa_family_t	lifc_family;
5857c478bd9Sstevel@tonic-gate 	int		lifc_flags;	/* request specific interfaces */
5867c478bd9Sstevel@tonic-gate 	int32_t	lifc_len;		/* size of associated buffer */
5877c478bd9Sstevel@tonic-gate 	union {
5887c478bd9Sstevel@tonic-gate 		caddr32_t lifcu_buf;
5897c478bd9Sstevel@tonic-gate 		caddr32_t lifcu_req;
5907c478bd9Sstevel@tonic-gate 	} lifc_lifcu;
5917c478bd9Sstevel@tonic-gate };
5927c478bd9Sstevel@tonic-gate 
5937c478bd9Sstevel@tonic-gate struct lifsrcof32 {
5947c478bd9Sstevel@tonic-gate 	uint_t	lifs_ifindex;	/* interface of interest */
5957c478bd9Sstevel@tonic-gate 	size32_t  lifs_maxlen;	/* size of buffer: input */
5967c478bd9Sstevel@tonic-gate 	size32_t  lifs_len;	/* size of buffer: output */
5977c478bd9Sstevel@tonic-gate 	union {
5987c478bd9Sstevel@tonic-gate 		caddr32_t lifsu_buf;
5997c478bd9Sstevel@tonic-gate 		caddr32_t lifsu_req;
6007c478bd9Sstevel@tonic-gate 	} lifs_lifsu;
6017c478bd9Sstevel@tonic-gate };
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
6047c478bd9Sstevel@tonic-gate 
605e11c3f44Smeem /*
606e11c3f44Smeem  * IPMP group information, for use with SIOCGLIFGROUPINFO.
607e11c3f44Smeem  */
608e11c3f44Smeem typedef struct lifgroupinfo {
609e11c3f44Smeem 	char		gi_grname[LIFGRNAMSIZ];	/* group name (set by caller) */
610e11c3f44Smeem 	char		gi_grifname[LIFNAMSIZ];	/* IPMP meta-interface name */
611e11c3f44Smeem 	char		gi_m4ifname[LIFNAMSIZ];	/* v4 mcast interface name */
612e11c3f44Smeem 	char		gi_m6ifname[LIFNAMSIZ];	/* v6 mcast interface name */
613e11c3f44Smeem 	char		gi_bcifname[LIFNAMSIZ];	/* v4 bcast interface name */
614e11c3f44Smeem 	boolean_t	gi_v4;			/* group is plumbed for v4 */
615e11c3f44Smeem 	boolean_t	gi_v6; 			/* group is plumbed for v6 */
616e11c3f44Smeem 	uint_t		gi_nv4;			/* # of underlying v4 if's */
617e11c3f44Smeem 	uint_t		gi_nv6;			/* # of underlying v6 if's */
618e11c3f44Smeem 	uint_t		gi_mactype; 		/* DLPI mac type of group */
619e11c3f44Smeem } lifgroupinfo_t;
620e11c3f44Smeem 
6217c478bd9Sstevel@tonic-gate /*
6227c478bd9Sstevel@tonic-gate  * OBSOLETE: Structure used in SIOCGIFCONF request.
6237c478bd9Sstevel@tonic-gate  * Used to retrieve interface configuration
6247c478bd9Sstevel@tonic-gate  * for machine (useful for programs which
6257c478bd9Sstevel@tonic-gate  * must know all networks accessible).
6267c478bd9Sstevel@tonic-gate  */
6277c478bd9Sstevel@tonic-gate struct	ifconf {
6287c478bd9Sstevel@tonic-gate 	int	ifc_len;		/* size of associated buffer */
6297c478bd9Sstevel@tonic-gate 	union {
6307c478bd9Sstevel@tonic-gate 		caddr_t	ifcu_buf;
6317c478bd9Sstevel@tonic-gate 		struct	ifreq *ifcu_req;
6327c478bd9Sstevel@tonic-gate 	} ifc_ifcu;
6337c478bd9Sstevel@tonic-gate #define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
6347c478bd9Sstevel@tonic-gate #define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
6357c478bd9Sstevel@tonic-gate };
6367c478bd9Sstevel@tonic-gate 
6377c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate struct	ifconf32 {
6407c478bd9Sstevel@tonic-gate 	int32_t	ifc_len;		/* size of associated buffer */
6417c478bd9Sstevel@tonic-gate 	union {
6427c478bd9Sstevel@tonic-gate 		caddr32_t ifcu_buf;
6437c478bd9Sstevel@tonic-gate 		caddr32_t ifcu_req;
6447c478bd9Sstevel@tonic-gate 	} ifc_ifcu;
6457c478bd9Sstevel@tonic-gate };
6467c478bd9Sstevel@tonic-gate 
6477c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
6487c478bd9Sstevel@tonic-gate 
6497c478bd9Sstevel@tonic-gate typedef struct if_data {
6507c478bd9Sstevel@tonic-gate 				/* generic interface information */
6517c478bd9Sstevel@tonic-gate 	uchar_t	ifi_type;	/* ethernet, tokenring, etc */
6527c478bd9Sstevel@tonic-gate 	uchar_t	ifi_addrlen;	/* media address length */
6537c478bd9Sstevel@tonic-gate 	uchar_t	ifi_hdrlen;	/* media header length */
6547c478bd9Sstevel@tonic-gate 	uint_t	ifi_mtu;	/* maximum transmission unit */
6557c478bd9Sstevel@tonic-gate 	uint_t	ifi_metric;	/* routing metric (external only) */
6567c478bd9Sstevel@tonic-gate 	uint_t	ifi_baudrate;	/* linespeed */
6577c478bd9Sstevel@tonic-gate 				/* volatile statistics */
6587c478bd9Sstevel@tonic-gate 	uint_t	ifi_ipackets;	/* packets received on interface */
6597c478bd9Sstevel@tonic-gate 	uint_t	ifi_ierrors;	/* input errors on interface */
6607c478bd9Sstevel@tonic-gate 	uint_t	ifi_opackets;	/* packets sent on interface */
6617c478bd9Sstevel@tonic-gate 	uint_t	ifi_oerrors;	/* output errors on interface */
6627c478bd9Sstevel@tonic-gate 	uint_t	ifi_collisions;	/* collisions on csma interfaces */
6637c478bd9Sstevel@tonic-gate 	uint_t	ifi_ibytes;	/* total number of octets received */
6647c478bd9Sstevel@tonic-gate 	uint_t	ifi_obytes;	/* total number of octets sent */
6657c478bd9Sstevel@tonic-gate 	uint_t	ifi_imcasts;	/* packets received via multicast */
6667c478bd9Sstevel@tonic-gate 	uint_t	ifi_omcasts;	/* packets sent via multicast */
6677c478bd9Sstevel@tonic-gate 	uint_t	ifi_iqdrops;	/* dropped on input, this interface */
6687c478bd9Sstevel@tonic-gate 	uint_t	ifi_noproto;	/* destined for unsupported protocol */
6697c478bd9Sstevel@tonic-gate #if defined(_LP64)
6707c478bd9Sstevel@tonic-gate 	struct	timeval32 ifi_lastchange; /* last updated */
6717c478bd9Sstevel@tonic-gate #else
6727c478bd9Sstevel@tonic-gate 	struct	timeval ifi_lastchange; /* last updated */
6737c478bd9Sstevel@tonic-gate #endif
6747c478bd9Sstevel@tonic-gate } if_data_t;
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate /*
6777c478bd9Sstevel@tonic-gate  * Message format for use in obtaining information about interfaces
6787c478bd9Sstevel@tonic-gate  * from the routing socket
6797c478bd9Sstevel@tonic-gate  */
6807c478bd9Sstevel@tonic-gate typedef struct if_msghdr {
6817c478bd9Sstevel@tonic-gate 	ushort_t ifm_msglen;	/* to skip over non-understood messages */
6827c478bd9Sstevel@tonic-gate 	uchar_t	ifm_version;	/* future binary compatibility */
6837c478bd9Sstevel@tonic-gate 	uchar_t	ifm_type;	/* message type */
6847c478bd9Sstevel@tonic-gate 	int	ifm_addrs;	/* like rtm_addrs */
6857c478bd9Sstevel@tonic-gate 	int	ifm_flags;	/* value of if_flags */
6867c478bd9Sstevel@tonic-gate 	ushort_t ifm_index;	/* index for associated ifp */
6877c478bd9Sstevel@tonic-gate 	struct	if_data ifm_data; /* statistics and other data about if */
6887c478bd9Sstevel@tonic-gate } if_msghdr_t;
6897c478bd9Sstevel@tonic-gate 
6907c478bd9Sstevel@tonic-gate /*
6917c478bd9Sstevel@tonic-gate  * Message format for use in obtaining information about interface addresses
6927c478bd9Sstevel@tonic-gate  * from the routing socket
6937c478bd9Sstevel@tonic-gate  */
6947c478bd9Sstevel@tonic-gate typedef struct ifa_msghdr {
6957c478bd9Sstevel@tonic-gate 	ushort_t ifam_msglen;	/* to skip over non-understood messages */
6967c478bd9Sstevel@tonic-gate 	uchar_t	ifam_version;	/* future binary compatibility */
6977c478bd9Sstevel@tonic-gate 	uchar_t	ifam_type;	/* message type */
6987c478bd9Sstevel@tonic-gate 	int	ifam_addrs;	/* like rtm_addrs */
6997c478bd9Sstevel@tonic-gate 	int	ifam_flags;	/* route flags */
7007c478bd9Sstevel@tonic-gate 	ushort_t ifam_index;	/* index for associated ifp */
7017c478bd9Sstevel@tonic-gate 	int	ifam_metric;	/* value of ipif_metric */
7027c478bd9Sstevel@tonic-gate } ifa_msghdr_t;
7037c478bd9Sstevel@tonic-gate 
7047c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
7057c478bd9Sstevel@tonic-gate 
7067c478bd9Sstevel@tonic-gate /*
7077c478bd9Sstevel@tonic-gate  * The if_nameindex structure holds the interface index value about
7087c478bd9Sstevel@tonic-gate  * a single interface. An array of this structure is used to return
7097c478bd9Sstevel@tonic-gate  * all interfaces and indexes.
7107c478bd9Sstevel@tonic-gate  */
7117c478bd9Sstevel@tonic-gate struct if_nameindex {
7127c478bd9Sstevel@tonic-gate 	unsigned 	if_index;	/* positive interface index */
7137c478bd9Sstevel@tonic-gate 	char		*if_name;	/* if name, e.g. "en0" */
7147c478bd9Sstevel@tonic-gate };
7157c478bd9Sstevel@tonic-gate 
7167c478bd9Sstevel@tonic-gate /* Interface index identification API definitions */
7177c478bd9Sstevel@tonic-gate extern	unsigned 		if_nametoindex(const char *);
7187c478bd9Sstevel@tonic-gate extern	char			*if_indextoname(unsigned, char *);
7197c478bd9Sstevel@tonic-gate extern	struct if_nameindex	*if_nameindex(void);
7207c478bd9Sstevel@tonic-gate extern	void			if_freenameindex(struct if_nameindex *);
7217c478bd9Sstevel@tonic-gate 
7227c478bd9Sstevel@tonic-gate #define	IF_NAMESIZE	_LIFNAMSIZ
723*940fff4bSDarren Reed /*
724*940fff4bSDarren Reed  * If changing IF_MAX_INDEX to a value greater than UINT16_MAX, check if
725*940fff4bSDarren Reed  * struct sockaddr_dl needs to be modified as the interface index is placed
726*940fff4bSDarren Reed  * in this structure by the kernel.
727*940fff4bSDarren Reed  */
728*940fff4bSDarren Reed #define	IF_INDEX_MAX	UINT16_MAX
7297c478bd9Sstevel@tonic-gate 
7307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7317c478bd9Sstevel@tonic-gate }
7327c478bd9Sstevel@tonic-gate #endif
7337c478bd9Sstevel@tonic-gate 
7347c478bd9Sstevel@tonic-gate #endif	/* _NET_IF_H */
735