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