Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get OID's type (syntax) from MIB using Net-SNMP API

Tags:

snmp

oid

net-snmp

How can I get the syntax type and read/write access for an OID using NET-SNMP API?

I am writing an SNMP tool that reads and sets values on a remote machine using SNMP protocol. Before setting the value, I need to check its type and access permissions (whether it is allowed to write this value on the server or not) from the MIB file.

Unfortunately, I could not find any mention regarding how to do this in the Net-SNMP documentation.

like image 221
Ser Avatar asked Jan 24 '11 20:01

Ser


1 Answers

Roughly speaking:

  oid name[128];
  size_t name_length = OID_LENGTH(name);
  strict tree *tp;

  read_objid("sysContact.0", &name, &name_length);
  tp = get_tree(name, name_length, get_tree_head();
  

Then look through the net-snmp/library/parse.h file for the tree structure and all the good data you need is inside it.

Also see the apps/snmptranslate.c file for further examples.

like image 160
Wes Hardaker Avatar answered Oct 15 '22 08:10

Wes Hardaker