[unisog] Getting the Arp table from a router, whit Java or C

stefano stefano.gargiulo at roma1.infn.it
Tue Apr 11 09:49:34 GMT 2006


Hi, sorry for my bad english, i know this and i'm working for make it 
better.. but here come the question: I've known this mailing list 
reading the previous thread talking about this argument (Getting ARP 
tables from Cisco switches via snmp -- slightly OT ) after a search on 
google..

I've to develop an* identical* application (that insert in a DB the 
*MAC*, the* IP* and if is possible the Switch port number..) but i've a 
condiction, i've to develop this using a java server, not one linux 
commands or application  (not , but max portability, because some 
servers are Windows and some are Unix, therefore*_ i can't use smnpwalk 
or arptrace!!_* ) i must to realize this operation whit *JavaAPIs* or 
whit portable a source code as a *C code.*

I've downloaded the *Adventnet java SNMP API* package, and i can get a 
variable from the MIB for example the OID /1.3.6.1.2.1.1.1.0/ return to 
me the string value /"Cisco Internetwork Operating System Software 
\r\nIOS (tm) RSP Software (RSP-JSV-M), Version 12.0(9), RELEASE SOFTWARE 
(fc1)\r\nCopyright (c) 1986-2000 by cisco Systems, Inc.\r\nCompiled Mon 
24-Jan-00 23:15 by bettyl"/ then i can deduce that the APIs work fine. 
But if i try to get a table, i recive a null pointer, and i don't know 
how i can do this operation correctly.

*anyone can help me?*

here there is the bad test code working only with a single MIB variable:

/public static void openSNMPSession() throws Exception
    {
        System.out.println("ci2ao");
        SnmpAPI api = new SnmpAPI();
        SnmpSession session = new SnmpSession(api);
        session.open();
        SnmpPDU pdu = new SnmpPDU();
        pdu.setRemoteHost("141.108.5.4");
        pdu.setCommand(SnmpAPI.GET_REQ_MSG);
        pdu.addNull(new SnmpOID(".1.3.6.1.2.1.4.22")); //doesn't work
        //pdu.addNull(newSnmpOID("//.1.3.6.1.2.1.1.1.0/ /")); work
        SnmpPDU response_pdu = session.syncSend(pdu);
        if(response_pdu == null)
        {
            System.out.println("The Request has timed out.");
        }
        else
        {
           
            System.out.println(response_pdu.printVarBinds());
            System.out.println("Errors: "+response_pdu.getError());
            System.out.println("Account: 
"+response_pdu.getCommunity()+"\n Ver "+response_pdu.getVariable(10));
           
        }
    }/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dshield.org/pipermail/unisog/attachments/20060411/dfa2cd4c/attachment.htm


More information about the unisog mailing list