aspose file tools*
The moose likes C / C++ and the fly likes Problems with SNMP(dev) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Problems with SNMP(dev)" Watch "Problems with SNMP(dev)" New topic
Author

Problems with SNMP(dev)

carlos Abrante
Greenhorn

Joined: Jun 29, 2011
Posts: 1
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problems with SNMP(dev)