HOME

com.ireasoning.protocol.snmp
Class SnmpV1Trap

java.lang.Object
  extended bycom.ireasoning.protocol.snmp.VarBindContainer
      extended bycom.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, serialVersionUID, TIMETICKS, UNSIGNED32, VARBIND
 
Fields inherited from interface com.ireasoning.protocol.Msg
ERROR_TYPE
 
Constructor Summary
SnmpV1Trap(SnmpOID enterprise)
          Constructs an 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 an 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
 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()
          Returns the value of IP address field of the trap
 int getSpecific()
          Returns the specific code of this trap.
 long getTimestamp()
          Returns the timestamp value (in hundredths of a second), 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"
 InetAddress getTrapSenderIpAddress()
          Returns the IP address associated with the received SNMP packet.
 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
 void setTrapSenderIpAddress(InetAddress addr)
          Sets the IP address associated with the received SNMP UDP packet
 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

See Also:
Constant Field Values

WARM_START_TRAP

public static final int WARM_START_TRAP
SnmpV1 trap type: warmStart

See Also:
Constant Field Values

LINK_DOWN_TRAP

public static final int LINK_DOWN_TRAP
SnmpV1 trap type: linkDown

See Also:
Constant Field Values

LINK_UP_TRAP

public static final int LINK_UP_TRAP
SnmpV1 trap type: linkUp

See Also:
Constant Field Values

AUTHENTICATION_FAILURE_TRAP

public static final int AUTHENTICATION_FAILURE_TRAP
SnmpV1 trap type: authenticationFailure

See Also:
Constant Field Values

EGPNEIGHBOR_LOSS_TRAP

public static final int EGPNEIGHBOR_LOSS_TRAP
SnmpV1 trap type: egpNeighborLoss

See Also:
Constant Field Values
Constructor Detail

SnmpV1Trap

public SnmpV1Trap(SnmpOID enterprise)
Constructs an 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 an 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 an SnmpV1Trap object
length - the number of bytes of data to be decoded
Returns:
decoded SnmpV1Trap object.
Throws:
SnmpDecodingException

encodeV1Trap

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

Parameters:
trap - SnmpV1Trap object
Throws:
SnmpEncodingException

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()
Returns the value of IP address field of the trap


getTrapSenderIpAddress

public InetAddress getTrapSenderIpAddress()
Returns the IP address associated with the received SNMP packet.

Note: It may be different from the return value of getIpAddress(), which is the IP address field contained in the SNMPv1 PDU


setTrapSenderIpAddress

public void setTrapSenderIpAddress(InetAddress addr)
Sets the IP address associated with the received SNMP UDP packet


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.

If the passed spec is not 0, generic will be set to be 6.

Parameters:
spec - The new specific identifier.

getTimestamp

public long getTimestamp()
Returns the timestamp value (in hundredths of a second), 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, in hundredths of a second.

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
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
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
Throws:
SnmpEncodingException

toString

public String toString()

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.