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
605 The ability of advanced network interfaces to offload certain
606 computational tasks from the host CPU to the board is limited
608 Therefore a separate field associated with an interface
610 .Va ifnet.if_data.ifi_hwassist
612 keeps a detailed description of its enabled capabilities
613 specific to TCP/IP processing.
614 The TCP/IP module consults the field to see which tasks
617 packet by the interface.
618 The flags defined for that field are a superset of those for
619 .Va mbuf.m_pkthdr.csum_flags ,
621 .Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
623 The interface will compute IP checksums.
625 The interface will compute TCP checksums.
627 The interface will compute UDP checksums.
629 The interface can compute a TCP or UDP checksum for a packet
630 fragmented by the host CPU.
631 Makes sense only along with
636 The interface will do the fragmentation of IP packets if necessary.
637 The host CPU does not need to care about MTU on this interface
638 as long as a packet to transmit through it is an IP one and it
639 does not exceed the size of the hardware buffer.
642 An interface notifies the TCP/IP module about the tasks
643 the former has performed on an
645 packet by setting the corresponding flags in the field
646 .Va mbuf.m_pkthdr.csum_flags
649 containing the packet.
654 The capability of a network interface to operate in
656 mode involves several flags in different
657 global variables and per-interface fields.
658 First, there is a system-wide
661 .Va kern.polling.enable ,
665 If that variable is set to non-zero,
667 will be used on those devices where it is enabled individually.
670 will not be used in the system.
671 Second, the capability flag
675 indicates support for
677 on the particular interface.
679 .Va if_capabilities ,
680 the same flag can be marked or cleared in the interface's
682 thus initiating switch of the interface to
686 The actual mode change will occur at an implementation-specific moment
687 in the future, e.g., during the next interrupt or
690 And finally, if the mode transition has been successful, the flag
692 is marked or cleared in the interface's
694 to indicate the current mode of the interface.
695 .Ss The Vt if_data Ss Structure
698 a subset of the interface information believed to be of interest to
699 management stations was segregated from the
701 structure and moved into its own
703 structure to facilitate its use by user programs.
704 The following elements of the
706 structure are initialized by the interface and are not expected to change
707 significantly over the course of normal operation:
708 .Bl -tag -width ".Va ifi_lastchange" -offset indent
711 The type of the interface, as defined in
713 and described below in the
714 .Sx "Interface Types"
718 Intended to represent a selection of physical layers on devices which
719 support more than one; never implemented.
722 Length of a link-layer address on this device, or zero if there are
724 Used to initialized the address length field in
726 structures referring to this interface.
729 Maximum length of any link-layer header which might be prepended by
730 the driver to a packet before transmission.
731 The generic code computes
732 the maximum over all interfaces and uses that value to influence the
735 to attempt to ensure that there is always
736 sufficient space to prepend a link-layer header without allocating an
741 .\" .It Va ifi_recvquota
743 .\" Number of packets the interface is permitted to receive at one time
744 .\" when in polled mode.
745 .\" .It Va ifi_xmitquota
747 .\" Number of packets the interface is permitted to queue for transmission
748 .\" at one time when in polled mode.
749 .\" There is some controversy over
750 .\" whether such a restriction makes any sense at all.
756 Allows some stabilization of the routing socket ABI in the face of
757 increases in the length of
761 The maximum transmission unit of the medium, exclusive of any
765 A dimensionless metric interpreted by a user-mode routing process.
768 The line rate of the interface, in bits per second.
771 A detailed interpretation of the capabilities
772 to offload computational tasks for
775 The interface driver must keep this field in accord with
780 The system uptime when interface was attached or the statistics
782 This is intended to be used to set the SNMP variable
783 .Va ifCounterDiscontinuityTime .
784 It may also be used to determine if two successive queries for an
785 interface of the same index have returned results for the same
789 The structure additionally contains generic statistics applicable to a
790 variety of different interface types (except as noted, all members are
793 .Bl -tag -width ".Va ifi_lastchange" -offset indent
794 .It Va ifi_link_state
796 The current link state of Ethernet interfaces.
798 .Sx Interface Link States
799 section for possible values.
801 Number of packets received.
803 Number of receive errors detected (e.g., FCS errors, DMA overruns,
805 More detailed breakdowns can often be had by way of a
808 Number of packets transmitted.
810 Number of output errors detected (e.g., late collisions, DMA overruns,
812 More detailed breakdowns can often be had by way of a
814 .It Va ifi_collisions
815 Total number of collisions detected on output for CSMA interfaces.
816 (This member is sometimes [ab]used by other types of interfaces for
817 other output error counts.)
819 Total traffic received, in bytes.
821 Total traffic transmitted, in bytes.
823 Number of packets received which were sent by link-layer multicast.
825 Number of packets sent by link-layer multicast.
827 Number of packets dropped on input.
830 Number of packets received for unknown network-layer protocol.
831 .\" .It Va ifi_recvtiming
832 .\" Amount of time, in microseconds, spent to receive an average packet on
837 .\" .It Va ifi_xmittiming
838 .\" Amount of time, in microseconds, spent to service a transmit-complete
839 .\" interrupt on this interface.
843 .It Va ifi_lastchange
844 .Pq Vt "struct timeval"
845 The time of the last administrative change to the interface (as required
852 defines symbolic constants for a number of different types of
856 .Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
858 none of the following
866 ISO 8802-5 Token Ring
872 Internet Point-to-Point Protocol
884 Asynchronous Transfer Mode
886 .Ss Interface Link States
887 The following link states are currently defined:
889 .Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
890 .It Dv LINK_STATE_UNKNOWN
891 The link is in an invalid or unknown state.
892 .It Dv LINK_STATE_DOWN
897 .Ss The Vt ifaddr Ss Structure
898 Every interface is associated with a list
901 of addresses, rooted at the interface structure's
904 The first element in this list is always an
906 address representing the interface itself; multi-access network
907 drivers should complete this structure by filling in their link-layer
908 addresses after calling
910 Other members of the structure represent network-layer addresses which
911 have been configured by means of the
915 called on a socket of the appropriate protocol family.
916 The elements of this list consist of
919 Most protocols will declare their own protocol-specific
920 interface address structures, but all begin with a
922 which provides the most-commonly-needed functionality across all
924 Interface addresses are reference-counted.
929 .Bl -tag -width ".Va ifa_rtrequest" -offset indent
931 .Pq Vt "struct sockaddr *"
932 The local address of the interface.
934 .Pq Vt "struct sockaddr *"
935 The remote address of point-to-point interfaces, and the broadcast
936 address of broadcast interfaces.
941 .Pq Vt "struct sockaddr *"
942 The network mask for multi-access interfaces, and the confusion
943 generator for point-to-point interfaces.
945 .Pq Vt "struct ifnet *"
946 A link back to the interface structure.
948 .Pq Fn TAILQ_ENTRY ifaddr
950 glue for list of addresses on each interface.
955 Some of the flags which would be used for a route representing this
956 address in the route table.
962 A metric associated with this interface address, for the use of some
963 external routing protocol.
968 structures are gained manually, by incrementing the
971 References are released by calling either the
978 is a pointer to a function which receives callouts from the routing
981 to perform link-layer-specific actions upon requests to add, resolve,
985 argument indicates the request in question:
986 .Dv RTM_ADD , RTM_RESOLVE ,
991 argument is the route in question; the
993 argument is the specific destination being manipulated
996 or a null pointer otherwise.
998 The functions provided by the generic interface code can be divided
999 into two groups: those which manipulate interfaces, and those which
1000 manipulate interface addresses.
1001 In addition to these functions, there
1002 may also be link-layer support routines which are used by a number of
1003 drivers implementing a specific link layer over different hardware;
1004 see the documentation for that link layer for more details.
1005 .Ss The Vt ifmultiaddr Ss Structure
1006 Every multicast-capable interface is associated with a list of
1007 multicast group memberships, which indicate at a low level which
1008 link-layer multicast addresses (if any) should be accepted, and at a
1009 high level, in which network-layer multicast groups a user process has
1012 The elements of the structure are as follows:
1013 .Bl -tag -width ".Va ifma_refcount" -offset indent
1015 .Pq Fn LIST_ENTRY ifmultiaddr
1019 .Pq Vt "struct sockaddr *"
1020 A pointer to the address which this record represents.
1022 memberships for various address families are stored in arbitrary
1025 .Pq Vt "struct sockaddr *"
1026 A pointer to the link-layer multicast address, if any, to which the
1027 network-layer multicast address in
1029 is mapped, else a null pointer.
1030 If this element is non-nil, this
1031 membership also holds an invisible reference to another membership for
1032 that link-layer address.
1033 .It Va ifma_refcount
1035 A reference count of requests for this particular membership.
1037 .Ss Interface Manipulation Functions
1038 .Bl -ohang -offset indent
1040 Allocate and initialize
1041 .Vt "struct ifnet" .
1042 Initialization includes the allocation of an interface index and may
1043 include the allocation of a
1045 specific structure in
1048 Link the specified interface
1050 into the list of network interfaces.
1051 Also initialize the list of
1052 addresses on that interface, and create a link-layer
1054 structure to be the first element in that list.
1056 this address structure is saved in the global array
1060 must have been allocated by
1063 Shut down and unlink the specified
1065 from the interface list.
1070 The interface must have been previously detached if it was ever attached.
1074 except that the given
1078 instead of the type in
1080 This is intended for use with drivers that change their interface type.
1087 flush its output queue, notify protocols of the transition,
1088 and generate a message from the
1094 as up, notify protocols of the transition,
1095 and generate a message from the
1099 Add or remove a promiscuous reference to
1103 is true, add a reference;
1104 if it is false, remove a reference.
1105 On reference count transitions
1106 from zero to one and one to zero, set the
1108 flag appropriately and call
1110 to set up the interface in the desired mode.
1114 but for the all-multicasts
1116 flag instead of the promiscuous flag.
1120 pointer for the interface named
1123 Process the ioctl request
1131 This is the main routine for handling all interface configuration
1132 requests from user mode.
1133 It is ordinarily only called from the socket-layer
1135 handler, and only for commands with class
1137 Any unrecognized commands will be passed down to socket
1140 further interpretation.
1141 The following commands are handled by
1144 .Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact
1147 Get interface configuration.
1148 (No call-down to driver.)
1151 Set the interface name.
1153 departure and arrival messages are sent so that
1154 routing code that relies on the interface name will update its interface
1156 Caller must have appropriate privilege.
1157 (No call-down to driver.)
1160 .It Dv SIOCGIFMETRIC
1163 Get interface capabilities, flags, metric, MTU, medium selection.
1164 (No call-down to driver.)
1167 Enable or disable interface capabilities.
1168 Caller must have appropriate privilege.
1169 Before a call to the driver-specific
1171 routine, the requested mask for enabled capabilities is checked
1172 against the mask of capabilities supported by the interface,
1173 .Va if_capabilities .
1174 Requesting to enable an unsupported capability is invalid.
1175 The rest is supposed to be done by the driver,
1176 which includes updating
1179 .Va if_data.ifi_hwassist
1183 Change interface flags.
1184 Caller must have appropriate privilege.
1191 is called as appropriate.
1194 are masked off, and the field
1196 in the interface structure is updated.
1199 routine is called to perform any setup
1202 .It Dv SIOCSIFMETRIC
1204 Change interface metric or medium.
1205 Caller must have appropriate privilege.
1208 Change interface MTU.
1209 Caller must have appropriate privilege.
1211 values less than 72 or greater than 65535 are considered invalid.
1214 routine is called to implement the change; it is responsible for any
1215 additional sanity checking and for actually modifying the MTU in the
1216 interface structure.
1220 Add or delete permanent multicast group memberships on the interface.
1221 Caller must have appropriate privilege.
1226 function is called to perform the operation; qq.v.
1228 .It Dv SIOCSIFDSTADDR
1230 .It Dv SIOCSIFBRDADDR
1231 .It Dv SIOCSIFNETMASK
1232 The socket's protocol control routine is called to implement the
1236 .It Dv OSIOCGIFDSTADDR
1237 .It Dv OSIOCGIFBRDADDR
1238 .It Dv OSIOCGIFNETMASK
1239 The socket's protocol control routine is called to implement the
1243 structures are converted into old-style (no
1257 .Ss "Interface Address Functions"
1258 Several functions exist to look up an interface address structure
1261 returns an interface address with either a local address or a
1262 broadcast address precisely matching the parameter
1264 .Fn ifa_ifwithdstaddr
1265 returns an interface address for a point-to-point interface whose
1272 returns the most specific interface address which matches the
1275 subject to its configured netmask, or a point-to-point interface
1276 address whose remote address is
1280 .Fn ifaof_ifpforaddr
1281 returns the most specific address configured on interface
1283 which matches address
1285 subject to its configured netmask.
1287 point-to-point, only an interface address whose remote address is
1292 All of these functions return a null pointer if no such address can be
1294 .Ss "Interface Multicast Address Functions"
1299 .Fn ifmaof_ifpforaddr
1300 functions provide support for requesting and relinquishing multicast
1301 group memberships, and for querying an interface's membership list,
1305 function takes a pointer to an interface,
1307 and a generic address,
1309 It also takes a pointer to a
1310 .Vt "struct ifmultiaddr *"
1311 which is filled in on successful return with the address of the
1312 group membership control block.
1315 function performs the following four-step process:
1316 .Bl -enum -offset indent
1318 Call the interface's
1320 entry point to determine the link-layer address, if any, corresponding
1321 to this membership request, and also to give the link layer an
1322 opportunity to veto this membership request should it so desire.
1324 Check the interface's group membership list for a pre-existing
1325 membership for this group.
1326 If one is not found, allocate a new one;
1327 if one is, increment its reference count.
1331 routine returned a link-layer address corresponding to the group,
1332 repeat the previous step for that address as well.
1334 If the interface's multicast address filter needs to be changed
1335 because a new membership was added, call the interface's
1342 to request that it do so.
1347 function, given an interface
1351 reverses this process.
1352 Both functions return zero on success, or a
1353 standard error number on failure.
1356 .Fn ifmaof_ifpforaddr
1357 function examines the membership list of interface
1359 for an address matching
1361 and returns a pointer to that
1362 .Vt "struct ifmultiaddr"
1363 if one is found, else it returns a null pointer.
1380 .%A W. Richard Stevens
1381 .%B TCP/IP Illustrated
1383 .%O Addison-Wesley, ISBN 0-201-63354-X
1386 This manual page was written by
1387 .An Garrett A. Wollman .