Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with SNMP(dev)

 
carlos Abrante
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm trying to develop a aplication in c to get the arp table from a router, i know the OID and using a snmpwalk (shell command) i can get it.
When i tried to code i saw an example but it was with pdu type SNMP_MSG_GET, but it gives an error (no such oid).

i found (with trace) that snmpwalk use a SNMP_MSG_GETNEXT, but when using it i just get the first MAC address without knowing from what ip is...

I can't found a good understandable example with GETNEXT..

Can anyone help? any good example? our know how to do it?



My code (juts the important part, i think):

pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);

get_node("IP-MIB::ipNetToMediaPhysAddress",id_oid, &id_len);
snmp_add_null_var(pdu,id_oid, id_len);
status=snmp_synch_response(ss_handle, pdu, &response);
for(vars = response->variables;vars;vars=vars->next_variable)
print_value(vars->name,vars->name_length,vars);


output:
STRING: ca:0:58:c0:0:8



I need something like this (to get the ip/MAC to put it in a DB)....

[root@localhost ~]# snmpwalk -v2c -c public 192.168.56.100 IP-MIB::ipNetToMediaPhysAddress
IP-MIB::ipNetToMediaPhysAddress.1.192.168.56.1 = STRING: 8:0:27:0:cc:e1
IP-MIB::ipNetToMediaPhysAddress.1.192.168.56.100 = STRING: ca:0:6:70:0:8
IP-MIB::ipNetToMediaPhysAddress.1.192.168.56.101 = STRING: 8:0:27:35:5c:da


Many Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic