MIB Extractor Documentation
The MIB Extractor library provides comprehensive parsing capabilities for SNMP Management Information Base (MIB) files in .NET applications. The primary class MIBParser handles the extraction of OID definitions, object types, notification types, and textual conventions from standard MIB files.
Namespace: Samayas.Tools.MIBExtractor
Main Class: MIBParser
Installation
dotnet add package Samayas.Tools.MIBExtractor
Constructor
MIBParser(string filename)
Initializes a new instance of the MIBParser class and parses the specified MIB file.
Parameters:
filename (string): Full path to the MIB file to parse
Exceptions:
ArgumentException: Thrown when filename is null or empty.
FileNotFoundException: Thrown when the specified file does not exist.
Example:
MIBParser(string[] lines)
Initializes a new instance of the MIBParser class and parses the specified MIB file .
lines (string[]): Array of strings containing the MIB file content, where each element represents a line
Exceptions:
ArgumentException: Thrown when filename is null or empty.
Example:

Properties
Warnings
Gets a collection of warning messages generated during the MIB parsing process.
Type: IList
Access: Read-only
Description:
Returns a list of non-fatal issues encountered during parsing, such as unresolved parent nodes, missing dependencies, or malformed definitions. These warnings help identify potential problems without stopping the parsing process.
Example:
Public Functions
GetParsedNodes() Description: Description:
Returns a dictionary containing all parsed MIB nodes indexed by their symbolic names.
Returns: IDictionary
Description:
Retrieves the complete collection of parsed MIB nodes as a dictionary where the key is the node name (e.g., "sysDescr", "ifTable") and the value is the corresponding MIBNode object containing all parsed properties. This includes object identifiers, object types, notification types, and textual conventions.
Example:

GetFlatListOfResolvedOIDs()
Returns a sorted list of all successfully resolved OID strings in the MIB.
Returns: IList
Description:
Extracts all fully resolved OID strings (e.g., "1.3.6.1.2.1.1.1.0") from the parsed nodes, filtering out any unresolved or incomplete OIDs. The list is sorted first by OID length, then lexicographically, making it easy to navigate the hierarchy.
Example:

GetNodeFromOID(string oid)
Retrieves a specific MIB node by its OID string.
Parameters:
Returns: MIBNode? - The matching MIB node, or null if not found.
Description:
Performs a lookup to find the MIB node that matches the specified OID string. Returns null if the OID parameter is null, empty, whitespace, or if no matching node exists.
Example:

PrintFlatListOfOIDs(TextWriter writer)
Outputs a formatted list of all resolved OIDs to a text stream.
Parameters:
Writes a formatted flat list of all successfully resolved OIDs to the specified TextWriter, with header and footer markers for easy identification. Useful for generating reports or console output.
Example:

PrintMIBTree(TextWriter writer)
Outputs a hierarchical tree representation of the MIB structure to a text stream.
Parameters:
Writes a formatted hierarchical tree showing the parent-child relationships between MIB nodes, with indentation to indicate depth in the tree. Each node displays its name, relative number, full OID, type, and key properties like access level, status, syntax, and description.
Example:

GetOIDDefinitions()
Returns the raw list of OID assignment definitions parsed from the MIB file.
Returns: IList
Description:
Retrieves the list of basic OID definitions extracted from OBJECT IDENTIFIER assignment statements in the MIB file. Each MIBDefinition contains the name, parent name, and relative number from the assignment.
Example:

GetTextualConventions()
Returns a dictionary of all textual convention definitions found in the MIB.
Returns: IDictionary
Description:
Extracts all TEXTUAL-CONVENTION definitions from the parsed MIB, which define custom data types used throughout the MIB. Each textual convention includes properties like display hints, syntax, status, and description.
Example:

Notes
-
- The parser automatically initializes standard SNMP root nodes (iso, org, dod, internet, mgmt, private, enterprises, etc.) during construction.
- OID resolution happens automatically and follows parent-child relationships to build complete OID paths.
- Nodes that cannot be resolved due to missing parent references are marked with "?.." prefix in their FullOID property and generate warnings.
- The parser handles multiple MIB construct types: OBJECT IDENTIFIER assignments, OBJECT-TYPE definitions, NOTIFICATION-TYPE definitions, MODULE-IDENTITY definitions, and TEXTUAL-CONVENTION definitions.
- Textual conventions do not have OIDs and are stored separately from the OID hierarchy.