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