@Override public String identifyHost(CommandResponderEvent message) { IpAddress ip = (IpAddress) message.getPeerAddress(); return ip.getInetAddress().getCanonicalHostName(); }
public SnmpMessage(CamelContext camelContext, PDU pdu, CommandResponderEvent event) { super(camelContext); this.pdu = pdu; this.setHeader("securityName", new OctetString(event.getSecurityName())); this.setHeader("peerAddress", event.getPeerAddress()); }
/** * Will be called whenever a {@link PDU} is received on the given port * specified in the listen() method. It extracts a {@link Variable} * according to the configured OID prefix and sends its value to the event * bus. */ @Override public void processPdu(CommandResponderEvent event) { Address addr = event.getPeerAddress(); if (addr == null) { return; } String s = addr.toString().split("/")[0]; if (s == null) { logger.error("TRAP: failed to translate address {}", addr); dispatchPdu(addr, event.getPDU()); } else { // Need to change the port to 161, which is what the bindings are configured for since // at least some SNMP devices send traps from a random port number. Otherwise the trap // won't be found as the address check will fail. It feels like there should be a better // way to do this!!! Address address = GenericAddress.parse("udp:" + s + "/161"); dispatchPdu(address, event.getPDU()); } }
public void processPdu(CommandResponderEvent event) { try { PDU pdu = event.getPDU(); if( !(pdu.getType() == PDU.TRAP || pdu.getType() == PDU.V1TRAP) ) { LOGGER.warn("Not a trap."); return; } LOGGER.info("A Trap Received! " + pdu); SnmpTrapMsg trapMsg = new Snmp4JTrapMsg(event.getPeerAddress(), pdu); LOGGER.info("TrapMessage Created:" + trapMsg.toMap().toString()); SnmpTrapHandler[] handlers = getHandlers(); for (SnmpTrapHandler handler : handlers) { if(handler.onTrapMsg(trapMsg)) { event.setProcessed(true); return; } } } catch (Exception e) { LOGGER.error("Error happened when handling trap!", e); } }
protected VariableBinding checkReport(CommandResponderEvent e, PDU pdu, PendingRequest request) { if (request == null) { logger.warn("Unmatched report PDU received from " + e.getPeerAddress()); return null; logger.error("Illegal report PDU received from " + e.getPeerAddress() + " missing report variable binding"); return null; logger.error("Received illegal REPORT PDU from " + e.getPeerAddress()); return null;
protected VariableBinding checkReport(CommandResponderEvent e, PDU pdu, PendingRequest request) { if (request == null) { logger.warn("Unmatched report PDU received from " + e.getPeerAddress()); return null; logger.error("Illegal report PDU received from " + e.getPeerAddress() + " missing report variable binding"); return null; logger.error("Received illegal REPORT PDU from " + e.getPeerAddress()); return null;
e.getPeerAddress(), reqPDU, pdu, e.getPeerAddress() + " with request ID " + pdu.getRequestID());
PDU pdu = trap.getPDU(); Address localaddr = trap.getTransportMapping().getListenAddress(); Address remoteaddr = trap.getPeerAddress(); ConnectionContext<?> ctx = ConnectionContext.EMPTY; if (localaddr instanceof TransportIpAddress && remoteaddr instanceof TransportIpAddress ) {
/** * Creates shallow copy of the supplied <code>CommandResponderEvent</code> * but the source of the event is set to the supplied source. * * @param source * the (new) source of event copy to create. * @param other * the <code>CommandResponderEvent</code> to copy. * @since 1.1 */ public CommandResponderEvent(Object source, CommandResponderEvent other) { super(source); setTransportMapping(other.transportMapping); setMessageProcessingModel(other.messageProcessingModel); setSecurityModel(other.securityModel); setSecurityName(other.securityName); setSecurityLevel(other.securityLevel); setPduHandle(other.pduHandle); setPDU(other.pdu); setMaxSizeResponsePDU(other.maxSizeResponsePDU); setStateReference(other.stateReference); setPeerAddress(other.getPeerAddress()); }
/** * Creates shallow copy of the supplied <code>CommandResponderEvent</code> * but the source of the event is set to the supplied source. * * @param source * the (new) source of event copy to create. * @param other * the <code>CommandResponderEvent</code> to copy. * @since 1.1 */ public CommandResponderEvent(Object source, CommandResponderEvent other) { super(source); setTransportMapping(other.transportMapping); setMessageProcessingModel(other.messageProcessingModel); setSecurityModel(other.securityModel); setSecurityName(other.securityName); setSecurityLevel(other.securityLevel); setPduHandle(other.pduHandle); setPDU(other.pdu); setMaxSizeResponsePDU(other.maxSizeResponsePDU); setStateReference(other.stateReference); setPeerAddress(other.getPeerAddress()); }
PDU command = e.getPDU(); if (command != null) { IpAddress addr = ((IpAddress)e.getPeerAddress()); if (command.getType() == PDU.INFORM) {
requestStatistics.getResponseRuntimeNanos())); CounterEvent counterEvent = new CounterEvent(Snmp.this, SnmpConstants.snmp4jStatsReqTableRuntime, event.getPeerAddress(), requestStatistics.getResponseRuntimeNanos()); counterSupport.fireIncrementCounter(counterEvent); logger.warn("Received response that cannot be matched to any " + "outstanding request, address=" + event.getPeerAddress() + ", requestID=" + pdu.getRequestID()); if (l != null) { l.onResponse(new ResponseEvent(this, event.getPeerAddress(), request.pdu, pdu,
/** * Creates shallow copy of the supplied <code>CommandResponderEvent</code> * but the source of the event is set to the supplied source. * * @param source * the (new) source of event copy to create. * @param other * the <code>CommandResponderEvent</code> to copy. * @since 1.1 */ public CommandResponderEvent(Object source, CommandResponderEvent other) { super(source); setTransportMapping(other.transportMapping); setMessageProcessingModel(other.messageProcessingModel); setSecurityModel(other.securityModel); setSecurityName(other.securityName); setSecurityLevel(other.securityLevel); setPduHandle(other.pduHandle); setPDU(other.pdu); setMaxSizeResponsePDU(other.maxSizeResponsePDU); setStateReference(other.stateReference); setPeerAddress(other.getPeerAddress()); }
logger.warn("Received response that cannot be matched to any " + "outstanding request, address=" + event.getPeerAddress() + ", requestID=" + pdu.getRequestID()); if (l != null) { l.onResponse(new ResponseEvent(this, event.getPeerAddress(), request.pdu, pdu,
PDU command = e.getPDU(); if (command != null) { IpAddress addr = ((IpAddress)e.getPeerAddress()); if (command.getType() == PDU.INFORM) {
requestStatistics.getResponseRuntimeNanos())); CounterEvent counterEvent = new CounterEvent(Snmp.this, SnmpConstants.snmp4jStatsReqTableRuntime, event.getPeerAddress(), requestStatistics.getResponseRuntimeNanos()); counterSupport.fireIncrementCounter(counterEvent); logger.warn("Received response that cannot be matched to any " + "outstanding request, address=" + event.getPeerAddress() + ", requestID=" + pdu.getRequestID()); if (l != null) { l.onResponse(new ResponseEvent(this, event.getPeerAddress(), request.pdu, pdu,
public void processPdu(CommandResponderEvent e) { PDU command = new PDU(e.getPDU()); IpAddress addr = ((IpAddress)e.getPeerAddress());
if ((cinfos != null) && (cinfos.length > 0)) { for (int i=0; i<cinfos.length; i++) { if (coexistenceProvider.passesFilter(event.getPeerAddress(), cinfos[i])) { cinfo = cinfos[i]; logger.warn("Access attempt from "+event.getPeerAddress()+ " denied because of source address filtering");
if (request.getCommandEvent().getPeerAddress() instanceof IpAddress) { InetAddress agentAddress = ((IpAddress) request.getCommandEvent().getPeerAddress()).getInetAddress(); targetV1.setAgentAddress(new IpAddress(agentAddress)); } else {
if (request.getCommandEvent().getPeerAddress() instanceof IpAddress) { InetAddress agentAddress = ((IpAddress) request.getCommandEvent().getPeerAddress()).getInetAddress(); targetV1.setAgentAddress(new IpAddress(agentAddress));