Editing SNMP MIB Implementation
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 24: | Line 24: | ||
==Convert MIB to Binary File== | ==Convert MIB to Binary File== | ||
− | * mib2bin tool is modified from [http://net-snmp.sourceforge.net/ net-snmp] to convert ASN.1 format file to | + | * mib2bin tool is modified from [http://net-snmp.sourceforge.net/ net-snmp] to convert ASN.1 format file to three files, because the microchip '''mib2bib''' converter only supports upto 255 OIDs. |
MIB compiler tools: '''mib2bin''' | MIB compiler tools: '''mib2bin''' | ||
[http://www.modtronix.com/products/sbc44ec/00870a.pdf foo.mib] (ANS.1 format) -----------------------------------> foo.bin + foo_trap.bin + foo.h + foo_data.h | [http://www.modtronix.com/products/sbc44ec/00870a.pdf foo.mib] (ANS.1 format) -----------------------------------> foo.bin + foo_trap.bin + foo.h + foo_data.h | ||
Line 31: | Line 31: | ||
'''mib2bin <MIBfile>... | '''mib2bin <MIBfile>... | ||
* where MIBfile file is ASN.1 format file. MIBfile = <name>.<type> | * where MIBfile file is ASN.1 format file. MIBfile = <name>.<type> | ||
− | ** '''<name>.bin''' is the binary file storing information of OID tree. This file can be placed on an SD media card to be read by the | + | ** '''<name>.bin''' is the binary file storing information of OID tree. This file can be placed on an SD media card to be read by the FAT16 file system. |
− | ** '''<name>_trap.bin''' is the binary file storing information of TRAP of MIB. This file can be placed on an SD media card to be read by the | + | ** '''<name>_trap.bin''' is the binary file storing information of TRAP of MIB. This file can be placed on an SD media card to be read by the FAT16 file system. |
− | ** '''<name>_data.h''' is C header file storing information of OID tree. This file is generated by converting mchip.bin file to the C header file. It's only used when a system don't have system file and place on program memory. | + | ** '''<name>_data.h''' is C header file storing information of OID tree. This file is generated by converting mchip.bin file to the C header file. |
+ | It's only used when a system don't have system file and place on program memory. | ||
** '''<name>.h''' is C header file storing ID that's reference to function service of OID. | ** '''<name>.h''' is C header file storing ID that's reference to function service of OID. | ||
* Note: | * Note: | ||
** Subfolder '''mibs''' containing the basics MIB files (e.g.: RFC1155-SMI, RFC1213-MIB, RFC-1215, SNMPv2-MIB ... for us MIB file), must be present under the directory of execution. | ** Subfolder '''mibs''' containing the basics MIB files (e.g.: RFC1155-SMI, RFC1213-MIB, RFC-1215, SNMPv2-MIB ... for us MIB file), must be present under the directory of execution. | ||
− | ** If the | + | ** If the three files exist, mib2bin tool will overwrite the files. |
===Binary File Format <name>.bin=== | ===Binary File Format <name>.bin=== | ||
Line 45: | Line 46: | ||
<oid>, <nodeInfo>, | <oid>, <nodeInfo>, | ||
[id], [siblingOffset]/[distantSiblingOffset], [dataType], [dataLen], [data], | [id], [siblingOffset]/[distantSiblingOffset], [dataType], [dataLen], [data], | ||
− | [{<IndexNumber>}, {<IndexCount>, <IndexNodeInfo>, <IndexDataType>} ...] | + | [{<IndexNumber>},{<IndexCount>, <IndexNodeInfo>, <IndexDataType>} ...] |
* where: | * where: | ||
** fields indicated by angle brackets (< >) are always present | ** fields indicated by angle brackets (< >) are always present | ||
Line 54: | Line 55: | ||
* The microchip format only supports OIDs upto 255. The following is an workaround to store OID greater than 255. | * The microchip format only supports OIDs upto 255. The following is an workaround to store OID greater than 255. | ||
* Format of OID: | * Format of OID: | ||
− | + | An OID is a series of (one or more) octets. Bit 8 of each octet indicates whether it is the last in the series: bit 8 of the last octet is zero; | |
− | + | bit 8 of each preceding octet is one. Bits 7 to 1 of the octets in the series collectively encode the OID. Conceptually, these groups of bits are | |
+ | concatenated to form an unsigned binary number whose most significant bit is bit 7 of the first octet and whose least significant bit is bit 1 of | ||
+ | the last octet. The OID shall be encoded in the fewest possible octets, that is, the leading octet of the OID shall not have the value 0x80. | ||
− | |||
− | |||
− | |||
* Example: | * Example: | ||
The OID encode of OID in binary file (hex) | The OID encode of OID in binary file (hex) | ||
− | 4 | + | 4 BYTE(0x04) |
− | 1 | + | 1 BYTE(0x01) |
− | 36061 BYTE(0x80 + 0x02) BYTE(0x80 + 0x19) BYTE(0x5D) | + | 36061 BYTE(0x80+ 0x02) BYTE(0x80 + 0x19) BYTE(0x5D) |
The OID = 36061 is decoded by 0x02*0x80*0x80 + 0x19*0x80 + 0x5D | The OID = 36061 is decoded by 0x02*0x80*0x80 + 0x19*0x80 + 0x5D | ||
Line 149: | Line 149: | ||
IndexNodeInfo = 0xA4 | IndexNodeInfo = 0xA4 | ||
IndexDataType = 0x04 | IndexDataType = 0x04 | ||
− | |||
===Binary File Format <name>_trap.bin=== | ===Binary File Format <name>_trap.bin=== | ||
* The binary file store TRAP information. It is generated by mib2bin tool. Agents will read binary file to get information of TRAP when something bad occurs. | * The binary file store TRAP information. It is generated by mib2bin tool. Agents will read binary file to get information of TRAP when something bad occurs. | ||
− | * In the binary file, | + | * In the binary file, A enterprise OID is stored first, followed by its first specific trap number and ID (this ID is match with ID of leaf in <name>.bin) data bindings to be included in this trap to last specific trap number and ID data bindings to be included it. Next, the structure of next this enterprise is stored. This structure is repeated until all enterprise in MIB file is stored. |
* The format of enterprise in <name>_trap.bin | * The format of enterprise in <name>_trap.bin | ||
<enterprise_oid><sibling_enterprise><enterprise_index>[specific_trap_number][sibling_specific_trap][number_varbinds][id_varbind]... | <enterprise_oid><sibling_enterprise><enterprise_index>[specific_trap_number][sibling_specific_trap][number_varbinds][id_varbind]... | ||
Line 176: | Line 175: | ||
6 no use | 6 no use | ||
7 the last sub_oid in enterprise | 7 the last sub_oid in enterprise | ||
− | |||
− | |||
====<sibling_enterprise> field==== | ====<sibling_enterprise> field==== | ||
* Point to next enterprise OID. | * Point to next enterprise OID. | ||
Line 215: | Line 212: | ||
[[File:Snmp mib binary example.jpg | thumb | center | 900px]] | [[File:Snmp mib binary example.jpg | thumb | center | 900px]] | ||
− | * The detail description of | + | * The detail description of mchip.bin is illustrated in the diagram below: |
** The black arrow lines represent the OID tree structure. | ** The black arrow lines represent the OID tree structure. | ||
** The red and green lines represent pointers to data. | ** The red and green lines represent pointers to data. | ||
Line 232: | Line 229: | ||
[[File:Snmp mib binary trap example.jpg | thumb | center | 900px]] | [[File:Snmp mib binary trap example.jpg | thumb | center | 900px]] | ||
− | = | + | ==Build SNMP's PDU using BER== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | = | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |