module snmp.mib; import c.net_snmp; import snmp.oid; struct MIB { static void init_() @trusted @nogc nothrow { netsnmp_init_mib(); } static void loadAll() @trusted @nogc nothrow { read_all_mibs(); } static void addDir(scope const(char)* dir) @trusted @nogc nothrow { if (dir) add_mibdir(dir); } static void load(scope const(char)* name) @trusted @nogc nothrow { if (name) read_mib(name); } } /// Falls back to numeric parsing for dotted-decimal strings. OID oidFromName(scope const(char)* name) @trusted @nogc nothrow { return OID.fromString(name); } unittest { init_snmp("snmp-d-mib-test"); auto o = OID.fromString("1.3.6.1.2.1.1.1.0"); assert(o.isValid); assert(o.length == 9); MIB.init_(); // silence snmp_log() noise from incomplete MIB sets snmp_disable_log(); MIB.loadAll(); snmp_enable_stderrlog(); auto named = OID.fromString("sysDescr.0"); if (named.isValid) assert(named.length == 9); }