summaryrefslogtreecommitdiff
path: root/static/freebsd/man4/ifmib.4 3.html
blob: 20d76a0a79684764aef3dc00134a67b9fe8e0155 (plain)
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
<table class="head">
  <tr>
    <td class="head-ltitle">IFMIB(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">IFMIB(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">ifmib</code> &#x2014; <span class="Nd">Management
    Information Base for network interfaces</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/types.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/socket.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/sysctl.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/time.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">net/if.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">net/if_mib.h</a>&gt;</code></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The <code class="Nm">ifmib</code> facility is an application of
    the <a class="Xr">sysctl(3)</a> interface to provide management information
    about network interfaces to client applications such as
    <a class="Xr">netstat(1)</a>, <a class="Xr">slstat(8)</a>, and 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 <a class="Xr">lo(4)</a>). 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 SNMP MIB defined for that
    particular interface class, if one exists and can be implemented in the
    kernel.)</p>
<p class="Pp">The <code class="Nm">ifmib</code> facility is accessed via the
    &#x201C;<code class="Li">net.link.generic</code>&#x201D; branch of the
    <a class="Xr">sysctl(3)</a> MIB. The manifest constants for each level in
    the <a class="Xr">sysctl(3)</a> <var class="Ar">name</var> are defined in
    <code class="In">&lt;<a class="In">net/if_mib.h</a>&gt;</code>. The index of
    the last row in the table is given by
    &#x201C;<code class="Li">net.link.generic.system.ifcount</code>&#x201D; (or,
    using the manifest constants, <code class="Dv">CTL_NET</code>,
    <code class="Dv">PF_LINK</code>, <code class="Dv">NETLINK_GENERIC</code>,
    <code class="Dv">IFMIB_SYSTEM</code>,
    <code class="Dv">IFMIB_IFCOUNT</code>). 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. Note that the table may be sparse, i.e., a given row may
    not exist, indicated by an <var class="Va">errno</var> of
    <code class="Er">ENOENT</code>. Such an error should be ignored, and the
    next row should be checked.</p>
<p class="Pp">The generic interface information, common to all interfaces, can
    be accessed via the following procedure:</p>
<div class="Bd Pp Bd-indent Li">
<pre>int
get_ifmib_general(int row, struct ifmibdata *ifmd)
{
	int name[6];
	size_t len;

	name[0] = CTL_NET;
	name[1] = PF_LINK;
	name[2] = NETLINK_GENERIC;
	name[3] = IFMIB_IFDATA;
	name[4] = row;
	name[5] = IFDATA_GENERAL;

	len = sizeof(*ifmd);

	return sysctl(name, 6, ifmd, &amp;len, (void *)0, 0);
}</pre>
</div>
<p class="Pp">The fields in <code class="Li">struct ifmibdata</code> are as
    follows:</p>
<dl class="Bl-tag">
  <dt id="ifmd_name"><a class="permalink" href="#ifmd_name"><code class="Li">ifmd_name</code></a></dt>
  <dd>(<code class="Li">char []</code>) the name of the interface, including the
      unit number</dd>
  <dt id="ifmd_pcount"><a class="permalink" href="#ifmd_pcount"><code class="Li">ifmd_pcount</code></a></dt>
  <dd>(<code class="Li">int</code>) the number of promiscuous listeners</dd>
  <dt id="ifmd_flags"><a class="permalink" href="#ifmd_flags"><code class="Li">ifmd_flags</code></a></dt>
  <dd>(<code class="Li">int</code>) the interface's flags (defined in
      <code class="In">&lt;<a class="In">net/if.h</a>&gt;</code>)</dd>
  <dt id="ifmd_snd_len"><a class="permalink" href="#ifmd_snd_len"><code class="Li">ifmd_snd_len</code></a></dt>
  <dd>(<code class="Li">int</code>) the current instantaneous length of the send
      queue</dd>
  <dt id="ifmd_snd_drops"><a class="permalink" href="#ifmd_snd_drops"><code class="Li">ifmd_snd_drops</code></a></dt>
  <dd>(<code class="Li">int</code>) the number of packets dropped at this
      interface because the send queue was full</dd>
  <dt id="ifmd_data"><a class="permalink" href="#ifmd_data"><code class="Li">ifmd_data</code></a></dt>
  <dd>(<code class="Li">struct if_data</code>) more information from a structure
      defined in <code class="In">&lt;<a class="In">net/if.h</a>&gt;</code> (see
      <a class="Xr">if_data(9)</a>)</dd>
</dl>
<p class="Pp">Class-specific information can be retrieved by examining the
    <code class="Dv">IFDATA_LINKSPECIFIC</code> column instead. Note that the
    form and length of the structure will depend on the class of interface. For
    <code class="Dv">IFT_ETHER</code>, <code class="Dv">IFT_ISO88023</code>, and
    <code class="Dv">IFT_STARLAN</code> interfaces, the structure is called
    &#x201C;<code class="Li">struct ifmib_iso_8802_3</code>&#x201D; (defined in
    <code class="In">&lt;<a class="In">net/if_mib.h</a>&gt;</code>), and
    implements a superset of the RFC 1650 MIB for Ethernet-like networks.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">sysctl(3)</a>, <a class="Xr">intro(4)</a>,
    <a class="Xr">ifnet(9)</a></p>
<p class="Pp"><cite class="Rs"><span class="RsA">F. Kastenholz</span>,
    <span class="RsT">Definitions of Managed Objects for the Ethernet-like
    Interface Types Using SMIv2</span>, <span class="RsD">August 1994</span>,
    <span class="RsO">RFC 1650</span>.</cite></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <code class="Nm">ifmib</code> interface first appeared in
    <span class="Ux">FreeBSD 2.2</span>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
<p class="Pp">Many Ethernet-like interfaces do not yet support the Ethernet MIB.
    Regardless, all interfaces automatically support the generic MIB.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">December 26, 2020</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>