hello any one
here what i trying i think i m in right way but i getting any null responses so can plz help to do broadcastingthanks Vijay class snmp_broadcast { public static void main(String[] args) { try { System.out.println("Hello World!");InetAddress host = InetAddress.getByName("localhost"); UdpAddress targetAddress = new UdpAddress(host,161);TransportMapping transport = new DefaultUdpTransportMapping();Snmp snmp = new Snmp(transport); // setting up target CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setAddress(targetAddress); target.setRetries(2); target.setTimeout(1500); target.setVersion(SnmpConstants.version1); // creating PDU PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(new int[] {1,3,6,1,2,1,1,1}))); pdu.add(new VariableBinding(new OID(new int[] {1,3,6,1,2,1,1,2}))); pdu.setType(PDU.GETNEXT); //MessageDispatcher ms ; // = new MessageDispatcher(); DefaultTcpTransportMapping trans = new DefaultTcpTransportMapping(); MessageDispatcherImpl msg = new MessageDispatcherImpl(); int messageProcessingModel = 3; int securityModel = 1; String s = "principal"; byte[] securityName = s.getBytes(); int securityLevel = 1; PduHandle pduhandle = new PduHandle(); int maxSizeResponseScopedPDU = 5; StateReference state = new StateReference();CommandResponderEvent event = new CommandResponderEvent(msg,trans,targetAddress,messageProcessingModel,securityModel,securityName,securityLevel,pduhandle,pdu,maxSizeResponseScopedPDU,state);// sending request ResponseListener listener = new ResponseListener() { public void onResponse(ResponseEvent event) {((Snmp)event.getSource()).cancel(event.getRequest(), this); System.out.println("Received response PDU is: "+event.getResponse());} }; // Always cancel async request when response has been received // otherwise a memory leak is created! Not canceling a request // immediately can be useful when sending a request to a broadcast // address. snmp.sendPDU(pdu, target, null, listener); System.out.println("Response"+listener);snmp.processPdu(event); //here something that i found in snmp core class} catch(IOException e) { System.out.println("Ha Ha Ha Ha Error"+e); } } }
_______________________________________________ SNMP4J mailing list [email protected] http://lists.agentpp.org/mailman/listinfo/snmp4j
