1c398230bSWarner Losh /*- 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1989, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 14df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 15df8bae1dSRodney W. Grimes * without specific prior written permission. 16df8bae1dSRodney W. Grimes * 17df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27df8bae1dSRodney W. Grimes * SUCH DAMAGE. 28df8bae1dSRodney W. Grimes * 29df8bae1dSRodney W. Grimes * @(#)if.h 8.1 (Berkeley) 6/10/93 30c3aac50fSPeter Wemm * $FreeBSD$ 31df8bae1dSRodney W. Grimes */ 32df8bae1dSRodney W. Grimes 33cea1da3bSPaul Richards #ifndef _NET_IF_H_ 34cea1da3bSPaul Richards #define _NET_IF_H_ 35cea1da3bSPaul Richards 36f2ba8326SMike Barcroft #include <sys/cdefs.h> 37f2ba8326SMike Barcroft 38d497e878SIan Dowse #ifdef _KERNEL 3930aad87dSBrooks Davis #include <sys/queue.h> 40d497e878SIan Dowse #endif 4130aad87dSBrooks Davis 42f2ba8326SMike Barcroft #if __BSD_VISIBLE 43df8bae1dSRodney W. Grimes /* 4409410d0fSPeter Wemm * <net/if.h> does not depend on <sys/time.h> on most other systems. This 452fa72ea7SJeroen Ruigrok van der Werven * helps userland compatibility. (struct timeval ifi_lastchange) 4609410d0fSPeter Wemm */ 47664a31e4SPeter Wemm #ifndef _KERNEL 4809410d0fSPeter Wemm #include <sys/time.h> 4909410d0fSPeter Wemm #endif 5009410d0fSPeter Wemm 5130aad87dSBrooks Davis struct ifnet; 52f2ba8326SMike Barcroft #endif 5330aad87dSBrooks Davis 5430aad87dSBrooks Davis /* 5530aad87dSBrooks Davis * Length of interface external name, including terminating '\0'. 5630aad87dSBrooks Davis * Note: this is the same size as a generic device's external name. 5730aad87dSBrooks Davis */ 58f2ba8326SMike Barcroft #define IF_NAMESIZE 16 59f2ba8326SMike Barcroft #if __BSD_VISIBLE 60f2ba8326SMike Barcroft #define IFNAMSIZ IF_NAMESIZE 619bf40edeSBrooks Davis #define IF_MAXUNIT 0x7fff /* historical value */ 62f2ba8326SMike Barcroft #endif 63f2ba8326SMike Barcroft #if __BSD_VISIBLE 64f2ba8326SMike Barcroft 6530aad87dSBrooks Davis /* 6630aad87dSBrooks Davis * Structure used to query names of interface cloners. 6730aad87dSBrooks Davis */ 6830aad87dSBrooks Davis 6930aad87dSBrooks Davis struct if_clonereq { 7030aad87dSBrooks Davis int ifcr_total; /* total cloners (out) */ 7130aad87dSBrooks Davis int ifcr_count; /* room for this many in user buffer */ 7230aad87dSBrooks Davis char *ifcr_buffer; /* buffer for cloner names */ 7330aad87dSBrooks Davis }; 7430aad87dSBrooks Davis 7509410d0fSPeter Wemm /* 76a73356a1SBill Fenner * Structure describing information about an interface 77a73356a1SBill Fenner * which may be of interest to management entities. 78a73356a1SBill Fenner */ 79df8bae1dSRodney W. Grimes struct if_data { 80df8bae1dSRodney W. Grimes /* generic interface information */ 81df8bae1dSRodney W. Grimes u_char ifi_type; /* ethernet, tokenring, etc */ 82995add1aSGarrett Wollman u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ 83df8bae1dSRodney W. Grimes u_char ifi_addrlen; /* media address length */ 84df8bae1dSRodney W. Grimes u_char ifi_hdrlen; /* media header length */ 85127d7b2dSAndre Oppermann u_char ifi_link_state; /* current link state */ 86bec59525SBrooks Davis u_char ifi_spare_char1; /* spare byte */ 87bec59525SBrooks Davis u_char ifi_spare_char2; /* spare byte */ 889e734b44SBrooks Davis u_char ifi_datalen; /* length of this data struct */ 89df8bae1dSRodney W. Grimes u_long ifi_mtu; /* maximum transmission unit */ 90df8bae1dSRodney W. Grimes u_long ifi_metric; /* routing metric (external only) */ 91df8bae1dSRodney W. Grimes u_long ifi_baudrate; /* linespeed */ 92df8bae1dSRodney W. Grimes /* volatile statistics */ 93df8bae1dSRodney W. Grimes u_long ifi_ipackets; /* packets received on interface */ 94df8bae1dSRodney W. Grimes u_long ifi_ierrors; /* input errors on interface */ 95df8bae1dSRodney W. Grimes u_long ifi_opackets; /* packets sent on interface */ 96df8bae1dSRodney W. Grimes u_long ifi_oerrors; /* output errors on interface */ 97df8bae1dSRodney W. Grimes u_long ifi_collisions; /* collisions on csma interfaces */ 98df8bae1dSRodney W. Grimes u_long ifi_ibytes; /* total number of octets received */ 99df8bae1dSRodney W. Grimes u_long ifi_obytes; /* total number of octets sent */ 100df8bae1dSRodney W. Grimes u_long ifi_imcasts; /* packets received via multicast */ 101df8bae1dSRodney W. Grimes u_long ifi_omcasts; /* packets sent via multicast */ 102df8bae1dSRodney W. Grimes u_long ifi_iqdrops; /* dropped on input, this interface */ 103df8bae1dSRodney W. Grimes u_long ifi_noproto; /* destined for unsupported protocol */ 10460d4ab7aSAndre Oppermann u_long ifi_hwassist; /* HW offload capabilities, see IFCAP */ 105bc9d2991SBrooks Davis time_t ifi_epoch; /* uptime at attach or stat reset */ 106e39a0280SGary Palmer struct timeval ifi_lastchange; /* time of last administrative change */ 1076f64074eSJoerg Wunsch }; 1086f64074eSJoerg Wunsch 109fc574570SRobert Watson /*- 110292ee7beSRobert Watson * Interface flags are of two types: network stack owned flags, and driver 111292ee7beSRobert Watson * owned flags. Historically, these values were stored in the same ifnet 112292ee7beSRobert Watson * flags field, but with the advent of fine-grained locking, they have been 113292ee7beSRobert Watson * broken out such that the network stack is responsible for synchronizing 114292ee7beSRobert Watson * the stack-owned fields, and the device driver the device-owned fields. 115292ee7beSRobert Watson * Both halves can perform lockless reads of the other half's field, subject 116292ee7beSRobert Watson * to accepting the involved races. 117292ee7beSRobert Watson * 118292ee7beSRobert Watson * Both sets of flags come from the same number space, and should not be 119292ee7beSRobert Watson * permitted to conflict, as they are exposed to user space via a single 120292ee7beSRobert Watson * field. 121292ee7beSRobert Watson * 122fc574570SRobert Watson * The following symbols identify read and write requirements for fields: 123fc574570SRobert Watson * 124fc574570SRobert Watson * (i) if_flags field set by device driver before attach, read-only there 125fc574570SRobert Watson * after. 126fc574570SRobert Watson * (n) if_flags field written only by the network stack, read by either the 127fc574570SRobert Watson * stack or driver. 128fc574570SRobert Watson * (d) if_drv_flags field written only by the device driver, read by either 129fc574570SRobert Watson * the stack or driver. 130292ee7beSRobert Watson */ 131fc574570SRobert Watson #define IFF_UP 0x1 /* (n) interface is up */ 132fc574570SRobert Watson #define IFF_BROADCAST 0x2 /* (i) broadcast address valid */ 133fc574570SRobert Watson #define IFF_DEBUG 0x4 /* (n) turn on debugging */ 134fc574570SRobert Watson #define IFF_LOOPBACK 0x8 /* (i) is a loopback net */ 135fc574570SRobert Watson #define IFF_POINTOPOINT 0x10 /* (i) is a point-to-point link */ 136fc574570SRobert Watson #define IFF_SMART 0x20 /* (i) interface manages own routes */ 137fc574570SRobert Watson #define IFF_DRV_RUNNING 0x40 /* (d) resources allocated */ 138fc574570SRobert Watson #define IFF_NOARP 0x80 /* (n) no address resolution protocol */ 139fc574570SRobert Watson #define IFF_PROMISC 0x100 /* (n) receive all packets */ 140fc574570SRobert Watson #define IFF_ALLMULTI 0x200 /* (n) receive all multicast packets */ 141fc574570SRobert Watson #define IFF_DRV_OACTIVE 0x400 /* (d) tx hardware queue is full */ 142fc574570SRobert Watson #define IFF_SIMPLEX 0x800 /* (i) can't hear own transmissions */ 143df8bae1dSRodney W. Grimes #define IFF_LINK0 0x1000 /* per link layer defined bit */ 144df8bae1dSRodney W. Grimes #define IFF_LINK1 0x2000 /* per link layer defined bit */ 145df8bae1dSRodney W. Grimes #define IFF_LINK2 0x4000 /* per link layer defined bit */ 14637be1da8SGarrett Wollman #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ 147fc574570SRobert Watson #define IFF_MULTICAST 0x8000 /* (i) supports multicast */ 14840929967SGleb Smirnoff /* 0x10000 */ 149fc574570SRobert Watson #define IFF_PPROMISC 0x20000 /* (n) user-requested promisc mode */ 150fc574570SRobert Watson #define IFF_MONITOR 0x40000 /* (n) user-requested monitor mode */ 151fc574570SRobert Watson #define IFF_STATICARP 0x80000 /* (n) static ARP */ 152fc574570SRobert Watson #define IFF_NEEDSGIANT 0x100000 /* (i) hold Giant over if_start calls */ 153e4fc250cSLuigi Rizzo 154292ee7beSRobert Watson /* 155292ee7beSRobert Watson * Old names for driver flags so that user space tools can continue to use 156fc574570SRobert Watson * the old (portable) names. 157292ee7beSRobert Watson */ 158292ee7beSRobert Watson #ifndef _KERNEL 159292ee7beSRobert Watson #define IFF_RUNNING IFF_DRV_RUNNING 160292ee7beSRobert Watson #define IFF_OACTIVE IFF_DRV_OACTIVE 161292ee7beSRobert Watson #endif 162292ee7beSRobert Watson 163df8bae1dSRodney W. Grimes /* flags set internally only: */ 164df8bae1dSRodney W. Grimes #define IFF_CANTCHANGE \ 165292ee7beSRobert Watson (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\ 16640929967SGleb Smirnoff IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC) 167df8bae1dSRodney W. Grimes 168bb68f0afSSam Leffler /* 169127d7b2dSAndre Oppermann * Values for if_link_state. 170127d7b2dSAndre Oppermann */ 171127d7b2dSAndre Oppermann #define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */ 172127d7b2dSAndre Oppermann #define LINK_STATE_DOWN 1 /* link is down */ 173127d7b2dSAndre Oppermann #define LINK_STATE_UP 2 /* link is up */ 174127d7b2dSAndre Oppermann 175127d7b2dSAndre Oppermann /* 176bb68f0afSSam Leffler * Some convenience macros used for setting ifi_baudrate. 177bb68f0afSSam Leffler * XXX 1000 vs. 1024? --thorpej@netbsd.org 178bb68f0afSSam Leffler */ 179bb68f0afSSam Leffler #define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */ 180bb68f0afSSam Leffler #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */ 181bb68f0afSSam Leffler #define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */ 182bb68f0afSSam Leffler 18360d4ab7aSAndre Oppermann /* 18460d4ab7aSAndre Oppermann * Capabilities that interfaces can advertise. 18560d4ab7aSAndre Oppermann * 18660d4ab7aSAndre Oppermann * struct ifnet.if_capabilities 18760d4ab7aSAndre Oppermann * contains the optional features & capabilities a particular interface 18860d4ab7aSAndre Oppermann * supports (not only the driver but also the detected hw revision). 18960d4ab7aSAndre Oppermann * Capabilities are defined by IFCAP_* below. 190d562befcSYaroslav Tykhiy * struct ifnet.if_capenable 19160d4ab7aSAndre Oppermann * contains the enabled (either by default or through ifconfig) optional 19260d4ab7aSAndre Oppermann * features & capabilities on this interface. 19360d4ab7aSAndre Oppermann * Capabilities are defined by IFCAP_* below. 19460d4ab7aSAndre Oppermann * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above 19560d4ab7aSAndre Oppermann * contains the enabled optional feature & capabilites that can be used 19660d4ab7aSAndre Oppermann * individually per packet and are specified in the mbuf pkthdr.csum_flags 19760d4ab7aSAndre Oppermann * field. IFCAP_* and CSUM_* do not match one to one and CSUM_* may be 198d562befcSYaroslav Tykhiy * more detailed or differenciated than IFCAP_*. 19960d4ab7aSAndre Oppermann * Hwassist features are defined CSUM_* in sys/mbuf.h 20060d4ab7aSAndre Oppermann */ 201f7d86692SJonathan Lemon #define IFCAP_RXCSUM 0x0001 /* can offload checksum on RX */ 202f7d86692SJonathan Lemon #define IFCAP_TXCSUM 0x0002 /* can offload checksum on TX */ 203f7d86692SJonathan Lemon #define IFCAP_NETCONS 0x0004 /* can be a network console */ 204bb68f0afSSam Leffler #define IFCAP_VLAN_MTU 0x0008 /* VLAN-compatible MTU */ 205bb68f0afSSam Leffler #define IFCAP_VLAN_HWTAGGING 0x0010 /* hardware VLAN tag support */ 206bb68f0afSSam Leffler #define IFCAP_JUMBO_MTU 0x0020 /* 9000 byte MTU supported */ 2073a3b019aSRuslan Ermilov #define IFCAP_POLLING 0x0040 /* driver supports polling */ 20875ee267cSGleb Smirnoff #define IFCAP_VLAN_HWCSUM 0x0080 /* can do IFCAP_HWCSUM on VLANs */ 209233dcce1SAndre Oppermann #define IFCAP_TSO4 0x0100 /* can do TCP Segmentation Offload */ 210233dcce1SAndre Oppermann #define IFCAP_TSO6 0x0200 /* can do TCP6 Segmentation Offload */ 211db24121cSAndre Oppermann #define IFCAP_LRO 0x0400 /* can do Large Receive Offload */ 212de0abf19SSam Leffler #define IFCAP_WOL_UCAST 0x0800 /* wake on any unicast frame */ 213de0abf19SSam Leffler #define IFCAP_WOL_MCAST 0x1000 /* wake on any multicast frame */ 214de0abf19SSam Leffler #define IFCAP_WOL_MAGIC 0x2000 /* wake on any Magic Packet */ 215a0d231fbSKip Macy #define IFCAP_TOE4 0x4000 /* interface can offload TCP */ 216a0d231fbSKip Macy #define IFCAP_TOE6 0x8000 /* interface can offload TCP6 */ 217f7d86692SJonathan Lemon 218f7d86692SJonathan Lemon #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) 219233dcce1SAndre Oppermann #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) 220de0abf19SSam Leffler #define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) 2214c908c35SKip Macy #define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6) 222016da741SJonathan Lemon 223df8bae1dSRodney W. Grimes #define IFQ_MAXLEN 50 224df8bae1dSRodney W. Grimes #define IFNET_SLOWHZ 1 /* granularity is 1 second */ 225df8bae1dSRodney W. Grimes 226df8bae1dSRodney W. Grimes /* 227df8bae1dSRodney W. Grimes * Message format for use in obtaining information about interfaces 228df8bae1dSRodney W. Grimes * from getkerninfo and the routing socket 229df8bae1dSRodney W. Grimes */ 230df8bae1dSRodney W. Grimes struct if_msghdr { 231df8bae1dSRodney W. Grimes u_short ifm_msglen; /* to skip over non-understood messages */ 2322fa72ea7SJeroen Ruigrok van der Werven u_char ifm_version; /* future binary compatibility */ 233df8bae1dSRodney W. Grimes u_char ifm_type; /* message type */ 234df8bae1dSRodney W. Grimes int ifm_addrs; /* like rtm_addrs */ 235df8bae1dSRodney W. Grimes int ifm_flags; /* value of if_flags */ 236df8bae1dSRodney W. Grimes u_short ifm_index; /* index for associated ifp */ 237df8bae1dSRodney W. Grimes struct if_data ifm_data;/* statistics and other data about if */ 238df8bae1dSRodney W. Grimes }; 239df8bae1dSRodney W. Grimes 240df8bae1dSRodney W. Grimes /* 241df8bae1dSRodney W. Grimes * Message format for use in obtaining information about interface addresses 242df8bae1dSRodney W. Grimes * from getkerninfo and the routing socket 243df8bae1dSRodney W. Grimes */ 244df8bae1dSRodney W. Grimes struct ifa_msghdr { 245df8bae1dSRodney W. Grimes u_short ifam_msglen; /* to skip over non-understood messages */ 2462fa72ea7SJeroen Ruigrok van der Werven u_char ifam_version; /* future binary compatibility */ 247df8bae1dSRodney W. Grimes u_char ifam_type; /* message type */ 248df8bae1dSRodney W. Grimes int ifam_addrs; /* like rtm_addrs */ 249df8bae1dSRodney W. Grimes int ifam_flags; /* value of ifa_flags */ 250df8bae1dSRodney W. Grimes u_short ifam_index; /* index for associated ifp */ 251df8bae1dSRodney W. Grimes int ifam_metric; /* value of ifa_metric */ 252df8bae1dSRodney W. Grimes }; 253df8bae1dSRodney W. Grimes 254df8bae1dSRodney W. Grimes /* 255477180fbSGarrett Wollman * Message format for use in obtaining information about multicast addresses 256477180fbSGarrett Wollman * from the routing socket 257477180fbSGarrett Wollman */ 258477180fbSGarrett Wollman struct ifma_msghdr { 259477180fbSGarrett Wollman u_short ifmam_msglen; /* to skip over non-understood messages */ 2602fa72ea7SJeroen Ruigrok van der Werven u_char ifmam_version; /* future binary compatibility */ 261477180fbSGarrett Wollman u_char ifmam_type; /* message type */ 262477180fbSGarrett Wollman int ifmam_addrs; /* like rtm_addrs */ 263477180fbSGarrett Wollman int ifmam_flags; /* value of ifa_flags */ 264477180fbSGarrett Wollman u_short ifmam_index; /* index for associated ifp */ 265477180fbSGarrett Wollman }; 266477180fbSGarrett Wollman 267477180fbSGarrett Wollman /* 2687b6edd04SRuslan Ermilov * Message format announcing the arrival or departure of a network interface. 2697b6edd04SRuslan Ermilov */ 2707b6edd04SRuslan Ermilov struct if_announcemsghdr { 2717b6edd04SRuslan Ermilov u_short ifan_msglen; /* to skip over non-understood messages */ 2727b6edd04SRuslan Ermilov u_char ifan_version; /* future binary compatibility */ 2737b6edd04SRuslan Ermilov u_char ifan_type; /* message type */ 2747b6edd04SRuslan Ermilov u_short ifan_index; /* index for associated ifp */ 2757b6edd04SRuslan Ermilov char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 2767b6edd04SRuslan Ermilov u_short ifan_what; /* what type of announcement */ 2777b6edd04SRuslan Ermilov }; 2787b6edd04SRuslan Ermilov 2797b6edd04SRuslan Ermilov #define IFAN_ARRIVAL 0 /* interface arrival */ 2807b6edd04SRuslan Ermilov #define IFAN_DEPARTURE 1 /* interface departure */ 2817b6edd04SRuslan Ermilov 2827b6edd04SRuslan Ermilov /* 283df8bae1dSRodney W. Grimes * Interface request structure used for socket 284df8bae1dSRodney W. Grimes * ioctl's. All interface ioctl's must have parameter 285df8bae1dSRodney W. Grimes * definitions which begin with ifr_name. The 286df8bae1dSRodney W. Grimes * remainder may be interface specific. 287df8bae1dSRodney W. Grimes */ 288df8bae1dSRodney W. Grimes struct ifreq { 289df8bae1dSRodney W. Grimes char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 290df8bae1dSRodney W. Grimes union { 291df8bae1dSRodney W. Grimes struct sockaddr ifru_addr; 292df8bae1dSRodney W. Grimes struct sockaddr ifru_dstaddr; 293df8bae1dSRodney W. Grimes struct sockaddr ifru_broadaddr; 2944add131eSPoul-Henning Kamp short ifru_flags[2]; 295de593450SJonathan Lemon short ifru_index; 296df8bae1dSRodney W. Grimes int ifru_metric; 297a7028af7SDavid Greenman int ifru_mtu; 298074c4a4eSGarrett Wollman int ifru_phys; 299a912e453SPeter Wemm int ifru_media; 300df8bae1dSRodney W. Grimes caddr_t ifru_data; 301016da741SJonathan Lemon int ifru_cap[2]; 302df8bae1dSRodney W. Grimes } ifr_ifru; 303df8bae1dSRodney W. Grimes #define ifr_addr ifr_ifru.ifru_addr /* address */ 304df8bae1dSRodney W. Grimes #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ 305df8bae1dSRodney W. Grimes #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ 30662f76486SMaxim Sobolev #define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */ 30762f76486SMaxim Sobolev #define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */ 308df8bae1dSRodney W. Grimes #define ifr_metric ifr_ifru.ifru_metric /* metric */ 309a7028af7SDavid Greenman #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ 310511cdd16SDavid Greenman #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ 311a912e453SPeter Wemm #define ifr_media ifr_ifru.ifru_media /* physical media */ 312df8bae1dSRodney W. Grimes #define ifr_data ifr_ifru.ifru_data /* for use by interface */ 313016da741SJonathan Lemon #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ 314016da741SJonathan Lemon #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ 315de593450SJonathan Lemon #define ifr_index ifr_ifru.ifru_index /* interface index */ 316df8bae1dSRodney W. Grimes }; 317df8bae1dSRodney W. Grimes 318906f09bcSGarrett Wollman #define _SIZEOF_ADDR_IFREQ(ifr) \ 319906f09bcSGarrett Wollman ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ 320906f09bcSGarrett Wollman (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ 321906f09bcSGarrett Wollman (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) 322906f09bcSGarrett Wollman 323df8bae1dSRodney W. Grimes struct ifaliasreq { 324df8bae1dSRodney W. Grimes char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 325df8bae1dSRodney W. Grimes struct sockaddr ifra_addr; 326df8bae1dSRodney W. Grimes struct sockaddr ifra_broadaddr; 327df8bae1dSRodney W. Grimes struct sockaddr ifra_mask; 328df8bae1dSRodney W. Grimes }; 329df8bae1dSRodney W. Grimes 330a912e453SPeter Wemm struct ifmediareq { 331a912e453SPeter Wemm char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 332a912e453SPeter Wemm int ifm_current; /* current media options */ 333a912e453SPeter Wemm int ifm_mask; /* don't care mask */ 334a912e453SPeter Wemm int ifm_status; /* media status */ 335a912e453SPeter Wemm int ifm_active; /* active options */ 336a912e453SPeter Wemm int ifm_count; /* # entries in ifm_ulist array */ 337a912e453SPeter Wemm int *ifm_ulist; /* media words */ 338a912e453SPeter Wemm }; 339413dd0baSPoul-Henning Kamp 3408f867517SAndrew Thompson struct ifdrv { 3418f867517SAndrew Thompson char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 3428f867517SAndrew Thompson unsigned long ifd_cmd; 3438f867517SAndrew Thompson size_t ifd_len; 3448f867517SAndrew Thompson void *ifd_data; 3458f867517SAndrew Thompson }; 3468f867517SAndrew Thompson 347413dd0baSPoul-Henning Kamp /* 348413dd0baSPoul-Henning Kamp * Structure used to retrieve aux status data from interfaces. 349712020a1SBruce Evans * Kernel suppliers to this interface should respect the formatting 350413dd0baSPoul-Henning Kamp * needed by ifconfig(8): each line starts with a TAB and ends with 351712020a1SBruce Evans * a newline. The canonical example to copy and paste is in if_tun.c. 352413dd0baSPoul-Henning Kamp */ 353413dd0baSPoul-Henning Kamp 354413dd0baSPoul-Henning Kamp #define IFSTATMAX 800 /* 10 lines of text */ 355413dd0baSPoul-Henning Kamp struct ifstat { 356413dd0baSPoul-Henning Kamp char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 357413dd0baSPoul-Henning Kamp char ascii[IFSTATMAX + 1]; 358413dd0baSPoul-Henning Kamp }; 359413dd0baSPoul-Henning Kamp 360df8bae1dSRodney W. Grimes /* 361df8bae1dSRodney W. Grimes * Structure used in SIOCGIFCONF request. 362df8bae1dSRodney W. Grimes * Used to retrieve interface configuration 363df8bae1dSRodney W. Grimes * for machine (useful for programs which 364df8bae1dSRodney W. Grimes * must know all networks accessible). 365df8bae1dSRodney W. Grimes */ 366df8bae1dSRodney W. Grimes struct ifconf { 367df8bae1dSRodney W. Grimes int ifc_len; /* size of associated buffer */ 368df8bae1dSRodney W. Grimes union { 369df8bae1dSRodney W. Grimes caddr_t ifcu_buf; 370df8bae1dSRodney W. Grimes struct ifreq *ifcu_req; 371df8bae1dSRodney W. Grimes } ifc_ifcu; 372df8bae1dSRodney W. Grimes #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ 373df8bae1dSRodney W. Grimes #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ 374df8bae1dSRodney W. Grimes }; 375df8bae1dSRodney W. Grimes 37619cf0498SPaul Saab #if defined (__amd64__) || defined (COMPAT_32BIT) 37719cf0498SPaul Saab struct ifconf32 { 37819cf0498SPaul Saab int ifc_len; /* size of associated buffer */ 37919cf0498SPaul Saab union { 38019cf0498SPaul Saab u_int ifcu_buf; 38119cf0498SPaul Saab u_int ifcu_req; 38219cf0498SPaul Saab } ifc_ifcu; 38319cf0498SPaul Saab }; 38419cf0498SPaul Saab #endif 38576429de4SYoshinobu Inoue 38676429de4SYoshinobu Inoue /* 3870dad3f0eSMax Laier * interface groups 3880dad3f0eSMax Laier */ 3890dad3f0eSMax Laier 3900dad3f0eSMax Laier #define IFG_ALL "all" /* group contains all interfaces */ 3910dad3f0eSMax Laier /* XXX: will we implement this? */ 3920dad3f0eSMax Laier #define IFG_EGRESS "egress" /* if(s) default route(s) point to */ 3930dad3f0eSMax Laier 3940dad3f0eSMax Laier struct ifg_req { 3950dad3f0eSMax Laier union { 3960dad3f0eSMax Laier char ifgrqu_group[IFNAMSIZ]; 3970dad3f0eSMax Laier char ifgrqu_member[IFNAMSIZ]; 3980dad3f0eSMax Laier } ifgrq_ifgrqu; 3990dad3f0eSMax Laier #define ifgrq_group ifgrq_ifgrqu.ifgrqu_group 4000dad3f0eSMax Laier #define ifgrq_member ifgrq_ifgrqu.ifgrqu_member 4010dad3f0eSMax Laier }; 4020dad3f0eSMax Laier 4030dad3f0eSMax Laier /* 4040dad3f0eSMax Laier * Used to lookup groups for an interface 4050dad3f0eSMax Laier */ 4060dad3f0eSMax Laier struct ifgroupreq { 4070dad3f0eSMax Laier char ifgr_name[IFNAMSIZ]; 4080dad3f0eSMax Laier u_int ifgr_len; 4090dad3f0eSMax Laier union { 4100dad3f0eSMax Laier char ifgru_group[IFNAMSIZ]; 4110dad3f0eSMax Laier struct ifg_req *ifgru_groups; 4120dad3f0eSMax Laier } ifgr_ifgru; 4130dad3f0eSMax Laier #define ifgr_group ifgr_ifgru.ifgru_group 4140dad3f0eSMax Laier #define ifgr_groups ifgr_ifgru.ifgru_groups 4150dad3f0eSMax Laier }; 4160dad3f0eSMax Laier 4170dad3f0eSMax Laier /* 41876429de4SYoshinobu Inoue * Structure for SIOC[AGD]LIFADDR 41976429de4SYoshinobu Inoue */ 42076429de4SYoshinobu Inoue struct if_laddrreq { 42176429de4SYoshinobu Inoue char iflr_name[IFNAMSIZ]; 42276429de4SYoshinobu Inoue u_int flags; 42376429de4SYoshinobu Inoue #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ 42476429de4SYoshinobu Inoue u_int prefixlen; /* in/out */ 42576429de4SYoshinobu Inoue struct sockaddr_storage addr; /* in/out */ 42676429de4SYoshinobu Inoue struct sockaddr_storage dstaddr; /* out */ 42776429de4SYoshinobu Inoue }; 42876429de4SYoshinobu Inoue 429f2ba8326SMike Barcroft #endif /* __BSD_VISIBLE */ 430f2ba8326SMike Barcroft 431664a31e4SPeter Wemm #ifdef _KERNEL 432a1c995b6SPoul-Henning Kamp #ifdef MALLOC_DECLARE 433a1c995b6SPoul-Henning Kamp MALLOC_DECLARE(M_IFADDR); 434a1c995b6SPoul-Henning Kamp MALLOC_DECLARE(M_IFMADDR); 435a1c995b6SPoul-Henning Kamp #endif 436a1c995b6SPoul-Henning Kamp #endif 437a1c995b6SPoul-Henning Kamp 438664a31e4SPeter Wemm #ifndef _KERNEL 43976429de4SYoshinobu Inoue struct if_nameindex { 440f2ba8326SMike Barcroft unsigned int if_index; /* 1, 2, ... */ 44176429de4SYoshinobu Inoue char *if_name; /* null terminated name: "le0", ... */ 44276429de4SYoshinobu Inoue }; 44376429de4SYoshinobu Inoue 44476429de4SYoshinobu Inoue __BEGIN_DECLS 445edfcad95SMike Barcroft void if_freenameindex(struct if_nameindex *); 446f2ba8326SMike Barcroft char *if_indextoname(unsigned int, char *); 447929ddbbbSAlfred Perlstein struct if_nameindex *if_nameindex(void); 448edfcad95SMike Barcroft unsigned int if_nametoindex(const char *); 44976429de4SYoshinobu Inoue __END_DECLS 45076429de4SYoshinobu Inoue #endif 45176429de4SYoshinobu Inoue 452664a31e4SPeter Wemm #ifdef _KERNEL 453b40ce416SJulian Elischer struct thread; 454712020a1SBruce Evans 455712020a1SBruce Evans /* XXX - this should go away soon. */ 45619ff91c6SGarrett Wollman #include <net/if_var.h> 457df8bae1dSRodney W. Grimes #endif 458cea1da3bSPaul Richards 459df708ff1SBruce Evans #endif /* !_NET_IF_H_ */ 460