xref: /freebsd/share/man/man4/ifmib.4 (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1.\" Copyright 1996 Massachusetts Institute of Technology
2.\"
3.\" Permission to use, copy, modify, and distribute this software and
4.\" its documentation for any purpose and without fee is hereby
5.\" granted, provided that both the above copyright notice and this
6.\" permission notice appear in all copies, that both the above
7.\" copyright notice and this permission notice appear in all
8.\" supporting documentation, and that the name of M.I.T. not be used
9.\" in advertising or publicity pertaining to distribution of the
10.\" software without specific, written prior permission.  M.I.T. makes
11.\" no representations about the suitability of this software for any
12.\" purpose.  It is provided "as is" without express or implied
13.\" warranty.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
16.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
17.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
19.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd December 26, 2020
29.Dt IFMIB 4
30.Os
31.Sh NAME
32.Nm ifmib
33.Nd Management Information Base for network interfaces
34.Sh SYNOPSIS
35.In sys/types.h
36.In sys/socket.h
37.In sys/sysctl.h
38.In sys/time.h
39.In net/if.h
40.In net/if_mib.h
41.Sh DESCRIPTION
42The
43.Nm
44facility is an application of the
45.Xr sysctl 3
46interface to provide management information about network interfaces
47to client applications such as
48.Xr netstat 1 ,
49.Xr slstat 8 ,
50and
51.Tn SNMP
52management agents.
53This information is structured as a table, where
54each row in the table represents a logical network interface (either a
55hardware device or a software pseudo-device like
56.Xr lo 4 ) .
57There are two columns in the table, each containing a single
58structure: one column contains generic information relevant to all
59interfaces, and the other contains information specific to the
60particular class of interface.
61(Generally the latter will implement
62the
63.Tn SNMP
64.Tn MIB
65defined for that particular interface class, if one exists and can be
66implemented in the kernel.)
67.Pp
68The
69.Nm
70facility is accessed via the
71.Dq Li net.link.generic
72branch of the
73.Xr sysctl 3
74MIB.
75The manifest constants for each level in the
76.Xr sysctl 3
77.Ar name
78are defined in
79.In net/if_mib.h .
80The index of the last row in the table is given by
81.Dq Li net.link.generic.system.ifcount
82(or, using the manifest constants,
83.Dv CTL_NET ,
84.Dv PF_LINK ,
85.Dv NETLINK_GENERIC ,
86.Dv IFMIB_SYSTEM ,
87.Dv IFMIB_IFCOUNT ) .
88A management application searching for a particular interface should
89start with row 1 and continue through the table row-by-row until the
90desired interface is found, or the interface count is reached.
91Note that the table may be sparse, i.e., a given row may not exist,
92indicated by an
93.Va errno
94of
95.Er ENOENT .
96Such an error should be ignored, and the next row should be checked.
97.Pp
98The generic interface information, common to all interfaces,
99can be accessed via the following procedure:
100.Bd -literal -offset indent
101int
102get_ifmib_general(int row, struct ifmibdata *ifmd)
103{
104	int name[6];
105	size_t len;
106
107	name[0] = CTL_NET;
108	name[1] = PF_LINK;
109	name[2] = NETLINK_GENERIC;
110	name[3] = IFMIB_IFDATA;
111	name[4] = row;
112	name[5] = IFDATA_GENERAL;
113
114	len = sizeof(*ifmd);
115
116	return sysctl(name, 6, ifmd, &len, (void *)0, 0);
117}
118.Ed
119.Pp
120The fields in
121.Li struct ifmibdata
122are as follows:
123.Bl -tag -width "ifmd_snd_drops"
124.It Li ifmd_name
125.Pq Li "char []"
126the name of the interface, including the unit number
127.It Li ifmd_pcount
128.Pq Li int
129the number of promiscuous listeners
130.It Li ifmd_flags
131.Pq Li int
132the interface's flags (defined in
133.In net/if.h )
134.It Li ifmd_snd_len
135.Pq Li int
136the current instantaneous length of the send queue
137.It Li ifmd_snd_drops
138.Pq Li int
139the number of packets dropped at this interface because the send queue
140was full
141.It Li ifmd_data
142.Pq Li struct if_data
143more information from a structure defined in
144.In net/if.h
145(see
146.Xr if_data 9 )
147.El
148.Pp
149Class-specific information can be retrieved by examining the
150.Dv IFDATA_LINKSPECIFIC
151column instead.
152Note that the form and length of the structure will
153depend on the class of interface.
154For
155.Dv IFT_ETHER ,
156.Dv IFT_ISO88023 ,
157and
158.Dv IFT_STARLAN
159interfaces, the structure is called
160.Dq Li struct ifmib_iso_8802_3
161(defined in
162.In net/if_mib.h ) ,
163and implements a superset of the
164.Tn "RFC 1650"
165MIB for Ethernet-like networks.
166.Sh SEE ALSO
167.Xr sysctl 3 ,
168.Xr intro 4 ,
169.Xr ifnet 9
170.\" .Xr ethermib 4 ,
171.Rs
172.%T "Definitions of Managed Objects for the Ethernet-like Interface Types Using SMIv2"
173.%A F. Kastenholz
174.%D August 1994
175.%O RFC 1650
176.Re
177.Sh HISTORY
178The
179.Nm
180interface first appeared in
181.Fx 2.2 .
182.Sh BUGS
183Many Ethernet-like interfaces do not yet support the Ethernet MIB.
184Regardless, all interfaces automatically support the generic MIB.
185