当前位置: 首页>>代码示例>>Java>>正文


Java PDU.getTypeString方法代码示例

本文整理汇总了Java中org.snmp4j.PDU.getTypeString方法的典型用法代码示例。如果您正苦于以下问题:Java PDU.getTypeString方法的具体用法?Java PDU.getTypeString怎么用?Java PDU.getTypeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.snmp4j.PDU的用法示例。


在下文中一共展示了PDU.getTypeString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.snmp4j.PDU; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:35,代码来源:Snmp4JTrapNotifier.java

示例2: Snmp4JV2TrapInformation

import org.snmp4j.PDU; //导入方法依赖的package包/类
/**
 * Constructs a new trap information instance that contains the sending
 * agent, the community string, and the Protocol Data Unit.
 * 
 * @param agent
 *            The sending agent's address
 * @param community
 *            The community string from the SNMP packet.
 * @param pdu
 *            The encapsulated Protocol Data Unit.
 * @param trapProcessor The trap processor used to process the trap data
 * 
 */
public Snmp4JV2TrapInformation(InetAddress agent, String community, PDU pdu, TrapProcessor trapProcessor) {
    super(agent, community, trapProcessor);
    m_pdu = pdu;
    m_pduTypeString = PDU.getTypeString(m_pdu.getType());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:Snmp4JTrapNotifier.java


注:本文中的org.snmp4j.PDU.getTypeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。