2 .\" Copyright 1996, 1997 Massachusetts Institute of Technology
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
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
39 .Nd kernel interfaces for manipulating network interfaces
48 .Ss "Interface Manipulation Functions"
50 .Fn if_alloc "u_char type"
52 .Fn if_attach "struct ifnet *ifp"
54 .Fn if_detach "struct ifnet *ifp"
56 .Fn if_free "struct ifnet *ifp"
58 .Fn if_free_type "struct ifnet *ifp" "u_char type"
60 .Fn if_down "struct ifnet *ifp"
62 .Fn ifioctl "struct socket *so" "u_long cmd" "caddr_t data" "struct thread *td"
64 .Fn ifpromisc "struct ifnet *ifp" "int pswitch"
66 .Fn if_allmulti "struct ifnet *ifp" "int amswitch"
68 .Fn ifunit "const char *name"
70 .Fn if_up "struct ifnet *ifp"
72 .Ss "Interface Address Functions"
74 .Fn ifa_ifwithaddr "struct sockaddr *addr"
76 .Fn ifa_ifwithdstaddr "struct sockaddr *addr"
78 .Fn ifa_ifwithnet "struct sockaddr *addr"
80 .Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp"
82 .Fn ifafree "struct ifaddr *ifa"
83 .Fn IFAFREE "struct ifaddr *ifa"
85 .Ss "Interface Multicast Address Functions"
87 .Fn if_addmulti "struct ifnet *ifp" "struct sockaddr *sa" "struct ifmultiaddr **ifmap"
89 .Fn if_delmulti "struct ifnet *ifp" "struct sockaddr *sa"
90 .Ft "struct ifmultiaddr *"
91 .Fn ifmaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp"
92 .Ss "Output queue macros"
93 .Fn IF_DEQUEUE "struct ifqueue *ifq" "struct mbuf *m"
95 .Ss "struct ifnet Member Functions"
97 .Fn \*(lp*if_input\*(rp "struct ifnet *ifp" "struct mbuf *m"
99 .Fo \*(lp*if_output\*(rp
100 .Fa "struct ifnet *ifp" "struct mbuf *m"
101 .Fa "struct sockaddr *dst" "struct rtentry *rt"
104 .Fn \*(lp*if_start\*(rp "struct ifnet *ifp"
106 .Fn \*(lp*if_transmit\*(rp "struct ifnet *ifp" "struct mbuf *m"
108 .Fn \*(lp*if_qflush\*(rp "struct ifnet *ifp"
110 .Fn \*(lp*if_ioctl\*(rp "struct ifnet *ifp" "int cmd" "caddr_t data"
112 .Fn \*(lp*if_watchdog\*(rp "struct ifnet *ifp"
114 .Fn \*(lp*if_init\*(rp "void *if_softc"
116 .Fo \*(lp*if_resolvemulti\*(rp
117 .Fa "struct ifnet *ifp" "struct sockaddr **retsa" "struct sockaddr *addr"
119 .Ss "struct ifaddr member function"
121 .Fo \*(lp*ifa_rtrequest\*(rp
122 .Fa "int cmd" "struct rtentry *rt" "struct sockaddr *dst"
125 .Ss "Global Variables"
126 .Vt extern struct ifnethead ifnet ;
127 .Vt extern struct ifaddr **ifnet_addrs ;
128 .Vt extern int if_index ;
129 .Vt extern int ifqmaxlen ;
131 The kernel mechanisms for handling network interfaces reside primarily
133 .Vt ifnet , if_data , ifaddr ,
140 and the functions named above and defined in
142 Those interfaces which are intended to be used by user programs
145 these include the interface flags, the
147 structure, and the structures defining the appearance of
148 interface-related messages on the
150 routing socket and in
154 defines the kernel-internal interfaces, including the
158 structures and the functions which manipulate them.
159 (A few user programs will need
161 because it is the prerequisite of some other header file like
162 .In netinet/if_ether.h .
163 Most references to those two files in particular can be replaced by
164 .In net/ethernet.h . )
166 The system keeps a linked list of interfaces using the
170 this list is headed by a
171 .Vt "struct ifnethead"
174 The elements of this list are of type
176 and most kernel routines which manipulate interface as such accept or
177 return pointers to these structures.
178 Each interface structure
181 structure, which contains statistics and identifying information used
182 by management programs, and which is exported to user programs by way
188 Each interface also has a
190 of interface addresses, described by
192 structures; the head of the queue is always an
197 describing the link layer implemented by the interface (if any).
198 (Some trivial interfaces do not provide any link layer addresses;
199 this structure, while still present, serves only to identify the
200 interface name and index.)
202 Finally, those interfaces supporting reception of multicast datagrams
205 of multicast group memberships, described by
208 These memberships are reference-counted.
210 Interfaces are also associated with an output queue, defined as a
211 .Vt "struct ifqueue" ;
212 this structure is used to hold packets while the interface is in the
213 process of sending another.
215 .Ss The Vt ifnet Ss structure
219 .Bl -tag -width ".Va if_capabilities" -offset indent
222 A pointer to the driver's private state block.
223 (Initialized by driver.)
226 A pointer to the common data for the interface's layer 2 protocol.
230 .Pq Fn TAILQ_ENTRY ifnet
235 The name of the interface,
240 (Initialized by driver.)
242 .Pq Vt "const char *"
243 The name of the driver.
244 (Initialized by driver.)
247 A unique number assigned to each interface managed by a particular
249 Drivers may choose to set this to
251 if a unit number is not associated with the device.
252 (Initialized by driver.)
254 .Pq Vt "struct ifaddrhead"
258 containing the list of addresses assigned to this interface.
261 A count of promiscuous listeners on this interface, used to
266 .Pq Vt "struct bpf_if *"
267 Opaque per-interface data for the packet filter,
273 A unique number assigned to each interface in sequence as it is
275 This number can be used in a
276 .Vt "struct sockaddr_dl"
277 to refer to a particular interface by index
284 Number of seconds until the watchdog timer
286 is called, or zero if the timer is disabled.
288 decremented by generic watchdog code.)
291 Flags describing operational parameters of this interface (see below).
292 (Manipulated by both driver and generic code.)
293 .It Va if_capabilities
295 Flags describing the capabilities the interface supports (see below).
298 Flags describing the enabled capabilities of the interface (see below).
299 .\" .It Va if_ipending
300 .\" Interrupt-pending bits for polled operation:
302 .\" (transmit complete interrupt)
305 .\" (received packet ready interrupt).
309 .\" (Manipulated by driver.)
312 A pointer to an interface-specific MIB structure exported by
314 (Initialized by driver.)
317 The size of said structure.
318 (Initialized by driver.)
320 .Pq Vt "struct if_data"
321 More statistics and information; see
322 .Sx "The if_data structure" ,
324 (Initialized by driver, manipulated by both driver and generic
327 .Pq Vt "struct ifqueue"
329 (Manipulated by driver.)
330 .\".It Va if_poll_slowq
331 .\".Pq Vt "struct ifqueue *"
332 .\"A pointer to the input queue for devices which do not support polling
337 .\"(Initialized by driver.)
340 There are in addition a number of function pointers which the driver
341 must initialize to complete its interface with the generic interface
343 .Bl -ohang -offset indent
345 Pass a packet to an appropriate upper layer as determined
346 from the link-layer header of the packet.
347 This routine is to be called from an interrupt handler or
348 used to emulate reception of a packet on this interface.
349 A single function implementing
351 can be shared among multiple drivers utilizing the same link-layer
352 framing, e.g., Ethernet.
354 Output a packet on interface
356 or queue it on the output queue if the interface is already active.
358 Transmit a packet on an interface or queue it if the interface is
359 in use. This function will return
361 if the devices software and hardware queues are both full. This
362 function must be installed after
364 Free mbufs in internally managed queues when the interface is marked down.
365 This function must be installed after
367 to override the default implementation. This function is exposed in order
368 to allow drivers to manage their own queues and to reduce the latency
369 caused by a frequently gratuitous enqueue / dequeue pair to ifq. The
370 suggested internal software queueing mechanism is buf_ring.
372 Start queued output on an interface.
373 This function is exposed in
374 order to provide for some interface classes to share a
378 may only be called when the
383 does not literally mean that output is active, but rather that the
384 device's internal output queue is full.) Please note that this function
385 will soon be deprecated.
388 We are not even sure what it was ever for.
389 The prototype is faked.
391 Process interface-related
396 Preliminary processing is done by the generic routine
398 to check for appropriate privileges, locate the interface being
399 manipulated, and perform certain generic operations like twiddling
400 flags and flushing queues.
401 See the description of
403 below for more information.
405 Routine called by the generic code when the watchdog timer,
408 Usually this will reset the interface.
409 .\" .It Fn if_poll_recv
410 .\" .It Fn if_poll_xmit
411 .\" .It Fn if_poll_slowinput
412 .\" .It Fn if_poll_intren
417 Initialize and bring up the hardware,
418 e.g., reset the chip and the watchdog timer and enable the receiver unit.
419 Should mark the interface running,
421 .Dv ( IFF_RUNNING , ~IIF_OACTIVE ) .
422 .It Fn if_resolvemulti
423 Check the requested multicast group membership,
425 for validity, and if necessary compute a link-layer group which
426 corresponds to that address which is returned in
428 Returns zero on success, or an error code on failure.
430 .Ss "Interface Flags"
431 Interface flags are used for a number of different purposes.
433 flags simply indicate information about the type of interface and its
434 capabilities; others are dynamically manipulated to reflect the
435 current state of the interface.
436 Flags of the former kind are marked
438 in this table; the latter are marked
443 defines the bits which cannot be set by a user program using the
447 these are indicated by an asterisk
449 in the following listing.
451 .Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
454 The interface has been configured up by the user-level code.
457 The interface supports broadcast.
460 Used to enable/disable driver debugging code.
463 The interface is a loopback device.
464 .It Dv IFF_POINTOPOINT
466 The interface is point-to-point;
468 address is actually the address of the other end.
471 The interface has been configured and dynamic resources were
472 successfully allocated.
473 Probably only useful internal to the
477 Disable network address resolution on this interface.
480 This interface is in promiscuous mode.
483 This interface is in the permanently promiscuous mode (implies
487 This interface is in all-multicasts mode (used by multicast routers).
490 The interface's hardware output queue (if any) is full; output packets
494 The interface cannot hear its own transmissions.
499 Control flags for the link layer.
500 (Currently abused to select among
501 multiple physical layers on some devices.)
504 This interface supports multicast.
511 .Sx Interface Capabilities Flags
514 .Ss "Interface Capabilities Flags"
515 Interface capabilities are specialized features an interface may
517 These capabilities are very hardware-specific
518 and allow, when enabled,
519 to offload specific network processing to the interface
520 or to offer a particular feature for use by other kernel parts.
522 It should be stressed that a capability can be completely
523 uncontrolled (i.e., stay always enabled with no way to disable it)
524 or allow limited control over itself (e.g., depend on another
526 Such peculiarities are determined solely by the hardware and driver
527 of a particular interface.
528 Only the driver possesses
529 the knowledge on whether and how the interface capabilities
531 Consequently, capabilities flags in
533 should never be modified directly by kernel code other than
534 the interface driver.
539 is the dedicated means to attempt altering
542 Userland code shall use
545 The following capabilities are currently supported by the system:
546 .Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent
548 This interface can be a network console.
550 This interface supports
552 See below for details.
554 This interface can do checksum validation on receiving data.
555 Some interfaces do not have sufficient buffer storage to store frames
556 above a certain MTU-size completely.
557 The driver for the interface might disable hardware checksum validation
558 if the MTU is set above the hardcoded limit.
560 This interface can do checksum calculation on transmitting data.
563 .Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
564 .It Dv IFCAP_VLAN_HWTAGGING
565 This interface can do VLAN tagging on output and
566 demultiplex frames by their VLAN tag on input.
567 .It Dv IFCAP_VLAN_MTU
570 driver can operate over this interface in software tagging mode
571 without having to decrease MTU on
573 interfaces below 1500 bytes.
574 This implies the ability of this interface to cope with frames somewhat
575 longer than permitted by the Ethernet specification.
576 .It Dv IFCAP_JUMBO_MTU
577 This Ethernet interface can transmit and receive frames up to
581 The ability of advanced network interfaces to offload certain
582 computational tasks from the host CPU to the board is limited
584 Therefore a separate field associated with an interface
586 .Va ifnet.if_data.ifi_hwassist
588 keeps a detailed description of its enabled capabilities
589 specific to TCP/IP processing.
590 The TCP/IP module consults the field to see which tasks
593 packet by the interface.
594 The flags defined for that field are a superset of those for
595 .Va mbuf.m_pkthdr.csum_flags ,
597 .Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
599 The interface will compute IP checksums.
601 The interface will compute TCP checksums.
603 The interface will compute UDP checksums.
605 The interface can compute a TCP or UDP checksum for a packet
606 fragmented by the host CPU.
607 Makes sense only along with
612 The interface will do the fragmentation of IP packets if necessary.
613 The host CPU does not need to care about MTU on this interface
614 as long as a packet to transmit through it is an IP one and it
615 does not exceed the size of the hardware buffer.
618 An interface notifies the TCP/IP module about the tasks
619 the former has performed on an
621 packet by setting the corresponding flags in the field
622 .Va mbuf.m_pkthdr.csum_flags
625 containing the packet.
630 The capability of a network interface to operate in
632 mode involves several flags in different
633 global variables and per-interface fields.
634 First, there is a system-wide
637 .Va kern.polling.enable ,
641 If that variable is set to non-zero,
643 will be used on those devices where it is enabled individually.
646 will not be used in the system.
647 Second, the capability flag
651 indicates support for
653 on the particular interface.
655 .Va if_capabilities ,
656 the same flag can be marked or cleared in the interface's
658 thus initiating switch of the interface to
662 The actual mode change will occur at an implementation-specific moment
663 in the future, e.g., during the next interrupt or
666 And finally, if the mode transition has been successful, the flag
668 is marked or cleared in the interface's
670 to indicate the current mode of the interface.
671 .Ss The Vt if_data Ss Structure
674 a subset of the interface information believed to be of interest to
675 management stations was segregated from the
677 structure and moved into its own
679 structure to facilitate its use by user programs.
680 The following elements of the
682 structure are initialized by the interface and are not expected to change
683 significantly over the course of normal operation:
684 .Bl -tag -width ".Va ifi_lastchange" -offset indent
687 The type of the interface, as defined in
689 and described below in the
690 .Sx "Interface Types"
694 Intended to represent a selection of physical layers on devices which
695 support more than one; never implemented.
698 Length of a link-layer address on this device, or zero if there are
700 Used to initialized the address length field in
702 structures referring to this interface.
705 Maximum length of any link-layer header which might be prepended by
706 the driver to a packet before transmission.
707 The generic code computes
708 the maximum over all interfaces and uses that value to influence the
711 to attempt to ensure that there is always
712 sufficient space to prepend a link-layer header without allocating an
717 .\" .It Va ifi_recvquota
719 .\" Number of packets the interface is permitted to receive at one time
720 .\" when in polled mode.
721 .\" .It Va ifi_xmitquota
723 .\" Number of packets the interface is permitted to queue for transmission
724 .\" at one time when in polled mode.
725 .\" There is some controversy over
726 .\" whether such a restriction makes any sense at all.
732 Allows some stabilization of the routing socket ABI in the face of
733 increases in the length of
737 The maximum transmission unit of the medium, exclusive of any
741 A dimensionless metric interpreted by a user-mode routing process.
744 The line rate of the interface, in bits per second.
747 A detailed interpretation of the capabilities
748 to offload computational tasks for
751 The interface driver must keep this field in accord with
756 The system uptime when interface was attached or the statistics
758 This is intended to be used to set the SNMP variable
759 .Va ifCounterDiscontinuityTime .
760 It may also be used to determine if two successive queries for an
761 interface of the same index have returned results for the same
765 The structure additionally contains generic statistics applicable to a
766 variety of different interface types (except as noted, all members are
769 .Bl -tag -width ".Va ifi_lastchange" -offset indent
770 .It Va ifi_link_state
772 The current link state of Ethernet interfaces.
774 .Sx Interface Link States
775 section for possible values.
777 Number of packets received.
779 Number of receive errors detected (e.g., FCS errors, DMA overruns,
781 More detailed breakdowns can often be had by way of a
784 Number of packets transmitted.
786 Number of output errors detected (e.g., late collisions, DMA overruns,
788 More detailed breakdowns can often be had by way of a
790 .It Va ifi_collisions
791 Total number of collisions detected on output for CSMA interfaces.
792 (This member is sometimes [ab]used by other types of interfaces for
793 other output error counts.)
795 Total traffic received, in bytes.
797 Total traffic transmitted, in bytes.
799 Number of packets received which were sent by link-layer multicast.
801 Number of packets sent by link-layer multicast.
803 Number of packets dropped on input.
806 Number of packets received for unknown network-layer protocol.
807 .\" .It Va ifi_recvtiming
808 .\" Amount of time, in microseconds, spent to receive an average packet on
813 .\" .It Va ifi_xmittiming
814 .\" Amount of time, in microseconds, spent to service a transmit-complete
815 .\" interrupt on this interface.
819 .It Va ifi_lastchange
820 .Pq Vt "struct timeval"
821 The time of the last administrative change to the interface (as required
828 defines symbolic constants for a number of different types of
832 .Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
834 none of the following
842 ISO 8802-5 Token Ring
848 Internet Point-to-Point Protocol
860 Asynchronous Transfer Mode
862 .Ss Interface Link States
863 The following link states are currently defined:
865 .Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
866 .It Dv LINK_STATE_UNKNOWN
867 The link is in an invalid or unknown state.
868 .It Dv LINK_STATE_DOWN
873 .Ss The Vt ifaddr Ss Structure
874 Every interface is associated with a list
877 of addresses, rooted at the interface structure's
880 The first element in this list is always an
882 address representing the interface itself; multi-access network
883 drivers should complete this structure by filling in their link-layer
884 addresses after calling
886 Other members of the structure represent network-layer addresses which
887 have been configured by means of the
891 called on a socket of the appropriate protocol family.
892 The elements of this list consist of
895 Most protocols will declare their own protocol-specific
896 interface address structures, but all begin with a
898 which provides the most-commonly-needed functionality across all
900 Interface addresses are reference-counted.
905 .Bl -tag -width ".Va ifa_rtrequest" -offset indent
907 .Pq Vt "struct sockaddr *"
908 The local address of the interface.
910 .Pq Vt "struct sockaddr *"
911 The remote address of point-to-point interfaces, and the broadcast
912 address of broadcast interfaces.
917 .Pq Vt "struct sockaddr *"
918 The network mask for multi-access interfaces, and the confusion
919 generator for point-to-point interfaces.
921 .Pq Vt "struct ifnet *"
922 A link back to the interface structure.
924 .Pq Fn TAILQ_ENTRY ifaddr
926 glue for list of addresses on each interface.
931 Some of the flags which would be used for a route representing this
932 address in the route table.
938 A metric associated with this interface address, for the use of some
939 external routing protocol.
944 structures are gained manually, by incrementing the
947 References are released by calling either the
954 is a pointer to a function which receives callouts from the routing
957 to perform link-layer-specific actions upon requests to add, resolve,
961 argument indicates the request in question:
962 .Dv RTM_ADD , RTM_RESOLVE ,
967 argument is the route in question; the
969 argument is the specific destination being manipulated
972 or a null pointer otherwise.
974 The functions provided by the generic interface code can be divided
975 into two groups: those which manipulate interfaces, and those which
976 manipulate interface addresses.
977 In addition to these functions, there
978 may also be link-layer support routines which are used by a number of
979 drivers implementing a specific link layer over different hardware;
980 see the documentation for that link layer for more details.
981 .Ss The Vt ifmultiaddr Ss Structure
982 Every multicast-capable interface is associated with a list of
983 multicast group memberships, which indicate at a low level which
984 link-layer multicast addresses (if any) should be accepted, and at a
985 high level, in which network-layer multicast groups a user process has
988 The elements of the structure are as follows:
989 .Bl -tag -width ".Va ifma_refcount" -offset indent
991 .Pq Fn LIST_ENTRY ifmultiaddr
995 .Pq Vt "struct sockaddr *"
996 A pointer to the address which this record represents.
998 memberships for various address families are stored in arbitrary
1001 .Pq Vt "struct sockaddr *"
1002 A pointer to the link-layer multicast address, if any, to which the
1003 network-layer multicast address in
1005 is mapped, else a null pointer.
1006 If this element is non-nil, this
1007 membership also holds an invisible reference to another membership for
1008 that link-layer address.
1009 .It Va ifma_refcount
1011 A reference count of requests for this particular membership.
1013 .Ss Interface Manipulation Functions
1014 .Bl -ohang -offset indent
1016 Allocate and initialize
1017 .Vt "struct ifnet" .
1018 Initialization includes the allocation of an interface index and may
1019 include the allocation of a
1021 specific structure in
1024 Link the specified interface
1026 into the list of network interfaces.
1027 Also initialize the list of
1028 addresses on that interface, and create a link-layer
1030 structure to be the first element in that list.
1032 this address structure is saved in the global array
1036 must have been allocated by
1039 Shut down and unlink the specified
1041 from the interface list.
1046 The interface must have been previously detached if it was ever attached.
1050 except that the given
1054 instead of the type in
1056 This is intended for use with drivers that change their interface type.
1063 flush its output queue, notify protocols of the transition,
1064 and generate a message from the
1070 as up, notify protocols of the transition,
1071 and generate a message from the
1075 Add or remove a promiscuous reference to
1079 is true, add a reference;
1080 if it is false, remove a reference.
1081 On reference count transitions
1082 from zero to one and one to zero, set the
1084 flag appropriately and call
1086 to set up the interface in the desired mode.
1090 but for the all-multicasts
1092 flag instead of the promiscuous flag.
1096 pointer for the interface named
1099 Process the ioctl request
1107 This is the main routine for handling all interface configuration
1108 requests from user mode.
1109 It is ordinarily only called from the socket-layer
1111 handler, and only for commands with class
1113 Any unrecognized commands will be passed down to socket
1116 further interpretation.
1117 The following commands are handled by
1120 .Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact
1123 Get interface configuration.
1124 (No call-down to driver.)
1127 Set the interface name.
1129 departure and arrival messages are sent so that
1130 routing code that relies on the interface name will update its interface
1132 Caller must have appropriate privilege.
1133 (No call-down to driver.)
1136 .It Dv SIOCGIFMETRIC
1139 Get interface capabilities, flags, metric, MTU, medium selection.
1140 (No call-down to driver.)
1143 Enable or disable interface capabilities.
1144 Caller must have appropriate privilege.
1145 Before a call to the driver-specific
1147 routine, the requested mask for enabled capabilities is checked
1148 against the mask of capabilities supported by the interface,
1149 .Va if_capabilities .
1150 Requesting to enable an unsupported capability is invalid.
1151 The rest is supposed to be done by the driver,
1152 which includes updating
1155 .Va if_data.ifi_hwassist
1159 Change interface flags.
1160 Caller must have appropriate privilege.
1167 is called as appropriate.
1170 are masked off, and the field
1172 in the interface structure is updated.
1175 routine is called to perform any setup
1178 .It Dv SIOCSIFMETRIC
1180 Change interface metric or medium.
1181 Caller must have appropriate privilege.
1184 Change interface MTU.
1185 Caller must have appropriate privilege.
1187 values less than 72 or greater than 65535 are considered invalid.
1190 routine is called to implement the change; it is responsible for any
1191 additional sanity checking and for actually modifying the MTU in the
1192 interface structure.
1196 Add or delete permanent multicast group memberships on the interface.
1197 Caller must have appropriate privilege.
1202 function is called to perform the operation; qq.v.
1204 .It Dv SIOCSIFDSTADDR
1206 .It Dv SIOCSIFBRDADDR
1207 .It Dv SIOCSIFNETMASK
1208 The socket's protocol control routine is called to implement the
1212 .It Dv OSIOCGIFDSTADDR
1213 .It Dv OSIOCGIFBRDADDR
1214 .It Dv OSIOCGIFNETMASK
1215 The socket's protocol control routine is called to implement the
1219 structures are converted into old-style (no
1233 .Ss "Interface Address Functions"
1234 Several functions exist to look up an interface address structure
1237 returns an interface address with either a local address or a
1238 broadcast address precisely matching the parameter
1240 .Fn ifa_ifwithdstaddr
1241 returns an interface address for a point-to-point interface whose
1248 returns the most specific interface address which matches the
1251 subject to its configured netmask, or a point-to-point interface
1252 address whose remote address is
1256 .Fn ifaof_ifpforaddr
1257 returns the most specific address configured on interface
1259 which matches address
1261 subject to its configured netmask.
1263 point-to-point, only an interface address whose remote address is
1268 All of these functions return a null pointer if no such address can be
1270 .Ss "Interface Multicast Address Functions"
1275 .Fn ifmaof_ifpforaddr
1276 functions provide support for requesting and relinquishing multicast
1277 group memberships, and for querying an interface's membership list,
1281 function takes a pointer to an interface,
1283 and a generic address,
1285 It also takes a pointer to a
1286 .Vt "struct ifmultiaddr *"
1287 which is filled in on successful return with the address of the
1288 group membership control block.
1291 function performs the following four-step process:
1292 .Bl -enum -offset indent
1294 Call the interface's
1296 entry point to determine the link-layer address, if any, corresponding
1297 to this membership request, and also to give the link layer an
1298 opportunity to veto this membership request should it so desire.
1300 Check the interface's group membership list for a pre-existing
1301 membership for this group.
1302 If one is not found, allocate a new one;
1303 if one is, increment its reference count.
1307 routine returned a link-layer address corresponding to the group,
1308 repeat the previous step for that address as well.
1310 If the interface's multicast address filter needs to be changed
1311 because a new membership was added, call the interface's
1318 to request that it do so.
1323 function, given an interface
1327 reverses this process.
1328 Both functions return zero on success, or a
1329 standard error number on failure.
1332 .Fn ifmaof_ifpforaddr
1333 function examines the membership list of interface
1335 for an address matching
1337 and returns a pointer to that
1338 .Vt "struct ifmultiaddr"
1339 if one is found, else it returns a null pointer.
1356 .%A W. Richard Stevens
1357 .%B TCP/IP Illustrated
1359 .%O Addison-Wesley, ISBN 0-201-63354-X
1362 This manual page was written by
1363 .An Garrett A. Wollman .