private void init(SnmpPdu req, SnmpAdaptorServer server) { this.server = server; // The translation table is easy in this case ... // final int max= translation.length; final SnmpVarBind[] list= req.varBindList; final NonSyncVector<SnmpVarBind> nonSyncVarBind = ((NonSyncVector<SnmpVarBind>)varBind); for(int i=0; i < max; i++) { translation[i]= i; // we need to allocate a new SnmpVarBind. Otherwise the first // sub request will modify the list... // final SnmpVarBind newVarBind = new SnmpVarBind(list[i].oid, list[i].value); nonSyncVarBind.addNonSyncElement(newVarBind); } }
private void init(SnmpAdaptorServer server, SnmpPdu req, int nonRepeat, int maxRepeat, int R) { this.server = server; this.nonRepeat= nonRepeat; this.maxRepeat= maxRepeat; this.globalR= R; final int max= translation.length; final SnmpVarBind[] list= req.varBindList; final NonSyncVector<SnmpVarBind> nonSyncVarBind = ((NonSyncVector<SnmpVarBind>)varBind); for(int i=0; i < max; i++) { translation[i]= i; // we need to allocate a new SnmpVarBind. Otherwise the first // sub request will modify the list... // final SnmpVarBind newVarBind = new SnmpVarBind(list[i].oid, list[i].value); nonSyncVarBind.addNonSyncElement(newVarBind); } }
private synchronized void sendTrap(SnmpOid trap, SnmpVarBindList list) { final Iterator<NotificationTarget> iterator = notificationTargets.iterator(); final SnmpAdaptorServer adaptor = (SnmpAdaptorServer) getSnmpAdaptor(); if (adaptor == null) { log.error("sendTrap", "Cannot send trap: adaptor is null."); return; } if (!adaptor.isActive()) { log.config("sendTrap", "Adaptor is not active: trap not sent."); return; } while(iterator.hasNext()) { NotificationTarget target = null; try { target = iterator.next(); SnmpPeer peer = new SnmpPeer(target.getAddress(), target.getPort()); SnmpParameters p = new SnmpParameters(); p.setRdCommunity(target.getCommunity()); peer.setParams(p); log.debug("handleNotification", "Sending trap to " + target.getAddress() + ":" + target.getPort()); adaptor.snmpV2Trap(peer, trap, list, null); }catch(Exception e) { log.error("sendTrap", "Exception occurred while sending trap to [" + target + "]. Exception : " + e); log.debug("sendTrap",e); } } }
/** * The constructor initialize the subrequest with the whole varbind * list contained in the original request. */ protected SnmpSubNextRequestHandler(SnmpAdaptorServer server, SnmpMibAgent agent, SnmpPdu req) { super(agent,req); init(req, server); }
protected SnmpSubNextRequestHandler(SnmpEngine engine, SnmpAdaptorServer server, SnmpIncomingRequest incRequest, SnmpMibAgent agent, SnmpPdu req) { super(engine, incRequest, agent, req); init(req, server); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubNextRequestHandler.class.getName(), "SnmpSubNextRequestHandler", "Constructor : " + this); } }
private synchronized void sendTrap(SnmpOid trap, SnmpVarBindList list) { final Iterator iterator = notificationTargets.iterator(); final SnmpAdaptorServer adaptor = (SnmpAdaptorServer) getSnmpAdaptor(); if (adaptor == null) { log.error("sendTrap", "Cannot send trap: adaptor is null."); return; } if (!adaptor.isActive()) { log.config("sendTrap", "Adaptor is not active: trap not sent."); return; } while(iterator.hasNext()) { NotificationTarget target = null; try { target = (NotificationTarget) iterator.next(); SnmpPeer peer = new SnmpPeer(target.getAddress(), target.getPort()); SnmpParameters p = new SnmpParameters(); p.setRdCommunity(target.getCommunity()); peer.setParams(p); log.debug("handleNotification", "Sending trap to " + target.getAddress() + ":" + target.getPort()); adaptor.snmpV2Trap(peer, trap, list, null); }catch(Exception e) { log.error("sendTrap", "Exception occured while sending trap to [" + target + "]. Exception : " + e); log.debug("sendTrap",e); } } }
/** * The constuctor initialize the subrequest with the whole varbind * list contained in the original request. */ protected SnmpSubNextRequestHandler(SnmpAdaptorServer server, SnmpMibAgent agent, SnmpPdu req) { super(agent,req); init(req, server); }
/** * The constuctor initialize the subrequest with the whole varbind list contained * in the original request. */ protected SnmpSubBulkRequestHandler(SnmpEngine engine, SnmpAdaptorServer server, SnmpIncomingRequest incRequest, SnmpMibAgent agent, SnmpPdu req, int nonRepeat, int maxRepeat, int R) { super(engine, incRequest, agent, req); init(server, req, nonRepeat, maxRepeat, R); }
/** * The constuctor initialize the subrequest with the whole varbind list contained * in the original request. */ protected SnmpSubBulkRequestHandler(SnmpAdaptorServer server, SnmpMibAgent agent, SnmpPdu req, int nonRepeat, int maxRepeat, int R) { super(agent, req); init(server, req, nonRepeat, maxRepeat, R); }