File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Problems with SNMP(dev)

carlos Abrante

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)

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 IP-MIB::ipNetToMediaPhysAddress
IP-MIB::ipNetToMediaPhysAddress. = STRING: 8:0:27:0:cc:e1
IP-MIB::ipNetToMediaPhysAddress. = STRING: ca:0:6:70:0:8
IP-MIB::ipNetToMediaPhysAddress. = STRING: 8:0:27:35:5c:da

Many Thanks!
I agree. Here's the link:
subject: Problems with SNMP(dev)
It's not a secret anymore!