use of org.snmp4j.smi.Integer32 in project openhab1-addons by openhab.
the class SnmpBinding method internalReceiveCommand.
/**
* @{inheritDoc
*/
@Override
public void internalReceiveCommand(String itemName, Command command) {
logger.debug("SNMP receive command {} from {}", itemName, command);
SnmpBindingProvider providerCmd = null;
for (SnmpBindingProvider provider : this.providers) {
OID oid = provider.getOID(itemName, command);
if (oid != null) {
providerCmd = provider;
break;
}
}
if (providerCmd == null) {
logger.warn("No match for binding provider [itemName={}, command={}]", itemName, command);
return;
}
logger.debug("SNMP command for {} to {}", itemName, providerCmd.toString());
// Set up the target
CommunityTarget target = new CommunityTarget();
target.setCommunity(providerCmd.getCommunity(itemName, command));
target.setAddress(providerCmd.getAddress(itemName, command));
target.setRetries(retries);
target.setTimeout(timeout);
target.setVersion(providerCmd.getSnmpVersion(itemName, command));
Variable var = providerCmd.getValue(itemName, command);
OID oid = providerCmd.getOID(itemName, command);
VariableBinding varBind = new VariableBinding(oid, var);
// Create the PDU
PDU pdu = new PDU();
pdu.add(varBind);
pdu.setType(PDU.SET);
pdu.setRequestID(new Integer32(1));
logger.debug("SNMP: Send CMD PDU {} {}", providerCmd.getAddress(itemName, command), pdu);
if (snmp == null) {
logger.error("SNMP: snmp not initialised - aborting request");
} else {
sendPDU(target, pdu);
}
}
use of org.snmp4j.smi.Integer32 in project opennms by OpenNMS.
the class LLDPMibIT method testGetNext.
@Test
public void testGetNext() throws Exception {
request(".1.0.8802.1.1.2.1.3.1").andExpect(".1.0.8802.1.1.2.1.3.1.0", SMIConstants.SYNTAX_INTEGER32, new Integer32(4));
doGetNext();
}
use of org.snmp4j.smi.Integer32 in project opennms by OpenNMS.
the class MockSnmpAgentIT method testDynamicVariableCacheAfterUpdateFromFile.
@Test
public void testDynamicVariableCacheAfterUpdateFromFile() throws Exception {
final String oid = "1.3.5.1.1.10.0";
request(oid).andExpect(oid, SMIConstants.SYNTAX_INTEGER, new Integer32(0));
doGet();
m_agent.updateValuesFromResource(classPathResource("differentSnmpData.properties"));
Sleeper.getInstance().resetWithVariable(new Integer32(42));
request(oid).andExpect(oid, SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
}
use of org.snmp4j.smi.Integer32 in project opennms by OpenNMS.
the class MockSnmpAgentIT method testGetNextMultipleVarbinds.
@Test
public void testGetNextMultipleVarbinds() throws Exception {
request("1.3.5.1.1.3").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGetNext();
m_agent.getUsm().setEngineBoots(15);
request("1.3.5.1.1.3").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGetNext();
request("1.3.5.1.1.3").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGetNext();
// This statement breaks the internal state of the SNMP4J agent
// m_agent.getUsm().setLocalEngine(m_agent.getUsm().getLocalEngineID(), 15, 200);
m_agent.getUsm().removeEngineTime(m_usm.getLocalEngineID());
m_usm.removeEngineTime(m_agent.getUsm().getLocalEngineID());
request("1.3.5.1.1.3").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGetNext();
}
use of org.snmp4j.smi.Integer32 in project opennms by OpenNMS.
the class MockSnmpAgentIT method testUpdateFromFileWithUSMTimeReset.
@Test
public void testUpdateFromFileWithUSMTimeReset() throws Exception {
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
m_agent.getUsm().setEngineBoots(15);
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
// This statement breaks the internal state of the SNMP4J agent
// m_agent.getUsm().setLocalEngine(m_agent.getUsm().getLocalEngineID(), 15, 200);
m_agent.getUsm().removeEngineTime(m_usm.getLocalEngineID());
m_usm.removeEngineTime(m_agent.getUsm().getLocalEngineID());
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
m_usm.removeEngineTime(m_agent.getUsm().getLocalEngineID());
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
request("1.3.5.1.1.3.0").andExpect("1.3.5.1.1.3.0", SMIConstants.SYNTAX_INTEGER, new Integer32(42));
doGet();
}
Aggregations