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 Flags describing operational parameters of this interface (see below).
291 (Manipulated by generic code.)
294 Flags describing operational status of this interface (see below).
295 (Manipulated by driver.)
296 .It Va if_capabilities
298 Flags describing the capabilities the interface supports (see below).
301 Flags describing the enabled capabilities of the interface (see below).
302 .\" .It Va if_ipending
303 .\" Interrupt-pending bits for polled operation:
305 .\" (transmit complete interrupt)
308 .\" (received packet ready interrupt).
312 .\" (Manipulated by driver.)
315 A pointer to an interface-specific MIB structure exported by
317 (Initialized by driver.)
320 The size of said structure.
321 (Initialized by driver.)
323 .Pq Vt "struct if_data"
324 More statistics and information; see
325 .Sx "The if_data structure" ,
327 (Initialized by driver, manipulated by both driver and generic
330 .Pq Vt "struct ifqueue"
332 (Manipulated by driver.)
333 .\".It Va if_poll_slowq
334 .\".Pq Vt "struct ifqueue *"
335 .\"A pointer to the input queue for devices which do not support polling
340 .\"(Initialized by driver.)
343 There are in addition a number of function pointers which the driver
344 must initialize to complete its interface with the generic interface
346 .Bl -ohang -offset indent
348 Pass a packet to an appropriate upper layer as determined
349 from the link-layer header of the packet.
350 This routine is to be called from an interrupt handler or
351 used to emulate reception of a packet on this interface.
352 A single function implementing
354 can be shared among multiple drivers utilizing the same link-layer
355 framing, e.g., Ethernet.
357 Output a packet on interface
359 or queue it on the output queue if the interface is already active.
361 Transmit a packet on an interface or queue it if the interface is
363 This function will return
365 if the devices software and hardware queues are both full.
366 This function must be installed after
368 to override the default implementation.
369 This function is exposed in order to allow drivers to manage their own queues
370 and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
372 The suggested internal software queueing mechanism is buf_ring.
374 Free mbufs in internally managed queues when the interface is marked down.
375 This function must be installed after
377 to override the default implementation.
378 This function is exposed in order to allow drivers to manage their own queues
379 and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
381 The suggested internal software queueing mechanism is buf_ring.
383 Start queued output on an interface.
384 This function is exposed in
385 order to provide for some interface classes to share a
389 may only be called when the
394 does not literally mean that output is active, but rather that the
395 device's internal output queue is full.) Please note that this function
396 will soon be deprecated.
399 We are not even sure what it was ever for.
400 The prototype is faked.
402 Process interface-related
407 Preliminary processing is done by the generic routine
409 to check for appropriate privileges, locate the interface being
410 manipulated, and perform certain generic operations like twiddling
411 flags and flushing queues.
412 See the description of
414 below for more information.
415 .\" .It Fn if_poll_recv
416 .\" .It Fn if_poll_xmit
417 .\" .It Fn if_poll_slowinput
418 .\" .It Fn if_poll_intren
423 Initialize and bring up the hardware,
424 e.g., reset the chip and enable the receiver unit.
425 Should mark the interface running,
427 .Dv ( IFF_DRV_RUNNING , ~IIF_DRV_OACTIVE ) .
428 .It Fn if_resolvemulti
429 Check the requested multicast group membership,
431 for validity, and if necessary compute a link-layer group which
432 corresponds to that address which is returned in
434 Returns zero on success, or an error code on failure.
436 .Ss "Interface Flags"
437 Interface flags are used for a number of different purposes.
439 flags simply indicate information about the type of interface and its
440 capabilities; others are dynamically manipulated to reflect the
441 current state of the interface.
442 Flags of the former kind are marked
444 in this table; the latter are marked
446 Flags which begin with
450 all other flags are stored in
455 defines the bits which cannot be set by a user program using the
459 these are indicated by an asterisk
461 in the following listing.
463 .Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
466 The interface has been configured up by the user-level code.
469 The interface supports broadcast.
472 Used to enable/disable driver debugging code.
475 The interface is a loopback device.
476 .It Dv IFF_POINTOPOINT
478 The interface is point-to-point;
480 address is actually the address of the other end.
481 .It Dv IFF_DRV_RUNNING
483 The interface has been configured and dynamic resources were
484 successfully allocated.
485 Probably only useful internal to the
489 Disable network address resolution on this interface.
492 This interface is in promiscuous mode.
495 This interface is in the permanently promiscuous mode (implies
499 This interface is in all-multicasts mode (used by multicast routers).
500 .It Dv IFF_DRV_OACTIVE
502 The interface's hardware output queue (if any) is full; output packets
506 The interface cannot hear its own transmissions.
511 Control flags for the link layer.
512 (Currently abused to select among
513 multiple physical layers on some devices.)
516 This interface supports multicast.
523 .Sx Interface Capabilities Flags
526 .Ss "Interface Capabilities Flags"
527 Interface capabilities are specialized features an interface may
529 These capabilities are very hardware-specific
530 and allow, when enabled,
531 to offload specific network processing to the interface
532 or to offer a particular feature for use by other kernel parts.
534 It should be stressed that a capability can be completely
535 uncontrolled (i.e., stay always enabled with no way to disable it)
536 or allow limited control over itself (e.g., depend on another
538 Such peculiarities are determined solely by the hardware and driver
539 of a particular interface.
540 Only the driver possesses
541 the knowledge on whether and how the interface capabilities
543 Consequently, capabilities flags in
545 should never be modified directly by kernel code other than
546 the interface driver.
551 is the dedicated means to attempt altering
554 Userland code shall use
557 The following capabilities are currently supported by the system:
558 .Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent
560 This interface can be a network console.
562 This interface supports
564 See below for details.
566 This interface can do checksum validation on receiving data.
567 Some interfaces do not have sufficient buffer storage to store frames
568 above a certain MTU-size completely.
569 The driver for the interface might disable hardware checksum validation
570 if the MTU is set above the hardcoded limit.
572 This interface can do checksum calculation on transmitting data.
575 .Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
576 .It Dv IFCAP_VLAN_HWTAGGING
577 This interface can do VLAN tagging on output and
578 demultiplex frames by their VLAN tag on input.
579 .It Dv IFCAP_VLAN_MTU
582 driver can operate over this interface in software tagging mode
583 without having to decrease MTU on
585 interfaces below 1500 bytes.
586 This implies the ability of this interface to cope with frames somewhat
587 longer than permitted by the Ethernet specification.
588 .It Dv IFCAP_JUMBO_MTU
589 This Ethernet interface can transmit and receive frames up to
593 The ability of advanced network interfaces to offload certain
594 computational tasks from the host CPU to the board is limited
596 Therefore a separate field associated with an interface
598 .Va ifnet.if_data.ifi_hwassist
600 keeps a detailed description of its enabled capabilities
601 specific to TCP/IP processing.
602 The TCP/IP module consults the field to see which tasks
605 packet by the interface.
606 The flags defined for that field are a superset of those for
607 .Va mbuf.m_pkthdr.csum_flags ,
609 .Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
611 The interface will compute IP checksums.
613 The interface will compute TCP checksums.
615 The interface will compute UDP checksums.
617 The interface can compute a TCP or UDP checksum for a packet
618 fragmented by the host CPU.
619 Makes sense only along with
624 The interface will do the fragmentation of IP packets if necessary.
625 The host CPU does not need to care about MTU on this interface
626 as long as a packet to transmit through it is an IP one and it
627 does not exceed the size of the hardware buffer.
630 An interface notifies the TCP/IP module about the tasks
631 the former has performed on an
633 packet by setting the corresponding flags in the field
634 .Va mbuf.m_pkthdr.csum_flags
637 containing the packet.
642 The capability of a network interface to operate in
644 mode involves several flags in different
645 global variables and per-interface fields.
646 First, there is a system-wide
649 .Va kern.polling.enable ,
653 If that variable is set to non-zero,
655 will be used on those devices where it is enabled individually.
658 will not be used in the system.
659 Second, the capability flag
663 indicates support for
665 on the particular interface.
667 .Va if_capabilities ,
668 the same flag can be marked or cleared in the interface's
670 thus initiating switch of the interface to
674 The actual mode change will occur at an implementation-specific moment
675 in the future, e.g., during the next interrupt or
678 And finally, if the mode transition has been successful, the flag
680 is marked or cleared in the interface's
682 to indicate the current mode of the interface.
683 .Ss The Vt if_data Ss Structure
686 a subset of the interface information believed to be of interest to
687 management stations was segregated from the
689 structure and moved into its own
691 structure to facilitate its use by user programs.
692 The following elements of the
694 structure are initialized by the interface and are not expected to change
695 significantly over the course of normal operation:
696 .Bl -tag -width ".Va ifi_lastchange" -offset indent
699 The type of the interface, as defined in
701 and described below in the
702 .Sx "Interface Types"
706 Intended to represent a selection of physical layers on devices which
707 support more than one; never implemented.
710 Length of a link-layer address on this device, or zero if there are
712 Used to initialized the address length field in
714 structures referring to this interface.
717 Maximum length of any link-layer header which might be prepended by
718 the driver to a packet before transmission.
719 The generic code computes
720 the maximum over all interfaces and uses that value to influence the
723 to attempt to ensure that there is always
724 sufficient space to prepend a link-layer header without allocating an
729 .\" .It Va ifi_recvquota
731 .\" Number of packets the interface is permitted to receive at one time
732 .\" when in polled mode.
733 .\" .It Va ifi_xmitquota
735 .\" Number of packets the interface is permitted to queue for transmission
736 .\" at one time when in polled mode.
737 .\" There is some controversy over
738 .\" whether such a restriction makes any sense at all.
744 Allows some stabilization of the routing socket ABI in the face of
745 increases in the length of
749 The maximum transmission unit of the medium, exclusive of any
753 A dimensionless metric interpreted by a user-mode routing process.
756 The line rate of the interface, in bits per second.
759 A detailed interpretation of the capabilities
760 to offload computational tasks for
763 The interface driver must keep this field in accord with
768 The system uptime when interface was attached or the statistics
770 This is intended to be used to set the SNMP variable
771 .Va ifCounterDiscontinuityTime .
772 It may also be used to determine if two successive queries for an
773 interface of the same index have returned results for the same
777 The structure additionally contains generic statistics applicable to a
778 variety of different interface types (except as noted, all members are
781 .Bl -tag -width ".Va ifi_lastchange" -offset indent
782 .It Va ifi_link_state
784 The current link state of Ethernet interfaces.
786 .Sx Interface Link States
787 section for possible values.
789 Number of packets received.
791 Number of receive errors detected (e.g., FCS errors, DMA overruns,
793 More detailed breakdowns can often be had by way of a
796 Number of packets transmitted.
798 Number of output errors detected (e.g., late collisions, DMA overruns,
800 More detailed breakdowns can often be had by way of a
802 .It Va ifi_collisions
803 Total number of collisions detected on output for CSMA interfaces.
804 (This member is sometimes [ab]used by other types of interfaces for
805 other output error counts.)
807 Total traffic received, in bytes.
809 Total traffic transmitted, in bytes.
811 Number of packets received which were sent by link-layer multicast.
813 Number of packets sent by link-layer multicast.
815 Number of packets dropped on input.
818 Number of packets received for unknown network-layer protocol.
819 .\" .It Va ifi_recvtiming
820 .\" Amount of time, in microseconds, spent to receive an average packet on
825 .\" .It Va ifi_xmittiming
826 .\" Amount of time, in microseconds, spent to service a transmit-complete
827 .\" interrupt on this interface.
831 .It Va ifi_lastchange
832 .Pq Vt "struct timeval"
833 The time of the last administrative change to the interface (as required
840 defines symbolic constants for a number of different types of
844 .Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
846 none of the following
854 ISO 8802-5 Token Ring
860 Internet Point-to-Point Protocol
872 Asynchronous Transfer Mode
874 .Ss Interface Link States
875 The following link states are currently defined:
877 .Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
878 .It Dv LINK_STATE_UNKNOWN
879 The link is in an invalid or unknown state.
880 .It Dv LINK_STATE_DOWN
885 .Ss The Vt ifaddr Ss Structure
886 Every interface is associated with a list
889 of addresses, rooted at the interface structure's
892 The first element in this list is always an
894 address representing the interface itself; multi-access network
895 drivers should complete this structure by filling in their link-layer
896 addresses after calling
898 Other members of the structure represent network-layer addresses which
899 have been configured by means of the
903 called on a socket of the appropriate protocol family.
904 The elements of this list consist of
907 Most protocols will declare their own protocol-specific
908 interface address structures, but all begin with a
910 which provides the most-commonly-needed functionality across all
912 Interface addresses are reference-counted.
917 .Bl -tag -width ".Va ifa_rtrequest" -offset indent
919 .Pq Vt "struct sockaddr *"
920 The local address of the interface.
922 .Pq Vt "struct sockaddr *"
923 The remote address of point-to-point interfaces, and the broadcast
924 address of broadcast interfaces.
929 .Pq Vt "struct sockaddr *"
930 The network mask for multi-access interfaces, and the confusion
931 generator for point-to-point interfaces.
933 .Pq Vt "struct ifnet *"
934 A link back to the interface structure.
936 .Pq Fn TAILQ_ENTRY ifaddr
938 glue for list of addresses on each interface.
943 Some of the flags which would be used for a route representing this
944 address in the route table.
950 A metric associated with this interface address, for the use of some
951 external routing protocol.
956 structures are gained manually, by incrementing the
959 References are released by calling either the
966 is a pointer to a function which receives callouts from the routing
969 to perform link-layer-specific actions upon requests to add, resolve,
973 argument indicates the request in question:
974 .Dv RTM_ADD , RTM_RESOLVE ,
979 argument is the route in question; the
981 argument is the specific destination being manipulated
984 or a null pointer otherwise.
986 The functions provided by the generic interface code can be divided
987 into two groups: those which manipulate interfaces, and those which
988 manipulate interface addresses.
989 In addition to these functions, there
990 may also be link-layer support routines which are used by a number of
991 drivers implementing a specific link layer over different hardware;
992 see the documentation for that link layer for more details.
993 .Ss The Vt ifmultiaddr Ss Structure
994 Every multicast-capable interface is associated with a list of
995 multicast group memberships, which indicate at a low level which
996 link-layer multicast addresses (if any) should be accepted, and at a
997 high level, in which network-layer multicast groups a user process has
1000 The elements of the structure are as follows:
1001 .Bl -tag -width ".Va ifma_refcount" -offset indent
1003 .Pq Fn LIST_ENTRY ifmultiaddr
1007 .Pq Vt "struct sockaddr *"
1008 A pointer to the address which this record represents.
1010 memberships for various address families are stored in arbitrary
1013 .Pq Vt "struct sockaddr *"
1014 A pointer to the link-layer multicast address, if any, to which the
1015 network-layer multicast address in
1017 is mapped, else a null pointer.
1018 If this element is non-nil, this
1019 membership also holds an invisible reference to another membership for
1020 that link-layer address.
1021 .It Va ifma_refcount
1023 A reference count of requests for this particular membership.
1025 .Ss Interface Manipulation Functions
1026 .Bl -ohang -offset indent
1028 Allocate and initialize
1029 .Vt "struct ifnet" .
1030 Initialization includes the allocation of an interface index and may
1031 include the allocation of a
1033 specific structure in
1036 Link the specified interface
1038 into the list of network interfaces.
1039 Also initialize the list of
1040 addresses on that interface, and create a link-layer
1042 structure to be the first element in that list.
1044 this address structure is saved in the global array
1048 must have been allocated by
1051 Shut down and unlink the specified
1053 from the interface list.
1058 The interface must have been previously detached if it was ever attached.
1062 except that the given
1066 instead of the type in
1068 This is intended for use with drivers that change their interface type.
1075 flush its output queue, notify protocols of the transition,
1076 and generate a message from the
1082 as up, notify protocols of the transition,
1083 and generate a message from the
1087 Add or remove a promiscuous reference to
1091 is true, add a reference;
1092 if it is false, remove a reference.
1093 On reference count transitions
1094 from zero to one and one to zero, set the
1096 flag appropriately and call
1098 to set up the interface in the desired mode.
1102 but for the all-multicasts
1104 flag instead of the promiscuous flag.
1108 pointer for the interface named
1111 Process the ioctl request
1119 This is the main routine for handling all interface configuration
1120 requests from user mode.
1121 It is ordinarily only called from the socket-layer
1123 handler, and only for commands with class
1125 Any unrecognized commands will be passed down to socket
1128 further interpretation.
1129 The following commands are handled by
1132 .Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact
1135 Get interface configuration.
1136 (No call-down to driver.)
1139 Set the interface name.
1141 departure and arrival messages are sent so that
1142 routing code that relies on the interface name will update its interface
1144 Caller must have appropriate privilege.
1145 (No call-down to driver.)
1148 .It Dv SIOCGIFMETRIC
1151 Get interface capabilities, flags, metric, MTU, medium selection.
1152 (No call-down to driver.)
1155 Enable or disable interface capabilities.
1156 Caller must have appropriate privilege.
1157 Before a call to the driver-specific
1159 routine, the requested mask for enabled capabilities is checked
1160 against the mask of capabilities supported by the interface,
1161 .Va if_capabilities .
1162 Requesting to enable an unsupported capability is invalid.
1163 The rest is supposed to be done by the driver,
1164 which includes updating
1167 .Va if_data.ifi_hwassist
1171 Change interface flags.
1172 Caller must have appropriate privilege.
1179 is called as appropriate.
1182 are masked off, and the field
1184 in the interface structure is updated.
1187 routine is called to perform any setup
1190 .It Dv SIOCSIFMETRIC
1192 Change interface metric or medium.
1193 Caller must have appropriate privilege.
1196 Change interface MTU.
1197 Caller must have appropriate privilege.
1199 values less than 72 or greater than 65535 are considered invalid.
1202 routine is called to implement the change; it is responsible for any
1203 additional sanity checking and for actually modifying the MTU in the
1204 interface structure.
1208 Add or delete permanent multicast group memberships on the interface.
1209 Caller must have appropriate privilege.
1214 function is called to perform the operation; qq.v.
1216 .It Dv SIOCSIFDSTADDR
1218 .It Dv SIOCSIFBRDADDR
1219 .It Dv SIOCSIFNETMASK
1220 The socket's protocol control routine is called to implement the
1224 .It Dv OSIOCGIFDSTADDR
1225 .It Dv OSIOCGIFBRDADDR
1226 .It Dv OSIOCGIFNETMASK
1227 The socket's protocol control routine is called to implement the
1231 structures are converted into old-style (no
1245 .Ss "Interface Address Functions"
1246 Several functions exist to look up an interface address structure
1249 returns an interface address with either a local address or a
1250 broadcast address precisely matching the parameter
1252 .Fn ifa_ifwithdstaddr
1253 returns an interface address for a point-to-point interface whose
1260 returns the most specific interface address which matches the
1263 subject to its configured netmask, or a point-to-point interface
1264 address whose remote address is
1268 .Fn ifaof_ifpforaddr
1269 returns the most specific address configured on interface
1271 which matches address
1273 subject to its configured netmask.
1275 point-to-point, only an interface address whose remote address is
1280 All of these functions return a null pointer if no such address can be
1282 .Ss "Interface Multicast Address Functions"
1287 .Fn ifmaof_ifpforaddr
1288 functions provide support for requesting and relinquishing multicast
1289 group memberships, and for querying an interface's membership list,
1293 function takes a pointer to an interface,
1295 and a generic address,
1297 It also takes a pointer to a
1298 .Vt "struct ifmultiaddr *"
1299 which is filled in on successful return with the address of the
1300 group membership control block.
1303 function performs the following four-step process:
1304 .Bl -enum -offset indent
1306 Call the interface's
1308 entry point to determine the link-layer address, if any, corresponding
1309 to this membership request, and also to give the link layer an
1310 opportunity to veto this membership request should it so desire.
1312 Check the interface's group membership list for a pre-existing
1313 membership for this group.
1314 If one is not found, allocate a new one;
1315 if one is, increment its reference count.
1319 routine returned a link-layer address corresponding to the group,
1320 repeat the previous step for that address as well.
1322 If the interface's multicast address filter needs to be changed
1323 because a new membership was added, call the interface's
1330 to request that it do so.
1335 function, given an interface
1339 reverses this process.
1340 Both functions return zero on success, or a
1341 standard error number on failure.
1344 .Fn ifmaof_ifpforaddr
1345 function examines the membership list of interface
1347 for an address matching
1349 and returns a pointer to that
1350 .Vt "struct ifmultiaddr"
1351 if one is found, else it returns a null pointer.
1368 .%A W. Richard Stevens
1369 .%B TCP/IP Illustrated
1371 .%O Addison-Wesley, ISBN 0-201-63354-X
1374 This manual page was written by
1375 .An Garrett A. Wollman .