1.\" 2.\" Copyright 1996 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.\" $Id: ifnet.9,v 1.2 1996/12/18 22:06:47 mpp Exp $ 30.Dd December 16, 1996 31.Os FreeBSD 2.2 32.Dt IFNET 9 33.Sh NAME 34.Nm ifnet , 35.Nm ifaddr , 36.Nm ifqueue , 37.Nm if_data 38.Nd kernel interfaces for manipulating network interfaces 39.Sh SYNOPSIS 40.Fd #include <sys/types.h> 41.Fd #include <sys/time.h> 42.Fd #include <sys/socket.h> 43.Fd #include <net/if.h> 44.Fd #include <net/if_types.h> 45.\" 46.Ss "Interface manipulation functions" 47.Ft void 48.Fn if_attach "struct ifnet *ifp" 49.Ft void 50.Fn if_down "struct ifnet *ifp" 51.Ft int 52.Fn ifioctl "struct socket *so" "int cmd" "caddr_t data" "struct proc *p" 53.Ft int 54.Fn ifpromisc "struct ifnet *ifp" "int pswitch" 55.Ft "struct ifnet *" 56.Fn ifunit "char *name" 57.Ft void 58.Fn if_up "struct ifnet *ifp" 59.\" 60.Ss "Interface address functions" 61.Ft "struct ifaddr *" 62.Fn ifa_ifwithaddr "struct sockaddr *addr" 63.Ft "struct ifaddr *" 64.Fn ifa_ifwithdstaddr "struct sockaddr *addr" 65.Ft "struct ifaddr *" 66.Fn ifa_ifwithnet "struct sockaddr *addr" 67.Ft "struct ifaddr *" 68.Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp" 69.Ft void 70.Fn ifafree "struct ifaddr *ifa" 71.Ft void \"macro 72.Fn IFAFREE "struct ifaddr *ifa" 73.\" 74.Ss "Output queue macros" 75.Ft void \"macro 76.Fn IF_ENQ_DROP "struct ifqueue *ifq" "struct mbuf *m" 77.Ft void \"macro 78.Fn IF_DEQUEUE "struct ifqueue *ifq" "struct mbuf *m" 79.\" 80.Ss "struct ifnet member functions" 81.Ft int 82.Fn (*if_output) "struct ifnet *ifp" "struct mbuf *m" "struct sockaddr *dst" "struct rtentry *rt" 83.Ft void 84.Fn (*if_start) "struct ifnet *ifp" 85.Ft int 86.Fn (*if_dont) "struct ifnet *ifp" 87.Ft int 88.Fn (*if_ioctl) "struct ifnet *ifp" "int cmd" "caddr_t data" 89.Ft void 90.Fn (*if_watchdog) "struct ifnet *ifp" 91.Ft int 92.Fn (*if_poll_recv) "struct ifnet *ifp" "int *quotap" 93.Ft int 94.Fn (*if_poll_xmit) "struct ifnet *ifp" "int *quotap" 95.Ft void 96.Fn (*if_poll_inttrn) "struct ifnet *ifp" 97.Ft void 98.Fn (*if_poll_slowinput) "struct ifnet *ifp" "struct mbuf *m" 99.Ft void 100.Fn (*if_init) "void *wtf_is_this" 101.Ss "struct ifaddr member function" 102.Ft void 103.Fn (*ifa_rtrequest) "int cmd" "struct rtentry *rt" "struct sockaddr *dst" 104.Ss "Global variables" 105.Fd extern struct ifnethead ifnet; 106.Fd extern struct ifaddr \&**ifnet_addrs; 107.Fd extern int if_index; 108.Fd extern int ifqmaxlen; 109.Sh DATA STRUCTURES 110The kernel mechanisms for handling network interfaces reside primarily 111in the 112.Li ifnet , 113.Li if_data , 114and 115.Li ifaddr 116structures in 117.Aq Pa net/if.h , 118and the functions named above and defined in 119.Pa /sys/net/if.c . 120The system keeps a linked list of interfaces using the 121.Li TAILQ 122macros defined in 123.Xr queue 3 ; 124this list is headed by a 125.Li "struct ifnethead" 126called 127.Li ifnet . 128The elements of this list are of type 129.Li "struct ifnet" , 130and most kernel routines which manipulate interface as such accept or 131return pointers to these structures. Each interface structure 132contains an 133.Li if_data 134structure, which contains statistics and identifying information used 135by management programs, and which is exported to user programs by way 136of the 137.Xr ifmib 4 138branch of the 139.Xr sysctl 3 140MIB. 141Each interface also has a 142.Li TAILQ 143of interface addresses, described by 144.Li ifaddr 145structures; the head of the queue is always an 146.Dv AF_LINK 147address 148(see 149.Xr link_addr 3 ) 150describing the link layer implemented by the interface (if any). 151(Some trivial interfaces do not provide any link layer addresses; 152this structure, while still present, serves only to identify the 153interface name and index.) 154.Pp 155Interfaces are also associated with an output queue, defined as a 156.Li "struct ifqueue" ; 157this structure is used to hold packets while the interface is in the 158process of sending another. The current implementation implements a 159drop-tail queuing discipline, but in the future a Random Early Drop 160discipline is expected to be used. For this reason, kernel code 161should not depend on the internals of the queue structure; in 162particular, only the 163.Fn IF_ENQ_DROP 164and 165.Fn IF_DEQUEUE 166macros will be supported in future implementations. 167.\" The old structure will probably be retained for compatibility 168.\" under a different name. 169.Pp 170.Ss The ifnet structure 171The fields of 172.Li "struct ifnet" 173are as follows: 174.Pp 175.Bl -tag -width "if_poll_slowq" -offset indent 176.It Li "if_softc" 177.Pq Li "void *" 178A pointer to the driver's private state block. (Initialized by 179driver.) 180.It Li if_name 181.Pq Li "char *" 182The name of the interface, not including the unit number 183(e.g., 184.Dq Li de 185or 186.Dq Li lo ) . 187(Initialized by driver.) 188.It Li if_link 189.Pq Li "TAILQ_ENTRY(ifnet)" 190.Xr queue 3 191macro glue. 192.It Li if_addrhead 193.Pq Li "struct ifaddrhead" 194The head of the 195.Xr queue 3 196.Li TAILQ 197containing the list of addresses assigned to this interface. 198.It Li if_pcount 199.Pq Li "int" 200A count of promiscuous listeners on this interface, used to 201reference-count the 202.Dv IFF_PROMISC 203flag. 204.It Li "if_bpf" 205.Pq Li "struct bpf_if *" 206Opaque per-interface data for the packet filter, 207.Xr bpf 4 . 208(Initialized by 209.Fn bpf_attach . ) 210.It Li "if_index" 211.Pq Li "u_short" 212A unique number assigned to each interface in sequence as it is 213attached. This number can be used in a 214.Li "struct sockaddr_dl" 215to refer to a particular interface by index 216(see 217.Xr link_addr 3 ) . 218.It Li "if_unit" 219.Pq Li "short" 220A unique number assigned to each interface managed by a particular 221driver, usually related to the unit number of a physical device in the 222kernel configuration file 223(see 224.Xr config 8 ) . 225(Initialized by driver.) 226.It Li "if_timer" 227.Pq Li "short" 228Number of seconds until the watchdog timer 229.Fn if_watchdog 230is called, or zero if the timer is disabled. (Set by driver, 231decremented by generic watchdog code.) 232.It Li "if_flags" 233.Pq Li "short" 234Flags describing operational parameters of this interface (see below). 235(Manipulated by both driver and generic code.) 236.\" .It Li "if_ipending" 237.\" Interrupt-pending bits for polled operation: 238.\" .Dv IFI_XMIT 239.\" (transmit complete interrupt) 240.\" and 241.\" .Dv IFI_RECV 242.\" (received packet ready interrupt). See the 243.\" .Sx Polling 244.\" section, below. (Manipulated by driver.) 245.It Li "if_linkmib" 246.Pq Li "void *" 247A pointer to an interface-specific MIB structure exported by 248.Xr ifmib 4 . 249(Initialized by driver.) 250.It Li "if_linkmiblen" 251.Pq Li "size_t" 252The size of said structure. (Initialized by driver.) 253.It Li "if_data" 254.Pq Li "struct if_data" 255More statistics and information; see 256.Dq Sx "The if_data structure" , 257below. (Initialized by driver, manipulated by both driver and generic 258code.) 259.It Li "if_snd" 260.Pq Li "struct ifqueue" 261The output queue. (Manipulated by driver.) 262.\".It Li "if_poll_slowq" 263.\".Pq Li "struct ifqueue *" 264.\"A pointer to the input queue for devices which do not support polling 265.\"well. See the 266.\".Sx Polling 267.\"section, below. (Initialized by driver.) 268.El 269.Pp 270There are in addition a number of function pointers which the driver 271must initialize to complete its interface with the generic interface 272layer: 273.Bl -ohang -offset indent 274.It Fn if_output 275Output a packet on interface 276.Ar ifp , 277or queue it on the output queue if the interface is already active. 278.It Fn if_start 279Start queued output on an interface. This function is exposed in 280order to provide for some interface classes to share a 281.Fn if_output 282among all drivers. 283.Fn if_start 284may only be called when the 285.Dv IFF_OACTIVE 286flag is not set. (Thus, 287.Dv IFF_OACTIVE 288does not literally mean that output is active, but rather that the 289device's internal output queue is full.) 290.It Fn if_done 291Not used. We're not even sure what it was ever for. 292.It Fn if_ioctl 293Process interface-related 294.Xr ioctl 2 295requests 296(defined in 297.Aq Pa sys/sockio.h ) . 298Preliminary processing is done by the generic routine 299.Fn ifioctl 300to check for appropriate privileges, locate the interface being 301manipulated, and perform certain generic operations like twiddling 302flags and flushing queues. See the description of 303.Fn ifioctl 304below for more information. 305.It Fn if_watchdog 306Routine called by the generic code when the watchdog timer, 307.Li if_timer , 308expires. Usually this will reset the interface. 309.\" .It Fn if_poll_recv 310.\" .It Fn if_poll_xmit 311.\" .It Fn if_poll_slowinput 312.\" .It Fn if_poll_intren 313.\" See the 314.\" .Sx Polling 315.\" section, below. 316.It Fn if_init 317XXX fill me in 318.El 319.Ss "Interface flags" 320Interface flags are used for a number of different purposes. Some 321flags simply indicate information about the type of interface and its 322capabilities; others are dynamically manipulated to reflect the 323current state of the interface. Flags of the former kind are marked 324.Aq S 325in this table; the latter are marked 326.Aq D . 327.Pp 328.Bl -tag -width "IFF_POINTOPOINT" -compact -offset indent 329.It Dv IFF_UP 330.Aq D 331The interface has been configured up by the user-level code. 332.It Dv IFF_BROADCAST 333.Aq S* 334The interface supports broadcast. 335.It Dv IFF_DEBUG 336.Aq D 337Used to enable/disable driver debugging code. 338.It Dv IFF_LOOPBACK 339.Aq S 340The interface is a loopback device. 341.It Dv IFF_POINTOPOINT 342.Aq S* 343The interface is point-to-point; 344.Dq broadcast 345addresses are actually the address of the other end. 346.It Dv IFF_RUNNING 347.Aq D* 348The interface has been configured and dynamic resources were 349successfully allocated. Probably only useful internal to the 350interface. 351.It Dv IFF_NOARP 352.Aq D 353Disable network address resolution on this interface. 354.It Dv IFF_PROMISC 355.Aq D 356This interface is in promiscuous mode. 357.It Dv IFF_ALLMULTI 358.Aq D* 359This interface is in all-multicasts mode (used by multicast routers). 360.It Dv IFF_OACTIVE 361.Aq D* 362The interface's hardware output queue (if any) is full; output packets 363are to be queued. 364.It Dv IFF_SIMPLEX 365.Aq S* 366The interface cannot hear its own transmissions. 367.It Dv IFF_LINK0 368.It Dv IFF_LINK1 369.It Dv IFF_LINK2 370.Aq D 371Control flags for the link layer. (Currently abused to select among 372multiple physical layers on some devices.) 373.It Dv IFF_MULTICAST 374.Aq S* 375This interface supports multicast. 376.El 377.Pp 378The macro 379.Dv IFF_CANTCHANGE 380defines the bits which cannot be set by a user program using the 381.Dv SIOCSIFFLAGS 382command to 383.Xr ioctl 2 ; 384these are indicated by an asterisk in the listing above. 385.Ss The if_data structure 386In 387.Bx 4.4 , 388a subset of the interface information believed to be of interest to 389management stations was segregated from the 390.Li ifnet 391structure and moved into its own 392.Li if_data 393structure to facilitate its use by user programs. The following 394elements of the 395.Li if_data 396structure are initialized by the interface and are not expected to change 397significantly over the course of normal operation: 398.Bl -tag -width "ifi_lastchange" -offset indent 399.It Li ifi_type 400.Pq Li u_char 401The type of the interface, as defined in 402.Aq Pa net/if_types.h 403and described below in the 404.Dq Sx "Interface types" 405section. 406.It Li ifi_physical 407.Pq Li u_char 408Intended to represent a selection of physical layers on devices which 409support more than one; never implemented. 410.It Li ifi_addrlen 411.Pq Li u_char 412Length of a link-layer address on this device, or zero if there are 413none. Used to initialized the address length field in 414.Li "sockaddr_dl" 415structures referring to this interface. 416.It Li ifi_hdrlen 417.Pq Li u_char 418Maximum length of any link-layer header which might be prepended by 419the driver to a packet before transmission. The generic code computes 420the maximum over all interfaces and uses that value to influence the 421placement of data in 422.Li mbuf Ns s 423to attempt to ensure that there is always 424sufficient space to prepend a link-layer header without allocating an 425additional 426.Li mbuf . 427.\" (See 428.\" .Xr mbuf 9 . ) 429.\" .It Li ifi_recvquota 430.\" .Pq Li u_char 431.\" Number of packets the interface is permitted to receive at one time 432.\" when in polled mode. 433.\" .It Li ifi_xmitquota 434.\" .Pq Li u_char 435.\" Number of packets the interface is permitted to queue for transmission 436.\" at one time when in polled mode. There is some controversy over 437.\" whether such a restriction makes any sense at all. 438.It Li ifi_mtu 439.Pq Li u_long 440The maximum transmission unit of the medium, exclusive of any 441link-layer overhead. 442.It Li ifi_metric 443.Pq Li u_long 444A dimensionless metric interpreted by a user-mode routing process. 445.It Li ifi_baudrate 446.Pq Li u_long 447The line rate of the interface, in bits per second. 448.El 449.Pp 450The structure additionally contains generic statistics applicable to a 451variety of different interface types (except as noted, all members are 452of type 453.Li u_long ) : 454.Bl -tag -width "ifi_lastchange" -offset indent 455.It Li ifi_ipackets 456Number of packets received. 457.It Li ifi_ierrors 458Number of receive errors detected (e.g., FCS errors, DMA overruns, 459etc.). More detailed breakdowns can often be had by way of a 460link-specific MIB. 461.It Li ifi_opackets 462Number of packets transmitted. 463.It Li ifi_oerrors 464Number of output errors detected (e.g., late collisions, DMA overruns, 465etc.). More detailed breakdowns can often be had by way of a 466link-specific MIB. 467.It Li ifi_collisions 468Total number of collisions detected on output for CSMA interfaces. 469(This member is sometimes [ab]used by other types of interfaces for 470other output error counts.) 471.It Li ifi_ibytes 472Total traffic received, in bytes. 473.It Li ifi_obytes 474Total traffic transmitted, in bytes. 475.It Li ifi_imcasts 476Number of packets received which were sent by link-layer multicast. 477.It Li ifi_omcasts 478Number of packets sent by link-layer multicast. 479.It Li ifi_iqdrops 480Number of packets dropped on input. Rarely implemented. 481.It Li ifi_noproto 482Number of packets received for unknown network-layer protocol. 483.\" .It Li ifi_recvtiming 484.\" Amount of time, in microseconds, spent to receive an average packet on 485.\" this interface. See the 486.\" .Sx Polling 487.\" section, below. 488.\" .It Li ifi_xmittiming 489.\" Amount of time, in microseconds, spent to service a transmit-complete 490.\" interrupt on this interface. See the 491.\" .Sx Polling 492.\" section, below. 493.It Li ifi_lastchange 494.Pq Li "struct timeval" 495The time of the last administrative change to the interface (as required 496for 497.Tn SNMP ) . 498.El 499.Ss Interface types 500The header file 501.Aq Pa net/if_types.h 502defines symbolic constants for a number of different types of 503interfaces. The most common are: 504.Pp 505.Bl -tag -compact -offset indent -width IFT_PROPVIRTUAL 506.It Dv IFT_OTHER 507none of the following 508.It Dv IFT_ETHER 509Ethernet 510.It Dv IFT_ISO88023 511ISO 8802-3 CSMA/CD 512.It Dv IFT_ISO88024 513ISO 8802-4 Token Bus 514.It Dv IFT_ISO88025 515ISO 8802-5 Token Ring 516.It Dv IFT_ISO88026 517ISO 8802-6 DQDB MAN 518.It Dv IFT_FDDI 519FDDI 520.It Dv IFT_PPP 521Internet Point-to-Point Protocol 522.Pq Xr ppp 8 523.It Dv IFT_LOOP 524The loopback 525.Pq Xr lo 4 526interface. 527.It Dv IFT_SLIP 528Serial Line IP 529.It Dv IFT_PARA 530Parallel-port IP 531.Pq Dq Tn PLIP 532.It Dv IFT_ATM 533Asynchronous Transfer Mode 534.El 535.Ss The ifaddr structure 536Every interface is associated with a list 537(or, rather, a 538.Dv TAILQ ) 539of addresses, rooted at the interface structure's 540.Li if_addrlist 541member. The first element in this list is always an 542.Dv AF_LINK 543address representing the interface itself; multi-access network 544drivers should complete this structure by filling in their link-layer 545addresses after calling 546.Fn if_attach . 547Other members of the structure represent network-layer addresses which 548have been configured by means of the 549.Dv SIOCAIFADDR 550command to 551.Xr ioctl 2 , 552called on a socket of the appropriate protocol family. 553The elements of this list consist of 554.Li ifaddr 555structures. Most protocols will declare their own protocol-specific 556interface address structures, but all begin with a 557.Li "struct ifaddr" 558which provides the most-commonly-needed functionality across all 559protocols. Interface addresses are reference-counted. 560.Pp 561The members of 562.Li "struct ifaddr" 563are as follows: 564.Bl -tag -width ifa_rtrequest -offset indent 565.It Li ifa_addr 566.Pq Li "struct sockaddr *" 567The local address of the interface. 568.It Li ifa_dstaddr 569.Pq Li "struct sockaddr *" 570The remote address of point-to-point interfaces, and the broadcast 571address of broadcast interfaces. 572.Po 573.Li ifa_broadaddr 574is a macro for 575.Li ifa_dstaddr . 576.Pc 577.It Li ifa_netmask 578.Pq Li "struct sockaddr *" 579The network mask for multi-access interfaces, and the confusion 580generator for point-to-point interfaces. 581.It Li ifa_ifp 582.Pq Li "struct ifnet *" 583A link back to the interface structure. 584.It Li ifa_link 585.Pq Li TAILQ_ENTRY(ifaddr) 586.Xr queue 3 587glue for list of addresses on each interface. 588.It Li ifa_rtrequest 589See below. 590.It Li ifa_flags 591.Pq Li u_short 592Some of the flags which would be used for a route representing this 593address in the route table. 594.It Li ifa_refcnt 595.Pq Li short 596The reference count. 597.It Li ifa_metric 598.Pq Li int 599A metric associated with this interface address, for the use of some 600external routing protocol. 601.El 602.Pp 603References to 604.Li ifaddr 605structures are gained manually, by incrementing the 606.Li ifa_refcnt 607member. References are released by calling either the 608.Fn ifafree 609function or the 610.Fn IFAFREE 611macro. 612.Pp 613.Fn ifa_rtrequest 614is a pointer to a function which receives callouts from the routing 615code 616.Pq Fn rtrequest 617to perform link-layer-specific actions upon requests to add, resolve, 618or delete routes. The 619.Ar cmd 620argument indicates the request in question: 621.Dv RTM_ADD , 622.Dv RTM_RESOLVE , 623or 624.Dv RTM_DELETE . 625The 626.Ar rt 627argument is the route in question; the 628.Ar sa 629argument is the specific destination being manipulated 630for 631.Dv RTM_RESOLVE , 632or a null pointer otherwise. 633.Sh FUNCTIONS 634The functions provided by the generic interface code can be divided 635into two groups: those which manipulate interfaces, and those which 636manipulate interface addresses. In addition to these functions, there 637may also be link-layer support routines which are used by a number of 638drivers implementing a specific link layer over different hardware; 639see the documentation for that link layer for more details. 640.Ss Interface manipulation functions 641.Bl -ohang -offset indent 642.It Fn if_attach 643Link the specified interface 644.Ar ifp 645into the list of network interfaces. Also initialize the list of 646addresses on that interface, and create a link-layer 647.Li ifaddr 648structure to be the first element in that list. (A pointer to 649this address structure is saved in the global array 650.Li ifnet_addrs . ) 651.It Fn if_down 652Mark the interface 653.Ar ifp 654as down (i.e., 655.Dv IFF_UP 656is not set), 657flush its output queue, and call the interface's 658.Fn if_ioctl 659routine to notify the driver of the shutdown request. 660.It Fn if_up 661Mark the interface 662.Ar ifp 663as up, and call the interface's 664.Fn if_ioctl 665routine to (re-)initialize the driver. 666.It Fn ifpromisc 667Add or remove a promiscuous reference to 668.Ar ifp . 669If 670.Ar pswitch 671is true, add a reference; 672if it is false, remove a reference. On reference count transitions 673from zero to one and one to zero, set the 674.Dv IFF_PROMISC 675flag appropriately and call 676.Fn if_ioctl 677to set up the interface in the desired mode. 678.It Fn ifunit 679Return an 680.Li ifnet 681pointer for the interface named 682.Ar name . 683.It Fn ifioctl 684Process the ioctl request 685.Ar cmd , 686issued on socket 687.Ar so 688by process 689.Ar p , 690with data parameter 691.Ar data . 692This is the main routine for handling all interface configuration 693requests from user mode. 694It is ordinarily only called from the socket-layer 695.Xr ioctl 2 696handler, and only for commands with class 697.Sq Li i . 698Any unrecognized commands will be passed down to socket 699.Ar so Ns 's 700protocol for 701further interpretation. The following commands are handled by 702.Fn ifioctl : 703.Pp 704.Bl -tag -width OSIOCGIFNETMASK -compact -offset indent 705.It Dv SIOCGIFCONF 706.It Dv OSIOCGIFCONF 707Get interface configuration. (No call-down to driver.) 708.It Dv SIOCGIFFLAGS 709.It Dv SIOCGIFMETRIC 710.It Dv SIOCGIFMTU 711.It Dv SIOCGIFPHYS 712Get interface flags, metric, MTU, medium selection. (No call-down to 713driver.) 714.Pp 715.It Dv SIOCSIFFLAGS 716Change interface flags. Caller must have appropriate privilege. If 717requested a change to the IFF_UP flag is requested, 718.Fn if_up 719or 720.Fn if_down 721is called as appropriate. Flags listed in 722.Dv IFF_CANTCHANGE 723are masked off, and the driver 724.Fn if_ioctl 725routine is called to perform any setup 726requested. 727.It Dv SIOCSIFMETRIC 728.It Dv SIOCSIFPHYS 729Change interface metric or medium. Caller must have appropriate privilege. 730.Pp 731.It Dv SIOCSIFMTU 732Change interface MTU. Caller must have appropriate privilege. MTU 733values less than 72 or greater than 65535 are considered invalid. The 734driver 735.Fn if_ioctl 736routine is called to implement the change; it is responsible for any 737additional sanity checking and for actually modifying the MTU in the 738interface structure. 739.It Dv SIOCADDMULTI 740.It Dv SIOCDELMULTI 741Add or delete permanent multicast group memberships on the interface. 742Caller must have appropriate privilege. The driver 743.Fn if_ioctl 744routine is called to perform the requested action. 745.It Dv SIOCSIFDSTADDR 746.It Dv SIOCSIFADDR 747.It Dv SIOCSIFBRDADDR 748.It Dv SIOCSIFNETMASK 749The socket's protocol control routine is called to implement the 750requested action. 751.It Dv OSIOGIFADDR 752.It Dv OSIOCGIFDSTADDR 753.It Dv OSIOCGIFBRDADDR 754.It Dv OSIOCGIFNETMASK 755The socket's protocol control routine is called to implement the 756requested action. On return, 757.Li sockaddr 758structures are converted into old-style (no 759.Li sa_len 760member). 761.El 762.Pp 763.Fn if_down , 764.Fn ifioctl , 765.Fn ifpromisc , 766and 767.Fn if_up 768must be called at 769.Fn splnet 770or higher. 771.Ss "Interface address functions" 772Several functions exist to look up an interface address structure 773given an address. 774.Fn ifa_ifwithaddr 775returns an interface address with either a local address or a 776broadcast address precisely matching the parameter 777.Ar addr . 778.Fn ifa_ifwithdstaddr 779returns an interface address for a point-to-point interface whose 780remote (``destination'') address is 781.Ar addr . 782.Pp 783.Fn ifa_ifwithnet 784returns the most specific interface address which matches the 785specified address, 786.Ar addr , 787subject to its configured netmask, or a point-to-point interface 788address whose remote address is 789.Ar addr 790if one is found. 791.Pp 792.Fn ifaof_ifpforaddr 793returns the most specific address configured on interface 794.Ar ifp 795which matches address 796.Ar addr , 797subject to its configured netmask. If the interface is 798point-to-point, only an interface address whose remote address is 799precisely 800.Ar addr 801will be returned. 802.Pp 803All of these functions return a null pointer if no such address can be 804found. 805.\" .Sh POLLING 806.\" XXX write me! 807.Sh SEE ALSO 808.Xr ioctl 2 , 809.Xr link_addr 3 , 810.Xr queue 3 , 811.Xr sysctl 3 , 812.Xr bpf 4 , 813.Xr ifmib 4 , 814.Xr lo 4 , 815.Xr netintro 4 , 816.Xr config 8 , 817.Xr ppp 8 , 818.Xr rtentry 9 819.\" .Xr mbuf 9 , 820.Rs 821.%A Gary R. Wright and W. Richard Stevens 822.%B TCP/IP Illustrated 823.%V vol. 2 824.%O Addison-Wesley, ISBN 0-201-63354-X 825.Re 826.Sh AUTHOR 827This manual page was written by Garrett A. Wollman 828