/** * Builds target resource. * @param context Process context */ private void buildTargetResource(ProcessContext context) { if((this.transportMapping == null) || !this.transportMapping.isListening() || (this.snmp == null)) { try { this.transportMapping = new DefaultUdpTransportMapping(); this.snmp = new Snmp(this.transportMapping); if("SNMPv3".equals(context.getProperty(SNMP_VERSION).getValue())) { USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); } this.transportMapping.listen(); } catch (Exception e) { throw new IllegalStateException("Failed to initialize UDP transport mapping", e); } } if (this.snmpTarget == null) { this.snmpTarget = this.createSnmpTarget(context); } if (this.targetResource == null) { this.targetResource = this.finishBuildingTargetResource(context); } }
protected void fireProcessMessage(Address address, ByteBuffer buf, TransportStateReference tmStateReference) { if (transportListener != null) { for (TransportListener aTransportListener : transportListener) { aTransportListener.processMessage(this, address, buf, tmStateReference); } } }
public X509TrustManager create(X509TrustManager trustManager, boolean useClientMode, TransportStateReference tmStateReference) { return new TlsTrustManager(trustManager, useClientMode, tmStateReference); } }
/** {@inheritDoc} */ public TransportMapping createTransportMapping(TransportIpAddress transportIpAddress) throws IOException { return new DefaultTcpTransportMapping((TcpAddress) transportIpAddress); } }
/** * Gets the inbound buffer size for incoming requests. When SNMP packets are * received that are longer than this maximum size, the messages will be * silently dropped and the connection will be closed. * @return * the maximum inbound buffer size in bytes. */ public int getMaxInboundMessageSize() { return super.getMaxInboundMessageSize(); }
/** * Returns the <code>TransportMappings</code> singleton. * @return * the <code>TransportMappings</code> instance. */ public static TransportMappings getInstance() { if (instance == null) { instance = new TransportMappings(); } return instance; }
private synchronized void timeoutSocket(SocketEntry entry) { if (connectionTimeout > 0) { SocketTimeout socketTimeout = new SocketTimeout(entry); entry.setSocketTimeout(socketTimeout); socketCleaner.schedule(socketTimeout, connectionTimeout); } }
public X509TrustManager create(X509TrustManager trustManager, boolean useClientMode, TransportStateReference tmStateReference) { return new TlsTrustManager(trustManager, useClientMode, tmStateReference); } }
public SnmpHelper(String address, String community) { _target = new CommunityTarget(); _target.setCommunity(new OctetString(community)); _target.setVersion(SnmpConstants.version2c); _target.setAddress(new UdpAddress(address)); try { _snmp = new Snmp(new DefaultUdpTransportMapping()); } catch (IOException e) { _snmp = null; throw new CloudRuntimeException(" Error in crearting snmp object, " + e.getMessage()); } }
protected void fireProcessMessage(Address address, ByteBuffer buf, TransportStateReference tmStateReference) { if (transportListener != null) { for (TransportListener aTransportListener : transportListener) { aTransportListener.processMessage(this, address, buf, tmStateReference); } } }
/** * Gets the inbound buffer size for incoming requests. When SNMP packets are * received that are longer than this maximum size, the messages will be * silently dropped and the connection will be closed. * * @return the maximum inbound buffer size in bytes. */ public int getMaxInboundMessageSize() { return super.getMaxInboundMessageSize(); }
/** * Returns the <code>TransportMappings</code> singleton. * @return * the <code>TransportMappings</code> instance. */ public static TransportMappings getInstance() { if (instance == null) { instance = new TransportMappings(); } return instance; }
/** {@inheritDoc} */ public TransportMapping createTransportMapping(TransportIpAddress transportIpAddress) throws IOException { return new DefaultUdpTransportMapping((UdpAddress) transportIpAddress); } }
protected void fireProcessMessage(Address address, ByteBuffer buf, TransportStateReference tmStateReference) { if (transportListener != null) { for (TransportListener aTransportListener : transportListener) { aTransportListener.processMessage(this, address, buf, tmStateReference); } } }
/** * Gets the inbound buffer size for incoming requests. When SNMP packets are * received that are longer than this maximum size, the messages will be * silently dropped and the connection will be closed. * * @return the maximum inbound buffer size in bytes. */ public int getMaxInboundMessageSize() { return super.getMaxInboundMessageSize(); }
/** * Returns the <code>TransportMappings</code> singleton. * * @return the <code>TransportMappings</code> instance. */ public static TransportMappings getInstance() { if (instance == null) { instance = new TransportMappings(); } return instance; }
public static void main(String[] args) throws Exception { // Create PDU PDU trap = new PDU(); trap.setType(PDU.TRAP); OID oid = new OID("1.2.3.4.5"); trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, oid)); trap.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(5000))); // put your uptime here trap.add(new VariableBinding(SnmpConstants.sysDescr, new OctetString("System Description"))); //Add Payload Variable var = new OctetString("some string"); trap.add(new VariableBinding(oid, var)); // Specify receiver Address targetaddress = new UdpAddress("10.101.21.32/162"); CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setVersion(SnmpConstants.version2c); target.setAddress(targetaddress); // Send Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.send(trap, target, null, null); }
/** * Gets the inbound buffer size for incoming requests. When SNMP packets are * received that are longer than this maximum size, the messages will be * silently dropped and the connection will be closed. * @return * the maximum inbound buffer size in bytes. */ public int getMaxInboundMessageSize() { return super.getMaxInboundMessageSize(); }
TransportMapping transMap = new DefaultUdpTransportMapping(); snmp = new Snmp( transMap );
/** * Gets the inbound buffer size for incoming requests. When SNMP packets are * received that are longer than this maximum size, the messages will be * silently dropped and the connection will be closed. * @return * the maximum inbound buffer size in bytes. */ public int getMaxInboundMessageSize() { return super.getMaxInboundMessageSize(); }