public int getMessageProcessingModel() { return this.requestEvent.getMessageProcessingModel(); }
public int getMessageProcessingModel() { return this.source.getMessageProcessingModel(); }
StateReference ref = event.getStateReference(); try { event.getMessageDispatcher().returnResponsePdu(event.getMessageProcessingModel(), event.getSecurityModel(), event.getSecurityName(),
e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(), e.getSecurityModel(), e.getSecurityName(),
public synchronized void processPdu(CommandResponderEvent e) { PDU command = e.getPDU(); if (command != null) { if ((command.getType() != PDU.TRAP) && (command.getType() != PDU.V1TRAP) && (command.getType() != PDU.REPORT) && (command.getType() != PDU.RESPONSE)) { out.println(command.toString()); command.setErrorIndex(0); command.setErrorStatus(0); command.setType(PDU.RESPONSE); StatusInformation statusInformation = new StatusInformation(); StateReference ref = e.getStateReference(); try { e.getMessageDispatcher().returnResponsePdu(e. getMessageProcessingModel(), e.getSecurityModel(), e.getSecurityName(), e.getSecurityLevel(), command, e.getMaxSizeResponsePDU(), ref, statusInformation); } catch (MessageException ex) { err.println("Error while sending response: " + ex.getMessage()); LogFactory.getLogger(SnmpCommand.class).error(ex); } } } }
public synchronized void processPdu(CommandResponderEvent e) { PDU command = e.getPDU(); if (command != null) { System.out.println(command.toString()); if ((command.getType() != PDU.TRAP) && (command.getType() != PDU.V1TRAP) && (command.getType() != PDU.REPORT) && (command.getType() != PDU.RESPONSE)) { command.setErrorIndex(0); command.setErrorStatus(0); command.setType(PDU.RESPONSE); StatusInformation statusInformation = new StatusInformation(); StateReference ref = e.getStateReference(); try { e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(), e.getSecurityModel(), e.getSecurityName(), e.getSecurityLevel(), command, e.getMaxSizeResponsePDU(), ref, statusInformation); } catch (MessageException ex) { System.err.println("Error while sending response: "+ex.getMessage()); LogFactory.getLogger(SnmpRequest.class).error(ex); } } } }
/** * Sends a RESPONSE PDU to the source address of a INFORM request. * @param event * the <code>CommandResponderEvent</code> with the INFORM request. * @throws * MessageException if the response could not be created and sent. */ protected void sendInformResponse(CommandResponderEvent event) throws MessageException { PDU responsePDU = (PDU) event.getPDU().clone(); responsePDU.setType(PDU.RESPONSE); responsePDU.setErrorStatus(PDU.noError); responsePDU.setErrorIndex(0); messageDispatcher.returnResponsePdu(event.getMessageProcessingModel(), event.getSecurityModel(), event.getSecurityName(), event.getSecurityLevel(), responsePDU, event.getMaxSizeResponsePDU(), event.getStateReference(), new StatusInformation()); } }
/** * Sends a RESPONSE PDU to the source address of a INFORM request. * @param event * the <code>CommandResponderEvent</code> with the INFORM request. * @throws * MessageException if the response could not be created and sent. */ protected void sendInformResponse(CommandResponderEvent event) throws MessageException { PDU responsePDU = (PDU) event.getPDU().clone(); responsePDU.setType(PDU.RESPONSE); responsePDU.setErrorStatus(PDU.noError); responsePDU.setErrorIndex(0); messageDispatcher.returnResponsePdu(event.getMessageProcessingModel(), event.getSecurityModel(), event.getSecurityName(), event.getSecurityLevel(), responsePDU, event.getMaxSizeResponsePDU(), event.getStateReference(), new StatusInformation()); } }
try { e.getMessageDispatcher().returnResponsePdu(e. getMessageProcessingModel(), e.getSecurityModel(), e.getSecurityName(),
/** * Sends a RESPONSE PDU to the source address of a INFORM request. * * @param event * the <code>CommandResponderEvent</code> with the INFORM request. * * @throws MessageException * if the response could not be created and sent. */ protected void sendInformResponse(CommandResponderEvent event) throws MessageException { PDU responsePDU = (PDU) event.getPDU().clone(); responsePDU.setType(PDU.RESPONSE); responsePDU.setErrorStatus(PDU.noError); responsePDU.setErrorIndex(0); messageDispatcher.returnResponsePdu(event.getMessageProcessingModel(), event.getSecurityModel(), event.getSecurityName(), event.getSecurityLevel(), responsePDU, event.getMaxSizeResponsePDU(), event.getStateReference(), new StatusInformation()); } }
@Override public void processPdu(CommandResponderEvent e) { PDU command = e.getPDU(); if (command == null) return; PDU response = processRequest(command); if (response == null) return; StatusInformation statusInformation = new StatusInformation(); StateReference ref = e.getStateReference(); try { LOG.debug("Replying with: {}", command); e.setProcessed(true); e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(), e.getSecurityModel(), e.getSecurityName(), e.getSecurityLevel(), command, e.getMaxSizeResponsePDU(), ref, statusInformation); } catch (MessageException ex) { LOG.error("Error while sending response", ex); } }
StateReference ref = e.getStateReference(); try { e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(), e.getSecurityModel(), e.getSecurityName(),
protected boolean matchParameters(ProxyForwardRequest request, OctetString paramIn) { MOTableRow param2Match = targetMIB.getTargetParamsRow(paramIn, true); if (param2Match != null) { int mpModel = param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsMPModel).toInt(); int secModel = param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsSecurityModel).toInt(); int secLevel = param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsSecurityLevel).toInt(); OctetString secName = (OctetString) param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsSecurityName); if (logger.isDebugEnabled()) { logger.debug("Matching request " + request + " with mpModel=" + mpModel + ", secModel=" + secModel + ", secLevel=" + secLevel + ", secName=" + secName); } if ((mpModel == request.getCommandEvent().getMessageProcessingModel()) && (secName.equals(request.getSecurityName())) && ((secModel == 0) || (secModel == request.getCommandEvent().getSecurityModel())) && (secLevel == request.getCommandEvent().getSecurityLevel())) { return true; } } return false; }
protected boolean matchParameters(ProxyForwardRequest request, OctetString paramIn) { MOTableRow param2Match = targetMIB.getTargetParamsRow(paramIn, true); if (param2Match != null) { int mpModel = param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsMPModel).toInt(); int secModel = param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsSecurityModel).toInt(); int secLevel = param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsSecurityLevel).toInt(); OctetString secName = (OctetString) param2Match.getValue( SnmpTargetMIB.idxSnmpTargetParamsSecurityName); if (logger.isDebugEnabled()) { logger.debug("Matching request "+request+" with mpModel="+mpModel+ ", secModel="+secModel+", secLevel="+secLevel+ ", secName="+secName); } if ((mpModel == request.getCommandEvent().getMessageProcessingModel()) && (secName.equals(request.getSecurityName())) && ((secModel == 0) || (secModel == request.getCommandEvent().getSecurityModel())) && (secLevel == request.getCommandEvent().getSecurityLevel())) { return true; } } return false; }
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); } }
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); } }
protected void assignErrorStatus2Response() { int errStatus = getErrorStatus(); if (requestEvent.getMessageProcessingModel() == MessageProcessingModel.MPv1) { switch (errStatus) { case SnmpConstants.SNMP_ERROR_NOT_WRITEABLE:
protected void assignErrorStatus2Response() { int errStatus = getErrorStatus(); if (source.getMessageProcessingModel() == MessageProcessingModel.MPv1) { switch (errStatus) { case SnmpConstants.SNMP_ERROR_NOT_WRITEABLE:
public void run() { if (forwarder.forward(request)) { PDU response = request.getResponsePDU(); if (response != null) { sendResponse(request.getCommandEvent(), response); } } else if (request.getProxyType() != ProxyForwarder.PROXY_TYPE_NOTIFY) { // proxy drop CounterEvent cevent = new CounterEvent(this, SnmpConstants.snmpProxyDrops); fireIncrementCounter(cevent); CommandResponderEvent cre = request.getCommandEvent(); if ((cre.getMessageProcessingModel() == MPv3.ID) && (cre.getStateReference() != null)) { ScopedPDU reportPDU = new ScopedPDU(); reportPDU.setType(PDU.REPORT); reportPDU.setContextEngineID(request.getContextEngineID()); reportPDU.setContextName(request.getContext()); reportPDU.add(new VariableBinding(SnmpConstants.snmpProxyDrops, cevent.getCurrentValue())); sendResponse(request.getCommandEvent(), reportPDU); } } }
public void run() { if (forwarder.forward(request)) { PDU response = request.getResponsePDU(); if (response != null) { sendResponse(request.getCommandEvent(), response); } } else if (request.getProxyType() != ProxyForwarder.PROXY_TYPE_NOTIFY) { // proxy drop CounterEvent cevent = new CounterEvent(this, SnmpConstants.snmpProxyDrops); fireIncrementCounter(cevent); CommandResponderEvent cre = request.getCommandEvent(); if ((cre.getMessageProcessingModel() == MPv3.ID) && (cre.getStateReference() != null)) { ScopedPDU reportPDU = new ScopedPDU(); reportPDU.setType(PDU.REPORT); reportPDU.setContextEngineID(request.getContextEngineID()); reportPDU.setContextName(request.getContext()); reportPDU.add(new VariableBinding(SnmpConstants.snmpProxyDrops, cevent.getCurrentValue())); sendResponse(request.getCommandEvent(), reportPDU); } } }