HOME

com.ireasoning.protocol.snmp
Class SnmpV2Notification

java.lang.Object
  extended bycom.ireasoning.protocol.snmp.VarBindContainer
      extended bycom.ireasoning.protocol.snmp.SnmpPdu
          extended bycom.ireasoning.protocol.snmp.SnmpV2Notification
All Implemented Interfaces:
Msg, Serializable, SnmpDataType
Direct Known Subclasses:
SnmpInform, SnmpTrap

public abstract class SnmpV2Notification
extends SnmpPdu

This class represents SNMPv2 and SNMPv3 Notification type object, including trap and inform requests. SNMPv1 trap is represented by SnmpV1Trap class.

See Also:
SnmpV1Trap, Serialized Form

Field Summary
static SnmpOID AUTHENTICATION_FAILURE_TRAP_OID
          SNMPv2c warmStart trap oid: authenticationFailure
static SnmpOID COLD_START_TRAP_OID
          SNMPv2c coldStart trap oid
static SnmpOID EGPNEIGHBOR_LOSS_OID
          SNMPv2c warmStart trap oid: egpNeighborLoss
static SnmpOID LINK_DOWN_TRAP_OID
          SNMPv2c warmStart trap oid: linkDown
static SnmpOID LINK_UP_TRAP_OID
          SNMPv2c warmStart trap oid: linkUp
static SnmpOID SNMP_TRAP_ENTERPRISE_OID
          snmpTrapEnterprise (".1.3.6.1.6.3.1.1.4.3.0")
static SnmpOID SNMP_TRAP_OID
          snmpTrapOID (".1.3.6.1.6.3.1.1.4.1.0")
static SnmpOID SYS_UP_TIME_OID
          sysUpTime oid (".1.3.6.1.2.1.1.3.0")
static SnmpOID WARM_START_TRAP_OID
          SNMPv2c warmStart trap oid: warmStart
 
Fields inherited from interface com.ireasoning.protocol.snmp.SnmpDataType
BITS, BITSTRING, COUNTER32, COUNTER64, END_OF_MIB_VIEW, END_OF_MIB_VIEW_OBJECT, GAUGE32, INTEGER, IPADDRESS, NO_SUCH_INSTANCE, NO_SUCH_INSTANCE_OBJECT, NO_SUCH_OBJECT, NO_SUCH_OBJECT_OBJECT, NULL, OCTETSTRING, OID, OPAQUE, PDU, SEQUENCE, SEQUENCEOF, serialVersionUID, TIMETICKS, UNSIGNED32, VARBIND
 
Fields inherited from interface com.ireasoning.protocol.Msg
ERROR_TYPE
 
Constructor Summary
SnmpV2Notification(long sysUpTime, SnmpOID snmpTrapOID)
          Creates an SnmpV2Notification object using passed parameters
SnmpV2Notification(long sysUpTime, SnmpOID snmpTrapOID, SnmpVarBind[] varbinds)
          Creates an SnmpV2Notification object using passed parameters
SnmpV2Notification(SnmpV2Notification notif)
          Makes a copy of passed SnmpV2Notification object
 
Method Summary
 String getIpAddress()
          Returns the trap sender's IP address
 SnmpVarBind[] getObjects()
          Returns the OBJECTS variable bindings as defined in MIB.
 SnmpOID getSnmpTrapOID()
          Returns the snmpTrapOID.0 value contained in this trap.
 long getSysUpTime()
          Returns the sysUpTime value contained in this trap
 String getSysUpTimeString()
          Returns the string representation of sysUpTime value contained in this trap, such as "10 hours 5 minutes 20 seconds".
 void setIpAddress(InetAddress addr)
          Sets trap sender's ip address
 void setIpAddress(String ipAddr)
          Sets trap sender's ip address.
 void setSysUpTime(long time)
          Sets a new sysUpTime
 String toString()
          Returns a string representation of this trap object
 SnmpV1Trap toV1Trap()
          Converts this v2 trap object to v1 trap according to RFC 2576 and RFC 2089.
 SnmpV1Trap toV1Trap(String ipAddress)
          Converts this v2 trap object to v1 trap according to RFC 2576 and RFC 2089
 
Methods inherited from class com.ireasoning.protocol.snmp.SnmpPdu
copy, decodePdu, encode, encodePdu, getCommand, getCommunity, getContextEngineID, getContextName, getDestinationAddress, getDestinationPort, getErrorIndex, getErrorStatus, getErrorStatusString, getErrorStatusString, getErrorString, getMaxRepetitions, getNonRepeaters, getRequestID, getSnmpV3MsgHeader, getSnmpv3MsgSecurityParameters, getSourceAddress, getSourcePort, getType, getTypeString, getVersion, hasMore, isSnmpV3AuthenticationFailed, setCommand, setCommunity, setContextEngineID, setContextName, setDestinationAddress, setDestinationPort, setErrorIndex, setErrorStatus, setHasMore, setMaxRepetitions, setNonRepeaters, setOID, setOID, setOIDs, setOIDs, setRequestID, setSourceAddress, setSourcePort, setVersion
 
Methods inherited from class com.ireasoning.protocol.snmp.VarBindContainer
addVarBind, addVarBinds, addVarBinds, getFirstVarBind, getLastVarBind, getVarBind, getVarBindCount, getVarBinds, removeAllVarBinds, removeAllVarBinds, removeVarBind, setVarBinds, setVarBinds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ireasoning.protocol.snmp.SnmpDataType
equals, hashCode
 

Field Detail

