IFMIB(4)
π IFMIB(4) β the ifmib manual page, bestie edition π
okay so real talk: this is the ifmib page from the Kernel Interfaces Manual, and it's literally the blueprint for how your kernel spills the tea about network interfaces. no cap, it's giving "backstage pass to the interface table." let's get into it π«Ά
β¨ NAME β¨
ifmib β Management Information Base for network interfaces π
πΈ SYNOPSIS πΈ
like, include all of these or it won't work, bestie:
#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 an application of the sysctl(3) interface, and its whole job is providing management information about network interfaces to client applications β think netstat(1), slstat(8), and SNMP management agents. iconic clientele, honestly π
the info is structured as a table, and every row in that table = one logical network interface (either a hardware device or a software pseudo-device like lo(4)). two columns, and each column contains a single structure:
- one column has the generic info that's relevant to all interfaces
- the other has info specific to the particular class of interface
(generally that second one implements the SNMP MIB defined for that interface class, if one exists and if it can be implemented in the kernel β no promises, iykyk π)
the ifmib facility is accessed via the "net.link.generic" branch of the sysctl(3) MIB, and the manifest constants for each level in the sysctl(3) name live in <net/if_mib.h>. the index of the last row in the table is given by "net.link.generic.system.ifcount" β or, if you're using the manifest constants, CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT. write that down π
a management application searching for a particular interface should start with row 1 and continue through the table row-by-row until it finds the desired interface, or until it hits the interface count. β οΈ important vibe check: the table may be sparse, i.e., a given row may not exist, and that's indicated by an errno of ENOENT. do NOT panic β that error should be ignored and you just move on and check the next row. slay and continue, periodt.
the generic interface information (the stuff common to all interfaces) can be 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 π
ifmd_nameβ (char []) the name of the interface, including the unit number. literally its whole government name.ifmd_pcountβ (int) the number of promiscuous listeners πifmd_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 full π tragicifmd_dataβ (struct if_data) more information from a structure defined in<net/if.h>(seeif_data(9))
class-specific information can be retrieved by examining the IFDATA_LINKSPECIFIC column instead. heads up though: the form and length of the structure will depend on the class of interface. for IFT_ETHER, IFT_ISO88023, and IFT_STARLAN interfaces, the 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. she's thorough π
π SEE ALSO π
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 β a true elder icon, respect her π
π BUGS π
many Ethernet-like interfaces do not yet support the Ethernet MIB. kind of a flop, ngl. regardless, all interfaces automatically support the generic MIB β so at least everyone's got something π«Ά
β¨ and that's the whole page, bestie β¨ this beauty comes to you from Debian, dated December 26, 2020 β IFMIB(4), out. mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright 1996 Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms