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