public void updateByValue( URI url, List<Variable> values, SnmpUriCallback callback, Object userObject) throws UnknownHostException { Request request = createSnmpRequest(url); PDU pdu = request.getPdu(); pdu.setType(PDU.SET); OID[] oids = request.getOIDs(); for (int i = 0; i < oids.length && i < values.size(); i++) { pdu.add(new VariableBinding(oids[i], values.get(i))); } sendSnmpRequest(request, pdu, url, callback, userObject); }
public void sendByBinding( URI url, List<VariableBinding> values, int pduType, SnmpUriCallback callback, Object userObject) throws UnknownHostException { Request request = createSnmpRequest(url); PDU pdu = request.getPdu(); pdu.setType(pduType); for (VariableBinding vb : values) { pdu.add(vb); } sendSnmpRequest(request, pdu, url, callback, userObject); }
private void sendSnmpRequest( Request request, PDU pdu, URI url, SnmpUriCallback callback, Object userObject) { ResponseListener listener = new AsyncResponseListener(url, callback); try { snmp.send(pdu, request.getTarget(), userObject, listener); } catch (IOException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }
public void browse(URI url, SnmpUriCallback callback, Object userObject) throws UnknownHostException { Request request = createSnmpRequest(url); PDU pdu = request.getPdu(); switch (request.getType()) { case GET: pdu.setType(PDU.GET); pdu.addAll(VariableBinding.createFromOIDs(request.getOIDs())); sendSnmpRequest(request, pdu, url, callback, userObject); break; case NEXT: pdu.setType(PDU.GETNEXT); pdu.addAll(VariableBinding.createFromOIDs(request.getOIDs())); sendSnmpRequest(request, pdu, url, callback, userObject); break; case SUBTREE: TreeUtils treeUtils = new TreeUtils(snmp, pduFactory); TreeListener treeListener = new AsyncTreeListener(url, callback); treeUtils.walk(request.getTarget(), request.getOIDs(), userObject, treeListener); break; } }