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); }
@Override public void onResponse(ResponseEvent event) { SnmpUriResponse response = new SnmpUriResponse(SnmpUriResponse.Type.TIMEOUT); PDU responsePDU = event.getResponse(); if (responsePDU != null) { if (responsePDU.getErrorStatus() != PDU.noError) { response = new SnmpUriResponse(responsePDU.getErrorStatus()); } else { response = new SnmpUriResponse( Collections.singletonList( responsePDU .getVariableBindings() .toArray(new VariableBinding[responsePDU.size()]))); } } callback.onResponse(response, url, event.getUserObject()); }
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; } }