本文整理汇总了Java中org.snmp4j.PDU.INFORM属性的典型用法代码示例。如果您正苦于以下问题:Java PDU.INFORM属性的具体用法?Java PDU.INFORM怎么用?Java PDU.INFORM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.snmp4j.PDU
的用法示例。
在下文中一共展示了PDU.INFORM属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRequest
/**
* @param request
* @return
*/
private PDU processRequest(PDU request) {
if (!isRequestPDU(request)) return null;
switch(request.getType()) {
case PDU.GET:
return processGet(request);
case PDU.GETNEXT:
return processGetNext(request);
case PDU.GETBULK:
return processGetBulk(request);
case PDU.SET:
return processSet(request);
case PDU.INFORM:
return processInform(request);
default:
return processUnhandled(request);
}
}
示例2: newNotification
private Snmp4jNotification newNotification(CommandResponderEvent event,
SnmpTarget target, VarbindCollection varbinds) {
switch (event.getPDU().getType()) {
case PDU.V1TRAP:
Snmp4jV1Trap trap = new Snmp4jV1Trap(target, varbinds);
PDUv1 pdu = (PDUv1) event.getPDU();
trap.setEnterprise(pdu.getEnterprise().toString());
trap.setAgentAddress(pdu.getAgentAddress().toString());
MibTrapV1Support trapSupport = varbindFactory.getMib()
.getV1TrapSupport();
trap.setGenericType(new ImmutableObjectValue(SMIConstants.SYNTAX_INTEGER,
pdu.getGenericTrap(), trapSupport.getGenericTrapFormatter()));
trap.setSpecificType(new ImmutableObjectValue(SMIConstants.SYNTAX_INTEGER,
pdu.getSpecificTrap(), trapSupport.getSpecificTrapFormatter()));
trap.setTimestamp(new ImmutableObjectValue(SMIConstants.SYNTAX_TIMETICKS,
pdu.getTimestamp(), trapSupport.getTimestampFormatter()));
return trap;
case PDU.INFORM:
return new Snmp4jNotification(SnmpNotification.Type.INFORM, target,
varbinds);
case PDU.TRAP:
return new Snmp4jNotification(SnmpNotification.Type.TRAP, target,
varbinds);
default:
throw new IllegalArgumentException("unrecognized PDU type");
}
}
示例3: validate
protected void validate() {
int pduType = getPdu().getType();
if (pduType != PDU.TRAP && pduType != PDU.INFORM) {
throw new IllegalArgumentException("Received not SNMPv2 Trap|Inform from host " + getTrapAddress() + " PDU Type = " + PDU.getTypeString(getPdu().getType()));
}
if (log().isDebugEnabled()) {
log().debug("V2 "+m_pduTypeString+" numVars or pdu length: " + getPduLength());
}
if (getPduLength() < 2) {
throw new IllegalArgumentException("V2 "+m_pduTypeString+" from " + getTrapAddress() + " IGNORED due to not having the required varbinds. Have " + getPduLength() + ", needed at least 2");
}
OID varBindName0 = getVarBindAt(0).getOid();
OID varBindName1 = getVarBindAt(1).getOid();
/*
* Modify the sysUpTime varbind OID to add the trailing 0 if it is
* missing, which is seen with some Extreme equipment.
*/
if (varBindName0.equals(EXTREME_SNMP_SYSUPTIME_OID)) {
log().info("V2 "+m_pduTypeString+" from " + getTrapAddress() + " has been corrected due to the sysUptime.0 varbind not having been sent with a trailing 0.\n\tVarbinds received are : " + varBindName0 + " and " + varBindName1);
varBindName0 = SNMP_SYSUPTIME_OID;
}
/*
* Confirm that the two required varbinds (sysUpTime and
* snmpTrapOID) are present and in that order.
*/
if ((!(varBindName0.equals(SNMP_SYSUPTIME_OID))) || (!(varBindName1.equals(SNMP_TRAP_OID)))) {
throw new IllegalArgumentException("V2 "+m_pduTypeString+" from " + getTrapAddress() + " IGNORED due to not having the required varbinds.\n\tThe first varbind must be sysUpTime.0 and the second snmpTrapOID.0\n\tVarbinds received are : " + varBindName0 + " and " + varBindName1);
}
}
示例4: processPdu
@Override
public void processPdu(CommandResponderEvent e) {
PDU command = new PDU(e.getPDU());
IpAddress addr = ((IpAddress)e.getPeerAddress());
if (command != null) {
if (command.getType() == PDU.INFORM) {
PDU response = new PDU(command);
response.setErrorIndex(0);
response.setErrorStatus(0);
response.setType(PDU.RESPONSE);
StatusInformation statusInformation = new StatusInformation();
StateReference ref = e.getStateReference();
try {
e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(),
e.getSecurityModel(),
e.getSecurityName(),
e.getSecurityLevel(),
response,
e.getMaxSizeResponsePDU(),
ref,
statusInformation);
if (log().isDebugEnabled()) {
log().debug("Sent RESPONSE PDU to peer " + addr + " acknowledging receipt of INFORM (reqId=" + command.getRequestID() + ")");
}
} catch (MessageException ex) {
log().error("Error while sending RESPONSE PDU to peer " + addr + ": " + ex.getMessage() + "acknowledging receipt of INFORM (reqId=" + command.getRequestID() + ")");
}
}
}
if (e.getPDU() instanceof PDUv1) {
m_listener.trapReceived(new Snmp4JV1TrapInformation(addr.getInetAddress(), new String(e.getSecurityName()), (PDUv1)e.getPDU(), m_trapProcessorFactory.createTrapProcessor()));
} else {
m_listener.trapReceived(new Snmp4JV2TrapInformation(addr.getInetAddress(), new String(e.getSecurityName()), e.getPDU(), m_trapProcessorFactory.createTrapProcessor()));
}
}
示例5: Snmp4JV2InformBuilder
protected Snmp4JV2InformBuilder(Snmp4JStrategy strategy) {
super(strategy, new PDU(), PDU.INFORM);
}