Hi, Extracting Variable Name

Thomas Johnson <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi,

I am new to net-snmp (and snmp) so struggling a bit here.

I am successfully talking to an SNMP device and getting back some variables which I can print out using the following code:

....init_snmp etc

then

sess_handle = snmp_open(&session);

  pdu = snmp_pdu_create(SNMP_MSG_GET);

  read_objid("Device::Alarm1.0", id_oid, &id_len);
   snmp_add_null_var(pdu, id_oid, id_len);
  read_objid("Device::Alarm2.0", id_oid, &id_len);
   snmp_add_null_var(pdu, id_oid, id_len);
  read_objid("Device::Alarm3.0", id_oid, &id_len);
   snmp_add_null_var(pdu, id_oid, id_len);
  read_objid("Device::Alarm4.0", id_oid, &id_len);
   snmp_add_null_var(pdu, id_oid, id_len);

  status = snmp_synch_response(sess_handle, pdu, &response);
   if (status==0)
    {
    for(vars = response->variables; vars; vars = vars->next_variable)
                {
                print_variable(vars->name, vars->name_length, vars);
                }
    }

The above works fine.

What I am struggling with is getting the data out of the vars variable list. I can get the type and value of the data but I don't seem to be able to get the variable name back.

What I want to do is from the vars variable get back the objid eg Alarm1.0 for each item in the list . How do I do this ?.

Many thanks for any assistance.

Tom Johnson

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.