This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with SNMP(dev)
 
Similar Threads
snmp4j
set value of a variable
Brackets problem
how to return multiple values in java?
can the cause of memory leak be detected here?