HOME

com.ireasoning.protocol.snmp
Class SnmpV1Trap

java.lang.Object
  |
  +--com.ireasoning.protocol.snmp.VarBindContainer
        |
        +--com.ireasoning.protocol.snmp.SnmpV1Trap
All Implemented Interfaces:
Msg, Serializable, SnmpDataType

public class SnmpV1Trap
extends VarBindContainer
implements SnmpDataType

This class represents SNMPv1 Trap message. SNMPv2c and SNMPv3 trap are represented by SnmpTrap class.

See Also:
SnmpTrap, Serialized Form

Field Summary
static int AUTHENTICATION_FAILURE_TRAP
          SnmpV1 trap type: authenticationFailure
static int COLD_START_TRAP
          SnmpV1 trap type: coldStart
static int EGPNEIGHBOR_LOSS_TRAP
          SnmpV1 trap type: egpNeighborLoss
static int LINK_DOWN_TRAP
          SnmpV1 trap type: linkDown
static int LINK_UP_TRAP
          SnmpV1 trap type: linkUp
static int WARM_START_TRAP
          SnmpV1 trap type: 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, TIMETICKS, UNSIGNED32, VARBIND
 
Fields inherited from interface com.ireasoning.protocol.Msg
ERROR_TYPE
 
Constructor Summary
SnmpV1Trap(SnmpOID enterprise)
          Constructs a SnmpV1Trap object with passed enterprise value, sets agent address to local ip address
SnmpV1Trap(SnmpV1Trap trap)
          Makes a copy of passed object
SnmpV1Trap(String enterprise)
          Constructs a SnmpV1Trap object with passed enterprise value, sets agent address to local ip address
 
Method Summary
 SnmpDataType copy()
          Makes a copy of itself
static SnmpV1Trap decodeV1Trap(byte[] data, int length)
          Constructs a SnmpV1Trap object based on passed byte array
 int encode(com.ireasoning.protocol.snmp.SnmpEncoder encoder)
          For internal use
static byte[] encodeV1Trap(SnmpV1Trap trap)
          Encodes passed SnmpV1Trap object to byte array
 SnmpIpAddress getAgentIpAddress()
          Deprecated. use getIpAddress() instead
 String getCommunity()
          Returns the community name contained in this object
 SnmpOID getEnterprise()
          Returns the enterpise OID.
 int getGeneric()
          Returns the generic-trap field of this trap.
 String getGenericString()
          Returns the string representation of generic-trap field.
 SnmpIpAddress getIpAddress()
          Gets trap sender's IP address.
 int getSpecific()
          Returns the specific code of this trap.
 long getTimestamp()
          Returns the timestamp value, which is time elapsed between the last (re)initialization of the network entity and the generation of the trap
 String getTimestampString()
          Returns the string format of timestamp value, such as "10 hours 12 minutes"
 int getType()
          Returns SnmpConst.V1TRAP
 String getTypeString()
          Returns "V1Trap"
 SnmpVarBind[] getVariables()
          Returns the variable bindings contained in this trap object
 void setCommunity(String community)
          Sets new community string
 void setEnterprise(SnmpOID id)
          Sets the enterprise identifier .
 void setEnterprise(String id)
          Sets the enterprise identifier .
 void setGeneric(int generic)
          Sets the generic-trap field of this trap.
 void setIpAddress(InetAddress addr)
          Sets the trap sender's IP address.
 void setIpAddress(SnmpIpAddress addr)
          Sets the trap sender's IP address.
 void setIpAddress(String addr)
          Sets the trap sender's IP address.
 void setSpecific(int spec)
          Sets the specific code for this trap.
 void setTimestamp(long timestamp)
          Sets the timestamp
 String toString()
           
 SnmpTrap toV2Trap()
          Converts to SNMPv2c trap according to RFC 2576 and RFC 1908.
 SnmpTrap toV2Trap(boolean isProxy)
          Converts to SNMPv2c trap according to RFC 2576 and RFC 1908
 
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

COLD_START_TRAP

public static final int COLD_START_TRAP
SnmpV1 trap type: coldStart

WARM_START_TRAP

public static final int WARM_START_TRAP
SnmpV1 trap type: warmStart

LINK_DOWN_TRAP

public static final int LINK_DOWN_TRAP
SnmpV1 trap type: linkDown

LINK_UP_TRAP

public static final int LINK_UP_TRAP
SnmpV1 trap type: linkUp

AUTHENTICATION_FAILURE_TRAP

public static final int AUTHENTICATION_FAILURE_TRAP
SnmpV1 trap type: authenticationFailure

EGPNEIGHBOR_LOSS_TRAP

public static final int EGPNEIGHBOR_LOSS_TRAP
SnmpV1 trap type: egpNeighborLoss
Constructor Detail

SnmpV1Trap

