/** * Construct the PDU to perform the SNMP Get request and returns * the result in order to create the flow file. * @return {@link ResponseEvent} */ public ResponseEvent get() { try { PDU pdu = null; if(this.target.getVersion() == SnmpConstants.version3) { pdu = new ScopedPDU(); } else { pdu = new PDU(); } pdu.add(new VariableBinding(this.oid)); pdu.setType(PDU.GET); return this.snmp.get(pdu, this.target); } catch (IOException e) { logger.error("Failed to get information from SNMP agent; " + this, e); throw new ProcessException(e); } }
pdu = new ScopedPDU(); } else { pdu = new PDU();
ScopedPDU pdu = new ScopedPDU(); pdu.add( new VariableBinding( new OID( Oid ), new OctetString( messageString ) ) ); pdu.setType( PDU.TRAP );
/** * Creates a PDU class that is used to parse incoming SNMP messages. * @param target * the <code>target</code> parameter must be ignored. * @return * a {@link ScopedPDU} instance by default. * @since 1.9.1 */ public PDU createPDU(Target target) { return new ScopedPDU(); }
/** {@inheritDoc} */ @Override protected PDU createPDU() { return new ScopedPDU(); }
/** {@inheritDoc} */ @Override protected PDU createPDU() { return new ScopedPDU(); }
protected Snmp4JV3InformBuilder(Snmp4JStrategy strategy) { super(strategy, new ScopedPDU(), ScopedPDU.INFORM); }
protected Snmp4JV3TrapBuilder(Snmp4JStrategy strategy) { super(strategy, new ScopedPDU(), ScopedPDU.TRAP); }
public Object clone() { return new ScopedPDU(this); }
public Object clone() { return new ScopedPDU(this); }
public Object clone() { return new ScopedPDU(this); }
protected Snmp4JV3TrapBuilder(Snmp4JStrategy strategy) { super(strategy, new ScopedPDU(), ScopedPDU.TRAP); }
protected Snmp4JV3InformBuilder(Snmp4JStrategy strategy) { super(strategy, new ScopedPDU(), ScopedPDU.INFORM); }
/** * Creates an SNMP4J PDU based on the SNMP4J version constants. * A v3 request requires a ScopedPDU. * * @param type * @return */ public PDU createPdu(int type) { PDU pdu = getVersion() == SnmpConstants.version3 ? new ScopedPDU() : new PDU(); pdu.setType(type); return pdu; }
private static PDU createPduByMP(MessageProcessingModel messageProcessingModel) { PDU pdu; switch (messageProcessingModel.getID()) { case MessageProcessingModel.MPv3: { pdu = new ScopedPDU(); break; } case MessageProcessingModel.MPv1: { pdu = new PDUv1(); break; } default: pdu = new PDU(); } return pdu; }
private static PDU createPduByMP(MessageProcessingModel messageProcessingModel) { PDU pdu; switch (messageProcessingModel.getID()) { case MessageProcessingModel.MPv3: { pdu = new ScopedPDU(); break; } case MessageProcessingModel.MPv1: { pdu = new PDUv1(); break; } default: pdu = new PDU(); } return pdu; }
/** * Construct the PDU to perform the SNMP Get request and returns * the result in order to create the flow file. * @return {@link ResponseEvent} */ public ResponseEvent get() { try { PDU pdu = null; if(this.target.getVersion() == SnmpConstants.version3) { pdu = new ScopedPDU(); } else { pdu = new PDU(); } pdu.add(new VariableBinding(this.oid)); pdu.setType(PDU.GET); return this.snmp.get(pdu, this.target); } catch (IOException e) { logger.error("Failed to get information from SNMP agent; " + this, e); throw new ProcessException(e); } }
private void discoverContextEngineID() { MessageProcessingModel mp = messageDispatcher.getMessageProcessingModel(target.getVersion()); if ((mp instanceof MPv3) && (target instanceof SecureTarget)) { MPv3 mpv3 = (MPv3) mp; SecureTarget st = (SecureTarget) target; SecurityModel sm = mpv3.getSecurityModel(st.getSecurityModel()); if ((sm != null) && (!sm.supportsEngineIdDiscovery())) { // Perform context engine ID discovery according to RFC 5343 if (logger.isInfoEnabled()) { logger.info("Performing RFC 5343 contextEngineID discovery on " + target); } ScopedPDU discoverPDU = new ScopedPDU(); discoverPDU.setContextEngineID(MPv3.LOCAL_ENGINE_ID); discoverPDU.add(new VariableBinding(SnmpConstants.snmpEngineID)); insertFirstPDU(discoverPDU); } } }
private void discoverContextEngineID() { MessageProcessingModel mp = messageDispatcher.getMessageProcessingModel(target.getVersion()); if ((mp instanceof MPv3) && (target instanceof SecureTarget)) { MPv3 mpv3 = (MPv3)mp; SecureTarget st = (SecureTarget)target; SecurityModel sm = mpv3.getSecurityModel(st.getSecurityModel()); if ((sm != null) && (!sm.supportsEngineIdDiscovery())) { // Perform context engine ID discovery according to RFC 5343 if (logger.isInfoEnabled()) { logger.info("Performing RFC 5343 contextEngineID discovery on "+target); } ScopedPDU discoverPDU = new ScopedPDU(); discoverPDU.setContextEngineID(MPv3.LOCAL_ENGINE_ID); discoverPDU.add(new VariableBinding(SnmpConstants.snmpEngineID)); insertFirstPDU(discoverPDU); } } }
private void sendUnknownPDUHandlersReport(CommandResponderEvent command) { logger.info("No PDU handler found for request " + command); CounterEvent counter = new CounterEvent(this, SnmpConstants.snmpUnknownPDUHandlers); fireIncrementCounter(counter); if ((command.getMessageProcessingModel() == MessageProcessingModel.MPv3) && (command.getPDU() instanceof ScopedPDU)) { ScopedPDU request = (ScopedPDU) command.getPDU(); ScopedPDU report = new ScopedPDU(); report.setContextEngineID(request.getContextEngineID()); report.setContextName(request.getContextName()); report.setType(PDU.REPORT); report.add(new VariableBinding(counter.getOid(), counter.getCurrentValue())); sendResponse(command, report); } else { PDU resp = (PDU) command.getPDU().clone(); resp.setErrorStatus(PDU.genErr); sendResponse(command, resp); } }