// Home | Go Back //
import com.ireasoning.util.ParseArguments;
import com.ireasoning.protocol.snmp.*;
import com.ireasoning.protocol.TimeoutException;
import java.io.IOException;
import java.util.ArrayList;
public class snmpbroadcast extends snmp
{
public static void main(String[] args)
{
snmpbroadcast s = new snmpbroadcast();
s.parseOptions(args, "snmpbroadcast");
s.broadcast();
}
private void broadcast()
{
try
{
SnmpSession.setToUseJCE(true);
SnmpSession session = new SnmpSession(_host, _port, _community,
_community, _version);
session.setTimeout(5000);
if(_isSnmpV3)
{
session.setV3Params(_user, _authProtocol, _authPassword, _privProtocol, _privPassword, _context, null);
}
ArrayList ret = session.broadcastDiscovery(new SnmpOID(_oids[0]));
for (int i = 0; i < ret.size() ; i++)
{
HostValue v = (HostValue) ret.get(i);
System.out.println( v);
}
session.close();
}
catch(TimeoutException timeout)
{
System.out.println( "time out");
}
catch(IOException e)
{
System.out.println(e);
e.printStackTrace();
}
}
protected void printExample(String programName)
{
System.out.println( "java " + programName + " 192.168.1.255 .1.3.6.1.2.1.1.2.0");
System.out.println( "java " + programName + " 192.168.1.255 -v 3 -u newUser -A abc12345 -X abc12345 .1.3.6.1.2.1.1.2.0");
}
protected ParseArguments newParseArgumentsInstance(String[] args)
{
return new ParseArguments(args, "?ho", "utvaAXxcpmnrw");
}
}