1.\" -*- Nroff -*- 2.\" Copyright 1996, 1997 Massachusetts Institute of Technology 3.\" 4.\" Permission to use, copy, modify, and distribute this software and 5.\" its documentation for any purpose and without fee is hereby 6.\" granted, provided that both the above copyright notice and this 7.\" permission notice appear in all copies, that both the above 8.\" copyright notice and this permission notice appear in all 9.\" supporting documentation, and that the name of M.I.T. not be used 10.\" in advertising or publicity pertaining to distribution of the 11.\" software without specific, written prior permission. M.I.T. makes 12.\" no representations about the suitability of this software for any 13.\" purpose. It is provided "as is" without express or implied 14.\" warranty. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 17.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 18.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 20.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 23.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" $FreeBSD$ 30.\" 31.Dd March 20, 2012 32.Dt IFNET 9 33.Os 34.Sh NAME 35.Nm ifnet , 36.Nm ifaddr , 37.Nm ifqueue , 38.Nm if_data 39.Nd kernel interfaces for manipulating network interfaces 40.Sh SYNOPSIS 41.In sys/param.h 42.In sys/time.h 43.In sys/socket.h 44.In net/if.h 45.In net/if_var.h 46.In net/if_types.h 47.\" 48.Ss "Interface Manipulation Functions" 49.Ft "struct ifnet *" 50.Fn if_alloc "u_char type" 51.Ft void 52.Fn if_attach "struct ifnet *ifp" 53.Ft void 54.Fn if_detach "struct ifnet *ifp" 55.Ft void 56.Fn if_free "struct ifnet *ifp" 57.Ft void 58.Fn if_free_type "struct ifnet *ifp" "u_char type" 59.Ft void 60.Fn if_down "struct ifnet *ifp" 61.Ft int 62.Fn ifioctl "struct socket *so" "u_long cmd" "caddr_t data" "struct thread *td" 63.Ft int 64.Fn ifpromisc "struct ifnet *ifp" "int pswitch" 65.Ft int 66.Fn if_allmulti "struct ifnet *ifp" "int amswitch" 67.Ft "struct ifnet *" 68.Fn ifunit "const char *name" 69.Ft "struct ifnet *" 70.Fn ifunit_ref "const char *name" 71.Ft void 72.Fn if_up "struct ifnet *ifp" 73.\" 74.Ss "Interface Address Functions" 75.Ft "struct ifaddr *" 76.Fn ifaddr_byindex "u_short idx" 77.Ft "struct ifaddr *" 78.Fn ifa_ifwithaddr "struct sockaddr *addr" 79.Ft "struct ifaddr *" 80.Fn ifa_ifwithdstaddr "struct sockaddr *addr" 81.Ft "struct ifaddr *" 82.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp" 83.Ft "struct ifaddr *" 84.Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp" 85.Ft void 86.Fn ifa_ref "struct ifaddr *ifa" 87.Ft void 88.Fn ifa_free "struct ifaddr *ifa" 89.\" 90.Ss "Interface Multicast Address Functions" 91.Ft int 92.Fn if_addmulti "struct ifnet *ifp" "struct sockaddr *sa" "struct ifmultiaddr **ifmap" 93.Ft int 94.Fn if_delmulti "struct ifnet *ifp" "struct sockaddr *sa" 95.Ft "struct ifmultiaddr *" 96.Fn if_findmulti "struct ifnet *ifp" "struct sockaddr *sa" 97.Ss "Output queue macros" 98.Fn IF_DEQUEUE "struct ifqueue *ifq" "struct mbuf *m" 99.\" 100.Ss "struct ifnet Member Functions" 101.Ft void 102.Fn \*(lp*if_input\*(rp "struct ifnet *ifp" "struct mbuf *m" 103.Ft int 104.Fo \*(lp*if_output\*(rp 105.Fa "struct ifnet *ifp" "struct mbuf *m" 106.Fa "struct sockaddr *dst" "struct route *ro" 107.Fc 108.Ft void 109.Fn \*(lp*if_start\*(rp "struct ifnet *ifp" 110.Ft int 111.Fn \*(lp*if_transmit\*(rp "struct ifnet *ifp" "struct mbuf *m" 112.Ft void 113.Fn \*(lp*if_qflush\*(rp "struct ifnet *ifp" 114.Ft int 115.Fn \*(lp*if_ioctl\*(rp "struct ifnet *ifp" "u_long cmd" "caddr_t data" 116.Ft void 117.Fn \*(lp*if_init\*(rp "void *if_softc" 118.Ft int 119.Fo \*(lp*if_resolvemulti\*(rp 120.Fa "struct ifnet *ifp" "struct sockaddr **retsa" "struct sockaddr *addr" 121.Fc 122.Ss "struct ifaddr member function" 123.Ft void 124.Fo \*(lp*ifa_rtrequest\*(rp 125.Fa "int cmd" "struct rtentry *rt" "struct rt_addrinfo *info" 126.Fc 127.\" 128.Ss "Global Variables" 129.Vt extern struct ifnethead ifnet ; 130.\" extern struct ifindex_entry *ifindex_table ; 131.Vt extern int if_index ; 132.Vt extern int ifqmaxlen ; 133.Sh DATA STRUCTURES 134The kernel mechanisms for handling network interfaces reside primarily 135in the 136.Vt ifnet , if_data , ifaddr , 137and 138.Vt ifmultiaddr 139structures in 140.In net/if.h 141and 142.In net/if_var.h 143and the functions named above and defined in 144.Pa /sys/net/if.c . 145Those interfaces which are intended to be used by user programs 146are defined in 147.In net/if.h ; 148these include the interface flags, the 149.Vt if_data 150structure, and the structures defining the appearance of 151interface-related messages on the 152.Xr route 4 153routing socket and in 154.Xr sysctl 3 . 155The header file 156.In net/if_var.h 157defines the kernel-internal interfaces, including the 158.Vt ifnet , ifaddr , 159and 160.Vt ifmultiaddr 161structures and the functions which manipulate them. 162(A few user programs will need 163.In net/if_var.h 164because it is the prerequisite of some other header file like 165.In netinet/if_ether.h . 166Most references to those two files in particular can be replaced by 167.In net/ethernet.h . ) 168.Pp 169The system keeps a linked list of interfaces using the 170.Li TAILQ 171macros defined in 172.Xr queue 3 ; 173this list is headed by a 174.Vt "struct ifnethead" 175called 176.Va ifnet . 177The elements of this list are of type 178.Vt "struct ifnet" , 179and most kernel routines which manipulate interface as such accept or 180return pointers to these structures. 181Each interface structure 182contains an 183.Vt if_data 184structure used for statistics and information. 185Each interface also has a 186.Li TAILQ 187of interface addresses, described by 188.Vt ifaddr 189structures. 190An 191.Dv AF_LINK 192address 193(see 194.Xr link_addr 3 ) 195describing the link layer implemented by the interface (if any) 196is accessed by the 197.Fn ifaddr_byindex 198function or 199.Va if_addr 200structure. 201(Some trivial interfaces do not provide any link layer addresses; 202this structure, while still present, serves only to identify the 203interface name and index.) 204.Pp 205Finally, those interfaces supporting reception of multicast datagrams 206have a 207.Li TAILQ 208of multicast group memberships, described by 209.Vt ifmultiaddr 210structures. 211These memberships are reference-counted. 212.Pp 213Interfaces are also associated with an output queue, defined as a 214.Vt "struct ifqueue" ; 215this structure is used to hold packets while the interface is in the 216process of sending another. 217.Pp 218.Ss The Vt ifnet Ss structure 219The fields of 220.Vt "struct ifnet" 221are as follows: 222.Bl -tag -width ".Va if_capabilities" -offset indent 223.It Va if_softc 224.Pq Vt "void *" 225A pointer to the driver's private state block. 226(Initialized by driver.) 227.It Va if_l2com 228.Pq Vt "void *" 229A pointer to the common data for the interface's layer 2 protocol. 230(Initialized by 231.Fn if_alloc . ) 232.It Va if_vnet 233.Pq Vt "struct vnet *" 234A pointer to the virtual network stack instance. 235(Initialized by 236.Fn if_attach . ) 237.It Va if_home_vnet 238.Pq Vt "struct vnet *" 239A pointer to the parent virtual network stack, where this 240.Vt "struct ifnet" 241originates from. 242(Initialized by 243.Fn if_attach . ) 244.It Va if_link 245.Pq Fn TAILQ_ENTRY ifnet 246.Xr queue 3 247macro glue. 248.It Va if_xname 249.Pq Vt "char *" 250The name of the interface, 251(e.g., 252.Dq Li fxp0 253or 254.Dq Li lo0 ) . 255(Initialized by driver 256(usually via 257.Fn if_initname ) . ) 258.It Va if_dname 259.Pq Vt "const char *" 260The name of the driver. 261(Initialized by driver 262(usually via 263.Fn if_initname ) . ) 264.It Va if_dunit 265.Pq Vt int 266A unique number assigned to each interface managed by a particular 267driver. 268Drivers may choose to set this to 269.Dv IF_DUNIT_NONE 270if a unit number is not associated with the device. 271(Initialized by driver 272(usually via 273.Fn if_initname ) . ) 274.It Va if_refcount 275.Pq Vt u_int 276The reference count. 277(Initialized by 278.Fn if_alloc . ) 279.It Va if_addrhead 280.Pq Vt "struct ifaddrhead" 281The head of the 282.Xr queue 3 283.Li TAILQ 284containing the list of addresses assigned to this interface. 285.It Va if_pcount 286.Pq Vt int 287A count of promiscuous listeners on this interface, used to 288reference-count the 289.Dv IFF_PROMISC 290flag. 291.It Va if_carp 292.Pq Vt "struct carp_if *" 293A pointer to the CARP interface structure, 294.Xr carp 4 . 295(Initialized by the driver-specific 296.Fn if_ioctl 297routine.) 298.It Va if_bpf 299.Pq Vt "struct bpf_if *" 300Opaque per-interface data for the packet filter, 301.Xr bpf 4 . 302(Initialized by 303.Fn bpf_attach . ) 304.It Va if_index 305.Pq Vt u_short 306A unique number assigned to each interface in sequence as it is 307attached. 308This number can be used in a 309.Vt "struct sockaddr_dl" 310to refer to a particular interface by index 311(see 312.Xr link_addr 3 ) . 313(Initialized by 314.Fn if_alloc . ) 315.It Va if_vlantrunk 316.Pq Vt struct ifvlantrunk * 317A pointer to 802.1Q trunk structure, 318.Xr vlan 4 . 319(Initialized by the driver-specific 320.Fn if_ioctl 321routine.) 322.It Va if_flags 323.Pq Vt int 324Flags describing operational parameters of this interface (see below). 325(Manipulated by generic code.) 326.It Va if_drv_flags 327.Pq Vt int 328Flags describing operational status of this interface (see below). 329(Manipulated by driver.) 330.It Va if_capabilities 331.Pq Vt int 332Flags describing the capabilities the interface supports (see below). 333.It Va if_capenable 334.Pq Vt int 335Flags describing the enabled capabilities of the interface (see below). 336.It Va if_linkmib 337.Pq Vt "void *" 338A pointer to an interface-specific MIB structure exported by 339.Xr ifmib 4 . 340(Initialized by driver.) 341.It Va if_linkmiblen 342.Pq Vt size_t 343The size of said structure. 344(Initialized by driver.) 345.It Va if_data 346.Pq Vt "struct if_data" 347More statistics and information; see 348.Sx "The if_data structure" , 349below. 350(Initialized by driver, manipulated by both driver and generic 351code.) 352.It Va if_multiaddrs 353.Pq Vt struct ifmultihead 354The head of the 355.Xr queue 3 356.Li TAILQ 357containing the list of multicast addresses assigned to this interface. 358.It Va if_amcount 359.Pq Vt int 360A number of multicast requests on this interface, used to 361reference-count the 362.Dv IFF_ALLMULTI 363flag. 364.It Va if_addr 365.Pq Vt "struct ifaddr *" 366A pointer to the link-level interface address. 367(Initialized by 368.Fn if_alloc . ) 369.\" .It Va if_llsoftc 370.\" .Pq Vt "void *" 371.\" The purpose of the field is unclear. 372.It Va if_snd 373.Pq Vt "struct ifaltq" 374The output queue. 375(Manipulated by driver.) 376.It Va if_broadcastaddr 377.Pq Vt "const u_int8_t *" 378A link-level broadcast bytestring for protocols with variable address 379length. 380.It Va if_bridge 381.Pq Vt "void *" 382A pointer to the bridge interface structure, 383.Xr if_bridge 4 . 384(Initialized by the driver-specific 385.Fn if_ioctl 386routine.) 387.It Va if_label 388.Pq Vt "struct label *" 389A pointer to the MAC Framework label structure, 390.Xr mac 4 . 391(Initialized by 392.Fn if_alloc . ) 393.It Va if_afdata 394.Pq Vt "void *" 395An address family dependent data region. 396.It Va if_afdata_initialized 397.Pq Vt int 398Used to track the current state of address family initialization. 399.It Va if_afdata_lock 400.Pq Vt "struct rwlock" 401An 402.Xr rwlock 9 403lock used to protect 404.Va if_afdata 405internals. 406.It Va if_linktask 407.Pq Vt "struct task" 408A 409.Xr taskqueue 9 410task scheduled for link state change events of the interface. 411.It Va if_addr_lock 412.Pq Vt "struct rwlock" 413An 414.Xr rwlock 9 415lock used to protect interface-related address lists. 416.It Va if_clones 417.Pq Fn LIST_ENTRY ifnet 418.Xr queue 3 419macro glue for the list of clonable network interfaces. 420.It Va if_groups 421.Pq Fn TAILQ_HEAD ", ifg_list" 422The head of the 423.Xr queue 3 424.Li TAILQ 425containing the list of groups per interface. 426.It Va if_pf_kif 427.Pq Vt "void *" 428A pointer to the structure used for interface abstraction by 429.Xr pf 4 . 430.It Va if_lagg 431.Pq Vt "void *" 432A pointer to the 433.Xr lagg 4 434interface structure. 435.It Va if_alloctype 436.Pq Vt u_char 437The type of the interface as it was at the time of its allocation. 438It is used to cache the type passed to 439.Fn if_alloc , 440but unlike 441.Va if_type , 442it would not be changed by drivers. 443.El 444.Pp 445References to 446.Vt ifnet 447structures are gained by calling the 448.Fn if_ref 449function and released by calling the 450.Fn if_rele 451function. 452They are used to allow kernel code walking global interface lists 453to release the 454.Vt ifnet 455lock yet keep the 456.Vt ifnet 457structure stable. 458.Pp 459There are in addition a number of function pointers which the driver 460must initialize to complete its interface with the generic interface 461layer: 462.Bl -ohang -offset indent 463.It Fn if_input 464Pass a packet to an appropriate upper layer as determined 465from the link-layer header of the packet. 466This routine is to be called from an interrupt handler or 467used to emulate reception of a packet on this interface. 468A single function implementing 469.Fn if_input 470can be shared among multiple drivers utilizing the same link-layer 471framing, e.g., Ethernet. 472.It Fn if_output 473Output a packet on interface 474.Fa ifp , 475or queue it on the output queue if the interface is already active. 476.It Fn if_transmit 477Transmit a packet on an interface or queue it if the interface is 478in use. 479This function will return 480.Dv ENOBUFS 481if the devices software and hardware queues are both full. 482This function must be installed after 483.Fn if_attach 484to override the default implementation. 485This function is exposed in order to allow drivers to manage their own queues 486and to reduce the latency caused by a frequently gratuitous enqueue / dequeue 487pair to ifq. 488The suggested internal software queueing mechanism is buf_ring. 489.It Fn if_qflush 490Free mbufs in internally managed queues when the interface is marked down. 491This function must be installed after 492.Fn if_attach 493to override the default implementation. 494This function is exposed in order to allow drivers to manage their own queues 495and to reduce the latency caused by a frequently gratuitous enqueue / dequeue 496pair to ifq. 497The suggested internal software queueing mechanism is buf_ring. 498.It Fn if_start 499Start queued output on an interface. 500This function is exposed in 501order to provide for some interface classes to share a 502.Fn if_output 503among all drivers. 504.Fn if_start 505may only be called when the 506.Dv IFF_DRV_OACTIVE 507flag is not set. 508(Thus, 509.Dv IFF_DRV_OACTIVE 510does not literally mean that output is active, but rather that the 511device's internal output queue is full.) Please note that this function 512will soon be deprecated. 513.It Fn if_ioctl 514Process interface-related 515.Xr ioctl 2 516requests 517(defined in 518.In sys/sockio.h ) . 519Preliminary processing is done by the generic routine 520.Fn ifioctl 521to check for appropriate privileges, locate the interface being 522manipulated, and perform certain generic operations like twiddling 523flags and flushing queues. 524See the description of 525.Fn ifioctl 526below for more information. 527.It Fn if_init 528Initialize and bring up the hardware, 529e.g., reset the chip and enable the receiver unit. 530Should mark the interface running, 531but not active 532.Dv ( IFF_DRV_RUNNING , ~IIF_DRV_OACTIVE ) . 533.It Fn if_resolvemulti 534Check the requested multicast group membership, 535.Fa addr , 536for validity, and if necessary compute a link-layer group which 537corresponds to that address which is returned in 538.Fa *retsa . 539Returns zero on success, or an error code on failure. 540.El 541.Ss "Interface Flags" 542Interface flags are used for a number of different purposes. 543Some 544flags simply indicate information about the type of interface and its 545capabilities; others are dynamically manipulated to reflect the 546current state of the interface. 547Flags of the former kind are marked 548.Aq S 549in this table; the latter are marked 550.Aq D . 551Flags which begin with 552.Dq IFF_DRV_ 553are stored in 554.Va if_drv_flags ; 555all other flags are stored in 556.Va if_flags . 557.Pp 558The macro 559.Dv IFF_CANTCHANGE 560defines the bits which cannot be set by a user program using the 561.Dv SIOCSIFFLAGS 562command to 563.Xr ioctl 2 ; 564these are indicated by an asterisk 565.Pq Ql * 566in the following listing. 567.Pp 568.Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact 569.It Dv IFF_UP 570.Aq D 571The interface has been configured up by the user-level code. 572.It Dv IFF_BROADCAST 573.Aq S* 574The interface supports broadcast. 575.It Dv IFF_DEBUG 576.Aq D 577Used to enable/disable driver debugging code. 578.It Dv IFF_LOOPBACK 579.Aq S 580The interface is a loopback device. 581.It Dv IFF_POINTOPOINT 582.Aq S* 583The interface is point-to-point; 584.Dq broadcast 585address is actually the address of the other end. 586.It Dv IFF_DRV_RUNNING 587.Aq D* 588The interface has been configured and dynamic resources were 589successfully allocated. 590Probably only useful internal to the 591interface. 592.It Dv IFF_NOARP 593.Aq D 594Disable network address resolution on this interface. 595.It Dv IFF_PROMISC 596.Aq D* 597This interface is in promiscuous mode. 598.It Dv IFF_PPROMISC 599.Aq D 600This interface is in the permanently promiscuous mode (implies 601.Dv IFF_PROMISC ) . 602.It Dv IFF_ALLMULTI 603.Aq D* 604This interface is in all-multicasts mode (used by multicast routers). 605.It Dv IFF_DRV_OACTIVE 606.Aq D* 607The interface's hardware output queue (if any) is full; output packets 608are to be queued. 609.It Dv IFF_SIMPLEX 610.Aq S* 611The interface cannot hear its own transmissions. 612.It Dv IFF_LINK0 613.It Dv IFF_LINK1 614.It Dv IFF_LINK2 615.Aq D 616Control flags for the link layer. 617(Currently abused to select among 618multiple physical layers on some devices.) 619.It Dv IFF_MULTICAST 620.Aq S* 621This interface supports multicast. 622.It Dv IFF_POLLING 623.Aq D* 624The interface is in 625.Xr polling 4 626mode. 627See 628.Sx Interface Capabilities Flags 629for details. 630.El 631.Ss "Interface Capabilities Flags" 632Interface capabilities are specialized features an interface may 633or may not support. 634These capabilities are very hardware-specific 635and allow, when enabled, 636to offload specific network processing to the interface 637or to offer a particular feature for use by other kernel parts. 638.Pp 639It should be stressed that a capability can be completely 640uncontrolled (i.e., stay always enabled with no way to disable it) 641or allow limited control over itself (e.g., depend on another 642capability's state.) 643Such peculiarities are determined solely by the hardware and driver 644of a particular interface. 645Only the driver possesses 646the knowledge on whether and how the interface capabilities 647can be controlled. 648Consequently, capabilities flags in 649.Va if_capenable 650should never be modified directly by kernel code other than 651the interface driver. 652The command 653.Dv SIOCSIFCAP 654to 655.Fn ifioctl 656is the dedicated means to attempt altering 657.Va if_capenable 658on an interface. 659Userland code shall use 660.Xr ioctl 2 . 661.Pp 662The following capabilities are currently supported by the system: 663.Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent 664.It Dv IFCAP_NETCONS 665This interface can be a network console. 666.It Dv IFCAP_POLLING 667This interface supports 668.Xr polling 4 . 669See below for details. 670.It Dv IFCAP_RXCSUM 671This interface can do checksum validation on receiving data. 672Some interfaces do not have sufficient buffer storage to store frames 673above a certain MTU-size completely. 674The driver for the interface might disable hardware checksum validation 675if the MTU is set above the hardcoded limit. 676.It Dv IFCAP_TXCSUM 677This interface can do checksum calculation on transmitting data. 678.It Dv IFCAP_HWCSUM 679A shorthand for 680.Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM . 681.It Dv IFCAP_VLAN_HWTAGGING 682This interface can do VLAN tagging on output and 683demultiplex frames by their VLAN tag on input. 684.It Dv IFCAP_VLAN_MTU 685The 686.Xr vlan 4 687driver can operate over this interface in software tagging mode 688without having to decrease MTU on 689.Xr vlan 4 690interfaces below 1500 bytes. 691This implies the ability of this interface to cope with frames somewhat 692longer than permitted by the Ethernet specification. 693.It Dv IFCAP_JUMBO_MTU 694This Ethernet interface can transmit and receive frames up to 6959000 bytes long. 696.It Dv IFCAP_TSO4 697This Ethernet interface supports TCP Segmentation offloading. 698.It Dv IFCAP_TSO6 699This Ethernet interface supports TCP6 Segmentation offloading. 700.It Dv IFCAP_TSO 701A shorthand for 702.Pq Dv IFCAP_TSO4 | IFCAP_TSO6 . 703.It Dv IFCAP_TOE4 704This Ethernet interface supports TCP offloading. 705.It Dv IFCAP_TOE6 706This Ethernet interface supports TCP6 offloading. 707.It Dv ICAP_TOE 708A shorthand for 709.Pq Dv IFCAP_TOE4 | IFCAP_TOE6 . 710.It Dv IFCAP_WOL_UCAST 711This Ethernet interface supports waking up on any Unicast packet. 712.It Dv IFCAP_WOL_MCAST 713This Ethernet interface supports waking up on any Multicast packet. 714.It Dv IFCAP_WOL_MAGIC 715This Ethernet interface supports waking up on any Magic packet such 716as those sent by 717.Xr wake 8 . 718.It Dv IFCAP_WOL 719A shorthand for 720.Pq Dv IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC . 721.El 722.Pp 723The ability of advanced network interfaces to offload certain 724computational tasks from the host CPU to the board is limited 725mostly to TCP/IP. 726Therefore a separate field associated with an interface 727(see 728.Va ifnet.if_data.ifi_hwassist 729below) 730keeps a detailed description of its enabled capabilities 731specific to TCP/IP processing. 732The TCP/IP module consults the field to see which tasks 733can be done on an 734.Em outgoing 735packet by the interface. 736The flags defined for that field are a superset of those for 737.Va mbuf.m_pkthdr.csum_flags , 738namely: 739.Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent 740.It Dv CSUM_IP 741The interface will compute IP checksums. 742.It Dv CSUM_TCP 743The interface will compute TCP checksums. 744.It Dv CSUM_UDP 745The interface will compute UDP checksums. 746.It Dv CSUM_IP_FRAGS 747The interface can compute a TCP or UDP checksum for a packet 748fragmented by the host CPU. 749Makes sense only along with 750.Dv CSUM_TCP 751or 752.Dv CSUM_UDP . 753.It Dv CSUM_FRAGMENT 754The interface will do the fragmentation of IP packets if necessary. 755The host CPU does not need to care about MTU on this interface 756as long as a packet to transmit through it is an IP one and it 757does not exceed the size of the hardware buffer. 758.El 759.Pp 760An interface notifies the TCP/IP module about the tasks 761the former has performed on an 762.Em incoming 763packet by setting the corresponding flags in the field 764.Va mbuf.m_pkthdr.csum_flags 765of the 766.Vt mbuf chain 767containing the packet. 768See 769.Xr mbuf 9 770for details. 771.Pp 772The capability of a network interface to operate in 773.Xr polling 4 774mode involves several flags in different 775global variables and per-interface fields. 776First, there is a system-wide 777.Xr sysctl 8 778master switch named 779.Va kern.polling.enable , 780which can toggle 781.Xr polling 4 782globally. 783If that variable is set to non-zero, 784.Xr polling 4 785will be used on those devices where it is enabled individually. 786Otherwise, 787.Xr polling 4 788will not be used in the system. 789Second, the capability flag 790.Dv IFCAP_POLLING 791set in interface's 792.Va if_capabilities 793indicates support for 794.Xr polling 4 795on the particular interface. 796If set in 797.Va if_capabilities , 798the same flag can be marked or cleared in the interface's 799.Va if_capenable , 800thus initiating switch of the interface to 801.Xr polling 4 802mode or interrupt 803mode, respectively. 804The actual mode change will occur at an implementation-specific moment 805in the future, e.g., during the next interrupt or 806.Xr polling 4 807cycle. 808And finally, if the mode transition has been successful, the flag 809.Dv IFF_POLLING 810is marked or cleared in the interface's 811.Va if_flags 812to indicate the current mode of the interface. 813.Ss The Vt if_data Ss Structure 814The 815.Vt if_data 816structure contains statistics and identifying information used 817by management programs, and which is exported to user programs by way 818of the 819.Xr ifmib 4 820branch of the 821.Xr sysctl 3 822MIB. 823The following elements of the 824.Vt if_data 825structure are initialized by the interface and are not expected to change 826significantly over the course of normal operation: 827.Bl -tag -width ".Va ifi_lastchange" -offset indent 828.It Va ifi_type 829.Pq Vt u_char 830The type of the interface, as defined in 831.In net/if_types.h 832and described below in the 833.Sx "Interface Types" 834section. 835.It Va ifi_physical 836.Pq Vt u_char 837Intended to represent a selection of physical layers on devices which 838support more than one; never implemented. 839.It Va ifi_addrlen 840.Pq Vt u_char 841Length of a link-layer address on this device, or zero if there are 842none. 843Used to initialized the address length field in 844.Vt sockaddr_dl 845structures referring to this interface. 846.It Va ifi_hdrlen 847.Pq Vt u_char 848Maximum length of any link-layer header which might be prepended by 849the driver to a packet before transmission. 850The generic code computes 851the maximum over all interfaces and uses that value to influence the 852placement of data in 853.Vt mbuf Ns s 854to attempt to ensure that there is always 855sufficient space to prepend a link-layer header without allocating an 856additional 857.Vt mbuf . 858.\" (See 859.\" .Xr mbuf 9 . ) 860.\" .It Va ifi_recvquota 861.\" .Pq Vt u_char 862.\" Number of packets the interface is permitted to receive at one time 863.\" when in polled mode. 864.\" .It Va ifi_xmitquota 865.\" .Pq Vt u_char 866.\" Number of packets the interface is permitted to queue for transmission 867.\" at one time when in polled mode. 868.\" There is some controversy over 869.\" whether such a restriction makes any sense at all. 870.It Va ifi_datalen 871.Pq Vt u_char 872Length of the 873.Vt if_data 874structure. 875Allows some stabilization of the routing socket ABI in the face of 876increases in the length of 877.Vt struct ifdata . 878.It Va ifi_mtu 879.Pq Vt u_long 880The maximum transmission unit of the medium, exclusive of any 881link-layer overhead. 882.It Va ifi_metric 883.Pq Vt u_long 884A dimensionless metric interpreted by a user-mode routing process. 885.It Va ifi_baudrate 886.Pq Vt u_long 887The line rate of the interface, in bits per second. 888.It Va ifi_hwassist 889.Pq Vt u_long 890A detailed interpretation of the capabilities 891to offload computational tasks for 892.Em outgoing 893packets. 894The interface driver must keep this field in accord with 895the current value of 896.Va if_capenable . 897.It Va ifi_epoch 898.Pq Vt time_t 899The system uptime when interface was attached or the statistics 900below were reset. 901This is intended to be used to set the SNMP variable 902.Va ifCounterDiscontinuityTime . 903It may also be used to determine if two successive queries for an 904interface of the same index have returned results for the same 905interface. 906.El 907.Pp 908The structure additionally contains generic statistics applicable to a 909variety of different interface types (except as noted, all members are 910of type 911.Vt u_long ) : 912.Bl -tag -width ".Va ifi_lastchange" -offset indent 913.It Va ifi_link_state 914.Pq Vt u_char 915The current link state of Ethernet interfaces. 916See the 917.Sx Interface Link States 918section for possible values. 919.It Va ifi_ipackets 920Number of packets received. 921.It Va ifi_ierrors 922Number of receive errors detected (e.g., FCS errors, DMA overruns, 923etc.). 924More detailed breakdowns can often be had by way of a 925link-specific MIB. 926.It Va ifi_opackets 927Number of packets transmitted. 928.It Va ifi_oerrors 929Number of output errors detected (e.g., late collisions, DMA overruns, 930etc.). 931More detailed breakdowns can often be had by way of a 932link-specific MIB. 933.It Va ifi_collisions 934Total number of collisions detected on output for CSMA interfaces. 935(This member is sometimes [ab]used by other types of interfaces for 936other output error counts.) 937.It Va ifi_ibytes 938Total traffic received, in bytes. 939.It Va ifi_obytes 940Total traffic transmitted, in bytes. 941.It Va ifi_imcasts 942Number of packets received which were sent by link-layer multicast. 943.It Va ifi_omcasts 944Number of packets sent by link-layer multicast. 945.It Va ifi_iqdrops 946Number of packets dropped on input. 947Rarely implemented. 948.It Va ifi_noproto 949Number of packets received for unknown network-layer protocol. 950.\" .It Va ifi_recvtiming 951.\" Amount of time, in microseconds, spent to receive an average packet on 952.\" this interface. 953.\" See the 954.\" .Sx Polling 955.\" section, below. 956.\" .It Va ifi_xmittiming 957.\" Amount of time, in microseconds, spent to service a transmit-complete 958.\" interrupt on this interface. 959.\" See the 960.\" .Sx Polling 961.\" section, below. 962.It Va ifi_lastchange 963.Pq Vt "struct timeval" 964The time of the last administrative change to the interface (as required 965for 966.Tn SNMP ) . 967.El 968.Ss Interface Types 969The header file 970.In net/if_types.h 971defines symbolic constants for a number of different types of 972interfaces. 973The most common are: 974.Pp 975.Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact 976.It Dv IFT_OTHER 977none of the following 978.It Dv IFT_ETHER 979Ethernet 980.It Dv IFT_ISO88023 981ISO 8802-3 CSMA/CD 982.It Dv IFT_ISO88024 983ISO 8802-4 Token Bus 984.It Dv IFT_ISO88025 985ISO 8802-5 Token Ring 986.It Dv IFT_ISO88026 987ISO 8802-6 DQDB MAN 988.It Dv IFT_FDDI 989FDDI 990.It Dv IFT_PPP 991Internet Point-to-Point Protocol 992.Pq Xr ppp 8 993.It Dv IFT_LOOP 994The loopback 995.Pq Xr lo 4 996interface 997.It Dv IFT_SLIP 998Serial Line IP 999.It Dv IFT_PARA 1000Parallel-port IP 1001.Pq Dq Tn PLIP 1002.It Dv IFT_ATM 1003Asynchronous Transfer Mode 1004.El 1005.Ss Interface Link States 1006The following link states are currently defined: 1007.Pp 1008.Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact 1009.It Dv LINK_STATE_UNKNOWN 1010The link is in an invalid or unknown state. 1011.It Dv LINK_STATE_DOWN 1012The link is down. 1013.It Dv LINK_STATE_UP 1014The link is up. 1015.El 1016.Ss The Vt ifaddr Ss Structure 1017Every interface is associated with a list 1018(or, rather, a 1019.Li TAILQ ) 1020of addresses, rooted at the interface structure's 1021.Va if_addrlist 1022member. 1023The first element in this list is always an 1024.Dv AF_LINK 1025address representing the interface itself; multi-access network 1026drivers should complete this structure by filling in their link-layer 1027addresses after calling 1028.Fn if_attach . 1029Other members of the structure represent network-layer addresses which 1030have been configured by means of the 1031.Dv SIOCAIFADDR 1032command to 1033.Xr ioctl 2 , 1034called on a socket of the appropriate protocol family. 1035The elements of this list consist of 1036.Vt ifaddr 1037structures. 1038Most protocols will declare their own protocol-specific 1039interface address structures, but all begin with a 1040.Vt "struct ifaddr" 1041which provides the most-commonly-needed functionality across all 1042protocols. 1043Interface addresses are reference-counted. 1044.Pp 1045The members of 1046.Vt "struct ifaddr" 1047are as follows: 1048.Bl -tag -width ".Va ifa_rtrequest" -offset indent 1049.It Va ifa_addr 1050.Pq Vt "struct sockaddr *" 1051The local address of the interface. 1052.It Va ifa_dstaddr 1053.Pq Vt "struct sockaddr *" 1054The remote address of point-to-point interfaces, and the broadcast 1055address of broadcast interfaces. 1056.Va ( ifa_broadaddr 1057is a macro for 1058.Va ifa_dstaddr . ) 1059.It Va ifa_netmask 1060.Pq Vt "struct sockaddr *" 1061The network mask for multi-access interfaces, and the confusion 1062generator for point-to-point interfaces. 1063.It Va ifa_ifp 1064.Pq Vt "struct ifnet *" 1065A link back to the interface structure. 1066.It Va ifa_link 1067.Pq Fn TAILQ_ENTRY ifaddr 1068.Xr queue 3 1069glue for list of addresses on each interface. 1070.It Va ifa_rtrequest 1071See below. 1072.It Va ifa_flags 1073.Pq Vt u_short 1074Some of the flags which would be used for a route representing this 1075address in the route table. 1076.It Va ifa_refcnt 1077.Pq Vt short 1078The reference count. 1079.It Va ifa_metric 1080.Pq Vt int 1081A metric associated with this interface address, for the use of some 1082external routing protocol. 1083.El 1084.Pp 1085References to 1086.Vt ifaddr 1087structures are gained by calling the 1088.Fn ifa_ref 1089function and released by calling the 1090.Fn ifa_free 1091function. 1092.Pp 1093.Fn ifa_rtrequest 1094is a pointer to a function which receives callouts from the routing 1095code 1096.Pq Fn rtrequest 1097to perform link-layer-specific actions upon requests to add, 1098or delete routes. 1099The 1100.Fa cmd 1101argument indicates the request in question: 1102.Dv RTM_ADD , 1103or 1104.Dv RTM_DELETE . 1105The 1106.Fa rt 1107argument is the route in question; the 1108.Fa info 1109argument contains the specific destination being manipulated. 1110.Sh FUNCTIONS 1111The functions provided by the generic interface code can be divided 1112into two groups: those which manipulate interfaces, and those which 1113manipulate interface addresses. 1114In addition to these functions, there 1115may also be link-layer support routines which are used by a number of 1116drivers implementing a specific link layer over different hardware; 1117see the documentation for that link layer for more details. 1118.Ss The Vt ifmultiaddr Ss Structure 1119Every multicast-capable interface is associated with a list of 1120multicast group memberships, which indicate at a low level which 1121link-layer multicast addresses (if any) should be accepted, and at a 1122high level, in which network-layer multicast groups a user process has 1123expressed interest. 1124.Pp 1125The elements of the structure are as follows: 1126.Bl -tag -width ".Va ifma_refcount" -offset indent 1127.It Va ifma_link 1128.Pq Fn LIST_ENTRY ifmultiaddr 1129.Xr queue 3 1130macro glue. 1131.It Va ifma_addr 1132.Pq Vt "struct sockaddr *" 1133A pointer to the address which this record represents. 1134The 1135memberships for various address families are stored in arbitrary 1136order. 1137.It Va ifma_lladdr 1138.Pq Vt "struct sockaddr *" 1139A pointer to the link-layer multicast address, if any, to which the 1140network-layer multicast address in 1141.Va ifma_addr 1142is mapped, else a null pointer. 1143If this element is non-nil, this 1144membership also holds an invisible reference to another membership for 1145that link-layer address. 1146.It Va ifma_refcount 1147.Pq Vt u_int 1148A reference count of requests for this particular membership. 1149.El 1150.Ss Interface Manipulation Functions 1151.Bl -ohang -offset indent 1152.It Fn if_alloc 1153Allocate and initialize 1154.Vt "struct ifnet" . 1155Initialization includes the allocation of an interface index and may 1156include the allocation of a 1157.Fa type 1158specific structure in 1159.Va if_l2com . 1160.It Fn if_attach 1161Link the specified interface 1162.Fa ifp 1163into the list of network interfaces. 1164Also initialize the list of 1165addresses on that interface, and create a link-layer 1166.Vt ifaddr 1167structure to be the first element in that list. 1168(A pointer to 1169this address structure is saved in the 1170.Vt ifnet 1171structure and shall be accessed by the 1172.Fn ifaddr_byindex 1173function.) 1174The 1175.Fa ifp 1176must have been allocated by 1177.Fn if_alloc . 1178.It Fn if_detach 1179Shut down and unlink the specified 1180.Fa ifp 1181from the interface list. 1182.It Fn if_free 1183Free the given 1184.Fa ifp 1185back to the system. 1186The interface must have been previously detached if it was ever attached. 1187.It Fn if_free_type 1188Identical to 1189.Fn if_free 1190except that the given 1191.Fa type 1192is used to free 1193.Va if_l2com 1194instead of the type in 1195.Va if_type . 1196This is intended for use with drivers that change their interface type. 1197.It Fn if_down 1198Mark the interface 1199.Fa ifp 1200as down (i.e., 1201.Dv IFF_UP 1202is not set), 1203flush its output queue, notify protocols of the transition, 1204and generate a message from the 1205.Xr route 4 1206routing socket. 1207.It Fn if_up 1208Mark the interface 1209.Fa ifp 1210as up, notify protocols of the transition, 1211and generate a message from the 1212.Xr route 4 1213routing socket. 1214.It Fn ifpromisc 1215Add or remove a promiscuous reference to 1216.Fa ifp . 1217If 1218.Fa pswitch 1219is true, add a reference; 1220if it is false, remove a reference. 1221On reference count transitions 1222from zero to one and one to zero, set the 1223.Dv IFF_PROMISC 1224flag appropriately and call 1225.Fn if_ioctl 1226to set up the interface in the desired mode. 1227.It Fn if_allmulti 1228As 1229.Fn ifpromisc , 1230but for the all-multicasts 1231.Pq Dv IFF_ALLMULTI 1232flag instead of the promiscuous flag. 1233.It Fn ifunit 1234Return an 1235.Vt ifnet 1236pointer for the interface named 1237.Fa name . 1238.It Fn ifunit_ref 1239Return a reference-counted (via 1240.Fn ifa_ref ) 1241.Vt ifnet 1242pointer for the interface named 1243.Fa name . 1244This is the preferred function over 1245.Fn ifunit . 1246The caller is responsible for releasing the reference with 1247.Fn if_rele 1248when it is finished with the ifnet. 1249.It Fn ifioctl 1250Process the ioctl request 1251.Fa cmd , 1252issued on socket 1253.Fa so 1254by thread 1255.Fa td , 1256with data parameter 1257.Fa data . 1258This is the main routine for handling all interface configuration 1259requests from user mode. 1260It is ordinarily only called from the socket-layer 1261.Xr ioctl 2 1262handler, and only for commands with class 1263.Sq Li i . 1264Any unrecognized commands will be passed down to socket 1265.Fa so Ns 's 1266protocol for 1267further interpretation. 1268The following commands are handled by 1269.Fn ifioctl : 1270.Pp 1271.Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact 1272.It Dv SIOCGIFCONF 1273.It Dv OSIOCGIFCONF 1274Get interface configuration. 1275(No call-down to driver.) 1276.Pp 1277.It Dv SIOCSIFNAME 1278Set the interface name. 1279.Dv RTM_IFANNOUNCE 1280departure and arrival messages are sent so that 1281routing code that relies on the interface name will update its interface 1282list. 1283Caller must have appropriate privilege. 1284(No call-down to driver.) 1285.It Dv SIOCGIFCAP 1286.It Dv SIOCGIFFIB 1287.It Dv SIOCGIFFLAGS 1288.It Dv SIOCGIFMETRIC 1289.It Dv SIOCGIFMTU 1290.It Dv SIOCGIFPHYS 1291Get interface capabilities, FIB, flags, metric, MTU, medium selection. 1292(No call-down to driver.) 1293.Pp 1294.It Dv SIOCSIFCAP 1295Enable or disable interface capabilities. 1296Caller must have appropriate privilege. 1297Before a call to the driver-specific 1298.Fn if_ioctl 1299routine, the requested mask for enabled capabilities is checked 1300against the mask of capabilities supported by the interface, 1301.Va if_capabilities . 1302Requesting to enable an unsupported capability is invalid. 1303The rest is supposed to be done by the driver, 1304which includes updating 1305.Va if_capenable 1306and 1307.Va if_data.ifi_hwassist 1308appropriately. 1309.Pp 1310.It Dv SIOCSIFFIB 1311Sets interface FIB. 1312Caller must have appropriate privilege. 1313FIB values start at 0 and values greater or equals than 1314.Va net.fibs 1315are considered invalid. 1316.It Dv SIOCSIFFLAGS 1317Change interface flags. 1318Caller must have appropriate privilege. 1319If a change to the 1320.Dv IFF_UP 1321flag is requested, 1322.Fn if_up 1323or 1324.Fn if_down 1325is called as appropriate. 1326Flags listed in 1327.Dv IFF_CANTCHANGE 1328are masked off, and the field 1329.Va if_flags 1330in the interface structure is updated. 1331Finally, the driver 1332.Fn if_ioctl 1333routine is called to perform any setup 1334requested. 1335.Pp 1336.It Dv SIOCSIFMETRIC 1337.It Dv SIOCSIFPHYS 1338Change interface metric or medium. 1339Caller must have appropriate privilege. 1340.Pp 1341.It Dv SIOCSIFMTU 1342Change interface MTU. 1343Caller must have appropriate privilege. 1344MTU 1345values less than 72 or greater than 65535 are considered invalid. 1346The driver 1347.Fn if_ioctl 1348routine is called to implement the change; it is responsible for any 1349additional sanity checking and for actually modifying the MTU in the 1350interface structure. 1351.Pp 1352.It Dv SIOCADDMULTI 1353.It Dv SIOCDELMULTI 1354Add or delete permanent multicast group memberships on the interface. 1355Caller must have appropriate privilege. 1356The 1357.Fn if_addmulti 1358or 1359.Fn if_delmulti 1360function is called to perform the operation; qq.v. 1361.Pp 1362.It Dv SIOCAIFADDR 1363.It Dv SIOCDIFADDR 1364The socket's protocol control routine is called to implement the 1365requested action. 1366.Pp 1367.It Dv OSIOCGIFADDR 1368.It Dv OSIOCGIFDSTADDR 1369.It Dv OSIOCGIFBRDADDR 1370.It Dv OSIOCGIFNETMASK 1371The socket's protocol control routine is called to implement the 1372requested action. 1373On return, 1374.Vt sockaddr 1375structures are converted into old-style (no 1376.Va sa_len 1377member). 1378.El 1379.El 1380.Pp 1381.Fn if_down , 1382.Fn ifioctl , 1383.Fn ifpromisc , 1384and 1385.Fn if_up 1386must be called at 1387.Fn splnet 1388or higher. 1389.Ss "Interface Address Functions" 1390Several functions exist to look up an interface address structure 1391given an address. 1392.Fn ifa_ifwithaddr 1393returns an interface address with either a local address or a 1394broadcast address precisely matching the parameter 1395.Fa addr . 1396.Fn ifa_ifwithdstaddr 1397returns an interface address for a point-to-point interface whose 1398remote 1399.Pq Dq destination 1400address is 1401.Fa addr . 1402.Pp 1403.Fn ifa_ifwithnet 1404returns the most specific interface address which matches the 1405specified address, 1406.Fa addr , 1407subject to its configured netmask, or a point-to-point interface 1408address whose remote address is 1409.Fa addr 1410if one is found. 1411If 1412.Fa ignore_ptp 1413is true, skip point-to-point interface addresses. 1414.Pp 1415.Fn ifaof_ifpforaddr 1416returns the most specific address configured on interface 1417.Fa ifp 1418which matches address 1419.Fa addr , 1420subject to its configured netmask. 1421If the interface is 1422point-to-point, only an interface address whose remote address is 1423precisely 1424.Fa addr 1425will be returned. 1426.Pp 1427.Fn ifaddr_byindex 1428returns the link-level address of the interface with the given index 1429.Fa idx . 1430.Pp 1431All of these functions return a null pointer if no such address can be 1432found. 1433.Ss "Interface Multicast Address Functions" 1434The 1435.Fn if_addmulti , 1436.Fn if_delmulti , 1437and 1438.Fn if_findmulti 1439functions provide support for requesting and relinquishing multicast 1440group memberships, and for querying an interface's membership list, 1441respectively. 1442The 1443.Fn if_addmulti 1444function takes a pointer to an interface, 1445.Fa ifp , 1446and a generic address, 1447.Fa sa . 1448It also takes a pointer to a 1449.Vt "struct ifmultiaddr *" 1450which is filled in on successful return with the address of the 1451group membership control block. 1452The 1453.Fn if_addmulti 1454function performs the following four-step process: 1455.Bl -enum -offset indent 1456.It 1457Call the interface's 1458.Fn if_resolvemulti 1459entry point to determine the link-layer address, if any, corresponding 1460to this membership request, and also to give the link layer an 1461opportunity to veto this membership request should it so desire. 1462.It 1463Check the interface's group membership list for a pre-existing 1464membership for this group. 1465If one is not found, allocate a new one; 1466if one is, increment its reference count. 1467.It 1468If the 1469.Fn if_resolvemulti 1470routine returned a link-layer address corresponding to the group, 1471repeat the previous step for that address as well. 1472.It 1473If the interface's multicast address filter needs to be changed 1474because a new membership was added, call the interface's 1475.Fn if_ioctl 1476routine 1477(with a 1478.Fa cmd 1479argument of 1480.Dv SIOCADDMULTI ) 1481to request that it do so. 1482.El 1483.Pp 1484The 1485.Fn if_delmulti 1486function, given an interface 1487.Fa ifp 1488and an address, 1489.Fa sa , 1490reverses this process. 1491Both functions return zero on success, or a 1492standard error number on failure. 1493.Pp 1494The 1495.Fn if_findmulti 1496function examines the membership list of interface 1497.Fa ifp 1498for an address matching 1499.Fa sa , 1500and returns a pointer to that 1501.Vt "struct ifmultiaddr" 1502if one is found, else it returns a null pointer. 1503.Sh SEE ALSO 1504.Xr ioctl 2 , 1505.Xr link_addr 3 , 1506.Xr queue 3 , 1507.Xr sysctl 3 , 1508.Xr bpf 4 , 1509.Xr ifmib 4 , 1510.Xr lo 4 , 1511.Xr netintro 4 , 1512.Xr polling 4 , 1513.Xr config 8 , 1514.Xr ppp 8 , 1515.Xr mbuf 9 , 1516.Xr rtentry 9 1517.Rs 1518.%A Gary R. Wright 1519.%A W. Richard Stevens 1520.%B TCP/IP Illustrated 1521.%V Vol. 2 1522.%O Addison-Wesley, ISBN 0-201-63354-X 1523.Re 1524.Sh AUTHORS 1525This manual page was written by 1526.An Garrett A. Wollman . 1527