1c398230bSWarner Losh /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 4df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1989, 1993 5df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 6df8bae1dSRodney W. Grimes * 7df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 8df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 9df8bae1dSRodney W. Grimes * are met: 10df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 12df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 13df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 14df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 15fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 16df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 17df8bae1dSRodney W. Grimes * without specific prior written permission. 18df8bae1dSRodney W. Grimes * 19df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29df8bae1dSRodney W. Grimes * SUCH DAMAGE. 30df8bae1dSRodney W. Grimes */ 31df8bae1dSRodney W. Grimes 32cea1da3bSPaul Richards #ifndef _NET_IF_H_ 33cea1da3bSPaul Richards #define _NET_IF_H_ 34cea1da3bSPaul Richards 35f2ba8326SMike Barcroft #include <sys/cdefs.h> 36f2ba8326SMike Barcroft 37f2ba8326SMike Barcroft #if __BSD_VISIBLE 38df8bae1dSRodney W. Grimes /* 3909410d0fSPeter Wemm * <net/if.h> does not depend on <sys/time.h> on most other systems. This 402fa72ea7SJeroen Ruigrok van der Werven * helps userland compatibility. (struct timeval ifi_lastchange) 41cf05e311SEd Schouten * The same holds for <sys/socket.h>. (struct sockaddr ifru_addr) 4209410d0fSPeter Wemm */ 43664a31e4SPeter Wemm #ifndef _KERNEL 4409410d0fSPeter Wemm #include <sys/time.h> 45cf05e311SEd Schouten #include <sys/socket.h> 4609410d0fSPeter Wemm #endif 47f2ba8326SMike Barcroft #endif 4830aad87dSBrooks Davis 4930aad87dSBrooks Davis /* 5030aad87dSBrooks Davis * Length of interface external name, including terminating '\0'. 5130aad87dSBrooks Davis * Note: this is the same size as a generic device's external name. 5230aad87dSBrooks Davis */ 53f2ba8326SMike Barcroft #define IF_NAMESIZE 16 54f2ba8326SMike Barcroft #if __BSD_VISIBLE 55f2ba8326SMike Barcroft #define IFNAMSIZ IF_NAMESIZE 569bf40edeSBrooks Davis #define IF_MAXUNIT 0x7fff /* historical value */ 57f2ba8326SMike Barcroft #endif 58f2ba8326SMike Barcroft #if __BSD_VISIBLE 59f2ba8326SMike Barcroft 6030aad87dSBrooks Davis /* 6130aad87dSBrooks Davis * Structure used to query names of interface cloners. 6230aad87dSBrooks Davis */ 6330aad87dSBrooks Davis 6430aad87dSBrooks Davis struct if_clonereq { 6530aad87dSBrooks Davis int ifcr_total; /* total cloners (out) */ 6630aad87dSBrooks Davis int ifcr_count; /* room for this many in user buffer */ 6730aad87dSBrooks Davis char *ifcr_buffer; /* buffer for cloner names */ 6830aad87dSBrooks Davis }; 6930aad87dSBrooks Davis 7009410d0fSPeter Wemm /* 71a73356a1SBill Fenner * Structure describing information about an interface 72a73356a1SBill Fenner * which may be of interest to management entities. 73a73356a1SBill Fenner */ 74df8bae1dSRodney W. Grimes struct if_data { 75df8bae1dSRodney W. Grimes /* generic interface information */ 76b245f96cSGleb Smirnoff uint8_t ifi_type; /* ethernet, tokenring, etc */ 77b245f96cSGleb Smirnoff uint8_t ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ 78b245f96cSGleb Smirnoff uint8_t ifi_addrlen; /* media address length */ 79b245f96cSGleb Smirnoff uint8_t ifi_hdrlen; /* media header length */ 80b245f96cSGleb Smirnoff uint8_t ifi_link_state; /* current link state */ 81b245f96cSGleb Smirnoff uint8_t ifi_vhid; /* carp vhid */ 82b245f96cSGleb Smirnoff uint16_t ifi_datalen; /* length of this data struct */ 83b245f96cSGleb Smirnoff uint32_t ifi_mtu; /* maximum transmission unit */ 84b245f96cSGleb Smirnoff uint32_t ifi_metric; /* routing metric (external only) */ 85b245f96cSGleb Smirnoff uint64_t ifi_baudrate; /* linespeed */ 86df8bae1dSRodney W. Grimes /* volatile statistics */ 87b245f96cSGleb Smirnoff uint64_t ifi_ipackets; /* packets received on interface */ 88b245f96cSGleb Smirnoff uint64_t ifi_ierrors; /* input errors on interface */ 89b245f96cSGleb Smirnoff uint64_t ifi_opackets; /* packets sent on interface */ 90b245f96cSGleb Smirnoff uint64_t ifi_oerrors; /* output errors on interface */ 91b245f96cSGleb Smirnoff uint64_t ifi_collisions; /* collisions on csma interfaces */ 92b245f96cSGleb Smirnoff uint64_t ifi_ibytes; /* total number of octets received */ 93b245f96cSGleb Smirnoff uint64_t ifi_obytes; /* total number of octets sent */ 94b245f96cSGleb Smirnoff uint64_t ifi_imcasts; /* packets received via multicast */ 95b245f96cSGleb Smirnoff uint64_t ifi_omcasts; /* packets sent via multicast */ 96b245f96cSGleb Smirnoff uint64_t ifi_iqdrops; /* dropped on input */ 97b245f96cSGleb Smirnoff uint64_t ifi_oqdrops; /* dropped on output */ 98b245f96cSGleb Smirnoff uint64_t ifi_noproto; /* destined for unsupported protocol */ 991b4381afSAndre Oppermann uint64_t ifi_hwassist; /* HW offload capabilities, see IFCAP */ 100b245f96cSGleb Smirnoff 101b245f96cSGleb Smirnoff /* Unions are here to make sizes MI. */ 102b245f96cSGleb Smirnoff union { /* uptime at attach or stat reset */ 103b245f96cSGleb Smirnoff time_t tt; 104b245f96cSGleb Smirnoff uint64_t ph; 105b245f96cSGleb Smirnoff } __ifi_epoch; 106b245f96cSGleb Smirnoff #define ifi_epoch __ifi_epoch.tt 107b245f96cSGleb Smirnoff union { /* time of last administrative change */ 108b245f96cSGleb Smirnoff struct timeval tv; 109b245f96cSGleb Smirnoff struct { 110b245f96cSGleb Smirnoff uint64_t ph1; 111b245f96cSGleb Smirnoff uint64_t ph2; 112b245f96cSGleb Smirnoff } ph; 113b245f96cSGleb Smirnoff } __ifi_lastchange; 114b245f96cSGleb Smirnoff #define ifi_lastchange __ifi_lastchange.tv 1156f64074eSJoerg Wunsch }; 1166f64074eSJoerg Wunsch 117fc574570SRobert Watson /*- 118292ee7beSRobert Watson * Interface flags are of two types: network stack owned flags, and driver 119292ee7beSRobert Watson * owned flags. Historically, these values were stored in the same ifnet 120292ee7beSRobert Watson * flags field, but with the advent of fine-grained locking, they have been 121292ee7beSRobert Watson * broken out such that the network stack is responsible for synchronizing 122292ee7beSRobert Watson * the stack-owned fields, and the device driver the device-owned fields. 123292ee7beSRobert Watson * Both halves can perform lockless reads of the other half's field, subject 124292ee7beSRobert Watson * to accepting the involved races. 125292ee7beSRobert Watson * 126292ee7beSRobert Watson * Both sets of flags come from the same number space, and should not be 127292ee7beSRobert Watson * permitted to conflict, as they are exposed to user space via a single 128292ee7beSRobert Watson * field. 129292ee7beSRobert Watson * 130fc574570SRobert Watson * The following symbols identify read and write requirements for fields: 131fc574570SRobert Watson * 132fc574570SRobert Watson * (i) if_flags field set by device driver before attach, read-only there 133fc574570SRobert Watson * after. 134fc574570SRobert Watson * (n) if_flags field written only by the network stack, read by either the 135fc574570SRobert Watson * stack or driver. 136fc574570SRobert Watson * (d) if_drv_flags field written only by the device driver, read by either 137fc574570SRobert Watson * the stack or driver. 138292ee7beSRobert Watson */ 139fc574570SRobert Watson #define IFF_UP 0x1 /* (n) interface is up */ 140fc574570SRobert Watson #define IFF_BROADCAST 0x2 /* (i) broadcast address valid */ 141fc574570SRobert Watson #define IFF_DEBUG 0x4 /* (n) turn on debugging */ 142fc574570SRobert Watson #define IFF_LOOPBACK 0x8 /* (i) is a loopback net */ 143fc574570SRobert Watson #define IFF_POINTOPOINT 0x10 /* (i) is a point-to-point link */ 144a6b55ee6SGleb Smirnoff #define IFF_NEEDSEPOCH 0x20 /* (i) calls if_input w/o net epoch */ 145fc574570SRobert Watson #define IFF_DRV_RUNNING 0x40 /* (d) resources allocated */ 146fc574570SRobert Watson #define IFF_NOARP 0x80 /* (n) no address resolution protocol */ 147fc574570SRobert Watson #define IFF_PROMISC 0x100 /* (n) receive all packets */ 148fc574570SRobert Watson #define IFF_ALLMULTI 0x200 /* (n) receive all multicast packets */ 149fc574570SRobert Watson #define IFF_DRV_OACTIVE 0x400 /* (d) tx hardware queue is full */ 150fc574570SRobert Watson #define IFF_SIMPLEX 0x800 /* (i) can't hear own transmissions */ 151df8bae1dSRodney W. Grimes #define IFF_LINK0 0x1000 /* per link layer defined bit */ 152df8bae1dSRodney W. Grimes #define IFF_LINK1 0x2000 /* per link layer defined bit */ 153df8bae1dSRodney W. Grimes #define IFF_LINK2 0x4000 /* per link layer defined bit */ 15437be1da8SGarrett Wollman #define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ 155fc574570SRobert Watson #define IFF_MULTICAST 0x8000 /* (i) supports multicast */ 1566e3cb000SWeongyo Jeong #define IFF_CANTCONFIG 0x10000 /* (i) unconfigurable using ioctl(2) */ 157fc574570SRobert Watson #define IFF_PPROMISC 0x20000 /* (n) user-requested promisc mode */ 158fc574570SRobert Watson #define IFF_MONITOR 0x40000 /* (n) user-requested monitor mode */ 159fc574570SRobert Watson #define IFF_STATICARP 0x80000 /* (n) static ARP */ 160c9a5c48aSKonrad Sewiłło-Jopek #define IFF_STICKYARP 0x100000 /* (n) sticky ARP */ 161242a8e72SRobert Watson #define IFF_DYING 0x200000 /* (n) interface is winding down */ 1625428776eSJohn Baldwin #define IFF_RENAMING 0x400000 /* (n) interface is being renamed */ 163*58f19422SMark Johnston #define IFF_PALLMULTI 0x800000 /* (n) user-requested allmulti mode */ 1641bcd230fSAlexander V. Chernikov #define IFF_NETLINK_1 0x1000000 /* (n) used by netlink */ 16509f6ff4fSMatt Macy 166292ee7beSRobert Watson /* 167292ee7beSRobert Watson * Old names for driver flags so that user space tools can continue to use 168fc574570SRobert Watson * the old (portable) names. 169292ee7beSRobert Watson */ 170292ee7beSRobert Watson #ifndef _KERNEL 171292ee7beSRobert Watson #define IFF_RUNNING IFF_DRV_RUNNING 172292ee7beSRobert Watson #define IFF_OACTIVE IFF_DRV_OACTIVE 173292ee7beSRobert Watson #endif 174292ee7beSRobert Watson 175df8bae1dSRodney W. Grimes /* flags set internally only: */ 176df8bae1dSRodney W. Grimes #define IFF_CANTCHANGE \ 177292ee7beSRobert Watson (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\ 178af50ea38SGleb Smirnoff IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC|\ 179a6b55ee6SGleb Smirnoff IFF_DYING|IFF_CANTCONFIG|IFF_NEEDSEPOCH) 180df8bae1dSRodney W. Grimes 181bb68f0afSSam Leffler /* 182127d7b2dSAndre Oppermann * Values for if_link_state. 183127d7b2dSAndre Oppermann */ 184127d7b2dSAndre Oppermann #define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */ 185127d7b2dSAndre Oppermann #define LINK_STATE_DOWN 1 /* link is down */ 186127d7b2dSAndre Oppermann #define LINK_STATE_UP 2 /* link is up */ 187127d7b2dSAndre Oppermann 188127d7b2dSAndre Oppermann /* 189bb68f0afSSam Leffler * Some convenience macros used for setting ifi_baudrate. 190bb68f0afSSam Leffler * XXX 1000 vs. 1024? --thorpej@netbsd.org 191bb68f0afSSam Leffler */ 192608ae712SMaksim Yevmenkin #define IF_Kbps(x) ((uintmax_t)(x) * 1000) /* kilobits/sec. */ 193bb68f0afSSam Leffler #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */ 194bb68f0afSSam Leffler #define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */ 195bb68f0afSSam Leffler 19660d4ab7aSAndre Oppermann /* 19760d4ab7aSAndre Oppermann * Capabilities that interfaces can advertise. 19860d4ab7aSAndre Oppermann * 19960d4ab7aSAndre Oppermann * struct ifnet.if_capabilities 20060d4ab7aSAndre Oppermann * contains the optional features & capabilities a particular interface 20160d4ab7aSAndre Oppermann * supports (not only the driver but also the detected hw revision). 20260d4ab7aSAndre Oppermann * Capabilities are defined by IFCAP_* below. 203d562befcSYaroslav Tykhiy * struct ifnet.if_capenable 20460d4ab7aSAndre Oppermann * contains the enabled (either by default or through ifconfig) optional 20560d4ab7aSAndre Oppermann * features & capabilities on this interface. 20660d4ab7aSAndre Oppermann * Capabilities are defined by IFCAP_* below. 20760d4ab7aSAndre Oppermann * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above 20860d4ab7aSAndre Oppermann * contains the enabled optional feature & capabilites that can be used 20960d4ab7aSAndre Oppermann * individually per packet and are specified in the mbuf pkthdr.csum_flags 21060d4ab7aSAndre Oppermann * field. IFCAP_* and CSUM_* do not match one to one and CSUM_* may be 211cefdb895SKonstantin Belousov * more detailed or differentiated than IFCAP_*. 21260d4ab7aSAndre Oppermann * Hwassist features are defined CSUM_* in sys/mbuf.h 213c9d658e9SLuigi Rizzo * 214c9d658e9SLuigi Rizzo * Capabilities that cannot be arbitrarily changed with ifconfig/ioctl 215c9d658e9SLuigi Rizzo * are listed in IFCAP_CANTCHANGE, similar to IFF_CANTCHANGE. 216c9d658e9SLuigi Rizzo * This is not strictly necessary because the common code never 217c9d658e9SLuigi Rizzo * changes capabilities, and it is left to the individual driver 218c9d658e9SLuigi Rizzo * to do the right thing. However, having the filter here 219c9d658e9SLuigi Rizzo * avoids replication of the same code in all individual drivers. 22060d4ab7aSAndre Oppermann */ 221c344eff9SAlexander V. Chernikov 222c344eff9SAlexander V. Chernikov /* IFCAP values as bit indexes */ 223c344eff9SAlexander V. Chernikov 224c344eff9SAlexander V. Chernikov #define IFCAP_B_RXCSUM 0 /* can offload checksum on RX */ 225c344eff9SAlexander V. Chernikov #define IFCAP_B_TXCSUM 1 /* can offload checksum on TX */ 226c344eff9SAlexander V. Chernikov #define IFCAP_B_NETCONS 2 /* can be a network console */ 227c344eff9SAlexander V. Chernikov #define IFCAP_B_VLAN_MTU 3 /* VLAN-compatible MTU */ 228c344eff9SAlexander V. Chernikov #define IFCAP_B_VLAN_HWTAGGING 4 /* hardware VLAN tag support */ 229c344eff9SAlexander V. Chernikov #define IFCAP_B_JUMBO_MTU 5 /* 9000 byte MTU supported */ 230c344eff9SAlexander V. Chernikov #define IFCAP_B_POLLING 6 /* driver supports polling */ 231c344eff9SAlexander V. Chernikov #define IFCAP_B_VLAN_HWCSUM 7 /* can do IFCAP_HWCSUM on VLANs */ 232c344eff9SAlexander V. Chernikov #define IFCAP_B_TSO4 8 /* can do TCP Segmentation Offload */ 233c344eff9SAlexander V. Chernikov #define IFCAP_B_TSO6 9 /* can do TCP6 Segmentation Offload */ 234c344eff9SAlexander V. Chernikov #define IFCAP_B_LRO 10 /* can do Large Receive Offload */ 235c344eff9SAlexander V. Chernikov #define IFCAP_B_WOL_UCAST 11 /* wake on any unicast frame */ 236c344eff9SAlexander V. Chernikov #define IFCAP_B_WOL_MCAST 12 /* wake on any multicast frame */ 237c344eff9SAlexander V. Chernikov #define IFCAP_B_WOL_MAGIC 13 /* wake on any Magic Packet */ 238c344eff9SAlexander V. Chernikov #define IFCAP_B_TOE4 14 /* interface can offload TCP */ 239c344eff9SAlexander V. Chernikov #define IFCAP_B_TOE6 15 /* interface can offload TCP6 */ 240c344eff9SAlexander V. Chernikov #define IFCAP_B_VLAN_HWFILTER 16 /* interface hw can filter vlan tag */ 241c344eff9SAlexander V. Chernikov #define IFCAP_B_NV 17 /* can do SIOCGIFCAPNV/SIOCSIFCAPNV */ 242c344eff9SAlexander V. Chernikov #define IFCAP_B_VLAN_HWTSO 18 /* can do IFCAP_TSO on VLANs */ 243c344eff9SAlexander V. Chernikov #define IFCAP_B_LINKSTATE 19 /* the runtime link state is dynamic */ 244c344eff9SAlexander V. Chernikov #define IFCAP_B_NETMAP 20 /* netmap mode supported/enabled */ 245c344eff9SAlexander V. Chernikov #define IFCAP_B_RXCSUM_IPV6 21 /* can offload checksum on IPv6 RX */ 246c344eff9SAlexander V. Chernikov #define IFCAP_B_TXCSUM_IPV6 22 /* can offload checksum on IPv6 TX */ 247c344eff9SAlexander V. Chernikov #define IFCAP_B_HWSTATS 23 /* manages counters internally */ 248c344eff9SAlexander V. Chernikov #define IFCAP_B_TXRTLMT 24 /* hardware supports TX rate limiting */ 249c344eff9SAlexander V. Chernikov #define IFCAP_B_HWRXTSTMP 25 /* hardware rx timestamping */ 250c344eff9SAlexander V. Chernikov #define IFCAP_B_MEXTPG 26 /* understands M_EXTPG mbufs */ 251c344eff9SAlexander V. Chernikov #define IFCAP_B_TXTLS4 27 /* can do TLS encryption and segmentation for TCP */ 252c344eff9SAlexander V. Chernikov #define IFCAP_B_TXTLS6 28 /* can do TLS encryption and segmentation for TCP6 */ 253c344eff9SAlexander V. Chernikov #define IFCAP_B_VXLAN_HWCSUM 29 /* can do IFCAN_HWCSUM on VXLANs */ 254c344eff9SAlexander V. Chernikov #define IFCAP_B_VXLAN_HWTSO 30 /* can do IFCAP_TSO on VXLANs */ 255c344eff9SAlexander V. Chernikov #define IFCAP_B_TXTLS_RTLMT 31 /* can do TLS with rate limiting */ 256c344eff9SAlexander V. Chernikov #define IFCAP_B_RXTLS4 32 /* can to TLS receive for TCP */ 257c344eff9SAlexander V. Chernikov #define IFCAP_B_RXTLS6 33 /* can to TLS receive for TCP6 */ 2582131654bSKonstantin Belousov #define IFCAP_B_IPSEC_OFFLOAD 34 /* inline IPSEC offload */ 2592131654bSKonstantin Belousov #define __IFCAP_B_SIZE 35 260c344eff9SAlexander V. Chernikov 261c344eff9SAlexander V. Chernikov #define IFCAP_B_MAX (__IFCAP_B_MAX - 1) 262c344eff9SAlexander V. Chernikov #define IFCAP_B_SIZE (__IFCAP_B_SIZE) 263c344eff9SAlexander V. Chernikov 264c344eff9SAlexander V. Chernikov #define IFCAP_BIT(x) (1 << (x)) 265c344eff9SAlexander V. Chernikov 266c344eff9SAlexander V. Chernikov #define IFCAP_RXCSUM IFCAP_BIT(IFCAP_B_RXCSUM) 267c344eff9SAlexander V. Chernikov #define IFCAP_TXCSUM IFCAP_BIT(IFCAP_B_TXCSUM) 268c344eff9SAlexander V. Chernikov #define IFCAP_NETCONS IFCAP_BIT(IFCAP_B_NETCONS) 269c344eff9SAlexander V. Chernikov #define IFCAP_VLAN_MTU IFCAP_BIT(IFCAP_B_VLAN_MTU) 270c344eff9SAlexander V. Chernikov #define IFCAP_VLAN_HWTAGGING IFCAP_BIT(IFCAP_B_VLAN_HWTAGGING) 271c344eff9SAlexander V. Chernikov #define IFCAP_JUMBO_MTU IFCAP_BIT(IFCAP_B_JUMBO_MTU) 272c344eff9SAlexander V. Chernikov #define IFCAP_POLLING IFCAP_BIT(IFCAP_B_POLLING) 273c344eff9SAlexander V. Chernikov #define IFCAP_VLAN_HWCSUM IFCAP_BIT(IFCAP_B_VLAN_HWCSUM) 274c344eff9SAlexander V. Chernikov #define IFCAP_TSO4 IFCAP_BIT(IFCAP_B_TSO4) 275c344eff9SAlexander V. Chernikov #define IFCAP_TSO6 IFCAP_BIT(IFCAP_B_TSO6) 276c344eff9SAlexander V. Chernikov #define IFCAP_LRO IFCAP_BIT(IFCAP_B_LRO) 277c344eff9SAlexander V. Chernikov #define IFCAP_WOL_UCAST IFCAP_BIT(IFCAP_B_WOL_UCAST) 278c344eff9SAlexander V. Chernikov #define IFCAP_WOL_MCAST IFCAP_BIT(IFCAP_B_WOL_MCAST) 279c344eff9SAlexander V. Chernikov #define IFCAP_WOL_MAGIC IFCAP_BIT(IFCAP_B_WOL_MAGIC) 280c344eff9SAlexander V. Chernikov #define IFCAP_TOE4 IFCAP_BIT(IFCAP_B_TOE4) 281c344eff9SAlexander V. Chernikov #define IFCAP_TOE6 IFCAP_BIT(IFCAP_B_TOE6) 282c344eff9SAlexander V. Chernikov #define IFCAP_VLAN_HWFILTER IFCAP_BIT(IFCAP_B_VLAN_HWFILTER) 283c344eff9SAlexander V. Chernikov #define IFCAP_NV IFCAP_BIT(IFCAP_B_NV) 284c344eff9SAlexander V. Chernikov #define IFCAP_VLAN_HWTSO IFCAP_BIT(IFCAP_B_VLAN_HWTSO) 285c344eff9SAlexander V. Chernikov #define IFCAP_LINKSTATE IFCAP_BIT(IFCAP_B_LINKSTATE) 286c344eff9SAlexander V. Chernikov #define IFCAP_NETMAP IFCAP_BIT(IFCAP_B_NETMAP) 287c344eff9SAlexander V. Chernikov #define IFCAP_RXCSUM_IPV6 IFCAP_BIT(IFCAP_B_RXCSUM_IPV6) 288c344eff9SAlexander V. Chernikov #define IFCAP_TXCSUM_IPV6 IFCAP_BIT(IFCAP_B_TXCSUM_IPV6) 289c344eff9SAlexander V. Chernikov #define IFCAP_HWSTATS IFCAP_BIT(IFCAP_B_HWSTATS) 290c344eff9SAlexander V. Chernikov #define IFCAP_TXRTLMT IFCAP_BIT(IFCAP_B_TXRTLMT) 291c344eff9SAlexander V. Chernikov #define IFCAP_HWRXTSTMP IFCAP_BIT(IFCAP_B_HWRXTSTMP) 292c344eff9SAlexander V. Chernikov #define IFCAP_MEXTPG IFCAP_BIT(IFCAP_B_MEXTPG) 293c344eff9SAlexander V. Chernikov #define IFCAP_TXTLS4 IFCAP_BIT(IFCAP_B_TXTLS4) 294c344eff9SAlexander V. Chernikov #define IFCAP_TXTLS6 IFCAP_BIT(IFCAP_B_TXTLS6) 295c344eff9SAlexander V. Chernikov #define IFCAP_VXLAN_HWCSUM IFCAP_BIT(IFCAP_B_VXLAN_HWCSUM) 296c344eff9SAlexander V. Chernikov #define IFCAP_VXLAN_HWTSO IFCAP_BIT(IFCAP_B_VXLAN_HWTSO) 297c344eff9SAlexander V. Chernikov #define IFCAP_TXTLS_RTLMT IFCAP_BIT(IFCAP_B_TXTLS_RTLMT) 298356ab07eSBjoern A. Zeeb 299eb1da3e5SJustin Hibbits /* IFCAP2_* are integers, not bits. */ 300c344eff9SAlexander V. Chernikov #define IFCAP2_RXTLS4 (IFCAP_B_RXTLS4 - 32) 301c344eff9SAlexander V. Chernikov #define IFCAP2_RXTLS6 (IFCAP_B_RXTLS6 - 32) 3022131654bSKonstantin Belousov #define IFCAP2_IPSEC_OFFLOAD (IFCAP_B_IPSEC_OFFLOAD - 32) 30301143ba1SKonstantin Belousov 30401143ba1SKonstantin Belousov #define IFCAP2_BIT(x) (1UL << (x)) 3056a311e6fSKonstantin Belousov 306356ab07eSBjoern A. Zeeb #define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6) 307f7d86692SJonathan Lemon 308f7d86692SJonathan Lemon #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) 309233dcce1SAndre Oppermann #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) 310de0abf19SSam Leffler #define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) 3114c908c35SKip Macy #define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6) 312b2e60773SJohn Baldwin #define IFCAP_TXTLS (IFCAP_TXTLS4 | IFCAP_TXTLS6) 313016da741SJonathan Lemon 314051e7d78SKonstantin Belousov #define IFCAP_CANTCHANGE (IFCAP_NETMAP | IFCAP_NV) 315051e7d78SKonstantin Belousov #define IFCAP_ALLCAPS 0xffffffff 316051e7d78SKonstantin Belousov 317df8bae1dSRodney W. Grimes #define IFQ_MAXLEN 50 318df8bae1dSRodney W. Grimes #define IFNET_SLOWHZ 1 /* granularity is 1 second */ 319df8bae1dSRodney W. Grimes 320df8bae1dSRodney W. Grimes /* 321df8bae1dSRodney W. Grimes * Message format for use in obtaining information about interfaces 322df8bae1dSRodney W. Grimes * from getkerninfo and the routing socket 3236d076ae8SBjoern A. Zeeb * For the new, extensible interface see struct if_msghdrl below. 324df8bae1dSRodney W. Grimes */ 325df8bae1dSRodney W. Grimes struct if_msghdr { 326df8bae1dSRodney W. Grimes u_short ifm_msglen; /* to skip over non-understood messages */ 3272fa72ea7SJeroen Ruigrok van der Werven u_char ifm_version; /* future binary compatibility */ 328df8bae1dSRodney W. Grimes u_char ifm_type; /* message type */ 329df8bae1dSRodney W. Grimes int ifm_addrs; /* like rtm_addrs */ 330df8bae1dSRodney W. Grimes int ifm_flags; /* value of if_flags */ 331df8bae1dSRodney W. Grimes u_short ifm_index; /* index for associated ifp */ 332d25f8522SMark Johnston u_short _ifm_spare1; 333df8bae1dSRodney W. Grimes struct if_data ifm_data;/* statistics and other data about if */ 334df8bae1dSRodney W. Grimes }; 335df8bae1dSRodney W. Grimes 336df8bae1dSRodney W. Grimes /* 3376d076ae8SBjoern A. Zeeb * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL. It is 3386d076ae8SBjoern A. Zeeb * extensible after ifm_data_off or within ifm_data. Both the if_msghdr and 3396d076ae8SBjoern A. Zeeb * if_data now have a member field detailing the struct length in addition to 3406d076ae8SBjoern A. Zeeb * the routing message length. Macros are provided to find the start of 341a2fcd3afSGordon Bergling * ifm_data and the start of the socket address structures immediately following 3426d076ae8SBjoern A. Zeeb * struct if_msghdrl given a pointer to struct if_msghdrl. 3436d076ae8SBjoern A. Zeeb */ 3446d076ae8SBjoern A. Zeeb #define IF_MSGHDRL_IFM_DATA(_l) \ 3456d076ae8SBjoern A. Zeeb (struct if_data *)((char *)(_l) + (_l)->ifm_data_off) 3466d076ae8SBjoern A. Zeeb #define IF_MSGHDRL_RTA(_l) \ 3476d076ae8SBjoern A. Zeeb (void *)((uintptr_t)(_l) + (_l)->ifm_len) 3486d076ae8SBjoern A. Zeeb struct if_msghdrl { 3496d076ae8SBjoern A. Zeeb u_short ifm_msglen; /* to skip over non-understood messages */ 3506d076ae8SBjoern A. Zeeb u_char ifm_version; /* future binary compatibility */ 3516d076ae8SBjoern A. Zeeb u_char ifm_type; /* message type */ 3526d076ae8SBjoern A. Zeeb int ifm_addrs; /* like rtm_addrs */ 3536d076ae8SBjoern A. Zeeb int ifm_flags; /* value of if_flags */ 3546d076ae8SBjoern A. Zeeb u_short ifm_index; /* index for associated ifp */ 3556d076ae8SBjoern A. Zeeb u_short _ifm_spare1; /* spare space to grow if_index, see if_var.h */ 3566d076ae8SBjoern A. Zeeb u_short ifm_len; /* length of if_msghdrl incl. if_data */ 3576d076ae8SBjoern A. Zeeb u_short ifm_data_off; /* offset of if_data from beginning */ 358d25f8522SMark Johnston int _ifm_spare2; 3596d076ae8SBjoern A. Zeeb struct if_data ifm_data;/* statistics and other data about if */ 3606d076ae8SBjoern A. Zeeb }; 3616d076ae8SBjoern A. Zeeb 3626d076ae8SBjoern A. Zeeb /* 363df8bae1dSRodney W. Grimes * Message format for use in obtaining information about interface addresses 364df8bae1dSRodney W. Grimes * from getkerninfo and the routing socket 3656d076ae8SBjoern A. Zeeb * For the new, extensible interface see struct ifa_msghdrl below. 366df8bae1dSRodney W. Grimes */ 367df8bae1dSRodney W. Grimes struct ifa_msghdr { 368df8bae1dSRodney W. Grimes u_short ifam_msglen; /* to skip over non-understood messages */ 3692fa72ea7SJeroen Ruigrok van der Werven u_char ifam_version; /* future binary compatibility */ 370df8bae1dSRodney W. Grimes u_char ifam_type; /* message type */ 371df8bae1dSRodney W. Grimes int ifam_addrs; /* like rtm_addrs */ 372df8bae1dSRodney W. Grimes int ifam_flags; /* value of ifa_flags */ 373df8bae1dSRodney W. Grimes u_short ifam_index; /* index for associated ifp */ 374d25f8522SMark Johnston u_short _ifam_spare1; 3759753faf5SGleb Smirnoff int ifam_metric; /* value of ifa_ifp->if_metric */ 376df8bae1dSRodney W. Grimes }; 377df8bae1dSRodney W. Grimes 378df8bae1dSRodney W. Grimes /* 3796d076ae8SBjoern A. Zeeb * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL. It is 3806d076ae8SBjoern A. Zeeb * extensible after ifam_metric or within ifam_data. Both the ifa_msghdrl and 3816d076ae8SBjoern A. Zeeb * if_data now have a member field detailing the struct length in addition to 3826d076ae8SBjoern A. Zeeb * the routing message length. Macros are provided to find the start of 383a2fcd3afSGordon Bergling * ifm_data and the start of the socket address structures immediately following 3846d076ae8SBjoern A. Zeeb * struct ifa_msghdrl given a pointer to struct ifa_msghdrl. 3856d076ae8SBjoern A. Zeeb */ 3866d076ae8SBjoern A. Zeeb #define IFA_MSGHDRL_IFAM_DATA(_l) \ 3876d076ae8SBjoern A. Zeeb (struct if_data *)((char *)(_l) + (_l)->ifam_data_off) 3886d076ae8SBjoern A. Zeeb #define IFA_MSGHDRL_RTA(_l) \ 3896d076ae8SBjoern A. Zeeb (void *)((uintptr_t)(_l) + (_l)->ifam_len) 3906d076ae8SBjoern A. Zeeb struct ifa_msghdrl { 3916d076ae8SBjoern A. Zeeb u_short ifam_msglen; /* to skip over non-understood messages */ 3926d076ae8SBjoern A. Zeeb u_char ifam_version; /* future binary compatibility */ 3936d076ae8SBjoern A. Zeeb u_char ifam_type; /* message type */ 3946d076ae8SBjoern A. Zeeb int ifam_addrs; /* like rtm_addrs */ 3956d076ae8SBjoern A. Zeeb int ifam_flags; /* value of ifa_flags */ 3966d076ae8SBjoern A. Zeeb u_short ifam_index; /* index for associated ifp */ 3976d076ae8SBjoern A. Zeeb u_short _ifam_spare1; /* spare space to grow if_index, see if_var.h */ 3986d076ae8SBjoern A. Zeeb u_short ifam_len; /* length of ifa_msghdrl incl. if_data */ 3996d076ae8SBjoern A. Zeeb u_short ifam_data_off; /* offset of if_data from beginning */ 4009753faf5SGleb Smirnoff int ifam_metric; /* value of ifa_ifp->if_metric */ 4016d076ae8SBjoern A. Zeeb struct if_data ifam_data;/* statistics and other data about if or 4026d076ae8SBjoern A. Zeeb * address */ 4036d076ae8SBjoern A. Zeeb }; 4046d076ae8SBjoern A. Zeeb 4056d076ae8SBjoern A. Zeeb /* 406477180fbSGarrett Wollman * Message format for use in obtaining information about multicast addresses 407477180fbSGarrett Wollman * from the routing socket 408477180fbSGarrett Wollman */ 409477180fbSGarrett Wollman struct ifma_msghdr { 410477180fbSGarrett Wollman u_short ifmam_msglen; /* to skip over non-understood messages */ 4112fa72ea7SJeroen Ruigrok van der Werven u_char ifmam_version; /* future binary compatibility */ 412477180fbSGarrett Wollman u_char ifmam_type; /* message type */ 413477180fbSGarrett Wollman int ifmam_addrs; /* like rtm_addrs */ 414477180fbSGarrett Wollman int ifmam_flags; /* value of ifa_flags */ 415477180fbSGarrett Wollman u_short ifmam_index; /* index for associated ifp */ 416d25f8522SMark Johnston u_short _ifmam_spare1; 417477180fbSGarrett Wollman }; 418477180fbSGarrett Wollman 419477180fbSGarrett Wollman /* 4207b6edd04SRuslan Ermilov * Message format announcing the arrival or departure of a network interface. 4217b6edd04SRuslan Ermilov */ 4227b6edd04SRuslan Ermilov struct if_announcemsghdr { 4237b6edd04SRuslan Ermilov u_short ifan_msglen; /* to skip over non-understood messages */ 4247b6edd04SRuslan Ermilov u_char ifan_version; /* future binary compatibility */ 4257b6edd04SRuslan Ermilov u_char ifan_type; /* message type */ 4267b6edd04SRuslan Ermilov u_short ifan_index; /* index for associated ifp */ 4277b6edd04SRuslan Ermilov char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 4287b6edd04SRuslan Ermilov u_short ifan_what; /* what type of announcement */ 4297b6edd04SRuslan Ermilov }; 4307b6edd04SRuslan Ermilov 4317b6edd04SRuslan Ermilov #define IFAN_ARRIVAL 0 /* interface arrival */ 4327b6edd04SRuslan Ermilov #define IFAN_DEPARTURE 1 /* interface departure */ 4337b6edd04SRuslan Ermilov 4347b6edd04SRuslan Ermilov /* 435215940b3SXin LI * Buffer with length to be used in SIOCGIFDESCR/SIOCSIFDESCR requests 436215940b3SXin LI */ 437215940b3SXin LI struct ifreq_buffer { 438215940b3SXin LI size_t length; 439215940b3SXin LI void *buffer; 440215940b3SXin LI }; 441215940b3SXin LI 442051e7d78SKonstantin Belousov struct ifreq_nv_req { 443051e7d78SKonstantin Belousov u_int buf_length; /* Total size of buffer, 444051e7d78SKonstantin Belousov u_int for ABI struct ifreq */ 445051e7d78SKonstantin Belousov u_int length; /* Length of the filled part */ 446051e7d78SKonstantin Belousov void *buffer; /* Buffer itself, containing packed nv */ 447051e7d78SKonstantin Belousov }; 448051e7d78SKonstantin Belousov 449051e7d78SKonstantin Belousov #define IFR_CAP_NV_MAXBUFSIZE (2 * 1024 * 1024) 450051e7d78SKonstantin Belousov 451215940b3SXin LI /* 452df8bae1dSRodney W. Grimes * Interface request structure used for socket 453df8bae1dSRodney W. Grimes * ioctl's. All interface ioctl's must have parameter 454df8bae1dSRodney W. Grimes * definitions which begin with ifr_name. The 455df8bae1dSRodney W. Grimes * remainder may be interface specific. 456df8bae1dSRodney W. Grimes */ 457df8bae1dSRodney W. Grimes struct ifreq { 458df8bae1dSRodney W. Grimes char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 459df8bae1dSRodney W. Grimes union { 460df8bae1dSRodney W. Grimes struct sockaddr ifru_addr; 461df8bae1dSRodney W. Grimes struct sockaddr ifru_dstaddr; 462df8bae1dSRodney W. Grimes struct sockaddr ifru_broadaddr; 463215940b3SXin LI struct ifreq_buffer ifru_buffer; 4644add131eSPoul-Henning Kamp short ifru_flags[2]; 465de593450SJonathan Lemon short ifru_index; 466679e1390SJamie Gritton int ifru_jid; 467df8bae1dSRodney W. Grimes int ifru_metric; 468a7028af7SDavid Greenman int ifru_mtu; 469074c4a4eSGarrett Wollman int ifru_phys; 470a912e453SPeter Wemm int ifru_media; 471df8bae1dSRodney W. Grimes caddr_t ifru_data; 472016da741SJonathan Lemon int ifru_cap[2]; 47335fd7bc0SBjoern A. Zeeb u_int ifru_fib; 4742ccbbd06SMarcelo Araujo u_char ifru_vlan_pcp; 475051e7d78SKonstantin Belousov struct ifreq_nv_req ifru_nv; 476df8bae1dSRodney W. Grimes } ifr_ifru; 477df8bae1dSRodney W. Grimes #define ifr_addr ifr_ifru.ifru_addr /* address */ 478df8bae1dSRodney W. Grimes #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ 479df8bae1dSRodney W. Grimes #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ 48086d2ef16SBrooks Davis #ifndef _KERNEL 481215940b3SXin LI #define ifr_buffer ifr_ifru.ifru_buffer /* user supplied buffer with its length */ 48286d2ef16SBrooks Davis #endif 48362f76486SMaxim Sobolev #define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */ 48462f76486SMaxim Sobolev #define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */ 485679e1390SJamie Gritton #define ifr_jid ifr_ifru.ifru_jid /* jail/vnet */ 486df8bae1dSRodney W. Grimes #define ifr_metric ifr_ifru.ifru_metric /* metric */ 487a7028af7SDavid Greenman #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ 488511cdd16SDavid Greenman #define ifr_phys ifr_ifru.ifru_phys /* physical wire */ 489a912e453SPeter Wemm #define ifr_media ifr_ifru.ifru_media /* physical media */ 490541d96aaSBrooks Davis #ifndef _KERNEL 491df8bae1dSRodney W. Grimes #define ifr_data ifr_ifru.ifru_data /* for use by interface */ 492541d96aaSBrooks Davis #endif 493016da741SJonathan Lemon #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ 494016da741SJonathan Lemon #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ 495de593450SJonathan Lemon #define ifr_index ifr_ifru.ifru_index /* interface index */ 49635fd7bc0SBjoern A. Zeeb #define ifr_fib ifr_ifru.ifru_fib /* interface fib */ 4972ccbbd06SMarcelo Araujo #define ifr_vlan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */ 498f1379734SKonstantin Belousov #define ifr_lan_pcp ifr_ifru.ifru_vlan_pcp /* VLAN priority */ 499051e7d78SKonstantin Belousov #define ifr_cap_nv ifr_ifru.ifru_nv /* nv-based cap interface */ 500df8bae1dSRodney W. Grimes }; 501df8bae1dSRodney W. Grimes 502906f09bcSGarrett Wollman #define _SIZEOF_ADDR_IFREQ(ifr) \ 503906f09bcSGarrett Wollman ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ 504906f09bcSGarrett Wollman (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ 505906f09bcSGarrett Wollman (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) 506906f09bcSGarrett Wollman 507df8bae1dSRodney W. Grimes struct ifaliasreq { 508df8bae1dSRodney W. Grimes char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 509df8bae1dSRodney W. Grimes struct sockaddr ifra_addr; 510df8bae1dSRodney W. Grimes struct sockaddr ifra_broadaddr; 511df8bae1dSRodney W. Grimes struct sockaddr ifra_mask; 51208b68b0eSGleb Smirnoff int ifra_vhid; 513df8bae1dSRodney W. Grimes }; 514df8bae1dSRodney W. Grimes 51577b89ad8SGleb Smirnoff /* 9.x compat */ 51677b89ad8SGleb Smirnoff struct oifaliasreq { 51777b89ad8SGleb Smirnoff char ifra_name[IFNAMSIZ]; 51877b89ad8SGleb Smirnoff struct sockaddr ifra_addr; 51977b89ad8SGleb Smirnoff struct sockaddr ifra_broadaddr; 52077b89ad8SGleb Smirnoff struct sockaddr ifra_mask; 52177b89ad8SGleb Smirnoff }; 52277b89ad8SGleb Smirnoff 523a912e453SPeter Wemm struct ifmediareq { 524a912e453SPeter Wemm char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 525a912e453SPeter Wemm int ifm_current; /* current media options */ 526a912e453SPeter Wemm int ifm_mask; /* don't care mask */ 527a912e453SPeter Wemm int ifm_status; /* media status */ 528a912e453SPeter Wemm int ifm_active; /* active options */ 529a912e453SPeter Wemm int ifm_count; /* # entries in ifm_ulist array */ 530a912e453SPeter Wemm int *ifm_ulist; /* media words */ 531a912e453SPeter Wemm }; 532413dd0baSPoul-Henning Kamp 5338f867517SAndrew Thompson struct ifdrv { 5348f867517SAndrew Thompson char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 5358f867517SAndrew Thompson unsigned long ifd_cmd; 5368f867517SAndrew Thompson size_t ifd_len; 5378f867517SAndrew Thompson void *ifd_data; 5388f867517SAndrew Thompson }; 5398f867517SAndrew Thompson 540413dd0baSPoul-Henning Kamp /* 541413dd0baSPoul-Henning Kamp * Structure used to retrieve aux status data from interfaces. 542712020a1SBruce Evans * Kernel suppliers to this interface should respect the formatting 543413dd0baSPoul-Henning Kamp * needed by ifconfig(8): each line starts with a TAB and ends with 544712020a1SBruce Evans * a newline. The canonical example to copy and paste is in if_tun.c. 545413dd0baSPoul-Henning Kamp */ 546413dd0baSPoul-Henning Kamp 547413dd0baSPoul-Henning Kamp #define IFSTATMAX 800 /* 10 lines of text */ 548413dd0baSPoul-Henning Kamp struct ifstat { 549413dd0baSPoul-Henning Kamp char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 550413dd0baSPoul-Henning Kamp char ascii[IFSTATMAX + 1]; 551413dd0baSPoul-Henning Kamp }; 552413dd0baSPoul-Henning Kamp 553df8bae1dSRodney W. Grimes /* 554df8bae1dSRodney W. Grimes * Structure used in SIOCGIFCONF request. 555df8bae1dSRodney W. Grimes * Used to retrieve interface configuration 556df8bae1dSRodney W. Grimes * for machine (useful for programs which 557df8bae1dSRodney W. Grimes * must know all networks accessible). 558df8bae1dSRodney W. Grimes */ 559df8bae1dSRodney W. Grimes struct ifconf { 560df8bae1dSRodney W. Grimes int ifc_len; /* size of associated buffer */ 561df8bae1dSRodney W. Grimes union { 562df8bae1dSRodney W. Grimes caddr_t ifcu_buf; 563df8bae1dSRodney W. Grimes struct ifreq *ifcu_req; 564df8bae1dSRodney W. Grimes } ifc_ifcu; 565df8bae1dSRodney W. Grimes #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ 566df8bae1dSRodney W. Grimes #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ 567df8bae1dSRodney W. Grimes }; 568df8bae1dSRodney W. Grimes 56976429de4SYoshinobu Inoue /* 5700dad3f0eSMax Laier * interface groups 5710dad3f0eSMax Laier */ 5720dad3f0eSMax Laier 5730dad3f0eSMax Laier #define IFG_ALL "all" /* group contains all interfaces */ 5740dad3f0eSMax Laier /* XXX: will we implement this? */ 5750dad3f0eSMax Laier #define IFG_EGRESS "egress" /* if(s) default route(s) point to */ 5760dad3f0eSMax Laier 5770dad3f0eSMax Laier struct ifg_req { 5780dad3f0eSMax Laier union { 5790dad3f0eSMax Laier char ifgrqu_group[IFNAMSIZ]; 5800dad3f0eSMax Laier char ifgrqu_member[IFNAMSIZ]; 5810dad3f0eSMax Laier } ifgrq_ifgrqu; 5820dad3f0eSMax Laier #define ifgrq_group ifgrq_ifgrqu.ifgrqu_group 5830dad3f0eSMax Laier #define ifgrq_member ifgrq_ifgrqu.ifgrqu_member 5840dad3f0eSMax Laier }; 5850dad3f0eSMax Laier 5860dad3f0eSMax Laier /* 5870dad3f0eSMax Laier * Used to lookup groups for an interface 5880dad3f0eSMax Laier */ 5890dad3f0eSMax Laier struct ifgroupreq { 5900dad3f0eSMax Laier char ifgr_name[IFNAMSIZ]; 5910dad3f0eSMax Laier u_int ifgr_len; 5920dad3f0eSMax Laier union { 5930dad3f0eSMax Laier char ifgru_group[IFNAMSIZ]; 5940dad3f0eSMax Laier struct ifg_req *ifgru_groups; 5950dad3f0eSMax Laier } ifgr_ifgru; 5960dad3f0eSMax Laier #define ifgr_group ifgr_ifgru.ifgru_group 5970dad3f0eSMax Laier #define ifgr_groups ifgr_ifgru.ifgru_groups 5980dad3f0eSMax Laier }; 5990dad3f0eSMax Laier 600ea463f2dSAlexander V. Chernikov /* 601ea463f2dSAlexander V. Chernikov * Structure used to request i2c data 602ea463f2dSAlexander V. Chernikov * from interface transceivers. 603ea463f2dSAlexander V. Chernikov */ 604ea463f2dSAlexander V. Chernikov struct ifi2creq { 605ea463f2dSAlexander V. Chernikov uint8_t dev_addr; /* i2c address (0xA0, 0xA2) */ 606ea463f2dSAlexander V. Chernikov uint8_t offset; /* read offset */ 607ea463f2dSAlexander V. Chernikov uint8_t len; /* read length */ 608ea463f2dSAlexander V. Chernikov uint8_t spare0; 609ea463f2dSAlexander V. Chernikov uint32_t spare1; 610ea463f2dSAlexander V. Chernikov uint8_t data[8]; /* read buffer */ 611ea463f2dSAlexander V. Chernikov }; 612ea463f2dSAlexander V. Chernikov 6130f3af041SSepherosa Ziehau /* 6140f3af041SSepherosa Ziehau * RSS hash. 6150f3af041SSepherosa Ziehau */ 6160f3af041SSepherosa Ziehau 6170f3af041SSepherosa Ziehau #define RSS_FUNC_NONE 0 /* RSS disabled */ 6180f3af041SSepherosa Ziehau #define RSS_FUNC_PRIVATE 1 /* non-standard */ 6190f3af041SSepherosa Ziehau #define RSS_FUNC_TOEPLITZ 2 6200f3af041SSepherosa Ziehau 6210f3af041SSepherosa Ziehau #define RSS_TYPE_IPV4 0x00000001 6220f3af041SSepherosa Ziehau #define RSS_TYPE_TCP_IPV4 0x00000002 6230f3af041SSepherosa Ziehau #define RSS_TYPE_IPV6 0x00000004 6240f3af041SSepherosa Ziehau #define RSS_TYPE_IPV6_EX 0x00000008 6250f3af041SSepherosa Ziehau #define RSS_TYPE_TCP_IPV6 0x00000010 6260f3af041SSepherosa Ziehau #define RSS_TYPE_TCP_IPV6_EX 0x00000020 6270f3af041SSepherosa Ziehau #define RSS_TYPE_UDP_IPV4 0x00000040 6280f3af041SSepherosa Ziehau #define RSS_TYPE_UDP_IPV6 0x00000080 6290f3af041SSepherosa Ziehau #define RSS_TYPE_UDP_IPV6_EX 0x00000100 6300f3af041SSepherosa Ziehau 6310f3af041SSepherosa Ziehau #define RSS_KEYLEN 128 6320f3af041SSepherosa Ziehau 6330f3af041SSepherosa Ziehau struct ifrsskey { 6340f3af041SSepherosa Ziehau char ifrk_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 6350f3af041SSepherosa Ziehau uint8_t ifrk_func; /* RSS_FUNC_ */ 6360f3af041SSepherosa Ziehau uint8_t ifrk_spare0; 6370f3af041SSepherosa Ziehau uint16_t ifrk_keylen; 6380f3af041SSepherosa Ziehau uint8_t ifrk_key[RSS_KEYLEN]; 6390f3af041SSepherosa Ziehau }; 6400f3af041SSepherosa Ziehau 6410f3af041SSepherosa Ziehau struct ifrsshash { 6420f3af041SSepherosa Ziehau char ifrh_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 6430f3af041SSepherosa Ziehau uint8_t ifrh_func; /* RSS_FUNC_ */ 6440f3af041SSepherosa Ziehau uint8_t ifrh_spare0; 6450f3af041SSepherosa Ziehau uint16_t ifrh_spare1; 6460f3af041SSepherosa Ziehau uint32_t ifrh_types; /* RSS_TYPE_ */ 6470f3af041SSepherosa Ziehau }; 6480f3af041SSepherosa Ziehau 649f1379734SKonstantin Belousov #define IFNET_PCP_NONE 0xff /* PCP disabled */ 650f1379734SKonstantin Belousov 651247cf566SKonstantin Belousov #define IFDR_MSG_SIZE 64 652247cf566SKonstantin Belousov #define IFDR_REASON_MSG 1 653247cf566SKonstantin Belousov #define IFDR_REASON_VENDOR 2 654247cf566SKonstantin Belousov struct ifdownreason { 655247cf566SKonstantin Belousov char ifdr_name[IFNAMSIZ]; 656247cf566SKonstantin Belousov uint32_t ifdr_reason; 657247cf566SKonstantin Belousov uint32_t ifdr_vendor; 658247cf566SKonstantin Belousov char ifdr_msg[IFDR_MSG_SIZE]; 659247cf566SKonstantin Belousov }; 660247cf566SKonstantin Belousov 661f2ba8326SMike Barcroft #endif /* __BSD_VISIBLE */ 662f2ba8326SMike Barcroft 663be4315dcSJustin Hibbits /* 664be4315dcSJustin Hibbits * Opaque interface structure. 665be4315dcSJustin Hibbits */ 666be4315dcSJustin Hibbits 667be4315dcSJustin Hibbits typedef struct ifnet *if_t; 668be4315dcSJustin Hibbits 66911905a0bSJustin Hibbits #ifdef _KERNEL 67011905a0bSJustin Hibbits #ifdef MALLOC_DECLARE 67111905a0bSJustin Hibbits MALLOC_DECLARE(M_IFADDR); 67211905a0bSJustin Hibbits MALLOC_DECLARE(M_IFMADDR); 67311905a0bSJustin Hibbits #endif 67411905a0bSJustin Hibbits 6756d2a10d9SKristof Provost extern struct sx ifnet_detach_sxlock; 6766d2a10d9SKristof Provost 677051e7d78SKonstantin Belousov struct nvlist; 678051e7d78SKonstantin Belousov struct ifcap_nv_bit_name; 679051e7d78SKonstantin Belousov int if_capnv_to_capint(const struct nvlist *nv, int *old_cap, 680051e7d78SKonstantin Belousov const struct ifcap_nv_bit_name *nn, bool all); 681051e7d78SKonstantin Belousov void if_capint_to_capnv(struct nvlist *nv, 682051e7d78SKonstantin Belousov const struct ifcap_nv_bit_name *nn, int ifr_cap, int ifr_req); 683051e7d78SKonstantin Belousov struct siocsifcapnv_driver_data { 684051e7d78SKonstantin Belousov int reqcap; 685051e7d78SKonstantin Belousov int reqcap2; 686051e7d78SKonstantin Belousov struct nvlist *nvcap; 687051e7d78SKonstantin Belousov }; 688a1c995b6SPoul-Henning Kamp #endif 689a1c995b6SPoul-Henning Kamp 690664a31e4SPeter Wemm #ifndef _KERNEL 69176429de4SYoshinobu Inoue struct if_nameindex { 692f2ba8326SMike Barcroft unsigned int if_index; /* 1, 2, ... */ 69376429de4SYoshinobu Inoue char *if_name; /* null terminated name: "le0", ... */ 69476429de4SYoshinobu Inoue }; 69576429de4SYoshinobu Inoue 69676429de4SYoshinobu Inoue __BEGIN_DECLS 697edfcad95SMike Barcroft void if_freenameindex(struct if_nameindex *); 698f2ba8326SMike Barcroft char *if_indextoname(unsigned int, char *); 699929ddbbbSAlfred Perlstein struct if_nameindex *if_nameindex(void); 700edfcad95SMike Barcroft unsigned int if_nametoindex(const char *); 70176429de4SYoshinobu Inoue __END_DECLS 70276429de4SYoshinobu Inoue #endif 703df708ff1SBruce Evans #endif /* !_NET_IF_H_ */ 704