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_done\*(rp "struct ifnet *ifp"
108 .Fn \*(lp*if_ioctl\*(rp "struct ifnet *ifp" "int cmd" "caddr_t data"
110 .Fn \*(lp*if_watchdog\*(rp "struct ifnet *ifp"
112 .Fn \*(lp*if_poll_recv\*(rp "struct ifnet *ifp" "int *quotap"
114 .Fn \*(lp*if_poll_xmit\*(rp "struct ifnet *ifp" "int *quotap"
116 .Fn \*(lp*if_poll_inttrn\*(rp "struct ifnet *ifp"
118 .Fn \*(lp*if_poll_slowinput\*(rp "struct ifnet *ifp" "struct mbuf *m"
120 .Fn \*(lp*if_init\*(rp "void *if_softc"
122 .Fo \*(lp*if_resolvemulti\*(rp
123 .Fa "struct ifnet *ifp" "struct sockaddr **retsa" "struct sockaddr *addr"
125 .Ss "struct ifaddr member function"
127 .Fo \*(lp*ifa_rtrequest\*(rp
128 .Fa "int cmd" "struct rtentry *rt" "struct sockaddr *dst"
131 .Ss "Global Variables"
132 .Vt extern struct ifnethead ifnet ;
133 .Vt extern struct ifaddr **ifnet_addrs ;
134 .Vt extern int if_index ;
135 .Vt extern int ifqmaxlen ;
137 The kernel mechanisms for handling network interfaces reside primarily
139 .Vt ifnet , if_data , ifaddr ,
146 and the functions named above and defined in
148 Those interfaces which are intended to be used by user programs
151 these include the interface flags, the
153 structure, and the structures defining the appearance of
154 interface-related messages on the
156 routing socket and in
160 defines the kernel-internal interfaces, including the
164 structures and the functions which manipulate them.
165 (A few user programs will need
167 because it is the prerequisite of some other header file like
168 .In netinet/if_ether.h .
169 Most references to those two files in particular can be replaced by
170 .In net/ethernet.h . )
172 The system keeps a linked list of interfaces using the
176 this list is headed by a
177 .Vt "struct ifnethead"
180 The elements of this list are of type
182 and most kernel routines which manipulate interface as such accept or
183 return pointers to these structures.
184 Each interface structure
187 structure, which contains statistics and identifying information used
188 by management programs, and which is exported to user programs by way
194 Each interface also has a
196 of interface addresses, described by
198 structures; the head of the queue is always an
203 describing the link layer implemented by the interface (if any).
204 (Some trivial interfaces do not provide any link layer addresses;
205 this structure, while still present, serves only to identify the
206 interface name and index.)
208 Finally, those interfaces supporting reception of multicast datagrams
211 of multicast group memberships, described by
214 These memberships are reference-counted.
216 Interfaces are also associated with an output queue, defined as a
217 .Vt "struct ifqueue" ;
218 this structure is used to hold packets while the interface is in the
219 process of sending another.
221 .Ss The Vt ifnet Ss structure
225 .Bl -tag -width ".Va if_capabilities" -offset indent
228 A pointer to the driver's private state block.
229 (Initialized by driver.)
232 A pointer to the common data for the interface's layer 2 protocol.
236 .Pq Fn TAILQ_ENTRY ifnet
241 The name of the interface,
246 (Initialized by driver.)
248 .Pq Vt "const char *"
249 The name of the driver.
250 (Initialized by driver.)
253 A unique number assigned to each interface managed by a particular
255 Drivers may choose to set this to
257 if a unit number is not associated with the device.
258 (Initialized by driver.)
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 both driver and generic code.)
299 .It Va if_capabilities
301 Flags describing the capabilities the interface supports (see below).
304 Flags describing the enabled capabilities of the interface (see below).
305 .\" .It Va if_ipending
306 .\" Interrupt-pending bits for polled operation:
308 .\" (transmit complete interrupt)
311 .\" (received packet ready interrupt).
315 .\" (Manipulated by driver.)
318 A pointer to an interface-specific MIB structure exported by
320 (Initialized by driver.)
323 The size of said structure.
324 (Initialized by driver.)
326 .Pq Vt "struct if_data"
327 More statistics and information; see
328 .Sx "The if_data structure" ,
330 (Initialized by driver, manipulated by both driver and generic
333 .Pq Vt "struct ifqueue"
335 (Manipulated by driver.)
336 .\".It Va if_poll_slowq
337 .\".Pq Vt "struct ifqueue *"
338 .\"A pointer to the input queue for devices which do not support polling
343 .\"(Initialized by driver.)
346 There are in addition a number of function pointers which the driver
347 must initialize to complete its interface with the generic interface
349 .Bl -ohang -offset indent
351 Pass a packet to an appropriate upper layer as determined
352 from the link-layer header of the packet.
353 This routine is to be called from an interrupt handler or
354 used to emulate reception of a packet on this interface.
355 A single function implementing
357 can be shared among multiple drivers utilizing the same link-layer
358 framing, e.g., Ethernet.
360 Output a packet on interface
362 or queue it on the output queue if the interface is already active.
364 Start queued output on an interface.
365 This function is exposed in
366 order to provide for some interface classes to share a
370 may only be called when the
375 does not literally mean that output is active, but rather that the
376 device's internal output queue is full.)
379 We are not even sure what it was ever for.
380 The prototype is faked.
382 Process interface-related
387 Preliminary processing is done by the generic routine
389 to check for appropriate privileges, locate the interface being
390 manipulated, and perform certain generic operations like twiddling
391 flags and flushing queues.
392 See the description of
394 below for more information.
396 Routine called by the generic code when the watchdog timer,
399 Usually this will reset the interface.
400 .\" .It Fn if_poll_recv
401 .\" .It Fn if_poll_xmit
402 .\" .It Fn if_poll_slowinput
403 .\" .It Fn if_poll_intren
408 Initialize and bring up the hardware,
409 e.g., reset the chip and the watchdog timer and enable the receiver unit.
410 Should mark the interface running,
412 .Dv ( IFF_RUNNING , ~IIF_OACTIVE ) .
413 .It Fn if_resolvemulti
414 Check the requested multicast group membership,
416 for validity, and if necessary compute a link-layer group which
417 corresponds to that address which is returned in
419 Returns zero on success, or an error code on failure.
421 .Ss "Interface Flags"
422 Interface flags are used for a number of different purposes.
424 flags simply indicate information about the type of interface and its
425 capabilities; others are dynamically manipulated to reflect the
426 current state of the interface.
427 Flags of the former kind are marked
429 in this table; the latter are marked
434 defines the bits which cannot be set by a user program using the
438 these are indicated by an asterisk
440 in the following listing.
442 .Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
445 The interface has been configured up by the user-level code.
448 The interface supports broadcast.
451 Used to enable/disable driver debugging code.
454 The interface is a loopback device.
455 .It Dv IFF_POINTOPOINT
457 The interface is point-to-point;
459 address is actually the address of the other end.
462 The interface has been configured and dynamic resources were
463 successfully allocated.
464 Probably only useful internal to the
468 Disable network address resolution on this interface.
471 This interface is in promiscuous mode.
474 This interface is in the permanently promiscuous mode (implies
478 This interface is in all-multicasts mode (used by multicast routers).
481 The interface's hardware output queue (if any) is full; output packets
485 The interface cannot hear its own transmissions.
490 Control flags for the link layer.
491 (Currently abused to select among
492 multiple physical layers on some devices.)
495 This interface supports multicast.
502 .Sx Interface Capabilities Flags
505 .Ss "Interface Capabilities Flags"
506 Interface capabilities are specialized features an interface may
508 These capabilities are very hardware-specific
509 and allow, when enabled,
510 to offload specific network processing to the interface
511 or to offer a particular feature for use by other kernel parts.
513 It should be stressed that a capability can be completely
514 uncontrolled (i.e., stay always enabled with no way to disable it)
515 or allow limited control over itself (e.g., depend on another
517 Such peculiarities are determined solely by the hardware and driver
518 of a particular interface.
519 Only the driver possesses
520 the knowledge on whether and how the interface capabilities
522 Consequently, capabilities flags in
524 should never be modified directly by kernel code other than
525 the interface driver.
530 is the dedicated means to attempt altering
533 Userland code shall use
536 The following capabilities are currently supported by the system:
537 .Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent
539 This interface can be a network console.
541 This interface supports
543 See below for details.
545 This interface can do checksum validation on receiving data.
546 Some interfaces do not have sufficient buffer storage to store frames
547 above a certain MTU-size completely.
548 The driver for the interface might disable hardware checksum validation
549 if the MTU is set above the hardcoded limit.
551 This interface can do checksum calculation on transmitting data.
554 .Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
555 .It Dv IFCAP_VLAN_HWTAGGING
556 This interface can do VLAN tagging on output and
557 demultiplex frames by their VLAN tag on input.
558 .It Dv IFCAP_VLAN_MTU
561 driver can operate over this interface in software tagging mode
562 without having to decrease MTU on
564 interfaces below 1500 bytes.
565 This implies the ability of this interface to cope with frames somewhat
566 longer than permitted by the Ethernet specification.
567 .It Dv IFCAP_JUMBO_MTU
568 This Ethernet interface can transmit and receive frames up to
572 The ability of advanced network interfaces to offload certain
573 computational tasks from the host CPU to the board is limited
575 Therefore a separate field associated with an interface
577 .Va ifnet.if_data.ifi_hwassist
579 keeps a detailed description of its enabled capabilities
580 specific to TCP/IP processing.
581 The TCP/IP module consults the field to see which tasks
584 packet by the interface.
585 The flags defined for that field are a superset of those for
586 .Va mbuf.m_pkthdr.csum_flags ,
588 .Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
590 The interface will compute IP checksums.
592 The interface will compute TCP checksums.
594 The interface will compute UDP checksums.
596 The interface can compute a TCP or UDP checksum for a packet
597 fragmented by the host CPU.
598 Makes sense only along with
603 The interface will do the fragmentation of IP packets if necessary.
604 The host CPU does not need to care about MTU on this interface
605 as long as a packet to transmit through it is an IP one and it
606 does not exceed the size of the hardware buffer.
609 An interface notifies the TCP/IP module about the tasks
610 the former has performed on an
612 packet by setting the corresponding flags in the field
613 .Va mbuf.m_pkthdr.csum_flags
616 containing the packet.
621 The capability of a network interface to operate in
623 mode involves several flags in different
624 global variables and per-interface fields.
625 First, there is a system-wide
628 .Va kern.polling.enable ,
632 If that variable is set to non-zero,
634 will be used on those devices where it is enabled individually.
637 will not be used in the system.
638 Second, the capability flag
642 indicates support for
644 on the particular interface.
646 .Va if_capabilities ,
647 the same flag can be marked or cleared in the interface's
649 thus initiating switch of the interface to
653 The actual mode change will occur at an implementation-specific moment
654 in the future, e.g., during the next interrupt or
657 And finally, if the mode transition has been successful, the flag
659 is marked or cleared in the interface's
661 to indicate the current mode of the interface.
662 .Ss The Vt if_data Ss Structure
665 a subset of the interface information believed to be of interest to
666 management stations was segregated from the
668 structure and moved into its own
670 structure to facilitate its use by user programs.
671 The following elements of the
673 structure are initialized by the interface and are not expected to change
674 significantly over the course of normal operation:
675 .Bl -tag -width ".Va ifi_lastchange" -offset indent
678 The type of the interface, as defined in
680 and described below in the
681 .Sx "Interface Types"
685 Intended to represent a selection of physical layers on devices which
686 support more than one; never implemented.
689 Length of a link-layer address on this device, or zero if there are
691 Used to initialized the address length field in
693 structures referring to this interface.
696 Maximum length of any link-layer header which might be prepended by
697 the driver to a packet before transmission.
698 The generic code computes
699 the maximum over all interfaces and uses that value to influence the
702 to attempt to ensure that there is always
703 sufficient space to prepend a link-layer header without allocating an
708 .\" .It Va ifi_recvquota
710 .\" Number of packets the interface is permitted to receive at one time
711 .\" when in polled mode.
712 .\" .It Va ifi_xmitquota
714 .\" Number of packets the interface is permitted to queue for transmission
715 .\" at one time when in polled mode.
716 .\" There is some controversy over
717 .\" whether such a restriction makes any sense at all.
723 Allows some stabilization of the routing socket ABI in the face of
724 increases in the length of
728 The maximum transmission unit of the medium, exclusive of any
732 A dimensionless metric interpreted by a user-mode routing process.
735 The line rate of the interface, in bits per second.
738 A detailed interpretation of the capabilities
739 to offload computational tasks for
742 The interface driver must keep this field in accord with
747 The system uptime when interface was attached or the statistics
749 This is intended to be used to set the SNMP variable
750 .Va ifCounterDiscontinuityTime .
751 It may also be used to determine if two successive queries for an
752 interface of the same index have returned results for the same
756 The structure additionally contains generic statistics applicable to a
757 variety of different interface types (except as noted, all members are
760 .Bl -tag -width ".Va ifi_lastchange" -offset indent
761 .It Va ifi_link_state
763 The current link state of Ethernet interfaces.
765 .Sx Interface Link States
766 section for possible values.
768 Number of packets received.
770 Number of receive errors detected (e.g., FCS errors, DMA overruns,
772 More detailed breakdowns can often be had by way of a
775 Number of packets transmitted.
777 Number of output errors detected (e.g., late collisions, DMA overruns,
779 More detailed breakdowns can often be had by way of a
781 .It Va ifi_collisions
782 Total number of collisions detected on output for CSMA interfaces.
783 (This member is sometimes [ab]used by other types of interfaces for
784 other output error counts.)
786 Total traffic received, in bytes.
788 Total traffic transmitted, in bytes.
790 Number of packets received which were sent by link-layer multicast.
792 Number of packets sent by link-layer multicast.
794 Number of packets dropped on input.
797 Number of packets received for unknown network-layer protocol.
798 .\" .It Va ifi_recvtiming
799 .\" Amount of time, in microseconds, spent to receive an average packet on
804 .\" .It Va ifi_xmittiming
805 .\" Amount of time, in microseconds, spent to service a transmit-complete
806 .\" interrupt on this interface.
810 .It Va ifi_lastchange
811 .Pq Vt "struct timeval"
812 The time of the last administrative change to the interface (as required
819 defines symbolic constants for a number of different types of
823 .Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
825 none of the following
833 ISO 8802-5 Token Ring
839 Internet Point-to-Point Protocol
851 Asynchronous Transfer Mode
853 .Ss Interface Link States
854 The following link states are currently defined:
856 .Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
857 .It Dv LINK_STATE_UNKNOWN
858 The link is in an invalid or unknown state.
859 .It Dv LINK_STATE_DOWN
864 .Ss The Vt ifaddr Ss Structure
865 Every interface is associated with a list
868 of addresses, rooted at the interface structure's
871 The first element in this list is always an
873 address representing the interface itself; multi-access network
874 drivers should complete this structure by filling in their link-layer
875 addresses after calling
877 Other members of the structure represent network-layer addresses which
878 have been configured by means of the
882 called on a socket of the appropriate protocol family.
883 The elements of this list consist of
886 Most protocols will declare their own protocol-specific
887 interface address structures, but all begin with a
889 which provides the most-commonly-needed functionality across all
891 Interface addresses are reference-counted.
896 .Bl -tag -width ".Va ifa_rtrequest" -offset indent
898 .Pq Vt "struct sockaddr *"
899 The local address of the interface.
901 .Pq Vt "struct sockaddr *"
902 The remote address of point-to-point interfaces, and the broadcast
903 address of broadcast interfaces.
908 .Pq Vt "struct sockaddr *"
909 The network mask for multi-access interfaces, and the confusion
910 generator for point-to-point interfaces.
912 .Pq Vt "struct ifnet *"
913 A link back to the interface structure.
915 .Pq Fn TAILQ_ENTRY ifaddr
917 glue for list of addresses on each interface.
922 Some of the flags which would be used for a route representing this
923 address in the route table.
929 A metric associated with this interface address, for the use of some
930 external routing protocol.
935 structures are gained manually, by incrementing the
938 References are released by calling either the
945 is a pointer to a function which receives callouts from the routing
948 to perform link-layer-specific actions upon requests to add, resolve,
952 argument indicates the request in question:
953 .Dv RTM_ADD , RTM_RESOLVE ,
958 argument is the route in question; the
960 argument is the specific destination being manipulated
963 or a null pointer otherwise.
965 The functions provided by the generic interface code can be divided
966 into two groups: those which manipulate interfaces, and those which
967 manipulate interface addresses.
968 In addition to these functions, there
969 may also be link-layer support routines which are used by a number of
970 drivers implementing a specific link layer over different hardware;
971 see the documentation for that link layer for more details.
972 .Ss The Vt ifmultiaddr Ss Structure
973 Every multicast-capable interface is associated with a list of
974 multicast group memberships, which indicate at a low level which
975 link-layer multicast addresses (if any) should be accepted, and at a
976 high level, in which network-layer multicast groups a user process has
979 The elements of the structure are as follows:
980 .Bl -tag -width ".Va ifma_refcount" -offset indent
982 .Pq Fn LIST_ENTRY ifmultiaddr
986 .Pq Vt "struct sockaddr *"
987 A pointer to the address which this record represents.
989 memberships for various address families are stored in arbitrary
992 .Pq Vt "struct sockaddr *"
993 A pointer to the link-layer multicast address, if any, to which the
994 network-layer multicast address in
996 is mapped, else a null pointer.
997 If this element is non-nil, this
998 membership also holds an invisible reference to another membership for
999 that link-layer address.
1000 .It Va ifma_refcount
1002 A reference count of requests for this particular membership.
1004 .Ss Interface Manipulation Functions
1005 .Bl -ohang -offset indent
1007 Allocate and initialize
1008 .Vt "struct ifnet" .
1009 Initalization includes the allocation of an interface index and may
1010 include the allocation of a
1012 specific structure in
1015 Link the specified interface
1017 into the list of network interfaces.
1018 Also initialize the list of
1019 addresses on that interface, and create a link-layer
1021 structure to be the first element in that list.
1023 this address structure is saved in the global array
1027 must have been allocted by
1030 Shut down and unlink the specified
1032 from the interface list.
1037 The interface must have been previously detached if it was ever attached.
1041 except that the given
1045 instead of the type in
1047 This is intended for use with drivers that change their interface type.
1054 flush its output queue, notify protocols of the transition,
1055 and generate a message from the
1061 as up, notify protocols of the transition,
1062 and generate a message from the
1066 Add or remove a promiscuous reference to
1070 is true, add a reference;
1071 if it is false, remove a reference.
1072 On reference count transitions
1073 from zero to one and one to zero, set the
1075 flag appropriately and call
1077 to set up the interface in the desired mode.
1081 but for the all-multicasts
1083 flag instead of the promiscuous flag.
1087 pointer for the interface named
1090 Process the ioctl request
1098 This is the main routine for handling all interface configuration
1099 requests from user mode.
1100 It is ordinarily only called from the socket-layer
1102 handler, and only for commands with class
1104 Any unrecognized commands will be passed down to socket
1107 further interpretation.
1108 The following commands are handled by
1111 .Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact
1114 Get interface configuration.
1115 (No call-down to driver.)
1118 Set the interface name.
1120 departure and arrival messages are sent so that
1121 routing code that relies on the interface name will update its interface
1123 Caller must have appropriate privilege.
1124 (No call-down to driver.)
1127 .It Dv SIOCGIFMETRIC
1130 Get interface capabilities, flags, metric, MTU, medium selection.
1131 (No call-down to driver.)
1134 Enable or disable interface capabilities.
1135 Caller must have appropriate privilege.
1136 Before a call to the driver-specific
1138 routine, the requested mask for enabled capabilities is checked
1139 against the mask of capabilities supported by the interface,
1140 .Va if_capabilities .
1141 Requesting to enable an unsupported capability is invalid.
1142 The rest is supposed to be done by the driver,
1143 which includes updating
1146 .Va if_data.ifi_hwassist
1150 Change interface flags.
1151 Caller must have appropriate privilege.
1158 is called as appropriate.
1161 are masked off, and the field
1163 in the interface structure is updated.
1166 routine is called to perform any setup
1169 .It Dv SIOCSIFMETRIC
1171 Change interface metric or medium.
1172 Caller must have appropriate privilege.
1175 Change interface MTU.
1176 Caller must have appropriate privilege.
1178 values less than 72 or greater than 65535 are considered invalid.
1181 routine is called to implement the change; it is responsible for any
1182 additional sanity checking and for actually modifying the MTU in the
1183 interface structure.
1187 Add or delete permanent multicast group memberships on the interface.
1188 Caller must have appropriate privilege.
1193 function is called to perform the operation; qq.v.
1195 .It Dv SIOCSIFDSTADDR
1197 .It Dv SIOCSIFBRDADDR
1198 .It Dv SIOCSIFNETMASK
1199 The socket's protocol control routine is called to implement the
1203 .It Dv OSIOCGIFDSTADDR
1204 .It Dv OSIOCGIFBRDADDR
1205 .It Dv OSIOCGIFNETMASK
1206 The socket's protocol control routine is called to implement the
1210 structures are converted into old-style (no
1224 .Ss "Interface Address Functions"
1225 Several functions exist to look up an interface address structure
1228 returns an interface address with either a local address or a
1229 broadcast address precisely matching the parameter
1231 .Fn ifa_ifwithdstaddr
1232 returns an interface address for a point-to-point interface whose
1239 returns the most specific interface address which matches the
1242 subject to its configured netmask, or a point-to-point interface
1243 address whose remote address is
1247 .Fn ifaof_ifpforaddr
1248 returns the most specific address configured on interface
1250 which matches address
1252 subject to its configured netmask.
1254 point-to-point, only an interface address whose remote address is
1259 All of these functions return a null pointer if no such address can be
1261 .Ss "Interface Multicast Address Functions"
1266 .Fn ifmaof_ifpforaddr
1267 functions provide support for requesting and relinquishing multicast
1268 group memberships, and for querying an interface's membership list,
1272 function takes a pointer to an interface,
1274 and a generic address,
1276 It also takes a pointer to a
1277 .Vt "struct ifmultiaddr *"
1278 which is filled in on successful return with the address of the
1279 group membership control block.
1282 function performs the following four-step process:
1283 .Bl -enum -offset indent
1285 Call the interface's
1287 entry point to determine the link-layer address, if any, corresponding
1288 to this membership request, and also to give the link layer an
1289 opportunity to veto this membership request should it so desire.
1291 Check the interface's group membership list for a pre-existing
1292 membership for this group.
1293 If one is not found, allocate a new one;
1294 if one is, increment its reference count.
1298 routine returned a link-layer address corresponding to the group,
1299 repeat the previous step for that address as well.
1301 If the interface's multicast address filter needs to be changed
1302 because a new membership was added, call the interface's
1309 to request that it do so.
1314 function, given an interface
1318 reverses this process.
1319 Both functions return zero on success, or a
1320 standard error number on failure.
1323 .Fn ifmaof_ifpforaddr
1324 function examines the membership list of interface
1326 for an address matching
1328 and returns a pointer to that
1329 .Vt "struct ifmultiaddr"
1330 if one is found, else it returns a null pointer.
1347 .%A W. Richard Stevens
1348 .%B TCP/IP Illustrated
1350 .%O Addison-Wesley, ISBN 0-201-63354-X
1353 This manual page was written by
1354 .An Garrett A. Wollman .