1997-01-15 19:28:39 +00:00
|
|
|
.\" -*- Nroff -*-
|
|
|
|
.\" Copyright 1996, 1997 Massachusetts Institute of Technology
|
1996-12-17 20:21:01 +00:00
|
|
|
.\"
|
|
|
|
.\" Permission to use, copy, modify, and distribute this software and
|
|
|
|
.\" its documentation for any purpose and without fee is hereby
|
|
|
|
.\" granted, provided that both the above copyright notice and this
|
|
|
|
.\" permission notice appear in all copies, that both the above
|
|
|
|
.\" copyright notice and this permission notice appear in all
|
|
|
|
.\" supporting documentation, and that the name of M.I.T. not be used
|
|
|
|
.\" in advertising or publicity pertaining to distribution of the
|
|
|
|
.\" software without specific, written prior permission. M.I.T. makes
|
|
|
|
.\" no representations about the suitability of this software for any
|
|
|
|
.\" purpose. It is provided "as is" without express or implied
|
|
|
|
.\" warranty.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1996-12-17 20:21:01 +00:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
|
|
|
.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
|
|
|
.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
|
.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
2004-06-16 15:57:59 +00:00
|
|
|
.\"
|
2013-11-05 12:52:56 +00:00
|
|
|
.Dd November 5, 2013
|
1996-12-17 20:21:01 +00:00
|
|
|
.Dt IFNET 9
|
2010-04-14 19:08:06 +00:00
|
|
|
.Os
|
1996-12-17 20:21:01 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm ifnet ,
|
|
|
|
.Nm ifaddr ,
|
|
|
|
.Nm ifqueue ,
|
|
|
|
.Nm if_data
|
|
|
|
.Nd kernel interfaces for manipulating network interfaces
|
|
|
|
.Sh SYNOPSIS
|
2001-12-26 23:14:04 +00:00
|
|
|
.In sys/param.h
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/time.h
|
|
|
|
.In sys/socket.h
|
|
|
|
.In net/if.h
|
|
|
|
.In net/if_var.h
|
|
|
|
.In net/if_types.h
|
1996-12-17 20:21:01 +00:00
|
|
|
.\"
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Manipulation Functions"
|
2005-06-10 16:49:24 +00:00
|
|
|
.Ft "struct ifnet *"
|
|
|
|
.Fn if_alloc "u_char type"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn if_attach "struct ifnet *ifp"
|
|
|
|
.Ft void
|
2005-06-10 16:49:24 +00:00
|
|
|
.Fn if_detach "struct ifnet *ifp"
|
|
|
|
.Ft void
|
|
|
|
.Fn if_free "struct ifnet *ifp"
|
|
|
|
.Ft void
|
|
|
|
.Fn if_free_type "struct ifnet *ifp" "u_char type"
|
|
|
|
.Ft void
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn if_down "struct ifnet *ifp"
|
|
|
|
.Ft int
|
2001-12-26 23:14:04 +00:00
|
|
|
.Fn ifioctl "struct socket *so" "u_long cmd" "caddr_t data" "struct thread *td"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn ifpromisc "struct ifnet *ifp" "int pswitch"
|
1997-01-15 19:28:39 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn if_allmulti "struct ifnet *ifp" "int amswitch"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft "struct ifnet *"
|
2001-12-26 23:14:04 +00:00
|
|
|
.Fn ifunit "const char *name"
|
2012-03-01 12:03:52 +00:00
|
|
|
.Ft "struct ifnet *"
|
|
|
|
.Fn ifunit_ref "const char *name"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn if_up "struct ifnet *ifp"
|
|
|
|
.\"
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Address Functions"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft "struct ifaddr *"
|
2012-03-06 08:59:42 +00:00
|
|
|
.Fn ifaddr_byindex "u_short idx"
|
|
|
|
.Ft "struct ifaddr *"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn ifa_ifwithaddr "struct sockaddr *addr"
|
|
|
|
.Ft "struct ifaddr *"
|
|
|
|
.Fn ifa_ifwithdstaddr "struct sockaddr *addr"
|
|
|
|
.Ft "struct ifaddr *"
|
2012-03-01 12:16:00 +00:00
|
|
|
.Fn ifa_ifwithnet "struct sockaddr *addr" "int ignore_ptp"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft "struct ifaddr *"
|
|
|
|
.Fn ifaof_ifpforaddr "struct sockaddr *addr" "struct ifnet *ifp"
|
|
|
|
.Ft void
|
2012-03-01 12:52:14 +00:00
|
|
|
.Fn ifa_ref "struct ifaddr *ifa"
|
|
|
|
.Ft void
|
|
|
|
.Fn ifa_free "struct ifaddr *ifa"
|
1996-12-17 20:21:01 +00:00
|
|
|
.\"
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Multicast Address Functions"
|
1997-01-15 19:28:39 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn if_addmulti "struct ifnet *ifp" "struct sockaddr *sa" "struct ifmultiaddr **ifmap"
|
|
|
|
.Ft int
|
|
|
|
.Fn if_delmulti "struct ifnet *ifp" "struct sockaddr *sa"
|
|
|
|
.Ft "struct ifmultiaddr *"
|
2012-03-02 09:52:42 +00:00
|
|
|
.Fn if_findmulti "struct ifnet *ifp" "struct sockaddr *sa"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ss "Output queue macros"
|
|
|
|
.Fn IF_DEQUEUE "struct ifqueue *ifq" "struct mbuf *m"
|
|
|
|
.\"
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "struct ifnet Member Functions"
|
2004-01-26 12:51:00 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn \*(lp*if_input\*(rp "struct ifnet *ifp" "struct mbuf *m"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft int
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fo \*(lp*if_output\*(rp
|
|
|
|
.Fa "struct ifnet *ifp" "struct mbuf *m"
|
2013-04-26 13:18:07 +00:00
|
|
|
.Fa "const struct sockaddr *dst" "struct route *ro"
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fc
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft void
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn \*(lp*if_start\*(rp "struct ifnet *ifp"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft int
|
2008-12-11 22:51:11 +00:00
|
|
|
.Fn \*(lp*if_transmit\*(rp "struct ifnet *ifp" "struct mbuf *m"
|
|
|
|
.Ft void
|
|
|
|
.Fn \*(lp*if_qflush\*(rp "struct ifnet *ifp"
|
|
|
|
.Ft int
|
2012-03-02 09:30:54 +00:00
|
|
|
.Fn \*(lp*if_ioctl\*(rp "struct ifnet *ifp" "u_long cmd" "caddr_t data"
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ft void
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn \*(lp*if_init\*(rp "void *if_softc"
|
1997-01-15 19:28:39 +00:00
|
|
|
.Ft int
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fo \*(lp*if_resolvemulti\*(rp
|
|
|
|
.Fa "struct ifnet *ifp" "struct sockaddr **retsa" "struct sockaddr *addr"
|
|
|
|
.Fc
|
1996-12-17 20:21:01 +00:00
|
|
|
.Ss "struct ifaddr member function"
|
|
|
|
.Ft void
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fo \*(lp*ifa_rtrequest\*(rp
|
2012-03-07 09:42:19 +00:00
|
|
|
.Fa "int cmd" "struct rtentry *rt" "struct rt_addrinfo *info"
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fc
|
|
|
|
.\"
|
|
|
|
.Ss "Global Variables"
|
2001-02-01 16:38:02 +00:00
|
|
|
.Vt extern struct ifnethead ifnet ;
|
2012-03-06 08:59:42 +00:00
|
|
|
.\" extern struct ifindex_entry *ifindex_table ;
|
2001-02-01 16:38:02 +00:00
|
|
|
.Vt extern int if_index ;
|
|
|
|
.Vt extern int ifqmaxlen ;
|
1996-12-17 20:21:01 +00:00
|
|
|
.Sh DATA STRUCTURES
|
|
|
|
The kernel mechanisms for handling network interfaces reside primarily
|
|
|
|
in the
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifnet , if_data , ifaddr ,
|
1996-12-17 20:21:01 +00:00
|
|
|
and
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifmultiaddr
|
1996-12-17 20:21:01 +00:00
|
|
|
structures in
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if.h
|
1997-01-15 19:28:39 +00:00
|
|
|
and
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if_var.h
|
1996-12-17 20:21:01 +00:00
|
|
|
and the functions named above and defined in
|
|
|
|
.Pa /sys/net/if.c .
|
1997-01-15 19:28:39 +00:00
|
|
|
Those interfaces which are intended to be used by user programs
|
|
|
|
are defined in
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if.h ;
|
1997-01-15 19:28:39 +00:00
|
|
|
these include the interface flags, the
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt if_data
|
1997-01-15 19:28:39 +00:00
|
|
|
structure, and the structures defining the appearance of
|
|
|
|
interface-related messages on the
|
|
|
|
.Xr route 4
|
|
|
|
routing socket and in
|
|
|
|
.Xr sysctl 3 .
|
|
|
|
The header file
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if_var.h
|
1997-01-15 19:28:39 +00:00
|
|
|
defines the kernel-internal interfaces, including the
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifnet , ifaddr ,
|
1997-01-15 19:28:39 +00:00
|
|
|
and
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifmultiaddr
|
1997-01-15 19:28:39 +00:00
|
|
|
structures and the functions which manipulate them.
|
|
|
|
(A few user programs will need
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if_var.h
|
1997-01-15 19:28:39 +00:00
|
|
|
because it is the prerequisite of some other header file like
|
2003-09-08 19:57:22 +00:00
|
|
|
.In netinet/if_ether.h .
|
1997-01-15 19:28:39 +00:00
|
|
|
Most references to those two files in particular can be replaced by
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/ethernet.h . )
|
1997-01-15 19:28:39 +00:00
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
The system keeps a linked list of interfaces using the
|
|
|
|
.Li TAILQ
|
|
|
|
macros defined in
|
|
|
|
.Xr queue 3 ;
|
|
|
|
this list is headed by a
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifnethead"
|
1996-12-17 20:21:01 +00:00
|
|
|
called
|
2002-01-10 11:57:10 +00:00
|
|
|
.Va ifnet .
|
1996-12-17 20:21:01 +00:00
|
|
|
The elements of this list are of type
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifnet" ,
|
1996-12-17 20:21:01 +00:00
|
|
|
and most kernel routines which manipulate interface as such accept or
|
2002-01-10 11:57:10 +00:00
|
|
|
return pointers to these structures.
|
|
|
|
Each interface structure
|
1996-12-17 20:21:01 +00:00
|
|
|
contains an
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt if_data
|
2012-03-07 14:53:53 +00:00
|
|
|
structure used for statistics and information.
|
1996-12-17 20:21:01 +00:00
|
|
|
Each interface also has a
|
|
|
|
.Li TAILQ
|
|
|
|
of interface addresses, described by
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifaddr
|
2012-03-06 08:59:42 +00:00
|
|
|
structures.
|
|
|
|
An
|
1996-12-17 20:21:01 +00:00
|
|
|
.Dv AF_LINK
|
|
|
|
address
|
|
|
|
(see
|
|
|
|
.Xr link_addr 3 )
|
2012-03-06 08:59:42 +00:00
|
|
|
describing the link layer implemented by the interface (if any)
|
|
|
|
is accessed by the
|
|
|
|
.Fn ifaddr_byindex
|
|
|
|
function or
|
|
|
|
.Va if_addr
|
|
|
|
structure.
|
1996-12-17 20:21:01 +00:00
|
|
|
(Some trivial interfaces do not provide any link layer addresses;
|
|
|
|
this structure, while still present, serves only to identify the
|
|
|
|
interface name and index.)
|
|
|
|
.Pp
|
1997-01-15 19:28:39 +00:00
|
|
|
Finally, those interfaces supporting reception of multicast datagrams
|
|
|
|
have a
|
2003-05-01 18:34:13 +00:00
|
|
|
.Li TAILQ
|
1997-01-15 19:28:39 +00:00
|
|
|
of multicast group memberships, described by
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifmultiaddr
|
|
|
|
structures.
|
|
|
|
These memberships are reference-counted.
|
1997-01-15 19:28:39 +00:00
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
Interfaces are also associated with an output queue, defined as a
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifqueue" ;
|
1996-12-17 20:21:01 +00:00
|
|
|
this structure is used to hold packets while the interface is in the
|
2002-01-10 11:57:10 +00:00
|
|
|
process of sending another.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss The Vt ifnet Ss structure
|
1996-12-17 20:21:01 +00:00
|
|
|
The fields of
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifnet"
|
1996-12-17 20:21:01 +00:00
|
|
|
are as follows:
|
2002-01-10 11:57:10 +00:00
|
|
|
.Bl -tag -width ".Va if_capabilities" -offset indent
|
|
|
|
.It Va if_softc
|
|
|
|
.Pq Vt "void *"
|
|
|
|
A pointer to the driver's private state block.
|
|
|
|
(Initialized by driver.)
|
2005-06-10 16:49:24 +00:00
|
|
|
.It Va if_l2com
|
|
|
|
.Pq Vt "void *"
|
|
|
|
A pointer to the common data for the interface's layer 2 protocol.
|
|
|
|
(Initialized by
|
|
|
|
.Fn if_alloc . )
|
Update the list of struct ifnet fields.
- Document if_vnet, if_home_vnet, if_carp, if_vlantrunk, if_multiaddrs,
if_amcount, if_addr, if_llsoftc stub, if_broadcastaddr, if_bridge,
if_label, if_afdata, if_afdata_initialized, if_afdata_lock, if_linktask,
if_addr_mtx (now if_addr_lock), if_clones, if_groups, if_pf_kif, if_lagg,
if_alloctype
- G/c now defunct and/or commented out in the manual page if_ipending,
if_poll_slowq, if_done, if_poll_recv, if_poll_xmit, if_poll_slowinput,
if_poll_intren
- Update if_snd type changed with ALTQ integration.
MFC after: 1 week
2012-03-20 16:56:35 +00:00
|
|
|
.It Va if_vnet
|
|
|
|
.Pq Vt "struct vnet *"
|
|
|
|
A pointer to the virtual network stack instance.
|
|
|
|
(Initialized by
|
|
|
|
.Fn if_attach . )
|
|
|
|
.It Va if_home_vnet
|
|
|
|
.Pq Vt "struct vnet *"
|
|
|
|
A pointer to the parent virtual network stack, where this
|
|
|
|
.Vt "struct ifnet"
|
|
|
|
originates from.
|
|
|
|
(Initialized by
|
|
|
|
.Fn if_attach . )
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_link
|
|
|
|
.Pq Fn TAILQ_ENTRY ifnet
|
1996-12-17 20:21:01 +00:00
|
|
|
.Xr queue 3
|
|
|
|
macro glue.
|
2003-10-31 18:32:15 +00:00
|
|
|
.It Va if_xname
|
|
|
|
.Pq Vt "char *"
|
|
|
|
The name of the interface,
|
|
|
|
(e.g.,
|
|
|
|
.Dq Li fxp0
|
|
|
|
or
|
2004-06-16 15:57:59 +00:00
|
|
|
.Dq Li lo0 ) .
|
2010-01-14 14:43:16 +00:00
|
|
|
(Initialized by driver
|
|
|
|
(usually via
|
|
|
|
.Fn if_initname ) . )
|
2003-10-31 18:32:15 +00:00
|
|
|
.It Va if_dname
|
|
|
|
.Pq Vt "const char *"
|
|
|
|
The name of the driver.
|
2010-01-14 14:43:16 +00:00
|
|
|
(Initialized by driver
|
|
|
|
(usually via
|
|
|
|
.Fn if_initname ) . )
|
2003-10-31 18:32:15 +00:00
|
|
|
.It Va if_dunit
|
|
|
|
.Pq Vt int
|
|
|
|
A unique number assigned to each interface managed by a particular
|
|
|
|
driver.
|
|
|
|
Drivers may choose to set this to
|
|
|
|
.Dv IF_DUNIT_NONE
|
|
|
|
if a unit number is not associated with the device.
|
2010-01-14 14:43:16 +00:00
|
|
|
(Initialized by driver
|
|
|
|
(usually via
|
|
|
|
.Fn if_initname ) . )
|
2012-03-01 11:03:39 +00:00
|
|
|
.It Va if_refcount
|
|
|
|
.Pq Vt u_int
|
|
|
|
The reference count.
|
|
|
|
(Initialized by
|
|
|
|
.Fn if_alloc . )
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_addrhead
|
|
|
|
.Pq Vt "struct ifaddrhead"
|
1996-12-17 20:21:01 +00:00
|
|
|
The head of the
|
|
|
|
.Xr queue 3
|
|
|
|
.Li TAILQ
|
|
|
|
containing the list of addresses assigned to this interface.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_pcount
|
|
|
|
.Pq Vt int
|
1996-12-17 20:21:01 +00:00
|
|
|
A count of promiscuous listeners on this interface, used to
|
|
|
|
reference-count the
|
|
|
|
.Dv IFF_PROMISC
|
|
|
|
flag.
|
Update the list of struct ifnet fields.
- Document if_vnet, if_home_vnet, if_carp, if_vlantrunk, if_multiaddrs,
if_amcount, if_addr, if_llsoftc stub, if_broadcastaddr, if_bridge,
if_label, if_afdata, if_afdata_initialized, if_afdata_lock, if_linktask,
if_addr_mtx (now if_addr_lock), if_clones, if_groups, if_pf_kif, if_lagg,
if_alloctype
- G/c now defunct and/or commented out in the manual page if_ipending,
if_poll_slowq, if_done, if_poll_recv, if_poll_xmit, if_poll_slowinput,
if_poll_intren
- Update if_snd type changed with ALTQ integration.
MFC after: 1 week
2012-03-20 16:56:35 +00:00
|
|
|
.It Va if_carp
|
|
|
|
.Pq Vt "struct carp_if *"
|
|
|
|
A pointer to the CARP interface structure,
|
|
|
|
.Xr carp 4 .
|
|
|
|
(Initialized by the driver-specific
|
|
|
|
.Fn if_ioctl
|
|
|
|
routine.)
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_bpf
|
|
|
|
.Pq Vt "struct bpf_if *"
|
1996-12-17 20:21:01 +00:00
|
|
|
Opaque per-interface data for the packet filter,
|
|
|
|
.Xr bpf 4 .
|
|
|
|
(Initialized by
|
|
|
|
.Fn bpf_attach . )
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_index
|
|
|
|
.Pq Vt u_short
|
1996-12-17 20:21:01 +00:00
|
|
|
A unique number assigned to each interface in sequence as it is
|
2002-01-10 11:57:10 +00:00
|
|
|
attached.
|
|
|
|
This number can be used in a
|
|
|
|
.Vt "struct sockaddr_dl"
|
1996-12-17 20:21:01 +00:00
|
|
|
to refer to a particular interface by index
|
|
|
|
(see
|
|
|
|
.Xr link_addr 3 ) .
|
2005-06-10 16:49:24 +00:00
|
|
|
(Initialized by
|
|
|
|
.Fn if_alloc . )
|
Update the list of struct ifnet fields.
- Document if_vnet, if_home_vnet, if_carp, if_vlantrunk, if_multiaddrs,
if_amcount, if_addr, if_llsoftc stub, if_broadcastaddr, if_bridge,
if_label, if_afdata, if_afdata_initialized, if_afdata_lock, if_linktask,
if_addr_mtx (now if_addr_lock), if_clones, if_groups, if_pf_kif, if_lagg,
if_alloctype
- G/c now defunct and/or commented out in the manual page if_ipending,
if_poll_slowq, if_done, if_poll_recv, if_poll_xmit, if_poll_slowinput,
if_poll_intren
- Update if_snd type changed with ALTQ integration.
MFC after: 1 week
2012-03-20 16:56:35 +00:00
|
|
|
.It Va if_vlantrunk
|
|
|
|
.Pq Vt struct ifvlantrunk *
|
|
|
|
A pointer to 802.1Q trunk structure,
|
|
|
|
.Xr vlan 4 .
|
|
|
|
(Initialized by the driver-specific
|
|
|
|
.Fn if_ioctl
|
|
|
|
routine.)
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_flags
|
2002-08-18 07:05:00 +00:00
|
|
|
.Pq Vt int
|
1996-12-17 20:21:01 +00:00
|
|
|
Flags describing operational parameters of this interface (see below).
|
2010-01-14 14:43:16 +00:00
|
|
|
(Manipulated by generic code.)
|
|
|
|
.It Va if_drv_flags
|
|
|
|
.Pq Vt int
|
|
|
|
Flags describing operational status of this interface (see below).
|
|
|
|
(Manipulated by driver.)
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_capabilities
|
|
|
|
.Pq Vt int
|
2001-09-22 12:34:19 +00:00
|
|
|
Flags describing the capabilities the interface supports (see below).
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_capenable
|
|
|
|
.Pq Vt int
|
2002-01-09 11:43:48 +00:00
|
|
|
Flags describing the enabled capabilities of the interface (see below).
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_linkmib
|
|
|
|
.Pq Vt "void *"
|
1996-12-17 20:21:01 +00:00
|
|
|
A pointer to an interface-specific MIB structure exported by
|
|
|
|
.Xr ifmib 4 .
|
|
|
|
(Initialized by driver.)
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_linkmiblen
|
|
|
|
.Pq Vt size_t
|
|
|
|
The size of said structure.
|
|
|
|
(Initialized by driver.)
|
|
|
|
.It Va if_data
|
|
|
|
.Pq Vt "struct if_data"
|
1996-12-17 20:21:01 +00:00
|
|
|
More statistics and information; see
|
2002-01-10 11:57:10 +00:00
|
|
|
.Sx "The if_data structure" ,
|
|
|
|
below.
|
|
|
|
(Initialized by driver, manipulated by both driver and generic
|
1996-12-17 20:21:01 +00:00
|
|
|
code.)
|
Update the list of struct ifnet fields.
- Document if_vnet, if_home_vnet, if_carp, if_vlantrunk, if_multiaddrs,
if_amcount, if_addr, if_llsoftc stub, if_broadcastaddr, if_bridge,
if_label, if_afdata, if_afdata_initialized, if_afdata_lock, if_linktask,
if_addr_mtx (now if_addr_lock), if_clones, if_groups, if_pf_kif, if_lagg,
if_alloctype
- G/c now defunct and/or commented out in the manual page if_ipending,
if_poll_slowq, if_done, if_poll_recv, if_poll_xmit, if_poll_slowinput,
if_poll_intren
- Update if_snd type changed with ALTQ integration.
MFC after: 1 week
2012-03-20 16:56:35 +00:00
|
|
|
.It Va if_multiaddrs
|
|
|
|
.Pq Vt struct ifmultihead
|
|
|
|
The head of the
|
|
|
|
.Xr queue 3
|
|
|
|
.Li TAILQ
|
|
|
|
containing the list of multicast addresses assigned to this interface.
|
|
|
|
.It Va if_amcount
|
|
|
|
.Pq Vt int
|
|
|
|
A number of multicast requests on this interface, used to
|
|
|
|
reference-count the
|
|
|
|
.Dv IFF_ALLMULTI
|
|
|
|
flag.
|
|
|
|
.It Va if_addr
|
|
|
|
.Pq Vt "struct ifaddr *"
|
|
|
|
A pointer to the link-level interface address.
|
|
|
|
(Initialized by
|
|
|
|
.Fn if_alloc . )
|
|
|
|
.\" .It Va if_llsoftc
|
|
|
|
.\" .Pq Vt "void *"
|
|
|
|
.\" The purpose of the field is unclear.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va if_snd
|
Update the list of struct ifnet fields.
- Document if_vnet, if_home_vnet, if_carp, if_vlantrunk, if_multiaddrs,
if_amcount, if_addr, if_llsoftc stub, if_broadcastaddr, if_bridge,
if_label, if_afdata, if_afdata_initialized, if_afdata_lock, if_linktask,
if_addr_mtx (now if_addr_lock), if_clones, if_groups, if_pf_kif, if_lagg,
if_alloctype
- G/c now defunct and/or commented out in the manual page if_ipending,
if_poll_slowq, if_done, if_poll_recv, if_poll_xmit, if_poll_slowinput,
if_poll_intren
- Update if_snd type changed with ALTQ integration.
MFC after: 1 week
2012-03-20 16:56:35 +00:00
|
|
|
.Pq Vt "struct ifaltq"
|
2002-01-10 11:57:10 +00:00
|
|
|
The output queue.
|
|
|
|
(Manipulated by driver.)
|
Update the list of struct ifnet fields.
- Document if_vnet, if_home_vnet, if_carp, if_vlantrunk, if_multiaddrs,
if_amcount, if_addr, if_llsoftc stub, if_broadcastaddr, if_bridge,
if_label, if_afdata, if_afdata_initialized, if_afdata_lock, if_linktask,
if_addr_mtx (now if_addr_lock), if_clones, if_groups, if_pf_kif, if_lagg,
if_alloctype
- G/c now defunct and/or commented out in the manual page if_ipending,
if_poll_slowq, if_done, if_poll_recv, if_poll_xmit, if_poll_slowinput,
if_poll_intren
- Update if_snd type changed with ALTQ integration.
MFC after: 1 week
2012-03-20 16:56:35 +00:00
|
|
|
.It Va if_broadcastaddr
|
|
|
|
.Pq Vt "const u_int8_t *"
|
|
|
|
A link-level broadcast bytestring for protocols with variable address
|
|
|
|
length.
|
|
|
|
.It Va if_bridge
|
|
|
|
.Pq Vt "void *"
|
|
|
|
A pointer to the bridge interface structure,
|
|
|
|
.Xr if_bridge 4 .
|
|
|
|
(Initialized by the driver-specific
|
|
|
|
.Fn if_ioctl
|
|
|
|
routine.)
|
|
|
|
.It Va if_label
|
|
|
|
.Pq Vt "struct label *"
|
|
|
|
A pointer to the MAC Framework label structure,
|
|
|
|
.Xr mac 4 .
|
|
|
|
(Initialized by
|
|
|
|
.Fn if_alloc . )
|
|
|
|
.It Va if_afdata
|
|
|
|
.Pq Vt "void *"
|
|
|
|
An address family dependent data region.
|
|
|
|
.It Va if_afdata_initialized
|
|
|
|
.Pq Vt int
|
|
|
|
Used to track the current state of address family initialization.
|
|
|
|
.It Va if_afdata_lock
|
|
|
|
.Pq Vt "struct rwlock"
|
|
|
|
An
|
|
|
|
.Xr rwlock 9
|
|
|
|
lock used to protect
|
|
|
|
.Va if_afdata
|
|
|
|
internals.
|
|
|
|
.It Va if_linktask
|
|
|
|
.Pq Vt "struct task"
|
|
|
|
A
|
|
|
|
.Xr taskqueue 9
|
|
|
|
task scheduled for link state change events of the interface.
|
|
|
|
.It Va if_addr_lock
|
|
|
|
.Pq Vt "struct rwlock"
|
|
|
|
An
|
|
|
|
.Xr rwlock 9
|
|
|
|
lock used to protect interface-related address lists.
|
|
|
|
.It Va if_clones
|
|
|
|
.Pq Fn LIST_ENTRY ifnet
|
|
|
|
.Xr queue 3
|
|
|
|
macro glue for the list of clonable network interfaces.
|
|
|
|
.It Va if_groups
|
|
|
|
.Pq Fn TAILQ_HEAD ", ifg_list"
|
|
|
|
The head of the
|
|
|
|
.Xr queue 3
|
|
|
|
.Li TAILQ
|
|
|
|
containing the list of groups per interface.
|
|
|
|
.It Va if_pf_kif
|
|
|
|
.Pq Vt "void *"
|
|
|
|
A pointer to the structure used for interface abstraction by
|
|
|
|
.Xr pf 4 .
|
|
|
|
.It Va if_lagg
|
|
|
|
.Pq Vt "void *"
|
|
|
|
A pointer to the
|
|
|
|
.Xr lagg 4
|
|
|
|
interface structure.
|
|
|
|
.It Va if_alloctype
|
|
|
|
.Pq Vt u_char
|
|
|
|
The type of the interface as it was at the time of its allocation.
|
|
|
|
It is used to cache the type passed to
|
|
|
|
.Fn if_alloc ,
|
|
|
|
but unlike
|
|
|
|
.Va if_type ,
|
|
|
|
it would not be changed by drivers.
|
1996-12-17 20:21:01 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2012-03-01 11:03:39 +00:00
|
|
|
References to
|
|
|
|
.Vt ifnet
|
|
|
|
structures are gained by calling the
|
|
|
|
.Fn if_ref
|
|
|
|
function and released by calling the
|
|
|
|
.Fn if_rele
|
|
|
|
function.
|
|
|
|
They are used to allow kernel code walking global interface lists
|
|
|
|
to release the
|
|
|
|
.Vt ifnet
|
|
|
|
lock yet keep the
|
|
|
|
.Vt ifnet
|
|
|
|
structure stable.
|
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
There are in addition a number of function pointers which the driver
|
|
|
|
must initialize to complete its interface with the generic interface
|
|
|
|
layer:
|
|
|
|
.Bl -ohang -offset indent
|
2004-01-26 12:51:00 +00:00
|
|
|
.It Fn if_input
|
|
|
|
Pass a packet to an appropriate upper layer as determined
|
|
|
|
from the link-layer header of the packet.
|
|
|
|
This routine is to be called from an interrupt handler or
|
|
|
|
used to emulate reception of a packet on this interface.
|
|
|
|
A single function implementing
|
|
|
|
.Fn if_input
|
|
|
|
can be shared among multiple drivers utilizing the same link-layer
|
|
|
|
framing, e.g., Ethernet.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn if_output
|
|
|
|
Output a packet on interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp ,
|
1996-12-17 20:21:01 +00:00
|
|
|
or queue it on the output queue if the interface is already active.
|
2008-12-11 22:51:11 +00:00
|
|
|
.It Fn if_transmit
|
|
|
|
Transmit a packet on an interface or queue it if the interface is
|
2010-01-14 14:43:16 +00:00
|
|
|
in use.
|
|
|
|
This function will return
|
2008-12-11 22:51:11 +00:00
|
|
|
.Dv ENOBUFS
|
2010-01-14 14:43:16 +00:00
|
|
|
if the devices software and hardware queues are both full.
|
|
|
|
This function must be installed after
|
2012-03-06 09:40:34 +00:00
|
|
|
.Fn if_attach
|
2010-01-14 14:43:16 +00:00
|
|
|
to override the default implementation.
|
|
|
|
This function is exposed in order to allow drivers to manage their own queues
|
|
|
|
and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
|
|
|
|
pair to ifq.
|
|
|
|
The suggested internal software queueing mechanism is buf_ring.
|
2008-12-11 22:51:11 +00:00
|
|
|
.It Fn if_qflush
|
|
|
|
Free mbufs in internally managed queues when the interface is marked down.
|
2012-03-06 09:40:34 +00:00
|
|
|
This function must be installed after
|
|
|
|
.Fn if_attach
|
2010-01-14 14:43:16 +00:00
|
|
|
to override the default implementation.
|
|
|
|
This function is exposed in order to allow drivers to manage their own queues
|
|
|
|
and to reduce the latency caused by a frequently gratuitous enqueue / dequeue
|
|
|
|
pair to ifq.
|
|
|
|
The suggested internal software queueing mechanism is buf_ring.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn if_start
|
2002-01-10 11:57:10 +00:00
|
|
|
Start queued output on an interface.
|
|
|
|
This function is exposed in
|
1996-12-17 20:21:01 +00:00
|
|
|
order to provide for some interface classes to share a
|
|
|
|
.Fn if_output
|
|
|
|
among all drivers.
|
|
|
|
.Fn if_start
|
|
|
|
may only be called when the
|
2010-01-14 14:43:16 +00:00
|
|
|
.Dv IFF_DRV_OACTIVE
|
2002-01-10 11:57:10 +00:00
|
|
|
flag is not set.
|
|
|
|
(Thus,
|
2010-01-14 14:43:16 +00:00
|
|
|
.Dv IFF_DRV_OACTIVE
|
1996-12-17 20:21:01 +00:00
|
|
|
does not literally mean that output is active, but rather that the
|
2008-12-11 22:51:11 +00:00
|
|
|
device's internal output queue is full.) Please note that this function
|
|
|
|
will soon be deprecated.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn if_ioctl
|
|
|
|
Process interface-related
|
|
|
|
.Xr ioctl 2
|
|
|
|
requests
|
|
|
|
(defined in
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/sockio.h ) .
|
1996-12-17 20:21:01 +00:00
|
|
|
Preliminary processing is done by the generic routine
|
|
|
|
.Fn ifioctl
|
|
|
|
to check for appropriate privileges, locate the interface being
|
|
|
|
manipulated, and perform certain generic operations like twiddling
|
2002-01-10 11:57:10 +00:00
|
|
|
flags and flushing queues.
|
|
|
|
See the description of
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn ifioctl
|
|
|
|
below for more information.
|
|
|
|
.It Fn if_init
|
2000-06-10 10:23:06 +00:00
|
|
|
Initialize and bring up the hardware,
|
2009-12-01 14:56:00 +00:00
|
|
|
e.g., reset the chip and enable the receiver unit.
|
2000-06-10 10:23:06 +00:00
|
|
|
Should mark the interface running,
|
|
|
|
but not active
|
2010-01-14 14:43:16 +00:00
|
|
|
.Dv ( IFF_DRV_RUNNING , ~IIF_DRV_OACTIVE ) .
|
1997-01-15 19:28:39 +00:00
|
|
|
.It Fn if_resolvemulti
|
|
|
|
Check the requested multicast group membership,
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa addr ,
|
1997-01-15 19:28:39 +00:00
|
|
|
for validity, and if necessary compute a link-layer group which
|
|
|
|
corresponds to that address which is returned in
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa *retsa .
|
1997-01-15 19:28:39 +00:00
|
|
|
Returns zero on success, or an error code on failure.
|
1996-12-17 20:21:01 +00:00
|
|
|
.El
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Flags"
|
|
|
|
Interface flags are used for a number of different purposes.
|
|
|
|
Some
|
1996-12-17 20:21:01 +00:00
|
|
|
flags simply indicate information about the type of interface and its
|
|
|
|
capabilities; others are dynamically manipulated to reflect the
|
2002-01-10 11:57:10 +00:00
|
|
|
current state of the interface.
|
|
|
|
Flags of the former kind are marked
|
1996-12-17 20:21:01 +00:00
|
|
|
.Aq S
|
|
|
|
in this table; the latter are marked
|
|
|
|
.Aq D .
|
2010-01-14 14:43:16 +00:00
|
|
|
Flags which begin with
|
|
|
|
.Dq IFF_DRV_
|
|
|
|
are stored in
|
|
|
|
.Va if_drv_flags ;
|
|
|
|
all other flags are stored in
|
|
|
|
.Va if_flags .
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
2004-06-08 09:01:37 +00:00
|
|
|
The macro
|
|
|
|
.Dv IFF_CANTCHANGE
|
|
|
|
defines the bits which cannot be set by a user program using the
|
|
|
|
.Dv SIOCSIFFLAGS
|
|
|
|
command to
|
|
|
|
.Xr ioctl 2 ;
|
|
|
|
these are indicated by an asterisk
|
|
|
|
.Pq Ql *
|
|
|
|
in the following listing.
|
|
|
|
.Pp
|
2002-01-10 11:57:10 +00:00
|
|
|
.Bl -tag -width ".Dv IFF_POINTOPOINT" -offset indent -compact
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv IFF_UP
|
|
|
|
.Aq D
|
|
|
|
The interface has been configured up by the user-level code.
|
|
|
|
.It Dv IFF_BROADCAST
|
|
|
|
.Aq S*
|
|
|
|
The interface supports broadcast.
|
|
|
|
.It Dv IFF_DEBUG
|
|
|
|
.Aq D
|
|
|
|
Used to enable/disable driver debugging code.
|
|
|
|
.It Dv IFF_LOOPBACK
|
|
|
|
.Aq S
|
|
|
|
The interface is a loopback device.
|
|
|
|
.It Dv IFF_POINTOPOINT
|
|
|
|
.Aq S*
|
|
|
|
The interface is point-to-point;
|
|
|
|
.Dq broadcast
|
2002-01-10 11:57:10 +00:00
|
|
|
address is actually the address of the other end.
|
2010-01-14 14:43:16 +00:00
|
|
|
.It Dv IFF_DRV_RUNNING
|
1996-12-17 20:21:01 +00:00
|
|
|
.Aq D*
|
|
|
|
The interface has been configured and dynamic resources were
|
2002-01-10 11:57:10 +00:00
|
|
|
successfully allocated.
|
|
|
|
Probably only useful internal to the
|
1996-12-17 20:21:01 +00:00
|
|
|
interface.
|
|
|
|
.It Dv IFF_NOARP
|
|
|
|
.Aq D
|
|
|
|
Disable network address resolution on this interface.
|
|
|
|
.It Dv IFF_PROMISC
|
2002-08-28 07:24:20 +00:00
|
|
|
.Aq D*
|
1996-12-17 20:21:01 +00:00
|
|
|
This interface is in promiscuous mode.
|
2002-08-28 07:24:20 +00:00
|
|
|
.It Dv IFF_PPROMISC
|
|
|
|
.Aq D
|
|
|
|
This interface is in the permanently promiscuous mode (implies
|
2002-11-29 11:39:20 +00:00
|
|
|
.Dv IFF_PROMISC ) .
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv IFF_ALLMULTI
|
|
|
|
.Aq D*
|
|
|
|
This interface is in all-multicasts mode (used by multicast routers).
|
2010-01-14 14:43:16 +00:00
|
|
|
.It Dv IFF_DRV_OACTIVE
|
1996-12-17 20:21:01 +00:00
|
|
|
.Aq D*
|
|
|
|
The interface's hardware output queue (if any) is full; output packets
|
|
|
|
are to be queued.
|
|
|
|
.It Dv IFF_SIMPLEX
|
|
|
|
.Aq S*
|
|
|
|
The interface cannot hear its own transmissions.
|
|
|
|
.It Dv IFF_LINK0
|
|
|
|
.It Dv IFF_LINK1
|
|
|
|
.It Dv IFF_LINK2
|
|
|
|
.Aq D
|
2002-01-10 11:57:10 +00:00
|
|
|
Control flags for the link layer.
|
|
|
|
(Currently abused to select among
|
1996-12-17 20:21:01 +00:00
|
|
|
multiple physical layers on some devices.)
|
|
|
|
.It Dv IFF_MULTICAST
|
|
|
|
.Aq S*
|
|
|
|
This interface supports multicast.
|
2012-03-23 06:01:16 +00:00
|
|
|
.It Dv IFF_CANTCONFIG
|
|
|
|
.Aq S*
|
2012-03-23 16:24:07 +00:00
|
|
|
The interface is not configurable in a meaningful way.
|
2012-03-23 06:01:16 +00:00
|
|
|
Primarily useful for
|
|
|
|
.Dv IFT_USB
|
|
|
|
interfaces registered at the interface list.
|
|
|
|
.It Dv IFF_MONITOR
|
|
|
|
.Aq D
|
|
|
|
This interface blocks transmission of packets and discards incoming
|
|
|
|
packets after BPF processing.
|
2012-05-20 16:43:47 +00:00
|
|
|
Used to monitor network traffic but not interact
|
2012-03-23 06:01:16 +00:00
|
|
|
with the network in question.
|
|
|
|
.It Dv IFF_STATICARP
|
|
|
|
.Aq D
|
|
|
|
Used to enable/disable ARP requests on this interface.
|
|
|
|
.It Dv IFF_DYING
|
|
|
|
.Aq D*
|
|
|
|
Set when the
|
|
|
|
.Vt ifnet
|
|
|
|
structure of this interface is being released and still has
|
|
|
|
.Va if_refcount
|
|
|
|
references.
|
|
|
|
.It Dv IFF_RENAMING
|
2004-06-08 08:48:49 +00:00
|
|
|
.Aq D*
|
2012-03-23 06:01:16 +00:00
|
|
|
Set when this interface is being renamed.
|
1996-12-17 20:21:01 +00:00
|
|
|
.El
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Capabilities Flags"
|
2001-09-22 12:34:19 +00:00
|
|
|
Interface capabilities are specialized features an interface may
|
|
|
|
or may not support.
|
|
|
|
These capabilities are very hardware-specific
|
|
|
|
and allow, when enabled,
|
2004-01-22 00:10:21 +00:00
|
|
|
to offload specific network processing to the interface
|
2004-06-07 16:46:28 +00:00
|
|
|
or to offer a particular feature for use by other kernel parts.
|
2004-01-22 00:10:21 +00:00
|
|
|
.Pp
|
2004-06-07 16:46:28 +00:00
|
|
|
It should be stressed that a capability can be completely
|
2004-01-22 00:10:21 +00:00
|
|
|
uncontrolled (i.e., stay always enabled with no way to disable it)
|
|
|
|
or allow limited control over itself (e.g., depend on another
|
|
|
|
capability's state.)
|
|
|
|
Such peculiarities are determined solely by the hardware and driver
|
|
|
|
of a particular interface.
|
2004-06-07 16:46:28 +00:00
|
|
|
Only the driver possesses
|
|
|
|
the knowledge on whether and how the interface capabilities
|
|
|
|
can be controlled.
|
|
|
|
Consequently, capabilities flags in
|
|
|
|
.Va if_capenable
|
|
|
|
should never be modified directly by kernel code other than
|
|
|
|
the interface driver.
|
|
|
|
The command
|
|
|
|
.Dv SIOCSIFCAP
|
|
|
|
to
|
|
|
|
.Fn ifioctl
|
|
|
|
is the dedicated means to attempt altering
|
|
|
|
.Va if_capenable
|
|
|
|
on an interface.
|
|
|
|
Userland code shall use
|
|
|
|
.Xr ioctl 2 .
|
2004-01-22 00:10:21 +00:00
|
|
|
.Pp
|
|
|
|
The following capabilities are currently supported by the system:
|
2012-03-23 10:39:50 +00:00
|
|
|
.Bl -tag -width ".Dv IFCAP_POLLING_NOCOUNT" -offset indent
|
2001-09-22 12:34:19 +00:00
|
|
|
.It Dv IFCAP_RXCSUM
|
2001-09-22 15:59:09 +00:00
|
|
|
This interface can do checksum validation on receiving data.
|
2001-09-22 12:34:19 +00:00
|
|
|
Some interfaces do not have sufficient buffer storage to store frames
|
|
|
|
above a certain MTU-size completely.
|
|
|
|
The driver for the interface might disable hardware checksum validation
|
|
|
|
if the MTU is set above the hardcoded limit.
|
|
|
|
.It Dv IFCAP_TXCSUM
|
2001-09-22 15:59:09 +00:00
|
|
|
This interface can do checksum calculation on transmitting data.
|
2004-01-22 00:10:21 +00:00
|
|
|
.It Dv IFCAP_HWCSUM
|
|
|
|
A shorthand for
|
2004-06-16 15:57:59 +00:00
|
|
|
.Pq Dv IFCAP_RXCSUM | IFCAP_TXCSUM .
|
2012-03-23 10:39:50 +00:00
|
|
|
.It Dv IFCAP_NETCONS
|
|
|
|
This interface can be a network console.
|
2004-01-22 00:10:21 +00:00
|
|
|
.It Dv IFCAP_VLAN_MTU
|
|
|
|
The
|
|
|
|
.Xr vlan 4
|
|
|
|
driver can operate over this interface in software tagging mode
|
|
|
|
without having to decrease MTU on
|
|
|
|
.Xr vlan 4
|
|
|
|
interfaces below 1500 bytes.
|
|
|
|
This implies the ability of this interface to cope with frames somewhat
|
|
|
|
longer than permitted by the Ethernet specification.
|
2012-03-23 10:39:50 +00:00
|
|
|
.It Dv IFCAP_VLAN_HWTAGGING
|
|
|
|
This interface can do VLAN tagging on output and
|
|
|
|
demultiplex frames by their VLAN tag on input.
|
2004-01-22 00:10:21 +00:00
|
|
|
.It Dv IFCAP_JUMBO_MTU
|
|
|
|
This Ethernet interface can transmit and receive frames up to
|
|
|
|
9000 bytes long.
|
2012-03-23 10:39:50 +00:00
|
|
|
.It Dv IFCAP_POLLING
|
|
|
|
This interface supports
|
|
|
|
.Xr polling 4 .
|
|
|
|
See below for details.
|
|
|
|
.It Dv IFCAP_VLAN_HWCSUM
|
|
|
|
This interface can do checksum calculation on both transmitting
|
|
|
|
and receiving data on
|
|
|
|
.Xr vlan 4
|
|
|
|
interfaces (implies
|
|
|
|
.Dv IFCAP_HWCSUM ) .
|
2010-07-27 08:45:29 +00:00
|
|
|
.It Dv IFCAP_TSO4
|
2012-03-23 10:39:50 +00:00
|
|
|
This Ethernet interface supports TCP4 Segmentation offloading.
|
2010-07-27 08:45:29 +00:00
|
|
|
.It Dv IFCAP_TSO6
|
|
|
|
This Ethernet interface supports TCP6 Segmentation offloading.
|
|
|
|
.It Dv IFCAP_TSO
|
2012-03-06 09:40:34 +00:00
|
|
|
A shorthand for
|
2010-07-27 08:45:29 +00:00
|
|
|
.Pq Dv IFCAP_TSO4 | IFCAP_TSO6 .
|
|
|
|
.It Dv IFCAP_TOE4
|
|
|
|
This Ethernet interface supports TCP offloading.
|
|
|
|
.It Dv IFCAP_TOE6
|
|
|
|
This Ethernet interface supports TCP6 offloading.
|
2012-03-23 10:39:50 +00:00
|
|
|
.It Dv IFCAP_TOE
|
2012-03-06 09:57:50 +00:00
|
|
|
A shorthand for
|
2010-07-27 08:45:29 +00:00
|
|
|
.Pq Dv IFCAP_TOE4 | IFCAP_TOE6 .
|
|
|
|
.It Dv IFCAP_WOL_UCAST
|
|
|
|
This Ethernet interface supports waking up on any Unicast packet.
|
|
|
|
.It Dv IFCAP_WOL_MCAST
|
|
|
|
This Ethernet interface supports waking up on any Multicast packet.
|
|
|
|
.It Dv IFCAP_WOL_MAGIC
|
|
|
|
This Ethernet interface supports waking up on any Magic packet such
|
|
|
|
as those sent by
|
|
|
|
.Xr wake 8 .
|
|
|
|
.It Dv IFCAP_WOL
|
|
|
|
A shorthand for
|
|
|
|
.Pq Dv IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC .
|
2012-03-23 10:39:50 +00:00
|
|
|
.It Dv IFCAP_TOE4
|
|
|
|
This Ethernet interface supports TCP4 Offload Engine.
|
|
|
|
.It Dv IFCAP_TOE6
|
|
|
|
This Ethernet interface supports TCP6 Offload Engine.
|
|
|
|
.It Dv IFCAP_TOE
|
|
|
|
A shorthand for
|
|
|
|
.Pq Dv IFCAP_TOE4 | IFCAP_TOE6 .
|
|
|
|
.It Dv IFCAP_VLAN_HWFILTER
|
|
|
|
This interface supports frame filtering in hardware on
|
|
|
|
.Xr vlan 4
|
|
|
|
interfaces.
|
|
|
|
.It Dv IFCAP_POLLING_NOCOUNT
|
|
|
|
The return value for the number of processed packets should be
|
|
|
|
skipped for this interface.
|
|
|
|
.It Dv IFCAP_VLAN_HWTSO
|
|
|
|
This interface supports TCP Segmentation offloading on
|
|
|
|
.Xr vlan 4
|
|
|
|
interfaces (implies
|
|
|
|
.Dv IFCAP_TSO ) .
|
|
|
|
.It Dv IFCAP_LINKSTATE
|
|
|
|
This Ethernet interface supports dynamic link state changes.
|
2004-01-22 00:10:21 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The ability of advanced network interfaces to offload certain
|
|
|
|
computational tasks from the host CPU to the board is limited
|
|
|
|
mostly to TCP/IP.
|
|
|
|
Therefore a separate field associated with an interface
|
|
|
|
(see
|
|
|
|
.Va ifnet.if_data.ifi_hwassist
|
|
|
|
below)
|
|
|
|
keeps a detailed description of its enabled capabilities
|
|
|
|
specific to TCP/IP processing.
|
|
|
|
The TCP/IP module consults the field to see which tasks
|
|
|
|
can be done on an
|
|
|
|
.Em outgoing
|
|
|
|
packet by the interface.
|
|
|
|
The flags defined for that field are a superset of those for
|
|
|
|
.Va mbuf.m_pkthdr.csum_flags ,
|
|
|
|
namely:
|
|
|
|
.Bl -tag -width ".Dv CSUM_FRAGMENT" -offset indent
|
|
|
|
.It Dv CSUM_IP
|
|
|
|
The interface will compute IP checksums.
|
|
|
|
.It Dv CSUM_TCP
|
|
|
|
The interface will compute TCP checksums.
|
|
|
|
.It Dv CSUM_UDP
|
|
|
|
The interface will compute UDP checksums.
|
|
|
|
.It Dv CSUM_IP_FRAGS
|
|
|
|
The interface can compute a TCP or UDP checksum for a packet
|
|
|
|
fragmented by the host CPU.
|
|
|
|
Makes sense only along with
|
|
|
|
.Dv CSUM_TCP
|
|
|
|
or
|
|
|
|
.Dv CSUM_UDP .
|
|
|
|
.It Dv CSUM_FRAGMENT
|
|
|
|
The interface will do the fragmentation of IP packets if necessary.
|
2004-06-16 15:57:59 +00:00
|
|
|
The host CPU does not need to care about MTU on this interface
|
2004-01-22 00:10:21 +00:00
|
|
|
as long as a packet to transmit through it is an IP one and it
|
2004-06-16 15:57:59 +00:00
|
|
|
does not exceed the size of the hardware buffer.
|
2001-09-22 12:34:19 +00:00
|
|
|
.El
|
2004-01-22 00:10:21 +00:00
|
|
|
.Pp
|
|
|
|
An interface notifies the TCP/IP module about the tasks
|
|
|
|
the former has performed on an
|
|
|
|
.Em incoming
|
|
|
|
packet by setting the corresponding flags in the field
|
|
|
|
.Va mbuf.m_pkthdr.csum_flags
|
|
|
|
of the
|
|
|
|
.Vt mbuf chain
|
|
|
|
containing the packet.
|
|
|
|
See
|
|
|
|
.Xr mbuf 9
|
|
|
|
for details.
|
2004-06-08 08:48:49 +00:00
|
|
|
.Pp
|
|
|
|
The capability of a network interface to operate in
|
|
|
|
.Xr polling 4
|
|
|
|
mode involves several flags in different
|
|
|
|
global variables and per-interface fields.
|
2012-03-23 10:33:24 +00:00
|
|
|
The capability flag
|
2004-06-08 08:48:49 +00:00
|
|
|
.Dv IFCAP_POLLING
|
|
|
|
set in interface's
|
|
|
|
.Va if_capabilities
|
|
|
|
indicates support for
|
|
|
|
.Xr polling 4
|
|
|
|
on the particular interface.
|
|
|
|
If set in
|
|
|
|
.Va if_capabilities ,
|
|
|
|
the same flag can be marked or cleared in the interface's
|
2012-03-23 10:33:24 +00:00
|
|
|
.Va if_capenable
|
|
|
|
within
|
|
|
|
.Fn ifioctl ,
|
2004-06-08 08:48:49 +00:00
|
|
|
thus initiating switch of the interface to
|
|
|
|
.Xr polling 4
|
|
|
|
mode or interrupt
|
|
|
|
mode, respectively.
|
2012-03-23 10:33:24 +00:00
|
|
|
The actual mode change is managed by the driver-specific
|
|
|
|
.Fn if_ioctl
|
|
|
|
routine.
|
|
|
|
The
|
|
|
|
.Xr polling
|
|
|
|
handler returns the number of packets processed.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss The Vt if_data Ss Structure
|
2012-03-07 14:53:53 +00:00
|
|
|
The
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt if_data
|
2012-03-07 14:53:53 +00:00
|
|
|
structure contains statistics and identifying information used
|
|
|
|
by management programs, and which is exported to user programs by way
|
|
|
|
of the
|
|
|
|
.Xr ifmib 4
|
|
|
|
branch of the
|
|
|
|
.Xr sysctl 3
|
|
|
|
MIB.
|
2002-01-10 11:57:10 +00:00
|
|
|
The following elements of the
|
|
|
|
.Vt if_data
|
1996-12-17 20:21:01 +00:00
|
|
|
structure are initialized by the interface and are not expected to change
|
|
|
|
significantly over the course of normal operation:
|
2002-01-10 11:57:10 +00:00
|
|
|
.Bl -tag -width ".Va ifi_lastchange" -offset indent
|
|
|
|
.It Va ifi_type
|
|
|
|
.Pq Vt u_char
|
1996-12-17 20:21:01 +00:00
|
|
|
The type of the interface, as defined in
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if_types.h
|
1996-12-17 20:21:01 +00:00
|
|
|
and described below in the
|
2002-01-10 11:57:10 +00:00
|
|
|
.Sx "Interface Types"
|
1996-12-17 20:21:01 +00:00
|
|
|
section.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_physical
|
|
|
|
.Pq Vt u_char
|
1996-12-17 20:21:01 +00:00
|
|
|
Intended to represent a selection of physical layers on devices which
|
|
|
|
support more than one; never implemented.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_addrlen
|
|
|
|
.Pq Vt u_char
|
1996-12-17 20:21:01 +00:00
|
|
|
Length of a link-layer address on this device, or zero if there are
|
2002-01-10 11:57:10 +00:00
|
|
|
none.
|
|
|
|
Used to initialized the address length field in
|
|
|
|
.Vt sockaddr_dl
|
1996-12-17 20:21:01 +00:00
|
|
|
structures referring to this interface.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_hdrlen
|
|
|
|
.Pq Vt u_char
|
1996-12-17 20:21:01 +00:00
|
|
|
Maximum length of any link-layer header which might be prepended by
|
2002-01-10 11:57:10 +00:00
|
|
|
the driver to a packet before transmission.
|
|
|
|
The generic code computes
|
1996-12-17 20:21:01 +00:00
|
|
|
the maximum over all interfaces and uses that value to influence the
|
|
|
|
placement of data in
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt mbuf Ns s
|
1996-12-17 20:21:01 +00:00
|
|
|
to attempt to ensure that there is always
|
|
|
|
sufficient space to prepend a link-layer header without allocating an
|
2001-07-14 19:41:16 +00:00
|
|
|
additional
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt mbuf .
|
2004-09-17 06:49:43 +00:00
|
|
|
.It Va ifi_datalen
|
|
|
|
.Pq Vt u_char
|
|
|
|
Length of the
|
|
|
|
.Vt if_data
|
|
|
|
structure.
|
|
|
|
Allows some stabilization of the routing socket ABI in the face of
|
|
|
|
increases in the length of
|
|
|
|
.Vt struct ifdata .
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_mtu
|
|
|
|
.Pq Vt u_long
|
1996-12-17 20:21:01 +00:00
|
|
|
The maximum transmission unit of the medium, exclusive of any
|
|
|
|
link-layer overhead.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_metric
|
|
|
|
.Pq Vt u_long
|
1996-12-17 20:21:01 +00:00
|
|
|
A dimensionless metric interpreted by a user-mode routing process.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_baudrate
|
|
|
|
.Pq Vt u_long
|
1996-12-17 20:21:01 +00:00
|
|
|
The line rate of the interface, in bits per second.
|
2004-01-22 00:10:21 +00:00
|
|
|
.It Va ifi_hwassist
|
|
|
|
.Pq Vt u_long
|
|
|
|
A detailed interpretation of the capabilities
|
|
|
|
to offload computational tasks for
|
|
|
|
.Em outgoing
|
|
|
|
packets.
|
|
|
|
The interface driver must keep this field in accord with
|
|
|
|
the current value of
|
|
|
|
.Va if_capenable .
|
2005-06-06 00:21:28 +00:00
|
|
|
.It Va ifi_epoch
|
2004-09-17 06:49:43 +00:00
|
|
|
.Pq Vt time_t
|
2005-02-25 19:46:41 +00:00
|
|
|
The system uptime when interface was attached or the statistics
|
2004-09-17 06:49:43 +00:00
|
|
|
below were reset.
|
2005-01-12 21:48:25 +00:00
|
|
|
This is intended to be used to set the SNMP variable
|
2004-09-17 06:49:43 +00:00
|
|
|
.Va ifCounterDiscontinuityTime .
|
|
|
|
It may also be used to determine if two successive queries for an
|
|
|
|
interface of the same index have returned results for the same
|
|
|
|
interface.
|
1996-12-17 20:21:01 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The structure additionally contains generic statistics applicable to a
|
|
|
|
variety of different interface types (except as noted, all members are
|
|
|
|
of type
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt u_long ) :
|
|
|
|
.Bl -tag -width ".Va ifi_lastchange" -offset indent
|
2004-09-17 06:49:43 +00:00
|
|
|
.It Va ifi_link_state
|
|
|
|
.Pq Vt u_char
|
|
|
|
The current link state of Ethernet interfaces.
|
2005-01-02 18:20:29 +00:00
|
|
|
See the
|
2004-09-17 06:49:43 +00:00
|
|
|
.Sx Interface Link States
|
|
|
|
section for possible values.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_ipackets
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of packets received.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_ierrors
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of receive errors detected (e.g., FCS errors, DMA overruns,
|
2002-01-10 11:57:10 +00:00
|
|
|
etc.).
|
|
|
|
More detailed breakdowns can often be had by way of a
|
1996-12-17 20:21:01 +00:00
|
|
|
link-specific MIB.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_opackets
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of packets transmitted.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_oerrors
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of output errors detected (e.g., late collisions, DMA overruns,
|
2002-01-10 11:57:10 +00:00
|
|
|
etc.).
|
|
|
|
More detailed breakdowns can often be had by way of a
|
1996-12-17 20:21:01 +00:00
|
|
|
link-specific MIB.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_collisions
|
1996-12-17 20:21:01 +00:00
|
|
|
Total number of collisions detected on output for CSMA interfaces.
|
|
|
|
(This member is sometimes [ab]used by other types of interfaces for
|
|
|
|
other output error counts.)
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_ibytes
|
1996-12-17 20:21:01 +00:00
|
|
|
Total traffic received, in bytes.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_obytes
|
1996-12-17 20:21:01 +00:00
|
|
|
Total traffic transmitted, in bytes.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_imcasts
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of packets received which were sent by link-layer multicast.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_omcasts
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of packets sent by link-layer multicast.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_iqdrops
|
|
|
|
Number of packets dropped on input.
|
|
|
|
Rarely implemented.
|
|
|
|
.It Va ifi_noproto
|
1996-12-17 20:21:01 +00:00
|
|
|
Number of packets received for unknown network-layer protocol.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifi_lastchange
|
|
|
|
.Pq Vt "struct timeval"
|
1996-12-18 22:06:47 +00:00
|
|
|
The time of the last administrative change to the interface (as required
|
1996-12-17 20:21:01 +00:00
|
|
|
for
|
|
|
|
.Tn SNMP ) .
|
|
|
|
.El
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss Interface Types
|
1996-12-17 20:21:01 +00:00
|
|
|
The header file
|
2003-09-08 19:57:22 +00:00
|
|
|
.In net/if_types.h
|
1996-12-17 20:21:01 +00:00
|
|
|
defines symbolic constants for a number of different types of
|
2002-01-10 11:57:10 +00:00
|
|
|
interfaces.
|
|
|
|
The most common are:
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
2002-01-10 11:57:10 +00:00
|
|
|
.Bl -tag -offset indent -width ".Dv IFT_PROPVIRTUAL" -compact
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv IFT_OTHER
|
|
|
|
none of the following
|
|
|
|
.It Dv IFT_ETHER
|
|
|
|
Ethernet
|
|
|
|
.It Dv IFT_ISO88023
|
|
|
|
ISO 8802-3 CSMA/CD
|
|
|
|
.It Dv IFT_ISO88024
|
|
|
|
ISO 8802-4 Token Bus
|
|
|
|
.It Dv IFT_ISO88025
|
|
|
|
ISO 8802-5 Token Ring
|
|
|
|
.It Dv IFT_ISO88026
|
|
|
|
ISO 8802-6 DQDB MAN
|
|
|
|
.It Dv IFT_FDDI
|
|
|
|
FDDI
|
|
|
|
.It Dv IFT_PPP
|
|
|
|
Internet Point-to-Point Protocol
|
|
|
|
.Pq Xr ppp 8
|
|
|
|
.It Dv IFT_LOOP
|
|
|
|
The loopback
|
|
|
|
.Pq Xr lo 4
|
2002-01-10 11:57:10 +00:00
|
|
|
interface
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv IFT_SLIP
|
|
|
|
Serial Line IP
|
|
|
|
.It Dv IFT_PARA
|
|
|
|
Parallel-port IP
|
|
|
|
.Pq Dq Tn PLIP
|
|
|
|
.It Dv IFT_ATM
|
|
|
|
Asynchronous Transfer Mode
|
2012-03-23 06:06:37 +00:00
|
|
|
.It Dv IFT_USB
|
|
|
|
USB Interface
|
1996-12-17 20:21:01 +00:00
|
|
|
.El
|
2004-09-17 06:49:43 +00:00
|
|
|
.Ss Interface Link States
|
|
|
|
The following link states are currently defined:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -offset indent -width ".Dv LINK_STATE_UNKNOWN" -compact
|
|
|
|
.It Dv LINK_STATE_UNKNOWN
|
|
|
|
The link is in an invalid or unknown state.
|
|
|
|
.It Dv LINK_STATE_DOWN
|
|
|
|
The link is down.
|
|
|
|
.It Dv LINK_STATE_UP
|
|
|
|
The link is up.
|
|
|
|
.El
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss The Vt ifaddr Ss Structure
|
1996-12-17 20:21:01 +00:00
|
|
|
Every interface is associated with a list
|
|
|
|
(or, rather, a
|
2002-01-10 11:57:10 +00:00
|
|
|
.Li TAILQ )
|
1996-12-17 20:21:01 +00:00
|
|
|
of addresses, rooted at the interface structure's
|
2002-01-10 11:57:10 +00:00
|
|
|
.Va if_addrlist
|
|
|
|
member.
|
|
|
|
The first element in this list is always an
|
1996-12-17 20:21:01 +00:00
|
|
|
.Dv AF_LINK
|
|
|
|
address representing the interface itself; multi-access network
|
|
|
|
drivers should complete this structure by filling in their link-layer
|
|
|
|
addresses after calling
|
|
|
|
.Fn if_attach .
|
|
|
|
Other members of the structure represent network-layer addresses which
|
|
|
|
have been configured by means of the
|
|
|
|
.Dv SIOCAIFADDR
|
|
|
|
command to
|
|
|
|
.Xr ioctl 2 ,
|
|
|
|
called on a socket of the appropriate protocol family.
|
|
|
|
The elements of this list consist of
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifaddr
|
|
|
|
structures.
|
|
|
|
Most protocols will declare their own protocol-specific
|
1996-12-17 20:21:01 +00:00
|
|
|
interface address structures, but all begin with a
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifaddr"
|
1996-12-17 20:21:01 +00:00
|
|
|
which provides the most-commonly-needed functionality across all
|
2002-01-10 11:57:10 +00:00
|
|
|
protocols.
|
|
|
|
Interface addresses are reference-counted.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
|
|
|
The members of
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifaddr"
|
1996-12-17 20:21:01 +00:00
|
|
|
are as follows:
|
2002-01-10 11:57:10 +00:00
|
|
|
.Bl -tag -width ".Va ifa_rtrequest" -offset indent
|
|
|
|
.It Va ifa_addr
|
|
|
|
.Pq Vt "struct sockaddr *"
|
1996-12-17 20:21:01 +00:00
|
|
|
The local address of the interface.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_dstaddr
|
|
|
|
.Pq Vt "struct sockaddr *"
|
1996-12-17 20:21:01 +00:00
|
|
|
The remote address of point-to-point interfaces, and the broadcast
|
|
|
|
address of broadcast interfaces.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Va ( ifa_broadaddr
|
1996-12-17 20:21:01 +00:00
|
|
|
is a macro for
|
2002-01-10 11:57:10 +00:00
|
|
|
.Va ifa_dstaddr . )
|
|
|
|
.It Va ifa_netmask
|
|
|
|
.Pq Vt "struct sockaddr *"
|
1996-12-17 20:21:01 +00:00
|
|
|
The network mask for multi-access interfaces, and the confusion
|
|
|
|
generator for point-to-point interfaces.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_ifp
|
|
|
|
.Pq Vt "struct ifnet *"
|
1996-12-17 20:21:01 +00:00
|
|
|
A link back to the interface structure.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_link
|
|
|
|
.Pq Fn TAILQ_ENTRY ifaddr
|
1996-12-17 20:21:01 +00:00
|
|
|
.Xr queue 3
|
|
|
|
glue for list of addresses on each interface.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_rtrequest
|
1996-12-17 20:21:01 +00:00
|
|
|
See below.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_flags
|
|
|
|
.Pq Vt u_short
|
1996-12-17 20:21:01 +00:00
|
|
|
Some of the flags which would be used for a route representing this
|
|
|
|
address in the route table.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_refcnt
|
|
|
|
.Pq Vt short
|
1996-12-17 20:21:01 +00:00
|
|
|
The reference count.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifa_metric
|
|
|
|
.Pq Vt int
|
1996-12-17 20:21:01 +00:00
|
|
|
A metric associated with this interface address, for the use of some
|
|
|
|
external routing protocol.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
References to
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifaddr
|
2012-03-01 12:52:14 +00:00
|
|
|
structures are gained by calling the
|
|
|
|
.Fn ifa_ref
|
|
|
|
function and released by calling the
|
|
|
|
.Fn ifa_free
|
|
|
|
function.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ifa_rtrequest
|
|
|
|
is a pointer to a function which receives callouts from the routing
|
|
|
|
code
|
|
|
|
.Pq Fn rtrequest
|
2012-03-07 09:42:19 +00:00
|
|
|
to perform link-layer-specific actions upon requests to add,
|
2002-01-10 11:57:10 +00:00
|
|
|
or delete routes.
|
|
|
|
The
|
|
|
|
.Fa cmd
|
1996-12-17 20:21:01 +00:00
|
|
|
argument indicates the request in question:
|
2012-03-07 09:42:19 +00:00
|
|
|
.Dv RTM_ADD ,
|
1996-12-17 20:21:01 +00:00
|
|
|
or
|
|
|
|
.Dv RTM_DELETE .
|
|
|
|
The
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa rt
|
1996-12-17 20:21:01 +00:00
|
|
|
argument is the route in question; the
|
2012-03-07 09:42:19 +00:00
|
|
|
.Fa info
|
|
|
|
argument contains the specific destination being manipulated.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Sh FUNCTIONS
|
|
|
|
The functions provided by the generic interface code can be divided
|
|
|
|
into two groups: those which manipulate interfaces, and those which
|
2002-01-10 11:57:10 +00:00
|
|
|
manipulate interface addresses.
|
|
|
|
In addition to these functions, there
|
1996-12-17 20:21:01 +00:00
|
|
|
may also be link-layer support routines which are used by a number of
|
|
|
|
drivers implementing a specific link layer over different hardware;
|
|
|
|
see the documentation for that link layer for more details.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss The Vt ifmultiaddr Ss Structure
|
1997-01-15 19:28:39 +00:00
|
|
|
Every multicast-capable interface is associated with a list of
|
|
|
|
multicast group memberships, which indicate at a low level which
|
|
|
|
link-layer multicast addresses (if any) should be accepted, and at a
|
|
|
|
high level, in which network-layer multicast groups a user process has
|
|
|
|
expressed interest.
|
|
|
|
.Pp
|
|
|
|
The elements of the structure are as follows:
|
2002-01-10 11:57:10 +00:00
|
|
|
.Bl -tag -width ".Va ifma_refcount" -offset indent
|
|
|
|
.It Va ifma_link
|
|
|
|
.Pq Fn LIST_ENTRY ifmultiaddr
|
1997-01-15 19:28:39 +00:00
|
|
|
.Xr queue 3
|
|
|
|
macro glue.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifma_addr
|
|
|
|
.Pq Vt "struct sockaddr *"
|
|
|
|
A pointer to the address which this record represents.
|
|
|
|
The
|
1997-01-15 19:28:39 +00:00
|
|
|
memberships for various address families are stored in arbitrary
|
|
|
|
order.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifma_lladdr
|
|
|
|
.Pq Vt "struct sockaddr *"
|
1997-01-15 19:28:39 +00:00
|
|
|
A pointer to the link-layer multicast address, if any, to which the
|
1999-06-27 02:38:46 +00:00
|
|
|
network-layer multicast address in
|
2002-01-10 11:57:10 +00:00
|
|
|
.Va ifma_addr
|
|
|
|
is mapped, else a null pointer.
|
|
|
|
If this element is non-nil, this
|
1997-01-15 19:28:39 +00:00
|
|
|
membership also holds an invisible reference to another membership for
|
|
|
|
that link-layer address.
|
2002-01-10 11:57:10 +00:00
|
|
|
.It Va ifma_refcount
|
|
|
|
.Pq Vt u_int
|
1997-01-15 19:28:39 +00:00
|
|
|
A reference count of requests for this particular membership.
|
|
|
|
.El
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss Interface Manipulation Functions
|
1996-12-17 20:21:01 +00:00
|
|
|
.Bl -ohang -offset indent
|
2005-06-10 16:49:24 +00:00
|
|
|
.It Fn if_alloc
|
2005-06-15 13:31:23 +00:00
|
|
|
Allocate and initialize
|
|
|
|
.Vt "struct ifnet" .
|
2005-07-31 03:30:48 +00:00
|
|
|
Initialization includes the allocation of an interface index and may
|
2005-06-10 16:49:24 +00:00
|
|
|
include the allocation of a
|
|
|
|
.Fa type
|
|
|
|
specific structure in
|
|
|
|
.Va if_l2com .
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn if_attach
|
|
|
|
Link the specified interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp
|
|
|
|
into the list of network interfaces.
|
|
|
|
Also initialize the list of
|
2001-07-14 19:41:16 +00:00
|
|
|
addresses on that interface, and create a link-layer
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifaddr
|
|
|
|
structure to be the first element in that list.
|
|
|
|
(A pointer to
|
2012-03-06 08:59:42 +00:00
|
|
|
this address structure is saved in the
|
|
|
|
.Vt ifnet
|
|
|
|
structure and shall be accessed by the
|
|
|
|
.Fn ifaddr_byindex
|
|
|
|
function.)
|
2005-06-10 16:49:24 +00:00
|
|
|
The
|
|
|
|
.Fa ifp
|
2006-12-14 14:33:13 +00:00
|
|
|
must have been allocated by
|
2005-06-10 16:49:24 +00:00
|
|
|
.Fn if_alloc .
|
|
|
|
.It Fn if_detach
|
|
|
|
Shut down and unlink the specified
|
|
|
|
.Fa ifp
|
|
|
|
from the interface list.
|
|
|
|
.It Fn if_free
|
|
|
|
Free the given
|
|
|
|
.Fa ifp
|
|
|
|
back to the system.
|
|
|
|
The interface must have been previously detached if it was ever attached.
|
|
|
|
.It Fn if_free_type
|
|
|
|
Identical to
|
|
|
|
.Fn if_free
|
|
|
|
except that the given
|
|
|
|
.Fa type
|
2005-06-15 13:31:23 +00:00
|
|
|
is used to free
|
2005-06-10 16:49:24 +00:00
|
|
|
.Va if_l2com
|
|
|
|
instead of the type in
|
|
|
|
.Va if_type .
|
|
|
|
This is intended for use with drivers that change their interface type.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn if_down
|
|
|
|
Mark the interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp
|
1996-12-17 20:21:01 +00:00
|
|
|
as down (i.e.,
|
|
|
|
.Dv IFF_UP
|
|
|
|
is not set),
|
1999-09-14 01:05:40 +00:00
|
|
|
flush its output queue, notify protocols of the transition,
|
|
|
|
and generate a message from the
|
|
|
|
.Xr route 4
|
|
|
|
routing socket.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn if_up
|
|
|
|
Mark the interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp
|
1999-09-14 01:05:40 +00:00
|
|
|
as up, notify protocols of the transition,
|
|
|
|
and generate a message from the
|
|
|
|
.Xr route 4
|
|
|
|
routing socket.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn ifpromisc
|
|
|
|
Add or remove a promiscuous reference to
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp .
|
2001-07-14 19:41:16 +00:00
|
|
|
If
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa pswitch
|
1996-12-17 20:21:01 +00:00
|
|
|
is true, add a reference;
|
2002-01-10 11:57:10 +00:00
|
|
|
if it is false, remove a reference.
|
|
|
|
On reference count transitions
|
1996-12-17 20:21:01 +00:00
|
|
|
from zero to one and one to zero, set the
|
|
|
|
.Dv IFF_PROMISC
|
|
|
|
flag appropriately and call
|
|
|
|
.Fn if_ioctl
|
|
|
|
to set up the interface in the desired mode.
|
1997-01-15 19:28:39 +00:00
|
|
|
.It Fn if_allmulti
|
|
|
|
As
|
|
|
|
.Fn ifpromisc ,
|
|
|
|
but for the all-multicasts
|
|
|
|
.Pq Dv IFF_ALLMULTI
|
|
|
|
flag instead of the promiscuous flag.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn ifunit
|
2001-07-14 19:41:16 +00:00
|
|
|
Return an
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt ifnet
|
1996-12-17 20:21:01 +00:00
|
|
|
pointer for the interface named
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa name .
|
2012-03-01 12:03:52 +00:00
|
|
|
.It Fn ifunit_ref
|
|
|
|
Return a reference-counted (via
|
|
|
|
.Fn ifa_ref )
|
|
|
|
.Vt ifnet
|
|
|
|
pointer for the interface named
|
|
|
|
.Fa name .
|
2012-03-01 12:30:57 +00:00
|
|
|
This is the preferred function over
|
2012-03-01 12:03:52 +00:00
|
|
|
.Fn ifunit .
|
2012-03-01 12:30:57 +00:00
|
|
|
The caller is responsible for releasing the reference with
|
|
|
|
.Fn if_rele
|
|
|
|
when it is finished with the ifnet.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Fn ifioctl
|
|
|
|
Process the ioctl request
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa cmd ,
|
1996-12-17 20:21:01 +00:00
|
|
|
issued on socket
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa so
|
2001-12-26 23:14:04 +00:00
|
|
|
by thread
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa td ,
|
1996-12-17 20:21:01 +00:00
|
|
|
with data parameter
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa data .
|
1996-12-17 20:21:01 +00:00
|
|
|
This is the main routine for handling all interface configuration
|
|
|
|
requests from user mode.
|
|
|
|
It is ordinarily only called from the socket-layer
|
|
|
|
.Xr ioctl 2
|
|
|
|
handler, and only for commands with class
|
|
|
|
.Sq Li i .
|
|
|
|
Any unrecognized commands will be passed down to socket
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa so Ns 's
|
1996-12-17 20:21:01 +00:00
|
|
|
protocol for
|
2002-01-10 11:57:10 +00:00
|
|
|
further interpretation.
|
|
|
|
The following commands are handled by
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn ifioctl :
|
|
|
|
.Pp
|
2013-11-05 10:29:47 +00:00
|
|
|
.Bl -tag -width ".Dv SIOCGIFNETMASK" -offset indent -compact
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv SIOCGIFCONF
|
2002-01-10 11:57:10 +00:00
|
|
|
Get interface configuration.
|
|
|
|
(No call-down to driver.)
|
|
|
|
.Pp
|
2004-02-04 02:54:25 +00:00
|
|
|
.It Dv SIOCSIFNAME
|
|
|
|
Set the interface name.
|
2004-06-16 15:57:59 +00:00
|
|
|
.Dv RTM_IFANNOUNCE
|
|
|
|
departure and arrival messages are sent so that
|
2004-02-04 02:54:25 +00:00
|
|
|
routing code that relies on the interface name will update its interface
|
|
|
|
list.
|
|
|
|
Caller must have appropriate privilege.
|
|
|
|
(No call-down to driver.)
|
2001-09-22 12:34:19 +00:00
|
|
|
.It Dv SIOCGIFCAP
|
2011-07-03 12:22:02 +00:00
|
|
|
.It Dv SIOCGIFFIB
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv SIOCGIFFLAGS
|
|
|
|
.It Dv SIOCGIFMETRIC
|
|
|
|
.It Dv SIOCGIFMTU
|
|
|
|
.It Dv SIOCGIFPHYS
|
2011-07-03 12:22:02 +00:00
|
|
|
Get interface capabilities, FIB, flags, metric, MTU, medium selection.
|
2001-09-22 12:34:19 +00:00
|
|
|
(No call-down to driver.)
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
2001-09-22 12:34:19 +00:00
|
|
|
.It Dv SIOCSIFCAP
|
2004-01-22 00:10:21 +00:00
|
|
|
Enable or disable interface capabilities.
|
2001-09-22 12:34:19 +00:00
|
|
|
Caller must have appropriate privilege.
|
2004-01-26 11:48:26 +00:00
|
|
|
Before a call to the driver-specific
|
|
|
|
.Fn if_ioctl
|
|
|
|
routine, the requested mask for enabled capabilities is checked
|
|
|
|
against the mask of capabilities supported by the interface,
|
2004-06-16 15:57:59 +00:00
|
|
|
.Va if_capabilities .
|
2004-01-26 11:48:26 +00:00
|
|
|
Requesting to enable an unsupported capability is invalid.
|
|
|
|
The rest is supposed to be done by the driver,
|
|
|
|
which includes updating
|
|
|
|
.Va if_capenable
|
|
|
|
and
|
|
|
|
.Va if_data.ifi_hwassist
|
|
|
|
appropriately.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Pp
|
2011-07-03 12:22:02 +00:00
|
|
|
.It Dv SIOCSIFFIB
|
|
|
|
Sets interface FIB.
|
|
|
|
Caller must have appropriate privilege.
|
|
|
|
FIB values start at 0 and values greater or equals than
|
|
|
|
.Va net.fibs
|
|
|
|
are considered invalid.
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv SIOCSIFFLAGS
|
2002-01-10 11:57:10 +00:00
|
|
|
Change interface flags.
|
|
|
|
Caller must have appropriate privilege.
|
|
|
|
If a change to the
|
|
|
|
.Dv IFF_UP
|
|
|
|
flag is requested,
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn if_up
|
|
|
|
or
|
|
|
|
.Fn if_down
|
2002-01-10 11:57:10 +00:00
|
|
|
is called as appropriate.
|
|
|
|
Flags listed in
|
1996-12-17 20:21:01 +00:00
|
|
|
.Dv IFF_CANTCHANGE
|
2004-01-26 12:08:23 +00:00
|
|
|
are masked off, and the field
|
|
|
|
.Va if_flags
|
|
|
|
in the interface structure is updated.
|
|
|
|
Finally, the driver
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn if_ioctl
|
|
|
|
routine is called to perform any setup
|
|
|
|
requested.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv SIOCSIFMETRIC
|
|
|
|
.It Dv SIOCSIFPHYS
|
2002-01-10 11:57:10 +00:00
|
|
|
Change interface metric or medium.
|
|
|
|
Caller must have appropriate privilege.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
|
|
|
.It Dv SIOCSIFMTU
|
2002-01-10 11:57:10 +00:00
|
|
|
Change interface MTU.
|
|
|
|
Caller must have appropriate privilege.
|
|
|
|
MTU
|
|
|
|
values less than 72 or greater than 65535 are considered invalid.
|
|
|
|
The driver
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn if_ioctl
|
|
|
|
routine is called to implement the change; it is responsible for any
|
|
|
|
additional sanity checking and for actually modifying the MTU in the
|
|
|
|
interface structure.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
.It Dv SIOCADDMULTI
|
|
|
|
.It Dv SIOCDELMULTI
|
|
|
|
Add or delete permanent multicast group memberships on the interface.
|
2002-01-10 11:57:10 +00:00
|
|
|
Caller must have appropriate privilege.
|
|
|
|
The
|
1997-01-15 19:28:39 +00:00
|
|
|
.Fn if_addmulti
|
|
|
|
or
|
|
|
|
.Fn if_delmulti
|
|
|
|
function is called to perform the operation; qq.v.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Pp
|
2012-01-26 11:08:55 +00:00
|
|
|
.It Dv SIOCAIFADDR
|
|
|
|
.It Dv SIOCDIFADDR
|
1996-12-17 20:21:01 +00:00
|
|
|
The socket's protocol control routine is called to implement the
|
|
|
|
requested action.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
.El
|
2000-12-29 09:18:45 +00:00
|
|
|
.El
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
|
|
|
.Fn if_down ,
|
|
|
|
.Fn ifioctl ,
|
|
|
|
.Fn ifpromisc ,
|
|
|
|
and
|
|
|
|
.Fn if_up
|
|
|
|
must be called at
|
|
|
|
.Fn splnet
|
|
|
|
or higher.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Address Functions"
|
1996-12-17 20:21:01 +00:00
|
|
|
Several functions exist to look up an interface address structure
|
|
|
|
given an address.
|
|
|
|
.Fn ifa_ifwithaddr
|
|
|
|
returns an interface address with either a local address or a
|
|
|
|
broadcast address precisely matching the parameter
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa addr .
|
1996-12-17 20:21:01 +00:00
|
|
|
.Fn ifa_ifwithdstaddr
|
|
|
|
returns an interface address for a point-to-point interface whose
|
2002-01-10 11:57:10 +00:00
|
|
|
remote
|
|
|
|
.Pq Dq destination
|
|
|
|
address is
|
|
|
|
.Fa addr .
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ifa_ifwithnet
|
|
|
|
returns the most specific interface address which matches the
|
|
|
|
specified address,
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa addr ,
|
1996-12-17 20:21:01 +00:00
|
|
|
subject to its configured netmask, or a point-to-point interface
|
|
|
|
address whose remote address is
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa addr
|
1996-12-17 20:21:01 +00:00
|
|
|
if one is found.
|
2012-03-01 12:16:00 +00:00
|
|
|
If
|
|
|
|
.Fa ignore_ptp
|
|
|
|
is true, skip point-to-point interface addresses.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ifaof_ifpforaddr
|
|
|
|
returns the most specific address configured on interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp
|
1996-12-17 20:21:01 +00:00
|
|
|
which matches address
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa addr ,
|
|
|
|
subject to its configured netmask.
|
|
|
|
If the interface is
|
1996-12-17 20:21:01 +00:00
|
|
|
point-to-point, only an interface address whose remote address is
|
|
|
|
precisely
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa addr
|
1996-12-17 20:21:01 +00:00
|
|
|
will be returned.
|
|
|
|
.Pp
|
2012-03-06 09:04:53 +00:00
|
|
|
.Fn ifaddr_byindex
|
|
|
|
returns the link-level address of the interface with the given index
|
|
|
|
.Fa idx .
|
|
|
|
.Pp
|
1996-12-17 20:21:01 +00:00
|
|
|
All of these functions return a null pointer if no such address can be
|
|
|
|
found.
|
2002-01-10 11:57:10 +00:00
|
|
|
.Ss "Interface Multicast Address Functions"
|
1997-01-15 19:28:39 +00:00
|
|
|
The
|
|
|
|
.Fn if_addmulti ,
|
|
|
|
.Fn if_delmulti ,
|
|
|
|
and
|
2012-03-02 09:52:42 +00:00
|
|
|
.Fn if_findmulti
|
1997-01-15 19:28:39 +00:00
|
|
|
functions provide support for requesting and relinquishing multicast
|
|
|
|
group memberships, and for querying an interface's membership list,
|
2002-01-10 11:57:10 +00:00
|
|
|
respectively.
|
|
|
|
The
|
1997-01-15 19:28:39 +00:00
|
|
|
.Fn if_addmulti
|
|
|
|
function takes a pointer to an interface,
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp ,
|
1997-01-15 19:28:39 +00:00
|
|
|
and a generic address,
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa sa .
|
1997-01-15 19:28:39 +00:00
|
|
|
It also takes a pointer to a
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifmultiaddr *"
|
1997-01-15 19:28:39 +00:00
|
|
|
which is filled in on successful return with the address of the
|
2002-01-10 11:57:10 +00:00
|
|
|
group membership control block.
|
|
|
|
The
|
1997-01-15 19:28:39 +00:00
|
|
|
.Fn if_addmulti
|
|
|
|
function performs the following four-step process:
|
|
|
|
.Bl -enum -offset indent
|
|
|
|
.It
|
|
|
|
Call the interface's
|
|
|
|
.Fn if_resolvemulti
|
|
|
|
entry point to determine the link-layer address, if any, corresponding
|
|
|
|
to this membership request, and also to give the link layer an
|
|
|
|
opportunity to veto this membership request should it so desire.
|
|
|
|
.It
|
|
|
|
Check the interface's group membership list for a pre-existing
|
2002-01-10 11:57:10 +00:00
|
|
|
membership for this group.
|
|
|
|
If one is not found, allocate a new one;
|
1997-01-15 19:28:39 +00:00
|
|
|
if one is, increment its reference count.
|
|
|
|
.It
|
|
|
|
If the
|
|
|
|
.Fn if_resolvemulti
|
|
|
|
routine returned a link-layer address corresponding to the group,
|
|
|
|
repeat the previous step for that address as well.
|
|
|
|
.It
|
|
|
|
If the interface's multicast address filter needs to be changed
|
|
|
|
because a new membership was added, call the interface's
|
|
|
|
.Fn if_ioctl
|
|
|
|
routine
|
|
|
|
(with a
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa cmd
|
1997-01-15 19:28:39 +00:00
|
|
|
argument of
|
|
|
|
.Dv SIOCADDMULTI )
|
|
|
|
to request that it do so.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn if_delmulti
|
|
|
|
function, given an interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp
|
1997-01-15 19:28:39 +00:00
|
|
|
and an address,
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa sa ,
|
|
|
|
reverses this process.
|
|
|
|
Both functions return zero on success, or a
|
1997-01-15 19:28:39 +00:00
|
|
|
standard error number on failure.
|
|
|
|
.Pp
|
|
|
|
The
|
2012-03-02 09:52:42 +00:00
|
|
|
.Fn if_findmulti
|
1997-01-15 19:28:39 +00:00
|
|
|
function examines the membership list of interface
|
2002-01-10 11:57:10 +00:00
|
|
|
.Fa ifp
|
1997-01-15 19:28:39 +00:00
|
|
|
for an address matching
|
2012-03-02 09:52:42 +00:00
|
|
|
.Fa sa ,
|
1997-01-15 19:28:39 +00:00
|
|
|
and returns a pointer to that
|
2002-01-10 11:57:10 +00:00
|
|
|
.Vt "struct ifmultiaddr"
|
1997-01-15 19:28:39 +00:00
|
|
|
if one is found, else it returns a null pointer.
|
1996-12-17 20:21:01 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr ioctl 2 ,
|
|
|
|
.Xr link_addr 3 ,
|
1996-12-26 16:16:37 +00:00
|
|
|
.Xr queue 3 ,
|
|
|
|
.Xr sysctl 3 ,
|
|
|
|
.Xr bpf 4 ,
|
|
|
|
.Xr ifmib 4 ,
|
1996-12-17 20:21:01 +00:00
|
|
|
.Xr lo 4 ,
|
|
|
|
.Xr netintro 4 ,
|
2004-06-08 08:48:49 +00:00
|
|
|
.Xr polling 4 ,
|
1996-12-26 16:16:37 +00:00
|
|
|
.Xr config 8 ,
|
1996-12-17 20:21:01 +00:00
|
|
|
.Xr ppp 8 ,
|
2004-01-22 00:10:21 +00:00
|
|
|
.Xr mbuf 9 ,
|
2002-01-10 11:57:10 +00:00
|
|
|
.Xr rtentry 9
|
1996-12-17 20:21:01 +00:00
|
|
|
.Rs
|
2000-05-10 09:49:04 +00:00
|
|
|
.%A Gary R. Wright
|
|
|
|
.%A W. Richard Stevens
|
1996-12-17 20:21:01 +00:00
|
|
|
.%B TCP/IP Illustrated
|
2002-01-10 11:57:10 +00:00
|
|
|
.%V Vol. 2
|
1996-12-17 20:21:01 +00:00
|
|
|
.%O Addison-Wesley, ISBN 0-201-63354-X
|
|
|
|
.Re
|
1998-03-12 07:31:21 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
This manual page was written by
|
|
|
|
.An Garrett A. Wollman .
|