public SnmpV1Trap(SnmpOID enterprise)
Constructs a SnmpV1Trap object with passed enterprise value, sets agent address to local ip address
Parameters:
enterprise - the enterprise identifier value of this object

SnmpV1Trap

public SnmpV1Trap(String enterprise)
Constructs a SnmpV1Trap object with passed enterprise value, sets agent address to local ip address
Parameters:
enterprise - the enterprise identifier value of this object

SnmpV1Trap

public SnmpV1Trap(SnmpV1Trap trap)
Makes a copy of passed object
Method Detail

decodeV1Trap

public static SnmpV1Trap decodeV1Trap(byte[] data,
                                      int length)
                               throws SnmpDecodingException
Constructs a SnmpV1Trap object based on passed byte array
Parameters:
data - byte array representation of a SnmpV1Trap object
length - the number of bytes of data to be decoded
Returns:
decoded SnmpV1Trap object.
Throws:
raised - if passed data is corrupted

encodeV1Trap

public static byte[] encodeV1Trap(SnmpV1Trap trap)
                           throws SnmpEncodingException
Encodes passed SnmpV1Trap object to byte array
Parameters:
trap - SnmpV1Trap object

getEnterprise

public SnmpOID getEnterprise()
Returns the enterpise OID.

setEnterprise

public void setEnterprise(SnmpOID id)
Sets the enterprise identifier .

setEnterprise

public void setEnterprise(String id)
Sets the enterprise identifier .

getIpAddress

public SnmpIpAddress getIpAddress()
Gets trap sender's IP address.

getAgentIpAddress

public SnmpIpAddress getAgentIpAddress()
Deprecated. use getIpAddress() instead

Gets trap sender's IP address.

setIpAddress

public void setIpAddress(SnmpIpAddress addr)
Sets the trap sender's IP address.
Parameters:
addr - ip address.

setIpAddress

public void setIpAddress(String addr)
Sets the trap sender's IP address.
Parameters:
addr - ip address.

setIpAddress

public void setIpAddress(InetAddress addr)
Sets the trap sender's IP address.
Parameters:
addr - ip address.

getGeneric

public int getGeneric()
Returns the generic-trap field of this trap.

getGenericString

public String getGenericString()
Returns the string representation of generic-trap field. Or null if no corresponding generic string

setGeneric

public void setGeneric(int generic)
Sets the generic-trap field of this trap.
Parameters:
generic - The new generic code for the trap. One of the following:
 0 -- cold start
 1 -- warm start
 2 -- link down
 3 -- link up
 4 -- authentification failure
 5 -- EGP neighbor loss
 6 -- enterprise specific
 

getSpecific

public int getSpecific()
Returns the specific code of this trap.

setSpecific

public void setSpecific(int spec)
Sets the specific code for this trap.
Parameters:
spec - The new specific identifier.

getTimestamp

public long getTimestamp()
Returns the timestamp value, which is time elapsed between the last (re)initialization of the network entity and the generation of the trap

setTimestamp

public void setTimestamp(long timestamp)
Sets the timestamp
Parameters:
timestamp - The timeticks for the trap.

getTimestampString

public String getTimestampString()
Returns the string format of timestamp value, such as "10 hours 12 minutes"

getCommunity

public String getCommunity()
Returns the community name contained in this object
Returns:
the community name

setCommunity

public void setCommunity(String community)
Sets new community string

getVariables

public SnmpVarBind[] getVariables()
Returns the variable bindings contained in this trap object

getType

public int getType()
Returns SnmpConst.V1TRAP
Specified by:
getType in interface SnmpDataType
Following copied from interface: com.ireasoning.protocol.snmp.SnmpDataType
Returns:
the object data type

getTypeString

public String getTypeString()
Returns "V1Trap"
Specified by:
getTypeString in interface SnmpDataType

toV2Trap

public SnmpTrap toV2Trap()
Converts to SNMPv2c trap according to RFC 2576 and RFC 1908. If the translation is being performed by a proxy, toV2Trap(true) method should be used instead.

toV2Trap

public SnmpTrap toV2Trap(boolean isProxy)
Converts to SNMPv2c trap according to RFC 2576 and RFC 1908
Parameters:
isProxy - true if it's performed by a proxy, three more variable bindings, { snmpTrapAddress.0, snmpTrapCommunity.0, snmpTrapEnterprise.0}, will be added

copy

public SnmpDataType copy()
Description copied from interface: SnmpDataType
Makes a copy of itself
Specified by:
copy in interface SnmpDataType
Following copied from interface: com.ireasoning.protocol.snmp.SnmpDataType
Returns:
a deep copy of this object

encode

public int encode(com.ireasoning.protocol.snmp.SnmpEncoder encoder)
           throws SnmpEncodingException
Description copied from interface: SnmpDataType
For internal use
Specified by:
encode in interface SnmpDataType

toString

public String toString()
Overrides:
toString in class Object

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.