if.h revision 550b6e4083768ca350e9e7c3a1ebbf720b23dcad
2N/A/*
2N/A * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1982, 1986 Regents of the University of California.
2N/A * All rights reserved. The Berkeley software License Agreement
2N/A * specifies the terms and conditions for redistribution.
2N/A */
2N/A
2N/A#ifndef _NET_IF_H
2N/A#define _NET_IF_H
2N/A
2N/A/* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86 */
2N/A
2N/A#include <sys/feature_tests.h>
2N/A
2N/A#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
2N/A#include <sys/socket.h>
2N/A#include <netinet/in.h>
58N/A#if defined(_LP64)
2N/A#include <sys/types32.h>
2N/A#endif
32N/A#endif
32N/A
127N/A#ifdef __cplusplus
127N/Aextern "C" {
145N/A#endif
127N/A
127N/A/*
127N/A * Structures defining a network interface, providing a packet
127N/A * transport mechanism (ala level 0 of the PUP protocols).
2N/A *
145N/A * Each interface accepts output datagrams of a specified maximum
26N/A * length, and provides higher level routines with input datagrams
38N/A * received from its medium.
38N/A *
29N/A * Output occurs when the routine if_output is called, with three parameters:
93N/A * (*ifp->if_output)(ifp, m, dst)
29N/A * Here m is the mbuf chain to be sent and dst is the destination address.
29N/A * The output routine encapsulates the supplied datagram if necessary,
26N/A * and then transmits it on its medium.
26N/A *
29N/A * On input, each interface unwraps the data received by it, and either
26N/A * places it on the input queue of a internetwork datagram routine
2N/A * and posts the associated software interrupt, or passes the datagram to a raw
38N/A * packet input routine.
2N/A *
6N/A * Routines exist for locating interfaces by their addresses
2N/A * or for locating a interface on a certain network, as well as more general
58N/A * routing and gateway routines maintaining information used to locate
2N/A * interfaces. These routines live in the files if.c and route.c
145N/A */
145N/A
34N/A#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
34N/A
34N/A/*
49N/A * Structure defining a queue for a network interface.
145N/A *
2N/A * (Would like to call this struct ``if'', but C isn't PL/1.)
34N/A */
34N/Astruct ifnet {
94N/A char *if_name; /* name, e.g. ``en'' or ``lo'' */
94N/A short if_unit; /* sub-unit for lower level driver */
156N/A short if_mtu; /* maximum transmission unit */
156N/A short if_flags; /* up/down, broadcast, etc. */
166N/A short if_timer; /* time 'til if_watchdog called */
166N/A ushort_t if_promisc; /* net # of requests for promisc mode */
34N/A int if_metric; /* routing metric (external only) */
59N/A struct ifaddr *if_addrlist; /* linked list of addresses per if */
72N/A struct ifqueue {
72N/A struct mbuf *ifq_head;
72N/A struct mbuf *ifq_tail;
59N/A int ifq_len;
2N/A int ifq_maxlen;
85N/A int ifq_drops;
61N/A } if_snd; /* output queue */
61N/A/* procedure handles */
61N/A int (*if_init)(); /* init routine */
61N/A int (*if_output)(); /* output routine */
61N/A int (*if_ioctl)(); /* ioctl routine */
61N/A int (*if_reset)(); /* bus reset routine */
61N/A int (*if_watchdog)(); /* timer routine */
61N/A/* generic interface statistics */
61N/A int if_ipackets; /* packets received on interface */
152N/A int if_ierrors; /* input errors on interface */
74N/A int if_opackets; /* packets sent on interface */
61N/A int if_oerrors; /* output errors on interface */
85N/A int if_collisions; /* collisions on csma interfaces */
61N/A/* end statistics */
61N/A struct ifnet *if_next;
61N/A struct ifnet *if_upper; /* next layer up */
61N/A struct ifnet *if_lower; /* next layer down */
61N/A int (*if_input)(); /* input routine */
61N/A int (*if_ctlin)(); /* control input routine */
61N/A int (*if_ctlout)(); /* control output routine */
61N/A struct map *if_memmap; /* rmap for interface specific memory */
152N/A};
152N/A
61N/A/*
61N/A * NOTE : These flags are not directly used within IP.
43N/A * ip_if.h has definitions derived from this which is used within IP.
43N/A * If you define a flag here, you need to define one in ip_if.h before
120N/A * using the new flag in IP. Don't use these flags directly in IP.
64N/A */
64N/A#define IFF_UP 0x0000000001 /* address is up */
64N/A#define IFF_BROADCAST 0x0000000002 /* broadcast address valid */
43N/A#define IFF_DEBUG 0x0000000004 /* turn on debugging */
43N/A#define IFF_LOOPBACK 0x0000000008 /* is a loopback net */
120N/A
64N/A#define IFF_POINTOPOINT 0x0000000010 /* interface is point-to-point link */
64N/A#define IFF_NOTRAILERS 0x0000000020 /* avoid use of trailers */
64N/A#define IFF_RUNNING 0x0000000040 /* resources allocated */
64N/A#define IFF_NOARP 0x0000000080 /* no address resolution protocol */
64N/A
64N/A#define IFF_PROMISC 0x0000000100 /* receive all packets */
64N/A#define IFF_ALLMULTI 0x0000000200 /* receive all multicast packets */
64N/A#define IFF_INTELLIGENT 0x0000000400 /* protocol code on board */
64N/A/*
64N/A * The IFF_MULTICAST flag indicates that the network can support the
64N/A * transmission and reception of higher-level (e.g., IP) multicast packets.
64N/A * It is independent of hardware support for multicasting; for example,
43N/A * point-to-point links or pure broadcast networks may well support
16N/A * higher-level multicasts.
16N/A */
16N/A#define IFF_MULTICAST 0x0000000800 /* supports multicast */
34N/A
34N/A#define IFF_MULTI_BCAST 0x0000001000 /* multicast using broadcast address */
16N/A#define IFF_UNNUMBERED 0x0000002000 /* non-unique address */
6N/A#define IFF_DHCPRUNNING 0x0000004000 /* DHCP controls this interface */
12N/A#define IFF_PRIVATE 0x0000008000 /* do not advertise */
12N/A
12N/A/*
12N/A * The following flags can't be grabbed or altered by SIOC[GS]IFFLAGS.
12N/A * Should use SIOC[GS]LIFFLAGS which has a larger flags field.
12N/A */
12N/A#define IFF_NOXMIT 0x0000010000 /* Do not transmit packets */
12N/A#define IFF_NOLOCAL 0x0000020000 /* No address - just on-link subnet */
12N/A#define IFF_DEPRECATED 0x0000040000 /* Address is deprecated */
12N/A#define IFF_ADDRCONF 0x0000080000 /* address from stateless addrconf */
12N/A
61N/A#define IFF_ROUTER 0x0000100000 /* router on this interface */
61N/A#define IFF_NONUD 0x0000200000 /* No NUD on this interface */
61N/A#define IFF_ANYCAST 0x0000400000 /* Anycast address */
61N/A#define IFF_NORTEXCH 0x0000800000 /* Do not exchange routing info */
61N/A
12N/A#define IFF_IPV4 0x0001000000 /* IPv4 interface */
12N/A#define IFF_IPV6 0x0002000000 /* IPv6 interface */
61N/A#define IFF_NOACCEPT 0x0004000000 /* no-accept mode VRRP ill */
61N/A#define IFF_NOFAILOVER 0x0008000000 /* in.mpathd(1M) test address */
12N/A
2N/A#define IFF_FAILED 0x0010000000 /* Interface has failed */
99N/A#define IFF_STANDBY 0x0020000000 /* Interface is a hot-spare */
99N/A#define IFF_INACTIVE 0x0040000000 /* Functioning but not used for data */
99N/A#define IFF_OFFLINE 0x0080000000 /* Interface is offline */
99N/A
40N/A/*
40N/A * The IFF_XRESOLV flag is an evolving interface and is subject
40N/A * to change without notice.
40N/A */
43N/A#define IFF_XRESOLV 0x0100000000ll /* IPv6 external resolver */
40N/A#define IFF_COS_ENABLED 0x0200000000ll /* If interface supports CoS marking */
127N/A#define IFF_PREFERRED 0x0400000000ll /* Prefer as source address */
2N/A#define IFF_TEMPORARY 0x0800000000ll /* RFC3041 */
99N/A
99N/A#define IFF_FIXEDMTU 0x1000000000ll /* MTU manually set with SIOCSLIFMTU */
2N/A#define IFF_VIRTUAL 0x2000000000ll /* Does not send or receive packets */
99N/A#define IFF_DUPLICATE 0x4000000000ll /* Local address already in use */
99N/A#define IFF_IPMP 0x8000000000ll /* IPMP IP interface */
2N/A#define IFF_VRRP 0x10000000000ll /* Managed by VRRP */
151N/A
151N/A#define IFF_NOLINKLOCAL 0x20000000000ll /* No default linklocal */
2N/A#define IFF_L3PROTECT 0x40000000000ll /* Layer-3 protection enforced */
151N/A
151N/A/* flags that cannot be changed by userland on any interface */
2N/A#define IFF_CANTCHANGE \
2N/A (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_PROMISC | \
2N/A IFF_MULTICAST | IFF_MULTI_BCAST | IFF_UNNUMBERED | IFF_IPV4 | \
2N/A IFF_IPV6 | IFF_IPMP | IFF_FIXEDMTU | IFF_VIRTUAL | \
61N/A IFF_LOOPBACK | IFF_ALLMULTI | IFF_DUPLICATE | IFF_COS_ENABLED | \
61N/A IFF_VRRP | IFF_NOLINKLOCAL | IFF_L3PROTECT)
61N/A
61N/A/* flags that cannot be changed by userland on an IPMP interface */
61N/A#define IFF_IPMP_CANTCHANGE IFF_FAILED
16N/A
16N/A/* flags that can never be set on an IPMP interface */
148N/A#define IFF_IPMP_INVALID (IFF_STANDBY | IFF_INACTIVE | IFF_OFFLINE | \
148N/A IFF_NOFAILOVER | IFF_NOARP | IFF_NONUD | IFF_XRESOLV | IFF_NOACCEPT)
148N/A
148N/A/*
2N/A * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
47N/A * input routines have queues of messages stored on ifqueue structures
2N/A * (defined above). Entries are added to and deleted from these structures
2N/A * by these macros, which should be called with ipl raised to splimp().
2N/A */
148N/A#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
2N/A#define IF_DROP(ifq) ((ifq)->ifq_drops++)
146N/A#define IF_ENQUEUE(ifq, m) { \
146N/A (m)->m_act = 0; \
146N/A if ((ifq)->ifq_tail == 0) \
146N/A (ifq)->ifq_head = m; \
146N/A else \
116N/A (ifq)->ifq_tail->m_act = m; \
116N/A (ifq)->ifq_tail = m; \
127N/A (ifq)->ifq_len++; \
127N/A}
2N/A#define IF_PREPEND(ifq, m) { \
2N/A (m)->m_act = (ifq)->ifq_head; \
82N/A if ((ifq)->ifq_tail == 0) \
99N/A (ifq)->ifq_tail = (m); \
99N/A (ifq)->ifq_head = (m); \
2N/A (ifq)->ifq_len++; \
105N/A}
2N/A
70N/A/*
2N/A * Packets destined for level-1 protocol input routines
160N/A * have a pointer to the receiving interface prepended to the data.
160N/A * IF_DEQUEUEIF extracts and returns this pointer when dequeuing the packet.
160N/A * IF_ADJ should be used otherwise to adjust for its presence.
160N/A */
165N/A#define IF_ADJ(m) { \
2N/A (m)->m_off += sizeof (struct ifnet *); \
2N/A (m)->m_len -= sizeof (struct ifnet *); \
2N/A if ((m)->m_len == 0) { \
7N/A struct mbuf *n; \
142N/A MFREE((m), n); \
43N/A (m) = n; \
43N/A } \
16N/A}
43N/A#define IF_DEQUEUEIF(ifq, m, ifp) { \
138N/A (m) = (ifq)->ifq_head; \
61N/A if (m) { \
61N/A if (((ifq)->ifq_head = (m)->m_act) == 0) \
61N/A (ifq)->ifq_tail = 0; \
61N/A (m)->m_act = 0; \
61N/A (ifq)->ifq_len--; \
99N/A (ifp) = *(mtod((m), struct ifnet **)); \
99N/A IF_ADJ(m); \
99N/A } \
99N/A}
99N/A#define IF_DEQUEUE(ifq, m) { \
99N/A (m) = (ifq)->ifq_head; \
99N/A if (m) { \
99N/A if (((ifq)->ifq_head = (m)->m_act) == 0) \
99N/A (ifq)->ifq_tail = 0; \
61N/A (m)->m_act = 0; \
99N/A (ifq)->ifq_len--; \
99N/A } \
99N/A}
99N/A
99N/A#define IFQ_MAXLEN 50
61N/A#define IFNET_SLOWHZ 1 /* granularity is 1 second */
99N/A
99N/A/*
99N/A * The ifaddr structure contains information about one address
99N/A * of an interface. They are maintained by the different address families,
61N/A * are allocated and attached when an address is set, and are linked
61N/A * together so all addresses for an interface can be located.
61N/A */
61N/Astruct ifaddr {
99N/A struct sockaddr ifa_addr; /* address of interface */
99N/A union {
99N/A struct sockaddr ifu_broadaddr;
99N/A struct sockaddr ifu_dstaddr;
99N/A } ifa_ifu;
99N/A#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
99N/A#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */
99N/A struct ifnet *ifa_ifp; /* back-pointer to interface */
99N/A struct ifaddr *ifa_next; /* next address for interface */
99N/A};
99N/A
99N/A/*
99N/A * For SIOCLIF*ND ioctls.
99N/A *
99N/A * The lnr_state_* fields use the ND_* neighbor reachability states.
99N/A * The 3 different fields are for use with SIOCLIFSETND to cover the cases
99N/A * when
99N/A * A new entry is created
102N/A * The entry already exists and the link-layer address is the same
108N/A * The entry already exists and the link-layer address differs
102N/A *
61N/A * Use ND_UNCHANGED and ND_ISROUTER_UNCHANGED to not change any state.
99N/A */
99N/A#define ND_MAX_HDW_LEN 64
99N/Atypedef struct lif_nd_req {
99N/A struct sockaddr_storage lnr_addr;
99N/A uint8_t lnr_state_create; /* When creating */
99N/A uint8_t lnr_state_same_lla; /* Update same addr */
99N/A uint8_t lnr_state_diff_lla; /* Update w/ diff. */
99N/A int lnr_hdw_len;
99N/A int lnr_flags; /* See below */
99N/A /* padding because ia32 "long long"s are only 4-byte aligned. */
99N/A int lnr_pad0;
99N/A char lnr_hdw_addr[ND_MAX_HDW_LEN];
99N/A} lif_nd_req_t;
99N/A
99N/A/*
99N/A * Neighbor reachability states
99N/A * Used with SIOCLIF*ND ioctls.
99N/A */
99N/A#define ND_UNCHANGED 0 /* For ioctls that don't modify state */
165N/A#define ND_INCOMPLETE 1 /* addr resolution in progress */
165N/A#define ND_REACHABLE 2 /* have recently been reachable */
165N/A#define ND_STALE 3 /* may be unreachable, don't do anything */
165N/A#define ND_DELAY 4 /* wait for upper layer hint */
165N/A#define ND_PROBE 5 /* send probes */
165N/A#define ND_UNREACHABLE 6 /* delete this route */
165N/A#define ND_INITIAL 7 /* ipv4: arp resolution has not been sent yet */
99N/A
102N/A#define ND_STATE_VALID_MIN 0
102N/A#define ND_STATE_VALID_MAX 7
102N/A
102N/A/*
102N/A * lnr_flags value of lif_nd_req.
99N/A * Used with SIOCLIF*ND ioctls.
99N/A */
99N/A#define NDF_ISROUTER_ON 0x1
61N/A#define NDF_ISROUTER_OFF 0x2
61N/A#define NDF_ANYCAST_ON 0x4
61N/A#define NDF_ANYCAST_OFF 0x8
61N/A#define NDF_PROXY_ON 0x10
99N/A#define NDF_PROXY_OFF 0x20
99N/A/*
102N/A * the NDF_STATIC entry ensures that an NCE will not be deleted, and is
99N/A * used by non-ON applications like IPv6 test suites.
99N/A */
99N/A#define NDF_STATIC 0x40
99N/A
99N/A/* For SIOC[GS]LIFLNKINFO */
99N/Atypedef struct lif_ifinfo_req {
102N/A uint8_t lir_maxhops;
99N/A uint32_t lir_reachtime; /* Reachable time in msec */
109N/A uint32_t lir_reachretrans; /* Retransmission timer msec */
109N/A uint32_t lir_maxmtu;
109N/A} lif_ifinfo_req_t;
109N/A
109N/A#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
109N/A
109N/A/*
109N/A * Maximum lengths of interface name and IPMP group name; these are the same
109N/A * for historical reasons. Note that the actual maximum length of a name is
109N/A * one byte less than these constants since the kernel always sets the final
109N/A * byte of lifr_name and lifr_groupname to NUL.
109N/A */
99N/A#define _LIFNAMSIZ 32
99N/A
99N/A#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
99N/A
99N/A#define LIFNAMSIZ _LIFNAMSIZ
99N/A#define LIFGRNAMSIZ LIFNAMSIZ
99N/A
99N/A/*
99N/A * Interface request structure used for socket
99N/A * ioctl's. All interface ioctl's must have parameter
109N/A * definitions which begin with ifr_name. The
109N/A * remainder may be interface specific.
61N/A * Note: This data structure uses 64bit type uint64_t which is not
99N/A * a valid type for strict ANSI/ISO C compilation for ILP32.
99N/A * Applications with ioctls using this structure that insist on
99N/A * building with strict ANSI/ISO C (-Xc) will need to be LP64.
99N/A */
99N/A#if defined(_INT64_TYPE)
99N/Astruct lifreq {
99N/A char lifr_name[LIFNAMSIZ]; /* if name, e.g. "en0" */
99N/A union {
99N/A int lifru_addrlen; /* for subnet/token etc */
99N/A uint_t lifru_ppa; /* SIOCSLIFNAME */
99N/A } lifr_lifru1;
61N/A#define lifr_addrlen lifr_lifru1.lifru_addrlen
99N/A#define lifr_ppa lifr_lifru1.lifru_ppa /* Driver's ppa */
99N/A uint_t lifr_type; /* IFT_ETHER, ... */
99N/A union {
99N/A struct sockaddr_storage lifru_addr;
99N/A struct sockaddr_storage lifru_dstaddr;
99N/A struct sockaddr_storage lifru_broadaddr;
99N/A struct sockaddr_storage lifru_token; /* With lifr_addrlen */
99N/A struct sockaddr_storage lifru_subnet; /* With lifr_addrlen */
99N/A int lifru_index; /* interface index */
99N/A uint64_t lifru_flags; /* Flags for SIOC?LIFFLAGS */
99N/A int lifru_metric;
99N/A uint_t lifru_mtu;
99N/A int lif_muxid[2]; /* mux id's for arp and ip */
99N/A struct lif_nd_req lifru_nd_req;
99N/A struct lif_ifinfo_req lifru_ifinfo_req;
99N/A char lifru_groupname[LIFGRNAMSIZ]; /* SIOC[GS]LIFGROUPNAME */
99N/A char lifru_binding[LIFNAMSIZ]; /* SIOCGLIFBINDING */
99N/A zoneid_t lifru_zoneid; /* SIOC[GS]LIFZONE */
61N/A uint_t lifru_dadstate; /* SIOCGLIFDADSTATE */
99N/A } lifr_lifru;
99N/A
99N/A#define lifr_addr lifr_lifru.lifru_addr /* address */
99N/A#define lifr_dstaddr lifr_lifru.lifru_dstaddr /* other end of p-to-p link */
99N/A#define lifr_broadaddr lifr_lifru.lifru_broadaddr /* broadcast address */
99N/A#define lifr_token lifr_lifru.lifru_token /* address token */
99N/A#define lifr_subnet lifr_lifru.lifru_subnet /* subnet prefix */
99N/A#define lifr_index lifr_lifru.lifru_index /* interface index */
99N/A#define lifr_flags lifr_lifru.lifru_flags /* flags */
99N/A#define lifr_metric lifr_lifru.lifru_metric /* metric */
99N/A#define lifr_mtu lifr_lifru.lifru_mtu /* mtu */
99N/A#define lifr_ip_muxid lifr_lifru.lif_muxid[0]
99N/A#define lifr_arp_muxid lifr_lifru.lif_muxid[1]
99N/A#define lifr_nd lifr_lifru.lifru_nd_req /* SIOCLIF*ND */
99N/A#define lifr_ifinfo lifr_lifru.lifru_ifinfo_req /* SIOC[GS]LIFLNKINFO */
99N/A#define lifr_groupname lifr_lifru.lifru_groupname
99N/A#define lifr_binding lifr_lifru.lifru_binding
99N/A#define lifr_zoneid lifr_lifru.lifru_zoneid
99N/A#define lifr_dadstate lifr_lifru.lifru_dadstate
99N/A};
99N/A#endif /* defined(_INT64_TYPE) */
99N/A
170N/A/*
170N/A * Argument structure for SIOCT* address testing ioctls.
170N/A */
99N/Astruct sioc_addrreq {
99N/A struct sockaddr_storage sa_addr; /* Address to test */
61N/A int sa_res; /* Result - 0/1 */
99N/A int sa_pad;
99N/A};
99N/A
99N/A/*
99N/A * Argument structure used by mrouted to get src-grp pkt counts using
99N/A * SIOCGETLSGCNT. See <netinet/ip_mroute.h>.
99N/A */
99N/Astruct sioc_lsg_req {
99N/A struct sockaddr_storage slr_src;
99N/A struct sockaddr_storage slr_grp;
99N/A uint_t slr_pktcnt;
99N/A uint_t slr_bytecnt;
61N/A uint_t slr_wrong_if;
99N/A uint_t slr_pad;
99N/A};
99N/A
99N/A/* Argument structure for SIOCGLIFDADSTATE ioctl */
99N/Atypedef enum {
99N/A DAD_IN_PROGRESS = 0x1,
99N/A DAD_DONE = 0x2
99N/A} glif_dad_state_t;
61N/A
99N/A/*
99N/A * OBSOLETE: Replaced by struct lifreq. Supported for compatibility.
99N/A *
99N/A * Interface request structure used for socket
99N/A * ioctl's. All interface ioctl's must have parameter
99N/A * definitions which begin with ifr_name. The
102N/A * remainder may be interface specific.
170N/A */
64N/Astruct ifreq {
62N/A#define IFNAMSIZ 16
64N/A char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
64N/A union {
82N/A struct sockaddr ifru_addr;
64N/A struct sockaddr ifru_dstaddr;
82N/A char ifru_oname[IFNAMSIZ]; /* other if name */
64N/A struct sockaddr ifru_broadaddr;
64N/A int ifru_index; /* interface index */
62N/A uint_t ifru_mtu;
62N/A short ifru_flags;
62N/A int ifru_metric;
62N/A char ifru_data[1]; /* interface dependent data */
char ifru_enaddr[6];
int if_muxid[2]; /* mux id's for arp and ip */
/* Struct for flags/ppa */
struct ifr_ppaflags {
short ifrup_flags; /* Space of ifru_flags. */
short ifrup_filler;
uint_t ifrup_ppa;
} ifru_ppaflags;
/* Struct for FDDI ioctl's */
struct ifr_dnld_reqs {
uint32_t v_addr;
uint32_t m_addr;
uint32_t ex_addr;
uint32_t size;
} ifru_dnld_req;
/* Struct for FDDI stats */
struct ifr_fddi_stats {
uint32_t stat_size;
uint32_t fddi_stats;
} ifru_fddi_stat;
struct ifr_netmapents {
uint32_t map_ent_size, /* size of netmap structure */
entry_number; /* index into netmap list */
uint32_t fddi_map_ent; /* pointer to user structure */
} ifru_netmapent;
/* Field for generic ioctl for fddi */
struct ifr_fddi_gen_struct {
uint32_t ifru_fddi_gioctl; /* field for gen ioctl */
uint32_t ifru_fddi_gaddr; /* Generic ptr to a field */
} ifru_fddi_gstruct;
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_oname ifr_ifru.ifru_oname /* other if name */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_enaddr ifr_ifru.ifru_enaddr /* ethernet address */
#define ifr_index ifr_ifru.ifru_index /* interface index */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
/* For setting ppa */
#define ifr_ppa ifr_ifru.ifru_ppaflags.ifrup_ppa
/* FDDI specific */
#define ifr_dnld_req ifr_ifru.ifru_dnld_req
#define ifr_fddi_stat ifr_ifru.ifru_fddi_stat
#define ifr_fddi_netmap ifr_ifru.ifru_netmapent /* FDDI network map entries */
#define ifr_fddi_gstruct ifr_ifru.ifru_fddi_gstruct
#define ifr_ip_muxid ifr_ifru.if_muxid[0]
#define ifr_arp_muxid ifr_ifru.if_muxid[1]
};
/* Used by SIOCGLIFNUM. Uses same flags as in struct lifconf */
struct lifnum {
sa_family_t lifn_family;
int lifn_flags; /* request specific interfaces */
int lifn_count; /* Result */
};
/*
* Structure used in SIOCGLIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible) for a given address family.
* Using AF_UNSPEC will retrieve all address families.
*/
struct lifconf {
sa_family_t lifc_family;
int lifc_flags; /* request specific interfaces */
int lifc_len; /* size of associated buffer */
union {
caddr_t lifcu_buf;
struct lifreq *lifcu_req;
} lifc_lifcu;
#define lifc_buf lifc_lifcu.lifcu_buf /* buffer address */
#define lifc_req lifc_lifcu.lifcu_req /* array of structures returned */
};
/*
* Structure used in SIOCGLIFSRCOF to get the interface
* configuration list for those interfaces that use an address
* hosted on the interface (set in lifs_ifindex), as the source
* address.
*/
struct lifsrcof {
uint_t lifs_ifindex; /* interface of interest */
size_t lifs_maxlen; /* size of buffer: input */
size_t lifs_len; /* size of buffer: output */
union {
caddr_t lifsu_buf;
struct lifreq *lifsu_req;
} lifs_lifsu;
#define lifs_buf lifs_lifsu.lifsu_buf /* buffer address */
#define lifs_req lifs_lifsu.lifsu_req /* array returned */
};
/* Flags */
#define LIFC_NOXMIT 0x01 /* Include IFF_NOXMIT interfaces */
#define LIFC_EXTERNAL_SOURCE 0x02 /* Exclude the interfaces which can't */
/* be used to communicate outside the */
/* node (exclude interfaces which are */
/* IFF_NOXMIT, IFF_NOLOCAL, */
/* IFF_LOOPBACK, IFF_DEPRECATED, or */
/* not IFF_UP). Has priority over */
/* LIFC_NOXMIT. */
#define LIFC_TEMPORARY 0x04 /* Include IFF_TEMPORARY interfaces */
#define LIFC_ALLZONES 0x08 /* Include all zones */
/* (must be issued from global zone) */
#define LIFC_UNDER_IPMP 0x10 /* Include underlying IPMP interfaces */
#define LIFC_ENABLED 0x20 /* Include only IFF_UP interfaces */
#if defined(_SYSCALL32)
struct lifconf32 {
sa_family_t lifc_family;
int lifc_flags; /* request specific interfaces */
int32_t lifc_len; /* size of associated buffer */
union {
caddr32_t lifcu_buf;
caddr32_t lifcu_req;
} lifc_lifcu;
};
struct lifsrcof32 {
uint_t lifs_ifindex; /* interface of interest */
size32_t lifs_maxlen; /* size of buffer: input */
size32_t lifs_len; /* size of buffer: output */
union {
caddr32_t lifsu_buf;
caddr32_t lifsu_req;
} lifs_lifsu;
};
#endif /* _SYSCALL32 */
/*
* IPMP group information, for use with SIOCGLIFGROUPINFO.
*/
typedef struct lifgroupinfo {
char gi_grname[LIFGRNAMSIZ]; /* group name (set by caller) */
char gi_grifname[LIFNAMSIZ]; /* IPMP meta-interface name */
char gi_m4ifname[LIFNAMSIZ]; /* v4 mcast interface name */
char gi_m6ifname[LIFNAMSIZ]; /* v6 mcast interface name */
char gi_bcifname[LIFNAMSIZ]; /* v4 bcast interface name */
boolean_t gi_v4; /* group is plumbed for v4 */
boolean_t gi_v6; /* group is plumbed for v6 */
uint_t gi_nv4; /* # of underlying v4 if's */
uint_t gi_nv6; /* # of underlying v6 if's */
uint_t gi_mactype; /* DLPI mac type of group */
} lifgroupinfo_t;
/*
* OBSOLETE: Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
int ifc_len; /* size of associated buffer */
union {
caddr_t ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};
#if defined(_SYSCALL32)
struct ifconf32 {
int32_t ifc_len; /* size of associated buffer */
union {
caddr32_t ifcu_buf;
caddr32_t ifcu_req;
} ifc_ifcu;
};
#endif /* _SYSCALL32 */
typedef struct if_data {
/* generic interface information */
uchar_t ifi_type; /* ethernet, tokenring, etc */
uchar_t ifi_addrlen; /* media address length */
uchar_t ifi_hdrlen; /* media header length */
uint_t ifi_mtu; /* maximum transmission unit */
uint_t ifi_metric; /* routing metric (external only) */
uint_t ifi_baudrate; /* linespeed */
/* volatile statistics */
uint_t ifi_ipackets; /* packets received on interface */
uint_t ifi_ierrors; /* input errors on interface */
uint_t ifi_opackets; /* packets sent on interface */
uint_t ifi_oerrors; /* output errors on interface */
uint_t ifi_collisions; /* collisions on csma interfaces */
uint_t ifi_ibytes; /* total number of octets received */
uint_t ifi_obytes; /* total number of octets sent */
uint_t ifi_imcasts; /* packets received via multicast */
uint_t ifi_omcasts; /* packets sent via multicast */
uint_t ifi_iqdrops; /* dropped on input, this interface */
uint_t ifi_noproto; /* destined for unsupported protocol */
#if defined(_LP64)
struct timeval32 ifi_lastchange; /* last updated */
#else
struct timeval ifi_lastchange; /* last updated */
#endif
} if_data_t;
/*
* Message format for use in obtaining information about interfaces
* from the routing socket
*/
typedef struct if_msghdr {
ushort_t ifm_msglen; /* to skip over non-understood messages */
uchar_t ifm_version; /* future binary compatibility */
uchar_t ifm_type; /* message type */
int ifm_addrs; /* like rtm_addrs */
int ifm_flags; /* value of if_flags */
ushort_t ifm_index; /* index for associated ifp */
struct if_data ifm_data; /* statistics and other data about if */
} if_msghdr_t;
/*
* Message format for use in obtaining information about interface addresses
* from the routing socket
*/
typedef struct ifa_msghdr {
ushort_t ifam_msglen; /* to skip over non-understood messages */
uchar_t ifam_version; /* future binary compatibility */
uchar_t ifam_type; /* message type */
int ifam_addrs; /* like rtm_addrs */
int ifam_flags; /* route flags */
ushort_t ifam_index; /* index for associated ifp */
int ifam_metric; /* value of ipif_metric */
} ifa_msghdr_t;
#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
/*
* The if_nameindex structure holds the interface index value about
* a single interface. An array of this structure is used to return
* all interfaces and indexes.
*/
struct if_nameindex {
unsigned if_index; /* positive interface index */
char *if_name; /* if name, e.g. "en0" */
};
/* Interface index identification API definitions */
extern unsigned if_nametoindex(const char *);
extern char *if_indextoname(unsigned, char *);
extern struct if_nameindex *if_nameindex(void);
extern void if_freenameindex(struct if_nameindex *);
#define IF_NAMESIZE _LIFNAMSIZ
#ifdef __cplusplus
}
#endif
#endif /* _NET_IF_H */