xref: /freebsd/share/man/man4/ifmib.4 (revision 6990ffd8a95caaba6858ad44ff1b3157d1efba8f)
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.\" $FreeBSD$
29.\"
30.Dd November 15, 1996
31.Dt IFMIB 4
32.Os
33.Sh NAME
34.Nm ifmib
35.Nd Management Information Base for network interfaces
36.Sh SYNOPSIS
37.Fd #include <sys/types.h>
38.Fd #include <sys/socket.h>
39.Fd #include <sys/sysctl.h>
40.Fd #include <sys/time.h>
41.Fd #include <net/if.h>
42.Fd #include <net/if_mib.h>
43.Sh DESCRIPTION
44The
45.Nm
46facility is an application of the
47.Xr sysctl 3
48interface to provide management information about network interfaces
49to client applications such as
50.Xr netstat 1 ,
51.Xr slstat 8 ,
52and
53.Tn SNMP
54management agents.  This information is structured as a table, where
55each row in the table represents a logical network interface (either a
56hardware device or a software pseudo-device like
57.Xr lo 4 ) .
58There are two columns in the table, each containing a single
59structure: one column contains generic information relevant to all
60interfaces, and the other contains information specific to the
61particular class of interface.  (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.  The manifest constants for each level in the
75.Xr sysctl 3
76.Ar name
77are defined in
78.Aq Pa net/if_mib.h .
79A count of interfaces (and thus rows in the table) is given by
80.Dq Li net.link.generic.system.ifcount
81(or, using the manifest constants,
82.Dv CTL_NET ,
83.Dv PF_LINK ,
84.Dv NETLINK_GENERIC ,
85.Dv IFMIB_SYSTEM ,
86.Dv IFMIB_IFCOUNT ) .
87A management application searching for a particular interface should
88start with row 1 and continue through the table row-by-row until the
89desired interface is found, or the interface count is reached.
90.Pp
91The generic interface information, common to all interfaces,
92can be accessed via the following procedure:
93.Bd -literal -offset indent
94int
95get_ifmib_general(int row, struct ifmibdata *ifmd)
96{
97	int name[6];
98
99	name[0] = CTL_NET;
100	name[1] = PF_LINK;
101	name[2] = NETLINK_GENERIC;
102	name[3] = IFMIB_IFDATA;
103	name[4] = row;
104	name[5] = IFDATA_GENERAL;
105
106	return sysctl(name, 6, ifmd, sizeof *ifmd, (void *)0, 0);
107}
108.Ed
109.Pp
110The fields in
111.Li struct ifmibdata
112are as follows:
113.Bl -tag -width "ifmd_snd_drops"
114.It Li ifmd_name
115.Pq Li "char []"
116the name of the interface, including the unit number
117.It Li ifmd_pcount
118.Pq Li int
119the number of promiscuous listeners
120.It Li ifmd_flags
121.Pq Li int
122the interface's flags (defined in
123.Aq Pa net/if.h )
124.It Li ifmd_snd_len
125.Pq Li int
126the current instantaneous length of the send queue
127.It Li ifmd_snd_drops
128.Pq Li int
129the number of packets dropped at this interface because the send queue
130was full
131.It Li ifmd_data
132.Pq Li struct if_data
133more information from a structure defined in
134.Aq Pa net/if.h
135(see
136.Xr if_data 9 )
137.El
138.Pp
139Class-specific information can be retrieved by examining the
140.Dv IFDATA_LINKSPECIFIC
141column instead.  Note that the form and length of the structure will
142depend on the class of interface.  For
143.Dv IFT_ETHER ,
144.Dv IFT_ISO88023 ,
145and
146.Dv IFT_STARLAN
147interfaces, the structure is called
148.Dq Li struct ifmib_iso_8802_3
149(defined in
150.Aq Pa net/if_mib.h ) ,
151and implements a superset of the
152.Tn "RFC 1650"
153MIB for Ethernet-like networks.
154.\" This will eventually be defined in an ethermib(4) page.
155For
156.Dv IFT_SLIP ,
157the structure is a
158.Dq Li struct sl_softc
159.Pq Aq Pa net/if_slvar.h .
160.Sh SEE ALSO
161.Xr sysctl 3 ,
162.Xr intro 4 ,
163.Xr ifnet 9
164.\" .Xr ethermib 4 ,
165.Rs
166.%T "Definitions of Managed Objects for the Ethernet-like Interface Types Using SMIv2"
167.%A F. Kastenholz
168.%D August 1994
169.%O RFC 1650
170.Re
171.Sh BUGS
172Many Ethernet-like interfaces do not yet support the Ethernet MIB;
173the interfaces known to support it include
174.Xr ed 4
175and
176.Xr de 4 .
177Regardless, all interfaces automatically support the generic MIB.
178.Sh HISTORY
179The
180.Nm
181interface first appeared in
182.Fx 2.2 .
183