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 .Fn if_initname ) . )
244 .Pq Vt "const char *"
245 The name of the driver.
246 (Initialized by driver
248 .Fn if_initname ) . )
251 A unique number assigned to each interface managed by a particular
253 Drivers may choose to set this to
255 if a unit number is not associated with the device.
256 (Initialized by driver
258 .Fn if_initname ) . )
260 .Pq Vt "struct ifaddrhead"
264 containing the list of addresses assigned to this interface.
267 A count of promiscuous listeners on this interface, used to
272 .Pq Vt "struct bpf_if *"
273 Opaque per-interface data for the packet filter,
279 A unique number assigned to each interface in sequence as it is
281 This number can be used in a
282 .Vt "struct sockaddr_dl"
283 to refer to a particular interface by index
290 Number of seconds until the watchdog timer
292 is called, or zero if the timer is disabled.
294 decremented by generic watchdog code.)
297 Flags describing operational parameters of this interface (see below).
298 (Manipulated by generic code.)
301 Flags describing operational status of this interface (see below).
302 (Manipulated by driver.)
303 .It Va if_capabilities
305 Flags describing the capabilities the interface supports (see below).
308 Flags describing the enabled capabilities of the interface (see below).
309 .\" .It Va if_ipending
310 .\" Interrupt-pending bits for polled operation:
312 .\" (transmit complete interrupt)
315 .\" (received packet ready interrupt).
319 .\" (Manipulated by driver.)
322 A pointer to an interface-specific MIB structure exported by
324 (Initialized by driver.)
327 The size of said structure.
328 (Initialized by driver.)
330 .Pq Vt "struct if_data"
331 More statistics and information; see
332 .Sx "The if_data structure" ,
334 (Initialized by driver, manipulated by both driver and generic
337 .Pq Vt "struct ifqueue"
339 (Manipulated by driver.)
340 .\".It Va if_poll_slowq
341 .\".Pq Vt "struct ifqueue *"
342 .\"A pointer to the input queue for devices which do not support polling
347 .\"(Initialized by driver.)
350 There are in addition a number of function pointers which the driver
351 must initialize to complete its interface with the generic interface
353 .Bl -ohang -offset indent
355 Pass a packet to an appropriate upper layer as determined
356 from the link-layer header of the packet.
357 This routine is to be called from an interrupt handler or
358 used to emulate reception of a packet on this interface.
359 A single function implementing
361 can be shared among multiple drivers utilizing the same link-layer
362 framing, e.g., Ethernet.
364 Output a packet on interface
366 or queue it on the output queue if the interface is already active.
368 Transmit a packet on an interface or queue it if the interface is
370 This function will return
372 if the devices software and hardware queues are both full.
373 This function must be installed after
375 to override the default implementation.
376 This function is exposed in order to allow drivers to manage their own queues
377 and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
379 The suggested internal software queueing mechanism is buf_ring.
381 Free mbufs in internally managed queues when the interface is marked down.
382 This function must be installed after
384 to override the default implementation.
385 This function is exposed in order to allow drivers to manage their own queues
386 and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
388 The suggested internal software queueing mechanism is buf_ring.
390 Start queued output on an interface.
391 This function is exposed in
392 order to provide for some interface classes to share a
396 may only be called when the
401 does not literally mean that output is active, but rather that the
402 device's internal output queue is full.) Please note that this function
403 will soon be deprecated.
406 We are not even sure what it was ever for.
407 The prototype is faked.
409 Process interface-related
414 Preliminary processing is done by the generic routine
416 to check for appropriate privileges, locate the interface being
417 manipulated, and perform certain generic operations like twiddling
418 flags and flushing queues.
419 See the description of
421 below for more information.
423 Routine called by the generic code when the watchdog timer,
426 Usually this will reset the interface.
427 .\" .It Fn if_poll_recv
428 .\" .It Fn if_poll_xmit
429 .\" .It Fn if_poll_slowinput
430 .\" .It Fn if_poll_intren
435 Initialize and bring up the hardware,
436 e.g., reset the chip and the watchdog timer and enable the receiver unit.
437 Should mark the interface running,
439 .Dv ( IFF_DRV_RUNNING , ~IIF_DRV_OACTIVE ) .
440 .It Fn if_resolvemulti
441 Check the requested multicast group membership,
443 for validity, and if necessary compute a link-layer group which
444 corresponds to that address which is returned in
446 Returns zero on success, or an error code on failure.
448 .Ss "Interface Flags"
449 Interface flags are used for a number of different purposes.
451 flags simply indicate information about the type of interface and its
452 capabilities; others are dynamically manipulated to reflect the
453 current state of the interface.
454 Flags of the former kind are marked
456 in this table; the latter are marked
458 Flags which begin with
462 all other flags are stored in
467 defines the bits which cannot be set by a user program using the
471 these are indicated by an asterisk
473 in the following listing.
475 .Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
478 The interface has been configured up by the user-level code.
481 The interface supports broadcast.
484 Used to enable/disable driver debugging code.
487 The interface is a loopback device.
488 .It Dv IFF_POINTOPOINT
490 The interface is point-to-point;
492 address is actually the address of the other end.
493 .It Dv IFF_DRV_RUNNING
495 The interface has been configured and dynamic resources were
496 successfully allocated.
497 Probably only useful internal to the
501 Disable network address resolution on this interface.
504 This interface is in promiscuous mode.
507 This interface is in the permanently promiscuous mode (implies
511 This interface is in all-multicasts mode (used by multicast routers).
512 .It Dv IFF_DRV_OACTIVE
514 The interface's hardware output queue (if any) is full; output packets
518 The interface cannot hear its own transmissions.
523 Control flags for the link layer.
524 (Currently abused to select among
525 multiple physical layers on some devices.)
528 This interface supports multicast.
535 .Sx Interface Capabilities Flags
538 .Ss "Interface Capabilities Flags"
539 Interface capabilities are specialized features an interface may
541 These capabilities are very hardware-specific
542 and allow, when enabled,
543 to offload specific network processing to the interface
544 or to offer a particular feature for use by other kernel parts.
546 It should be stressed that a capability can be completely
547 uncontrolled (i.e., stay always enabled with no way to disable it)
548 or allow limited control over itself (e.g., depend on another
550 Such peculiarities are determined solely by the hardware and driver
551 of a particular interface.
552 Only the driver possesses
553 the knowledge on whether and how the interface capabilities
555 Consequently, capabilities flags in
557 should never be modified directly by kernel code other than
558 the interface driver.
563 is the dedicated means to attempt altering
566 Userland code shall use
569 The following capabilities are currently supported by the system:
570 .Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent
572 This interface can be a network console.
574 This interface supports
576 See below for details.
578 This interface can do checksum validation on receiving data.
579 Some interfaces do not have sufficient buffer storage to store frames
580 above a certain MTU-size completely.
581 The driver for the interface might disable hardware checksum validation
582 if the MTU is set above the hardcoded limit.
584 This interface can do checksum calculation on transmitting data.
587 .Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
588 .It Dv IFCAP_VLAN_HWTAGGING
589 This interface can do VLAN tagging on output and
590 demultiplex frames by their VLAN tag on input.
591 .It Dv IFCAP_VLAN_MTU
594 driver can operate over this interface in software tagging mode
595 without having to decrease MTU on
597 interfaces below 1500 bytes.
598 This implies the ability of this interface to cope with frames somewhat
599 longer than permitted by the Ethernet specification.
600 .It Dv IFCAP_JUMBO_MTU
601 This Ethernet interface can transmit and receive frames up to
604 This Ethernet interface supports TCP Segmentation offloading.
606 This Ethernet interface supports TCP6 Segmentation offloading.
609 .Pq Dv IFCAP_TSO4 | IFCAP_TSO6 .
611 This Ethernet interface supports TCP offloading.
613 This Ethernet interface supports TCP6 offloading.
616 .Pq Dv IFCAP_TOE4 | IFCAP_TOE6 .
617 .It Dv IFCAP_WOL_UCAST
618 This Ethernet interface supports waking up on any Unicast packet.
619 .It Dv IFCAP_WOL_MCAST
620 This Ethernet interface supports waking up on any Multicast packet.
621 .It Dv IFCAP_WOL_MAGIC
622 This Ethernet interface supports waking up on any Magic packet such
627 .Pq Dv IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC .
630 The ability of advanced network interfaces to offload certain
631 computational tasks from the host CPU to the board is limited
633 Therefore a separate field associated with an interface
635 .Va ifnet.if_data.ifi_hwassist
637 keeps a detailed description of its enabled capabilities
638 specific to TCP/IP processing.
639 The TCP/IP module consults the field to see which tasks
642 packet by the interface.
643 The flags defined for that field are a superset of those for
644 .Va mbuf.m_pkthdr.csum_flags ,
646 .Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
648 The interface will compute IP checksums.
650 The interface will compute TCP checksums.
652 The interface will compute UDP checksums.
654 The interface can compute a TCP or UDP checksum for a packet
655 fragmented by the host CPU.
656 Makes sense only along with
661 The interface will do the fragmentation of IP packets if necessary.
662 The host CPU does not need to care about MTU on this interface
663 as long as a packet to transmit through it is an IP one and it
664 does not exceed the size of the hardware buffer.
667 An interface notifies the TCP/IP module about the tasks
668 the former has performed on an
670 packet by setting the corresponding flags in the field
671 .Va mbuf.m_pkthdr.csum_flags
674 containing the packet.
679 The capability of a network interface to operate in
681 mode involves several flags in different
682 global variables and per-interface fields.
683 First, there is a system-wide
686 .Va kern.polling.enable ,
690 If that variable is set to non-zero,
692 will be used on those devices where it is enabled individually.
695 will not be used in the system.
696 Second, the capability flag
700 indicates support for
702 on the particular interface.
704 .Va if_capabilities ,
705 the same flag can be marked or cleared in the interface's
707 thus initiating switch of the interface to
711 The actual mode change will occur at an implementation-specific moment
712 in the future, e.g., during the next interrupt or
715 And finally, if the mode transition has been successful, the flag
717 is marked or cleared in the interface's
719 to indicate the current mode of the interface.
720 .Ss The Vt if_data Ss Structure
723 a subset of the interface information believed to be of interest to
724 management stations was segregated from the
726 structure and moved into its own
728 structure to facilitate its use by user programs.
729 The following elements of the
731 structure are initialized by the interface and are not expected to change
732 significantly over the course of normal operation:
733 .Bl -tag -width ".Va ifi_lastchange" -offset indent
736 The type of the interface, as defined in
738 and described below in the
739 .Sx "Interface Types"
743 Intended to represent a selection of physical layers on devices which
744 support more than one; never implemented.
747 Length of a link-layer address on this device, or zero if there are
749 Used to initialized the address length field in
751 structures referring to this interface.
754 Maximum length of any link-layer header which might be prepended by
755 the driver to a packet before transmission.
756 The generic code computes
757 the maximum over all interfaces and uses that value to influence the
760 to attempt to ensure that there is always
761 sufficient space to prepend a link-layer header without allocating an
766 .\" .It Va ifi_recvquota
768 .\" Number of packets the interface is permitted to receive at one time
769 .\" when in polled mode.
770 .\" .It Va ifi_xmitquota
772 .\" Number of packets the interface is permitted to queue for transmission
773 .\" at one time when in polled mode.
774 .\" There is some controversy over
775 .\" whether such a restriction makes any sense at all.
781 Allows some stabilization of the routing socket ABI in the face of
782 increases in the length of
786 The maximum transmission unit of the medium, exclusive of any
790 A dimensionless metric interpreted by a user-mode routing process.
793 The line rate of the interface, in bits per second.
796 A detailed interpretation of the capabilities
797 to offload computational tasks for
800 The interface driver must keep this field in accord with
805 The system uptime when interface was attached or the statistics
807 This is intended to be used to set the SNMP variable
808 .Va ifCounterDiscontinuityTime .
809 It may also be used to determine if two successive queries for an
810 interface of the same index have returned results for the same
814 The structure additionally contains generic statistics applicable to a
815 variety of different interface types (except as noted, all members are
818 .Bl -tag -width ".Va ifi_lastchange" -offset indent
819 .It Va ifi_link_state
821 The current link state of Ethernet interfaces.
823 .Sx Interface Link States
824 section for possible values.
826 Number of packets received.
828 Number of receive errors detected (e.g., FCS errors, DMA overruns,
830 More detailed breakdowns can often be had by way of a
833 Number of packets transmitted.
835 Number of output errors detected (e.g., late collisions, DMA overruns,
837 More detailed breakdowns can often be had by way of a
839 .It Va ifi_collisions
840 Total number of collisions detected on output for CSMA interfaces.
841 (This member is sometimes [ab]used by other types of interfaces for
842 other output error counts.)
844 Total traffic received, in bytes.
846 Total traffic transmitted, in bytes.
848 Number of packets received which were sent by link-layer multicast.
850 Number of packets sent by link-layer multicast.
852 Number of packets dropped on input.
855 Number of packets received for unknown network-layer protocol.
856 .\" .It Va ifi_recvtiming
857 .\" Amount of time, in microseconds, spent to receive an average packet on
862 .\" .It Va ifi_xmittiming
863 .\" Amount of time, in microseconds, spent to service a transmit-complete
864 .\" interrupt on this interface.
868 .It Va ifi_lastchange
869 .Pq Vt "struct timeval"
870 The time of the last administrative change to the interface (as required
877 defines symbolic constants for a number of different types of
881 .Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
883 none of the following
891 ISO 8802-5 Token Ring
897 Internet Point-to-Point Protocol
909 Asynchronous Transfer Mode
911 .Ss Interface Link States
912 The following link states are currently defined:
914 .Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
915 .It Dv LINK_STATE_UNKNOWN
916 The link is in an invalid or unknown state.
917 .It Dv LINK_STATE_DOWN
922 .Ss The Vt ifaddr Ss Structure
923 Every interface is associated with a list
926 of addresses, rooted at the interface structure's
929 The first element in this list is always an
931 address representing the interface itself; multi-access network
932 drivers should complete this structure by filling in their link-layer
933 addresses after calling
935 Other members of the structure represent network-layer addresses which
936 have been configured by means of the
940 called on a socket of the appropriate protocol family.
941 The elements of this list consist of
944 Most protocols will declare their own protocol-specific
945 interface address structures, but all begin with a
947 which provides the most-commonly-needed functionality across all
949 Interface addresses are reference-counted.
954 .Bl -tag -width ".Va ifa_rtrequest" -offset indent
956 .Pq Vt "struct sockaddr *"
957 The local address of the interface.
959 .Pq Vt "struct sockaddr *"
960 The remote address of point-to-point interfaces, and the broadcast
961 address of broadcast interfaces.
966 .Pq Vt "struct sockaddr *"
967 The network mask for multi-access interfaces, and the confusion
968 generator for point-to-point interfaces.
970 .Pq Vt "struct ifnet *"
971 A link back to the interface structure.
973 .Pq Fn TAILQ_ENTRY ifaddr
975 glue for list of addresses on each interface.
980 Some of the flags which would be used for a route representing this
981 address in the route table.
987 A metric associated with this interface address, for the use of some
988 external routing protocol.
993 structures are gained manually, by incrementing the
996 References are released by calling either the
1003 is a pointer to a function which receives callouts from the routing
1006 to perform link-layer-specific actions upon requests to add, resolve,
1010 argument indicates the request in question:
1011 .Dv RTM_ADD , RTM_RESOLVE ,
1016 argument is the route in question; the
1018 argument is the specific destination being manipulated
1021 or a null pointer otherwise.
1023 The functions provided by the generic interface code can be divided
1024 into two groups: those which manipulate interfaces, and those which
1025 manipulate interface addresses.
1026 In addition to these functions, there
1027 may also be link-layer support routines which are used by a number of
1028 drivers implementing a specific link layer over different hardware;
1029 see the documentation for that link layer for more details.
1030 .Ss The Vt ifmultiaddr Ss Structure
1031 Every multicast-capable interface is associated with a list of
1032 multicast group memberships, which indicate at a low level which
1033 link-layer multicast addresses (if any) should be accepted, and at a
1034 high level, in which network-layer multicast groups a user process has
1037 The elements of the structure are as follows:
1038 .Bl -tag -width ".Va ifma_refcount" -offset indent
1040 .Pq Fn LIST_ENTRY ifmultiaddr
1044 .Pq Vt "struct sockaddr *"
1045 A pointer to the address which this record represents.
1047 memberships for various address families are stored in arbitrary
1050 .Pq Vt "struct sockaddr *"
1051 A pointer to the link-layer multicast address, if any, to which the
1052 network-layer multicast address in
1054 is mapped, else a null pointer.
1055 If this element is non-nil, this
1056 membership also holds an invisible reference to another membership for
1057 that link-layer address.
1058 .It Va ifma_refcount
1060 A reference count of requests for this particular membership.
1062 .Ss Interface Manipulation Functions
1063 .Bl -ohang -offset indent
1065 Allocate and initialize
1066 .Vt "struct ifnet" .
1067 Initialization includes the allocation of an interface index and may
1068 include the allocation of a
1070 specific structure in
1073 Link the specified interface
1075 into the list of network interfaces.
1076 Also initialize the list of
1077 addresses on that interface, and create a link-layer
1079 structure to be the first element in that list.
1081 this address structure is saved in the global array
1085 must have been allocated by
1088 Shut down and unlink the specified
1090 from the interface list.
1095 The interface must have been previously detached if it was ever attached.
1099 except that the given
1103 instead of the type in
1105 This is intended for use with drivers that change their interface type.
1112 flush its output queue, notify protocols of the transition,
1113 and generate a message from the
1119 as up, notify protocols of the transition,
1120 and generate a message from the
1124 Add or remove a promiscuous reference to
1128 is true, add a reference;
1129 if it is false, remove a reference.
1130 On reference count transitions
1131 from zero to one and one to zero, set the
1133 flag appropriately and call
1135 to set up the interface in the desired mode.
1139 but for the all-multicasts
1141 flag instead of the promiscuous flag.
1145 pointer for the interface named
1148 Process the ioctl request
1156 This is the main routine for handling all interface configuration
1157 requests from user mode.
1158 It is ordinarily only called from the socket-layer
1160 handler, and only for commands with class
1162 Any unrecognized commands will be passed down to socket
1165 further interpretation.
1166 The following commands are handled by
1169 .Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact
1172 Get interface configuration.
1173 (No call-down to driver.)
1176 Set the interface name.
1178 departure and arrival messages are sent so that
1179 routing code that relies on the interface name will update its interface
1181 Caller must have appropriate privilege.
1182 (No call-down to driver.)
1186 .It Dv SIOCGIFMETRIC
1189 Get interface capabilities, FIB, flags, metric, MTU, medium selection.
1190 (No call-down to driver.)
1193 Enable or disable interface capabilities.
1194 Caller must have appropriate privilege.
1195 Before a call to the driver-specific
1197 routine, the requested mask for enabled capabilities is checked
1198 against the mask of capabilities supported by the interface,
1199 .Va if_capabilities .
1200 Requesting to enable an unsupported capability is invalid.
1201 The rest is supposed to be done by the driver,
1202 which includes updating
1205 .Va if_data.ifi_hwassist
1210 Caller must have appropriate privilege.
1211 FIB values start at 0 and values greater or equals than
1213 are considered invalid.
1215 Change interface flags.
1216 Caller must have appropriate privilege.
1223 is called as appropriate.
1226 are masked off, and the field
1228 in the interface structure is updated.
1231 routine is called to perform any setup
1234 .It Dv SIOCSIFMETRIC
1236 Change interface metric or medium.
1237 Caller must have appropriate privilege.
1240 Change interface MTU.
1241 Caller must have appropriate privilege.
1243 values less than 72 or greater than 65535 are considered invalid.
1246 routine is called to implement the change; it is responsible for any
1247 additional sanity checking and for actually modifying the MTU in the
1248 interface structure.
1252 Add or delete permanent multicast group memberships on the interface.
1253 Caller must have appropriate privilege.
1258 function is called to perform the operation; qq.v.
1260 .It Dv SIOCSIFDSTADDR
1262 .It Dv SIOCSIFBRDADDR
1263 .It Dv SIOCSIFNETMASK
1264 The socket's protocol control routine is called to implement the
1268 .It Dv OSIOCGIFDSTADDR
1269 .It Dv OSIOCGIFBRDADDR
1270 .It Dv OSIOCGIFNETMASK
1271 The socket's protocol control routine is called to implement the
1275 structures are converted into old-style (no
1289 .Ss "Interface Address Functions"
1290 Several functions exist to look up an interface address structure
1293 returns an interface address with either a local address or a
1294 broadcast address precisely matching the parameter
1296 .Fn ifa_ifwithdstaddr
1297 returns an interface address for a point-to-point interface whose
1304 returns the most specific interface address which matches the
1307 subject to its configured netmask, or a point-to-point interface
1308 address whose remote address is
1312 .Fn ifaof_ifpforaddr
1313 returns the most specific address configured on interface
1315 which matches address
1317 subject to its configured netmask.
1319 point-to-point, only an interface address whose remote address is
1324 All of these functions return a null pointer if no such address can be
1326 .Ss "Interface Multicast Address Functions"
1331 .Fn ifmaof_ifpforaddr
1332 functions provide support for requesting and relinquishing multicast
1333 group memberships, and for querying an interface's membership list,
1337 function takes a pointer to an interface,
1339 and a generic address,
1341 It also takes a pointer to a
1342 .Vt "struct ifmultiaddr *"
1343 which is filled in on successful return with the address of the
1344 group membership control block.
1347 function performs the following four-step process:
1348 .Bl -enum -offset indent
1350 Call the interface's
1352 entry point to determine the link-layer address, if any, corresponding
1353 to this membership request, and also to give the link layer an
1354 opportunity to veto this membership request should it so desire.
1356 Check the interface's group membership list for a pre-existing
1357 membership for this group.
1358 If one is not found, allocate a new one;
1359 if one is, increment its reference count.
1363 routine returned a link-layer address corresponding to the group,
1364 repeat the previous step for that address as well.
1366 If the interface's multicast address filter needs to be changed
1367 because a new membership was added, call the interface's
1374 to request that it do so.
1379 function, given an interface
1383 reverses this process.
1384 Both functions return zero on success, or a
1385 standard error number on failure.
1388 .Fn ifmaof_ifpforaddr
1389 function examines the membership list of interface
1391 for an address matching
1393 and returns a pointer to that
1394 .Vt "struct ifmultiaddr"
1395 if one is found, else it returns a null pointer.
1412 .%A W. Richard Stevens
1413 .%B TCP/IP Illustrated
1415 .%O Addison-Wesley, ISBN 0-201-63354-X
1418 This manual page was written by
1419 .An Garrett A. Wollman .