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