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_ioctl\*(rp "struct ifnet *ifp" "int cmd" "caddr_t data"
108 .Fn \*(lp*if_watchdog\*(rp "struct ifnet *ifp"
110 .Fn \*(lp*if_init\*(rp "void *if_softc"
112 .Fo \*(lp*if_resolvemulti\*(rp
113 .Fa "struct ifnet *ifp" "struct sockaddr **retsa" "struct sockaddr *addr"
115 .Ss "struct ifaddr member function"
117 .Fo \*(lp*ifa_rtrequest\*(rp
118 .Fa "int cmd" "struct rtentry *rt" "struct sockaddr *dst"
121 .Ss "Global Variables"
122 .Vt extern struct ifnethead ifnet ;
123 .Vt extern struct ifaddr **ifnet_addrs ;
124 .Vt extern int if_index ;
125 .Vt extern int ifqmaxlen ;
127 The kernel mechanisms for handling network interfaces reside primarily
129 .Vt ifnet , if_data , ifaddr ,
136 and the functions named above and defined in
138 Those interfaces which are intended to be used by user programs
141 these include the interface flags, the
143 structure, and the structures defining the appearance of
144 interface-related messages on the
146 routing socket and in
150 defines the kernel-internal interfaces, including the
154 structures and the functions which manipulate them.
155 (A few user programs will need
157 because it is the prerequisite of some other header file like
158 .In netinet/if_ether.h .
159 Most references to those two files in particular can be replaced by
160 .In net/ethernet.h . )
162 The system keeps a linked list of interfaces using the
166 this list is headed by a
167 .Vt "struct ifnethead"
170 The elements of this list are of type
172 and most kernel routines which manipulate interface as such accept or
173 return pointers to these structures.
174 Each interface structure
177 structure, which contains statistics and identifying information used
178 by management programs, and which is exported to user programs by way
184 Each interface also has a
186 of interface addresses, described by
188 structures; the head of the queue is always an
193 describing the link layer implemented by the interface (if any).
194 (Some trivial interfaces do not provide any link layer addresses;
195 this structure, while still present, serves only to identify the
196 interface name and index.)
198 Finally, those interfaces supporting reception of multicast datagrams
201 of multicast group memberships, described by
204 These memberships are reference-counted.
206 Interfaces are also associated with an output queue, defined as a
207 .Vt "struct ifqueue" ;
208 this structure is used to hold packets while the interface is in the
209 process of sending another.
211 .Ss The Vt ifnet Ss structure
215 .Bl -tag -width ".Va if_capabilities" -offset indent
218 A pointer to the driver's private state block.
219 (Initialized by driver.)
222 A pointer to the common data for the interface's layer 2 protocol.
226 .Pq Fn TAILQ_ENTRY ifnet
231 The name of the interface,
236 (Initialized by driver.)
238 .Pq Vt "const char *"
239 The name of the driver.
240 (Initialized by driver.)
243 A unique number assigned to each interface managed by a particular
245 Drivers may choose to set this to
247 if a unit number is not associated with the device.
248 (Initialized by driver.)
250 .Pq Vt "struct ifaddrhead"
254 containing the list of addresses assigned to this interface.
257 A count of promiscuous listeners on this interface, used to
262 .Pq Vt "struct bpf_if *"
263 Opaque per-interface data for the packet filter,
269 A unique number assigned to each interface in sequence as it is
271 This number can be used in a
272 .Vt "struct sockaddr_dl"
273 to refer to a particular interface by index
280 Number of seconds until the watchdog timer
282 is called, or zero if the timer is disabled.
284 decremented by generic watchdog code.)
287 Flags describing operational parameters of this interface (see below).
288 (Manipulated by both driver and generic code.)
289 .It Va if_capabilities
291 Flags describing the capabilities the interface supports (see below).
294 Flags describing the enabled capabilities of the interface (see below).
295 .\" .It Va if_ipending
296 .\" Interrupt-pending bits for polled operation:
298 .\" (transmit complete interrupt)
301 .\" (received packet ready interrupt).
305 .\" (Manipulated by driver.)
308 A pointer to an interface-specific MIB structure exported by
310 (Initialized by driver.)
313 The size of said structure.
314 (Initialized by driver.)
316 .Pq Vt "struct if_data"
317 More statistics and information; see
318 .Sx "The if_data structure" ,
320 (Initialized by driver, manipulated by both driver and generic
323 .Pq Vt "struct ifqueue"
325 (Manipulated by driver.)
326 .\".It Va if_poll_slowq
327 .\".Pq Vt "struct ifqueue *"
328 .\"A pointer to the input queue for devices which do not support polling
333 .\"(Initialized by driver.)
336 There are in addition a number of function pointers which the driver
337 must initialize to complete its interface with the generic interface
339 .Bl -ohang -offset indent
341 Pass a packet to an appropriate upper layer as determined
342 from the link-layer header of the packet.
343 This routine is to be called from an interrupt handler or
344 used to emulate reception of a packet on this interface.
345 A single function implementing
347 can be shared among multiple drivers utilizing the same link-layer
348 framing, e.g., Ethernet.
350 Output a packet on interface
352 or queue it on the output queue if the interface is already active.
354 Start queued output on an interface.
355 This function is exposed in
356 order to provide for some interface classes to share a
360 may only be called when the
365 does not literally mean that output is active, but rather that the
366 device's internal output queue is full.)
369 We are not even sure what it was ever for.
370 The prototype is faked.
372 Process interface-related
377 Preliminary processing is done by the generic routine
379 to check for appropriate privileges, locate the interface being
380 manipulated, and perform certain generic operations like twiddling
381 flags and flushing queues.
382 See the description of
384 below for more information.
386 Routine called by the generic code when the watchdog timer,
389 Usually this will reset the interface.
390 .\" .It Fn if_poll_recv
391 .\" .It Fn if_poll_xmit
392 .\" .It Fn if_poll_slowinput
393 .\" .It Fn if_poll_intren
398 Initialize and bring up the hardware,
399 e.g., reset the chip and the watchdog timer and enable the receiver unit.
400 Should mark the interface running,
402 .Dv ( IFF_RUNNING , ~IIF_OACTIVE ) .
403 .It Fn if_resolvemulti
404 Check the requested multicast group membership,
406 for validity, and if necessary compute a link-layer group which
407 corresponds to that address which is returned in
409 Returns zero on success, or an error code on failure.
411 .Ss "Interface Flags"
412 Interface flags are used for a number of different purposes.
414 flags simply indicate information about the type of interface and its
415 capabilities; others are dynamically manipulated to reflect the
416 current state of the interface.
417 Flags of the former kind are marked
419 in this table; the latter are marked
424 defines the bits which cannot be set by a user program using the
428 these are indicated by an asterisk
430 in the following listing.
432 .Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
435 The interface has been configured up by the user-level code.
438 The interface supports broadcast.
441 Used to enable/disable driver debugging code.
444 The interface is a loopback device.
445 .It Dv IFF_POINTOPOINT
447 The interface is point-to-point;
449 address is actually the address of the other end.
452 The interface has been configured and dynamic resources were
453 successfully allocated.
454 Probably only useful internal to the
458 Disable network address resolution on this interface.
461 This interface is in promiscuous mode.
464 This interface is in the permanently promiscuous mode (implies
468 This interface is in all-multicasts mode (used by multicast routers).
471 The interface's hardware output queue (if any) is full; output packets
475 The interface cannot hear its own transmissions.
480 Control flags for the link layer.
481 (Currently abused to select among
482 multiple physical layers on some devices.)
485 This interface supports multicast.
492 .Sx Interface Capabilities Flags
495 .Ss "Interface Capabilities Flags"
496 Interface capabilities are specialized features an interface may
498 These capabilities are very hardware-specific
499 and allow, when enabled,
500 to offload specific network processing to the interface
501 or to offer a particular feature for use by other kernel parts.
503 It should be stressed that a capability can be completely
504 uncontrolled (i.e., stay always enabled with no way to disable it)
505 or allow limited control over itself (e.g., depend on another
507 Such peculiarities are determined solely by the hardware and driver
508 of a particular interface.
509 Only the driver possesses
510 the knowledge on whether and how the interface capabilities
512 Consequently, capabilities flags in
514 should never be modified directly by kernel code other than
515 the interface driver.
520 is the dedicated means to attempt altering
523 Userland code shall use
526 The following capabilities are currently supported by the system:
527 .Bl -tag -width ".Dv IFCAP_VLAN_HWTAGGING" -offset indent
529 This interface can be a network console.
531 This interface supports
533 See below for details.
535 This interface can do checksum validation on receiving data.
536 Some interfaces do not have sufficient buffer storage to store frames
537 above a certain MTU-size completely.
538 The driver for the interface might disable hardware checksum validation
539 if the MTU is set above the hardcoded limit.
541 This interface can do checksum calculation on transmitting data.
544 .Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
545 .It Dv IFCAP_VLAN_HWTAGGING
546 This interface can do VLAN tagging on output and
547 demultiplex frames by their VLAN tag on input.
548 .It Dv IFCAP_VLAN_MTU
551 driver can operate over this interface in software tagging mode
552 without having to decrease MTU on
554 interfaces below 1500 bytes.
555 This implies the ability of this interface to cope with frames somewhat
556 longer than permitted by the Ethernet specification.
557 .It Dv IFCAP_JUMBO_MTU
558 This Ethernet interface can transmit and receive frames up to
562 The ability of advanced network interfaces to offload certain
563 computational tasks from the host CPU to the board is limited
565 Therefore a separate field associated with an interface
567 .Va ifnet.if_data.ifi_hwassist
569 keeps a detailed description of its enabled capabilities
570 specific to TCP/IP processing.
571 The TCP/IP module consults the field to see which tasks
574 packet by the interface.
575 The flags defined for that field are a superset of those for
576 .Va mbuf.m_pkthdr.csum_flags ,
578 .Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
580 The interface will compute IP checksums.
582 The interface will compute TCP checksums.
584 The interface will compute UDP checksums.
586 The interface can compute a TCP or UDP checksum for a packet
587 fragmented by the host CPU.
588 Makes sense only along with
593 The interface will do the fragmentation of IP packets if necessary.
594 The host CPU does not need to care about MTU on this interface
595 as long as a packet to transmit through it is an IP one and it
596 does not exceed the size of the hardware buffer.
599 An interface notifies the TCP/IP module about the tasks
600 the former has performed on an
602 packet by setting the corresponding flags in the field
603 .Va mbuf.m_pkthdr.csum_flags
606 containing the packet.
611 The capability of a network interface to operate in
613 mode involves several flags in different
614 global variables and per-interface fields.
615 First, there is a system-wide
618 .Va kern.polling.enable ,
622 If that variable is set to non-zero,
624 will be used on those devices where it is enabled individually.
627 will not be used in the system.
628 Second, the capability flag
632 indicates support for
634 on the particular interface.
636 .Va if_capabilities ,
637 the same flag can be marked or cleared in the interface's
639 thus initiating switch of the interface to
643 The actual mode change will occur at an implementation-specific moment
644 in the future, e.g., during the next interrupt or
647 And finally, if the mode transition has been successful, the flag
649 is marked or cleared in the interface's
651 to indicate the current mode of the interface.
652 .Ss The Vt if_data Ss Structure
655 a subset of the interface information believed to be of interest to
656 management stations was segregated from the
658 structure and moved into its own
660 structure to facilitate its use by user programs.
661 The following elements of the
663 structure are initialized by the interface and are not expected to change
664 significantly over the course of normal operation:
665 .Bl -tag -width ".Va ifi_lastchange" -offset indent
668 The type of the interface, as defined in
670 and described below in the
671 .Sx "Interface Types"
675 Intended to represent a selection of physical layers on devices which
676 support more than one; never implemented.
679 Length of a link-layer address on this device, or zero if there are
681 Used to initialized the address length field in
683 structures referring to this interface.
686 Maximum length of any link-layer header which might be prepended by
687 the driver to a packet before transmission.
688 The generic code computes
689 the maximum over all interfaces and uses that value to influence the
692 to attempt to ensure that there is always
693 sufficient space to prepend a link-layer header without allocating an
698 .\" .It Va ifi_recvquota
700 .\" Number of packets the interface is permitted to receive at one time
701 .\" when in polled mode.
702 .\" .It Va ifi_xmitquota
704 .\" Number of packets the interface is permitted to queue for transmission
705 .\" at one time when in polled mode.
706 .\" There is some controversy over
707 .\" whether such a restriction makes any sense at all.
713 Allows some stabilization of the routing socket ABI in the face of
714 increases in the length of
718 The maximum transmission unit of the medium, exclusive of any
722 A dimensionless metric interpreted by a user-mode routing process.
725 The line rate of the interface, in bits per second.
728 A detailed interpretation of the capabilities
729 to offload computational tasks for
732 The interface driver must keep this field in accord with
737 The system uptime when interface was attached or the statistics
739 This is intended to be used to set the SNMP variable
740 .Va ifCounterDiscontinuityTime .
741 It may also be used to determine if two successive queries for an
742 interface of the same index have returned results for the same
746 The structure additionally contains generic statistics applicable to a
747 variety of different interface types (except as noted, all members are
750 .Bl -tag -width ".Va ifi_lastchange" -offset indent
751 .It Va ifi_link_state
753 The current link state of Ethernet interfaces.
755 .Sx Interface Link States
756 section for possible values.
758 Number of packets received.
760 Number of receive errors detected (e.g., FCS errors, DMA overruns,
762 More detailed breakdowns can often be had by way of a
765 Number of packets transmitted.
767 Number of output errors detected (e.g., late collisions, DMA overruns,
769 More detailed breakdowns can often be had by way of a
771 .It Va ifi_collisions
772 Total number of collisions detected on output for CSMA interfaces.
773 (This member is sometimes [ab]used by other types of interfaces for
774 other output error counts.)
776 Total traffic received, in bytes.
778 Total traffic transmitted, in bytes.
780 Number of packets received which were sent by link-layer multicast.
782 Number of packets sent by link-layer multicast.
784 Number of packets dropped on input.
787 Number of packets received for unknown network-layer protocol.
788 .\" .It Va ifi_recvtiming
789 .\" Amount of time, in microseconds, spent to receive an average packet on
794 .\" .It Va ifi_xmittiming
795 .\" Amount of time, in microseconds, spent to service a transmit-complete
796 .\" interrupt on this interface.
800 .It Va ifi_lastchange
801 .Pq Vt "struct timeval"
802 The time of the last administrative change to the interface (as required
809 defines symbolic constants for a number of different types of
813 .Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
815 none of the following
823 ISO 8802-5 Token Ring
829 Internet Point-to-Point Protocol
841 Asynchronous Transfer Mode
843 .Ss Interface Link States
844 The following link states are currently defined:
846 .Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
847 .It Dv LINK_STATE_UNKNOWN
848 The link is in an invalid or unknown state.
849 .It Dv LINK_STATE_DOWN
854 .Ss The Vt ifaddr Ss Structure
855 Every interface is associated with a list
858 of addresses, rooted at the interface structure's
861 The first element in this list is always an
863 address representing the interface itself; multi-access network
864 drivers should complete this structure by filling in their link-layer
865 addresses after calling
867 Other members of the structure represent network-layer addresses which
868 have been configured by means of the
872 called on a socket of the appropriate protocol family.
873 The elements of this list consist of
876 Most protocols will declare their own protocol-specific
877 interface address structures, but all begin with a
879 which provides the most-commonly-needed functionality across all
881 Interface addresses are reference-counted.
886 .Bl -tag -width ".Va ifa_rtrequest" -offset indent
888 .Pq Vt "struct sockaddr *"
889 The local address of the interface.
891 .Pq Vt "struct sockaddr *"
892 The remote address of point-to-point interfaces, and the broadcast
893 address of broadcast interfaces.
898 .Pq Vt "struct sockaddr *"
899 The network mask for multi-access interfaces, and the confusion
900 generator for point-to-point interfaces.
902 .Pq Vt "struct ifnet *"
903 A link back to the interface structure.
905 .Pq Fn TAILQ_ENTRY ifaddr
907 glue for list of addresses on each interface.
912 Some of the flags which would be used for a route representing this
913 address in the route table.
919 A metric associated with this interface address, for the use of some
920 external routing protocol.
925 structures are gained manually, by incrementing the
928 References are released by calling either the
935 is a pointer to a function which receives callouts from the routing
938 to perform link-layer-specific actions upon requests to add, resolve,
942 argument indicates the request in question:
943 .Dv RTM_ADD , RTM_RESOLVE ,
948 argument is the route in question; the
950 argument is the specific destination being manipulated
953 or a null pointer otherwise.
955 The functions provided by the generic interface code can be divided
956 into two groups: those which manipulate interfaces, and those which
957 manipulate interface addresses.
958 In addition to these functions, there
959 may also be link-layer support routines which are used by a number of
960 drivers implementing a specific link layer over different hardware;
961 see the documentation for that link layer for more details.
962 .Ss The Vt ifmultiaddr Ss Structure
963 Every multicast-capable interface is associated with a list of
964 multicast group memberships, which indicate at a low level which
965 link-layer multicast addresses (if any) should be accepted, and at a
966 high level, in which network-layer multicast groups a user process has
969 The elements of the structure are as follows:
970 .Bl -tag -width ".Va ifma_refcount" -offset indent
972 .Pq Fn LIST_ENTRY ifmultiaddr
976 .Pq Vt "struct sockaddr *"
977 A pointer to the address which this record represents.
979 memberships for various address families are stored in arbitrary
982 .Pq Vt "struct sockaddr *"
983 A pointer to the link-layer multicast address, if any, to which the
984 network-layer multicast address in
986 is mapped, else a null pointer.
987 If this element is non-nil, this
988 membership also holds an invisible reference to another membership for
989 that link-layer address.
992 A reference count of requests for this particular membership.
994 .Ss Interface Manipulation Functions
995 .Bl -ohang -offset indent
997 Allocate and initialize
999 Initialization includes the allocation of an interface index and may
1000 include the allocation of a
1002 specific structure in
1005 Link the specified interface
1007 into the list of network interfaces.
1008 Also initialize the list of
1009 addresses on that interface, and create a link-layer
1011 structure to be the first element in that list.
1013 this address structure is saved in the global array
1017 must have been allocated by
1020 Shut down and unlink the specified
1022 from the interface list.
1027 The interface must have been previously detached if it was ever attached.
1031 except that the given
1035 instead of the type in
1037 This is intended for use with drivers that change their interface type.
1044 flush its output queue, notify protocols of the transition,
1045 and generate a message from the
1051 as up, notify protocols of the transition,
1052 and generate a message from the
1056 Add or remove a promiscuous reference to
1060 is true, add a reference;
1061 if it is false, remove a reference.
1062 On reference count transitions
1063 from zero to one and one to zero, set the
1065 flag appropriately and call
1067 to set up the interface in the desired mode.
1071 but for the all-multicasts
1073 flag instead of the promiscuous flag.
1077 pointer for the interface named
1080 Process the ioctl request
1088 This is the main routine for handling all interface configuration
1089 requests from user mode.
1090 It is ordinarily only called from the socket-layer
1092 handler, and only for commands with class
1094 Any unrecognized commands will be passed down to socket
1097 further interpretation.
1098 The following commands are handled by
1101 .Bl -tag -width ".Dv OSIOCGIFNETMASK" -offset indent -compact
1104 Get interface configuration.
1105 (No call-down to driver.)
1108 Set the interface name.
1110 departure and arrival messages are sent so that
1111 routing code that relies on the interface name will update its interface
1113 Caller must have appropriate privilege.
1114 (No call-down to driver.)
1117 .It Dv SIOCGIFMETRIC
1120 Get interface capabilities, flags, metric, MTU, medium selection.
1121 (No call-down to driver.)
1124 Enable or disable interface capabilities.
1125 Caller must have appropriate privilege.
1126 Before a call to the driver-specific
1128 routine, the requested mask for enabled capabilities is checked
1129 against the mask of capabilities supported by the interface,
1130 .Va if_capabilities .
1131 Requesting to enable an unsupported capability is invalid.
1132 The rest is supposed to be done by the driver,
1133 which includes updating
1136 .Va if_data.ifi_hwassist
1140 Change interface flags.
1141 Caller must have appropriate privilege.
1148 is called as appropriate.
1151 are masked off, and the field
1153 in the interface structure is updated.
1156 routine is called to perform any setup
1159 .It Dv SIOCSIFMETRIC
1161 Change interface metric or medium.
1162 Caller must have appropriate privilege.
1165 Change interface MTU.
1166 Caller must have appropriate privilege.
1168 values less than 72 or greater than 65535 are considered invalid.
1171 routine is called to implement the change; it is responsible for any
1172 additional sanity checking and for actually modifying the MTU in the
1173 interface structure.
1177 Add or delete permanent multicast group memberships on the interface.
1178 Caller must have appropriate privilege.
1183 function is called to perform the operation; qq.v.
1185 .It Dv SIOCSIFDSTADDR
1187 .It Dv SIOCSIFBRDADDR
1188 .It Dv SIOCSIFNETMASK
1189 The socket's protocol control routine is called to implement the
1193 .It Dv OSIOCGIFDSTADDR
1194 .It Dv OSIOCGIFBRDADDR
1195 .It Dv OSIOCGIFNETMASK
1196 The socket's protocol control routine is called to implement the
1200 structures are converted into old-style (no
1214 .Ss "Interface Address Functions"
1215 Several functions exist to look up an interface address structure
1218 returns an interface address with either a local address or a
1219 broadcast address precisely matching the parameter
1221 .Fn ifa_ifwithdstaddr
1222 returns an interface address for a point-to-point interface whose
1229 returns the most specific interface address which matches the
1232 subject to its configured netmask, or a point-to-point interface
1233 address whose remote address is
1237 .Fn ifaof_ifpforaddr
1238 returns the most specific address configured on interface
1240 which matches address
1242 subject to its configured netmask.
1244 point-to-point, only an interface address whose remote address is
1249 All of these functions return a null pointer if no such address can be
1251 .Ss "Interface Multicast Address Functions"
1256 .Fn ifmaof_ifpforaddr
1257 functions provide support for requesting and relinquishing multicast
1258 group memberships, and for querying an interface's membership list,
1262 function takes a pointer to an interface,
1264 and a generic address,
1266 It also takes a pointer to a
1267 .Vt "struct ifmultiaddr *"
1268 which is filled in on successful return with the address of the
1269 group membership control block.
1272 function performs the following four-step process:
1273 .Bl -enum -offset indent
1275 Call the interface's
1277 entry point to determine the link-layer address, if any, corresponding
1278 to this membership request, and also to give the link layer an
1279 opportunity to veto this membership request should it so desire.
1281 Check the interface's group membership list for a pre-existing
1282 membership for this group.
1283 If one is not found, allocate a new one;
1284 if one is, increment its reference count.
1288 routine returned a link-layer address corresponding to the group,
1289 repeat the previous step for that address as well.
1291 If the interface's multicast address filter needs to be changed
1292 because a new membership was added, call the interface's
1299 to request that it do so.
1304 function, given an interface
1308 reverses this process.
1309 Both functions return zero on success, or a
1310 standard error number on failure.
1313 .Fn ifmaof_ifpforaddr
1314 function examines the membership list of interface
1316 for an address matching
1318 and returns a pointer to that
1319 .Vt "struct ifmultiaddr"
1320 if one is found, else it returns a null pointer.
1337 .%A W. Richard Stevens
1338 .%B TCP/IP Illustrated
1340 .%O Addison-Wesley, ISBN 0-201-63354-X
1343 This manual page was written by
1344 .An Garrett A. Wollman .