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