SYS_UP_TIME_OID

public static final SnmpOID SYS_UP_TIME_OID
sysUpTime oid (".1.3.6.1.2.1.1.3.0")


SNMP_TRAP_OID

public static final SnmpOID SNMP_TRAP_OID
snmpTrapOID (".1.3.6.1.6.3.1.1.4.1.0")


SNMP_TRAP_ENTERPRISE_OID

public static final SnmpOID SNMP_TRAP_ENTERPRISE_OID
snmpTrapEnterprise (".1.3.6.1.6.3.1.1.4.3.0")


COLD_START_TRAP_OID

public static final SnmpOID COLD_START_TRAP_OID
SNMPv2c coldStart trap oid


WARM_START_TRAP_OID

public static final SnmpOID WARM_START_TRAP_OID
SNMPv2c warmStart trap oid: warmStart


LINK_DOWN_TRAP_OID

public static final SnmpOID LINK_DOWN_TRAP_OID
SNMPv2c warmStart trap oid: linkDown


LINK_UP_TRAP_OID

public static final SnmpOID LINK_UP_TRAP_OID
SNMPv2c warmStart trap oid: linkUp


AUTHENTICATION_FAILURE_TRAP_OID

public static final SnmpOID AUTHENTICATION_FAILURE_TRAP_OID
SNMPv2c warmStart trap oid: authenticationFailure


EGPNEIGHBOR_LOSS_OID

public static final SnmpOID EGPNEIGHBOR_LOSS_OID
SNMPv2c warmStart trap oid: egpNeighborLoss

Constructor Detail

SnmpV2Notification

public SnmpV2Notification(long sysUpTime,
                          SnmpOID snmpTrapOID,
                          SnmpVarBind[] varbinds)
Creates an SnmpV2Notification object using passed parameters

Parameters:
sysUpTime - the sysUpTime value
snmpTrapOID - the snmpTrapOID value
varbinds - the other variable bindings of this trap object

SnmpV2Notification

public SnmpV2Notification(long sysUpTime,
                          SnmpOID snmpTrapOID)
Creates an SnmpV2Notification object using passed parameters

Parameters:
sysUpTime - the sysUpTime value
snmpTrapOID - the snmpTrapOID value

SnmpV2Notification

public SnmpV2Notification(SnmpV2Notification notif)
Makes a copy of passed SnmpV2Notification object

Method Detail

getSysUpTime

public long getSysUpTime()
Returns the sysUpTime value contained in this trap

Returns:
sysUpTime value, in 10 milliseconds.

setSysUpTime

public void setSysUpTime(long time)
Sets a new sysUpTime


getSysUpTimeString

public String getSysUpTimeString()
Returns the string representation of sysUpTime value contained in this trap, such as "10 hours 5 minutes 20 seconds".

Returns:
string representation of sysUpTime value, e.g. "10 hours 5 minutes 20 seconds"

getSnmpTrapOID

public SnmpOID getSnmpTrapOID()
Returns the snmpTrapOID.0 value contained in this trap. Or null if the number of variable bindings is less than 2.


getObjects

public SnmpVarBind[] getObjects()
Returns the OBJECTS variable bindings as defined in MIB.
For example,
  snaNodeActFailTrap NOTIFICATION-TYPE
     OBJECTS  { snaNodeOperName,
                snaNodeOperState,
                snaNodeOperActFailureReason }
     STATUS  current
     DESCRIPTION
             "This trap indicates a Node activation failure.
             The value of snaNodeOperState indicates the current
             state after the activation attempt.
             The value of snaNodeOperActFailureReason indicates
             the failure reason."
     ::=  { snaNodeTraps 2 }
 
In this NOTIFICATION object, OBJECTS are { snaNodeOperName, snaNodeOperState, snaNodeOperActFailureReason }, this method will returns variable bindings corresponding to those objects.
Note: sysUpTime and snmpTrapOID are not included in the returned variable bindings array.


getIpAddress

public String getIpAddress()
Returns the trap sender's IP address

Overrides:
getIpAddress in class SnmpPdu
See Also:
SnmpPdu.getSourceAddress()

setIpAddress

public void setIpAddress(String ipAddr)
Sets trap sender's ip address.

Note:
There's no IP address field in SNMPv2 TRAP/INFORM PDU. This method won't change the IP address of the UDP packet.

Overrides:
setIpAddress in class SnmpPdu
See Also:
SnmpPdu.setSourceAddress(java.lang.String)

setIpAddress

public void setIpAddress(InetAddress addr)
Sets trap sender's ip address

Note:
There's no IP address field in SNMPv2 TRAP/INFORM PDU. This method won't change the IP address of the UDP packet.


toString

public String toString()
Returns a string representation of this trap object

Overrides:
toString in class SnmpPdu

toV1Trap

public SnmpV1Trap toV1Trap()
Converts this v2 trap object to v1 trap according to RFC 2576 and RFC 2089. Use sender's IP address as the value of ip address field of SNMPv1 trap. If the translation occurs within a proxy application, the proxy must attempt to extract the original source of the notification from the variable-bindings. If the SNMPv2 variable-bindings contains a variable binding whose name is snmpTrapAddress.0, the agent-addr parameter SHALL be set to the value of that variable binding.

Returns:
V1 trap object

toV1Trap

public SnmpV1Trap toV1Trap(String ipAddress)
Converts this v2 trap object to v1 trap according to RFC 2576 and RFC 2089

Parameters:
ipAddress - notification originator's IP address
Returns:
V1 trap object

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.