xref: /freebsd/share/man/man4/ifmib.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
193194d37SGarrett Wollman.\" Copyright 1996 Massachusetts Institute of Technology
293194d37SGarrett Wollman.\"
393194d37SGarrett Wollman.\" Permission to use, copy, modify, and distribute this software and
493194d37SGarrett Wollman.\" its documentation for any purpose and without fee is hereby
593194d37SGarrett Wollman.\" granted, provided that both the above copyright notice and this
693194d37SGarrett Wollman.\" permission notice appear in all copies, that both the above
793194d37SGarrett Wollman.\" copyright notice and this permission notice appear in all
893194d37SGarrett Wollman.\" supporting documentation, and that the name of M.I.T. not be used
993194d37SGarrett Wollman.\" in advertising or publicity pertaining to distribution of the
1093194d37SGarrett Wollman.\" software without specific, written prior permission.  M.I.T. makes
1193194d37SGarrett Wollman.\" no representations about the suitability of this software for any
1293194d37SGarrett Wollman.\" purpose.  It is provided "as is" without express or implied
1393194d37SGarrett Wollman.\" warranty.
1493194d37SGarrett Wollman.\"
1593194d37SGarrett Wollman.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
1693194d37SGarrett Wollman.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
1793194d37SGarrett Wollman.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1893194d37SGarrett Wollman.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
1993194d37SGarrett Wollman.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2093194d37SGarrett Wollman.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2193194d37SGarrett Wollman.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2293194d37SGarrett Wollman.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2393194d37SGarrett Wollman.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2493194d37SGarrett Wollman.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2593194d37SGarrett Wollman.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2693194d37SGarrett Wollman.\" SUCH DAMAGE.
2793194d37SGarrett Wollman.\"
28*23af96adSMarius Strobl.Dd December 26, 2020
2993194d37SGarrett Wollman.Dt IFMIB 4
303d45e180SRuslan Ermilov.Os
3193194d37SGarrett Wollman.Sh NAME
3293194d37SGarrett Wollman.Nm ifmib
3393194d37SGarrett Wollman.Nd Management Information Base for network interfaces
3493194d37SGarrett Wollman.Sh SYNOPSIS
3532eef9aeSRuslan Ermilov.In sys/types.h
3632eef9aeSRuslan Ermilov.In sys/socket.h
3732eef9aeSRuslan Ermilov.In sys/sysctl.h
3832eef9aeSRuslan Ermilov.In sys/time.h
3932eef9aeSRuslan Ermilov.In net/if.h
4032eef9aeSRuslan Ermilov.In net/if_mib.h
4193194d37SGarrett Wollman.Sh DESCRIPTION
4293194d37SGarrett WollmanThe
434b66483fSRuslan Ermilov.Nm
4493194d37SGarrett Wollmanfacility is an application of the
4593194d37SGarrett Wollman.Xr sysctl 3
4693194d37SGarrett Wollmaninterface to provide management information about network interfaces
4793194d37SGarrett Wollmanto client applications such as
4893194d37SGarrett Wollman.Xr netstat 1 ,
4993194d37SGarrett Wollman.Xr slstat 8 ,
5093194d37SGarrett Wollmanand
5193194d37SGarrett Wollman.Tn SNMP
52b5e7e999SRuslan Ermilovmanagement agents.
53b5e7e999SRuslan ErmilovThis information is structured as a table, where
5493194d37SGarrett Wollmaneach row in the table represents a logical network interface (either a
5593194d37SGarrett Wollmanhardware device or a software pseudo-device like
5693194d37SGarrett Wollman.Xr lo 4 ) .
5793194d37SGarrett WollmanThere are two columns in the table, each containing a single
5893194d37SGarrett Wollmanstructure: one column contains generic information relevant to all
5993194d37SGarrett Wollmaninterfaces, and the other contains information specific to the
60b5e7e999SRuslan Ermilovparticular class of interface.
61b5e7e999SRuslan Ermilov(Generally the latter will implement
6293194d37SGarrett Wollmanthe
6393194d37SGarrett Wollman.Tn SNMP
6493194d37SGarrett Wollman.Tn MIB
6593194d37SGarrett Wollmandefined for that particular interface class, if one exists and can be
6693194d37SGarrett Wollmanimplemented in the kernel.)
6793194d37SGarrett Wollman.Pp
6893194d37SGarrett WollmanThe
6993194d37SGarrett Wollman.Nm
7093194d37SGarrett Wollmanfacility is accessed via the
7193194d37SGarrett Wollman.Dq Li net.link.generic
7293194d37SGarrett Wollmanbranch of the
7393194d37SGarrett Wollman.Xr sysctl 3
74b5e7e999SRuslan ErmilovMIB.
75b5e7e999SRuslan ErmilovThe manifest constants for each level in the
7693194d37SGarrett Wollman.Xr sysctl 3
7793194d37SGarrett Wollman.Ar name
7893194d37SGarrett Wollmanare defined in
79fe08efe6SRuslan Ermilov.In net/if_mib.h .
80b9d45cebSBill FennerThe index of the last row in the table is given by
8193194d37SGarrett Wollman.Dq Li net.link.generic.system.ifcount
8293194d37SGarrett Wollman(or, using the manifest constants,
8393194d37SGarrett Wollman.Dv CTL_NET ,
8493194d37SGarrett Wollman.Dv PF_LINK ,
8593194d37SGarrett Wollman.Dv NETLINK_GENERIC ,
8693194d37SGarrett Wollman.Dv IFMIB_SYSTEM ,
8793194d37SGarrett Wollman.Dv IFMIB_IFCOUNT ) .
8893194d37SGarrett WollmanA management application searching for a particular interface should
8993194d37SGarrett Wollmanstart with row 1 and continue through the table row-by-row until the
9093194d37SGarrett Wollmandesired interface is found, or the interface count is reached.
915203edcdSRuslan ErmilovNote that the table may be sparse, i.e., a given row may not exist,
929a107570SRuslan Ermilovindicated by an
939a107570SRuslan Ermilov.Va errno
949a107570SRuslan Ermilovof
95b9d45cebSBill Fenner.Er ENOENT .
96b9d45cebSBill FennerSuch an error should be ignored, and the next row should be checked.
9793194d37SGarrett Wollman.Pp
9893194d37SGarrett WollmanThe generic interface information, common to all interfaces,
9993194d37SGarrett Wollmancan be accessed via the following procedure:
10093194d37SGarrett Wollman.Bd -literal -offset indent
10193194d37SGarrett Wollmanint
10293194d37SGarrett Wollmanget_ifmib_general(int row, struct ifmibdata *ifmd)
10393194d37SGarrett Wollman{
10493194d37SGarrett Wollman	int name[6];
10522810858SJohan Karlsson	size_t len;
10693194d37SGarrett Wollman
10793194d37SGarrett Wollman	name[0] = CTL_NET;
10893194d37SGarrett Wollman	name[1] = PF_LINK;
10993194d37SGarrett Wollman	name[2] = NETLINK_GENERIC;
11093194d37SGarrett Wollman	name[3] = IFMIB_IFDATA;
11193194d37SGarrett Wollman	name[4] = row;
11293194d37SGarrett Wollman	name[5] = IFDATA_GENERAL;
11393194d37SGarrett Wollman
11422810858SJohan Karlsson	len = sizeof(*ifmd);
11522810858SJohan Karlsson
11622810858SJohan Karlsson	return sysctl(name, 6, ifmd, &len, (void *)0, 0);
11793194d37SGarrett Wollman}
11893194d37SGarrett Wollman.Ed
11993194d37SGarrett Wollman.Pp
12093194d37SGarrett WollmanThe fields in
12193194d37SGarrett Wollman.Li struct ifmibdata
12293194d37SGarrett Wollmanare as follows:
12393194d37SGarrett Wollman.Bl -tag -width "ifmd_snd_drops"
12493194d37SGarrett Wollman.It Li ifmd_name
12593194d37SGarrett Wollman.Pq Li "char []"
12693194d37SGarrett Wollmanthe name of the interface, including the unit number
12793194d37SGarrett Wollman.It Li ifmd_pcount
12893194d37SGarrett Wollman.Pq Li int
12993194d37SGarrett Wollmanthe number of promiscuous listeners
13093194d37SGarrett Wollman.It Li ifmd_flags
13193194d37SGarrett Wollman.Pq Li int
13293194d37SGarrett Wollmanthe interface's flags (defined in
133fe08efe6SRuslan Ermilov.In net/if.h )
13493194d37SGarrett Wollman.It Li ifmd_snd_len
13593194d37SGarrett Wollman.Pq Li int
13693194d37SGarrett Wollmanthe current instantaneous length of the send queue
13793194d37SGarrett Wollman.It Li ifmd_snd_drops
13893194d37SGarrett Wollman.Pq Li int
13993194d37SGarrett Wollmanthe number of packets dropped at this interface because the send queue
14093194d37SGarrett Wollmanwas full
14193194d37SGarrett Wollman.It Li ifmd_data
14293194d37SGarrett Wollman.Pq Li struct if_data
14393194d37SGarrett Wollmanmore information from a structure defined in
144fe08efe6SRuslan Ermilov.In net/if.h
145c4d9468eSRuslan Ermilov(see
146c4d9468eSRuslan Ermilov.Xr if_data 9 )
14793194d37SGarrett Wollman.El
14893194d37SGarrett Wollman.Pp
14993194d37SGarrett WollmanClass-specific information can be retrieved by examining the
15093194d37SGarrett Wollman.Dv IFDATA_LINKSPECIFIC
151b5e7e999SRuslan Ermilovcolumn instead.
152b5e7e999SRuslan ErmilovNote that the form and length of the structure will
153b5e7e999SRuslan Ermilovdepend on the class of interface.
154b5e7e999SRuslan ErmilovFor
15593194d37SGarrett Wollman.Dv IFT_ETHER ,
15693194d37SGarrett Wollman.Dv IFT_ISO88023 ,
15793194d37SGarrett Wollmanand
15893194d37SGarrett Wollman.Dv IFT_STARLAN
15993194d37SGarrett Wollmaninterfaces, the structure is called
16093194d37SGarrett Wollman.Dq Li struct ifmib_iso_8802_3
16193194d37SGarrett Wollman(defined in
162fe08efe6SRuslan Ermilov.In net/if_mib.h ) ,
16393194d37SGarrett Wollmanand implements a superset of the
16493194d37SGarrett Wollman.Tn "RFC 1650"
16593194d37SGarrett WollmanMIB for Ethernet-like networks.
16693194d37SGarrett Wollman.Sh SEE ALSO
16793194d37SGarrett Wollman.Xr sysctl 3 ,
168b4ccb10eSGarrett Wollman.Xr intro 4 ,
169b4ccb10eSGarrett Wollman.Xr ifnet 9
1700b992c1dSWolfram Schneider.\" .Xr ethermib 4 ,
17193194d37SGarrett Wollman.Rs
17293194d37SGarrett Wollman.%T "Definitions of Managed Objects for the Ethernet-like Interface Types Using SMIv2"
17393194d37SGarrett Wollman.%A F. Kastenholz
17493194d37SGarrett Wollman.%D August 1994
17593194d37SGarrett Wollman.%O RFC 1650
17693194d37SGarrett Wollman.Re
1779cbda590SRuslan Ermilov.Sh HISTORY
1789cbda590SRuslan ErmilovThe
1799cbda590SRuslan Ermilov.Nm
1809cbda590SRuslan Ermilovinterface first appeared in
1819cbda590SRuslan Ermilov.Fx 2.2 .
18293194d37SGarrett Wollman.Sh BUGS
183*23af96adSMarius StroblMany Ethernet-like interfaces do not yet support the Ethernet MIB.
18493194d37SGarrett WollmanRegardless, all interfaces automatically support the generic MIB.
185