netpkt/mib.rs#
Source: lib/netpkt/mib.rs
mib -- a small built-in MIB: the objects of SNMPv2-MIB (system, snmp, the notifications of
RFC 3418), IF-MIB (interfaces, ifTable, ifXTable, linkDown and linkUp of RFC 2863), IP-MIB
(ipForwarding, ipDefaultTTL, ipAddrTable) and IP-FORWARD-MIB (ipCidrRouteTable of RFC 2096)
with the nodes of SNMPv2-SMI above them: names, OIDs, syntax, access, the names of enumerated
values; for the tools of a shell and for dissectors
OBJECTS every object in OID order (Obj: module, name, oid, kind, syntax,
access, enums)
find(oid) / by_name(name) an object exactly
object_of(oid) the object an OID names or is an instance of, with the arcs of the
instance (sysName.0: sysName and [0])
name_of(oid, numeric) "SNMPv2-MIB::sysName.0", "IF-MIB::ifDescr.2",
"SNMPv2-SMI::enterprises.32473.1.4"; numeric: ".1.3.6.1.2.1.1.5.0"
lookup(text) an OID from what a user types: "SNMPv2-MIB::sysName.0",
"sysName.0", "ifTable", "iso.3.6.1", "1.3.6.1.2.1.1.5.0" or with a
leading dot
show(oid, value, numeric) the value as the tools of net-snmp print it after "=": "STRING:
R1", "INTEGER: up(1)", "Timeticks: (500) 0:00:05.00", "OID:
IF-MIB::linkDown" (the exceptions in our own words)
bare(oid, value) the same without the type (snmpget -Oq): "R1", "up"
ticks_text(t) "(500) 0:00:05.00", "(8640000) 1 day, 0:00:00.00"
children(oid) the objects one level below a node (a tree of the MIB)
Names and syntax follow the MIB modules; the table has only what JFNetworker's agent serves
and what names it, no descriptions (the RFCs have them). The access is the agent's: objects
a module allows to write but the agent does not (ipForwarding, ipDefaultTTL,
ifLinkUpDownTrapEnable, ifPromiscuousMode) are read-only here. A name the table does not know
is written with the arcs below the nearest one it knows, as net-snmp does ("iso.2.999").
enum ObjKindwhat an object isNode-- a node of the tree (system, ifMIB, enterprises)Scalar-- a scalar: its instance is .0TableEntry-- the row of a tableColumn-- a column: its instances are the indexes of the rowsNotification-- a notification (a value of snmpTrapOID.0)
enum Syntaxthe syntax of a scalar or a columnNoneIntegerDisplayString-- text up to 255 octets (RFC 2579)PhysAddress-- octets shown as hex digits with colons (RFC 2579)OctetsOidIpAddressCounter32Gauge32TimeTicksCounter64
impl Syntax
fn tag(self) -> u8the BER tag of its valuesfn name(self) -> &'static strthe name the MIB module gives itenum Accesswho may do what with an objectNotAccessibleReadOnlyReadWriteNotify-- only in notifications (snmpTrapOID)
impl Access
fn name(self) -> &'static strstruct Objan object of the MIBmodule: &'static strname: &'static stroid: &'static [u32]kind: ObjKindsyntax: Syntaxaccess: Accessenums: &'static [(i64, &'static str)]-- the names of an INTEGER's values ("up" for 1)
/// the objects in OID order
OBJECTS: &[Obj] = &[ node(SMI, "zeroDotZero", &[0, 0]), node(SMI, "iso", &[ ...
fn find(oid: &[u32]) -> Option<&'static Obj>an object by its OID exactlyfn by_name(name: &str) -> Option<&'static Obj>an object by its name (case matters, as in the MIB modules)fn object_of(oid: &[u32]) -> Option<(&'static Obj, &[u32])>the longest object the OID starts with, and the arcs after itfn column_of(oid: &[u32]) -> Option<&'static Obj>the scalar or column an OID is an instance of (sysName.0, ifDescr.2)fn name_of(oid: &[u32], numeric: bool) -> Stringa name as net-snmp's tools write it: MODULE::name and the arcs after it; numeric: the arcs with a leading dotfn short_name(oid: &[u32]) -> Stringthe name without the module ("sysName.0"; snmpget -Os)fn lookup(text: &str) -> Option<Oid>an OID from what a user types: MODULE::name.arcs, name.arcs, dotted arcs (a leading dot allowed); None for a name the table does not know or arcs that are no numbersfn children(oid: &[u32]) -> Vec<&'static Obj>the objects one level belowoid(the children of a node, the columns of an entry), in OID order; an object whose parent the table lacks hangs below its nearest ancestorfn ticks_text(t: u32) -> String"(500) 0:00:05.00", "(8640000) 1 day, 0:00:00.00" as net-snmp writes TimeTicksfn show(oid: &[u32], v: &Value, numeric: bool) -> Stringthe value after "=" as net-snmp's tools print it; the object named byoidgives the form of strings and the names of integers;numericwrites OIDs as numbersfn bare(oid: &[u32], v: &Value, numeric: bool) -> Stringthe value alone (snmpget -Oqv): the name of an enumerated value, a text without quotes