IFMIB(4)
π IFMIB π
okay bestie, so this is the manual page for ifmib β the Management Information Base for network interfaces π«Ά it's a section 4 page (kernel interfaces, iykyk), and honestly? it's giving "the kernel's little gossip spreadsheet about your network cards." let's get into it β¨
πΈ SYNOPSIS πΈ
like, include all of these, in this order, no skips:
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <net/if.h>
#include <net/if_mib.h>
β¨ DESCRIPTION β¨
so the ifmib facility is literally an application of the sysctl(3) interface, and its whole job is handing out management information about network interfaces to client applications β think netstat(1), slstat(8), and SNMP management agents π they all come here for the tea.
and the way this info is structured? it's a table π where every row is one logical network interface β either a hardware device or a software pseudo-device like lo(4). two columns, bestie, and each one holds a single structure:
- one column = generic info that's relevant to all interfaces
- the other column = info specific to that particular class of interface. (generally the latter will implement the SNMP MIB defined for that particular interface class, if one exists and can actually be implemented in the kernel π )
you get to all of this through the "net.link.generic" branch of the sysctl(3) MIB. the manifest constants for each level in the sysctl(3) name live in <net/if_mib.h>. and the index of the last row in the table? that's "net.link.generic.system.ifcount" β or, if you're speaking manifest-constant, CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT β
so a management application hunting for a specific interface should start at row 1 and just keep going row-by-row until it finds the one it wants, or until it hits the interface count. and here's the thing π
the table may be sparse β meaning a given row may not exist at all, and that shows up as anerrnoofENOENT. do not panic. that error should be ignored, and you just check the next row. π
π¦ getting the generic info π¦
the generic interface information β the stuff common to all interfaces β is accessed via this exact procedure, no cap:
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, &len, (void *)0, 0);
}
π the fields in struct ifmibdata π
here's the whole lineup, main character energy only:
ifmd_nameβ (char []) the name of the interface, including the unit numberifmd_pcountβ (int) the number of promiscuous listenersifmd_flagsβ (int) the interface's flags (defined in<net/if.h>)ifmd_snd_lenβ (int) the current instantaneous length of the send queueifmd_snd_dropsβ (int) the number of packets dropped at this interface because the send queue was fullifmd_dataβ (struct if_data) more information from a structure defined in<net/if.h>(seeif_data(9))
π§ class-specific info π§
want the stuff that's specific to a class of interface? you retrieve that by examining the IFDATA_LINKSPECIFIC column instead π and heads up β the form and the length of that structure depend entirely on the class of interface, so don't assume.
for IFT_ETHER, IFT_ISO88023, and IFT_STARLAN interfaces, that structure is called "struct ifmib_iso_8802_3" (defined in <net/if_mib.h>), and it implements a superset of the RFC 1650 MIB for Ethernet-like networks π slay.
π SEE ALSO π
sysctl(3)intro(4)ifnet(9)- F. Kastenholz, Definitions of Managed Objects for the Ethernet-like Interface Types Using SMIv2, August 1994, RFC 1650.
β HISTORY β
the ifmib interface first appeared in FreeBSD 2.2 π«Ά ancient. iconic. still here.
π BUGS π
ngl, a lot of Ethernet-like interfaces do not yet support the Ethernet MIB π the interfaces known to support it include ed(4) and de(4). but regardless β all interfaces automatically support the generic MIB, so you're never fully left on read π
and that's the whole page, bestie π this was IFMIB(4) from the Debian distribution, dated October 28, 2009 β go forth and query your interfaces, mwah πβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright 1996 Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms