OpenNMS API 1.2.3

org.opennms.protocols.snmp
Class SnmpPduTrap

java.lang.Object
  extended byorg.opennms.protocols.snmp.SnmpPduTrap
All Implemented Interfaces:
java.lang.Cloneable, SnmpSyntax

public class SnmpPduTrap
extends java.lang.Object
implements SnmpSyntax, java.lang.Cloneable

The SnmpPduTrap object represents the SNMP Protoco Data Unit for an SNMP Trap. The PDU format for a TRAP is not similar to the PDU format for other V1 types, and thus the SnmpPduTrap object does not extend the SnmpPduPacket class.

Version:
1.1.1.1
Author:
Brian Weaver , OpenNMS

Field Summary
static int GenericAuthenticationFailure
          Generic trap type: authentication-failure.
static int GenericColdStart
          Generic trap type: cold start.
static int GenericEgpNeighborLoss
          Generic trap type: EGP Neighbor Loss.
static int GenericEnterpriseSpecific
          Generic trap type: Enterprise Specific.
static int GenericLinkDown
          Generic trap type: link down.
static int GenericLinkUp
          Generic trap type: link up.
static int GenericWarmStart
          Generic trap type: warm start.
private  SnmpIPAddress m_agentAddr
          The IP Address of the remote agent sending the trap.
private  SnmpObjectId m_enterprise
          The trap's enterprise object identifier
private  int m_generic
          The generic trap number.
private  int m_specific
          The specific trap number.
private  long m_tstamp
          The timestamp for when the trap occured.
private  java.util.ArrayList m_variables
          The list of variable bindings for the trap.
static int TRAP
          The ASN.1 type for the SNMPv1 Trap.
 
Constructor Summary
  SnmpPduTrap()
          Constructs a new SnmpPduTrap with the default values.
protected SnmpPduTrap(SnmpPduTrap second)
          Constructs a new trap pdu that is identical to the passed pdu.
 
Method Summary
 void addVarBind(SnmpVarBind vb)
          Adds a new variable to the protocol data unit.
 void addVarBindAt(int ndx, SnmpVarBind vb)
          Adds a variable at a specific index.
 java.lang.Object clone()
           
 int decodeASN(byte[] buf, int offset, AsnEncoder encoder)
          Decodes the protocol data unit from the passed buffer.
 SnmpSyntax duplicate()
          Creates a duplicate (in memory) object of the caller.
 int encodeASN(byte[] buf, int offset, AsnEncoder encoder)
          Encodes the protocol data unit using the passed encoder and stores the results in the passed buffer.
 SnmpIPAddress getAgentAddress()
          Gets the remote agent's IP address.
 SnmpObjectId getEnterprise()
          Used to get the enterpise identifier of the trap.
 int getGeneric()
          Returns the generic code for the trap.
 int getLength()
          Returns the number of variables contained in the PDU.
 int getSpecific()
          Returns the specific code for the trap.
 long getTimeStamp()
          Returns the timeticks from the trap.
 SnmpVarBind getVarBindAt(int ndx)
          Retrieves the variable at the specific index.
 SnmpVarBind removeVarBindAt(int ndx)
          Removes the variable as defined by the index
 void setAgentAddress(SnmpIPAddress addr)
          Sets the remote agent's IP address.
 void setEnterprise(SnmpObjectId id)
          Sets the enterprise identifier for the trap.
 void setEnterprise(java.lang.String id)
          Sets the enterprise identifier for the trap.
 void setGeneric(int generic)
          Sets the generic code for the trap.
 void setSpecific(int spec)
          Sets the specific type for the trap.
 void setTimeStamp(long ts)
          Set's the timeticks in the trap.
 void setVarBindAt(int ndx, SnmpVarBind vb)
          Sets the specific variable at the requested location.
 SnmpVarBind[] toVarBindArray()
          Returns a list of all the variables managed by this protocol data unit.
 byte typeId()
          Returns the PDU commmand in an 8-bit format
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_enterprise

private SnmpObjectId m_enterprise
The trap's enterprise object identifier


m_agentAddr

private SnmpIPAddress m_agentAddr
The IP Address of the remote agent sending the trap.


m_generic

private int m_generic
The generic trap number.


m_specific

private int m_specific
The specific trap number.


m_tstamp

private long m_tstamp
The timestamp for when the trap occured. This should be the sysUpTime from the remote system.


m_variables

private java.util.ArrayList m_variables
The list of variable bindings for the trap.


TRAP

public static final int TRAP
The ASN.1 type for the SNMPv1 Trap.

See Also:
Constant Field Values

GenericColdStart

public static final int GenericColdStart
Generic trap type: cold start.

See Also:
Constant Field Values

GenericWarmStart

public static final int GenericWarmStart
Generic trap type: warm start.

See Also:
Constant Field Values

GenericLinkDown

public static final int GenericLinkDown
Generic trap type: link down.

See Also:
Constant Field Values

GenericLinkUp

public static final int GenericLinkUp
Generic trap type: link up.

See Also:
Constant Field Values

GenericAuthenticationFailure

public static final int GenericAuthenticationFailure
Generic trap type: authentication-failure.

See Also:
Constant Field Values

GenericEgpNeighborLoss

public static final int GenericEgpNeighborLoss
Generic trap type: EGP Neighbor Loss.

See Also:
Constant Field Values

GenericEnterpriseSpecific

public static final int GenericEnterpriseSpecific
Generic trap type: Enterprise Specific.

See Also:
Constant Field Values
Constructor Detail

SnmpPduTrap

public SnmpPduTrap()
Constructs a new SnmpPduTrap with the default values.


SnmpPduTrap

protected SnmpPduTrap(SnmpPduTrap second)
Constructs a new trap pdu that is identical to the passed pdu.

Parameters:
second - The object to copy.
Method Detail

getEnterprise

public SnmpObjectId getEnterprise()
Used to get the enterpise identifier of the trap.


setEnterprise

public void setEnterprise(SnmpObjectId id)
Sets the enterprise identifier for the trap.

Parameters:
id - The object identifier.

setEnterprise

public void setEnterprise(java.lang.String id)
Sets the enterprise identifier for the trap. The string must be in the format of a dotted decimal object identifier.

Parameters:
id - The new identifier.

getAgentAddress

public SnmpIPAddress getAgentAddress()
Gets the remote agent's IP address.


setAgentAddress

public void setAgentAddress(SnmpIPAddress addr)
Sets the remote agent's IP address.

Parameters:
addr - The remote agent's ip address.

getGeneric

public int getGeneric()
Returns the generic code for the trap.


setGeneric

public void setGeneric(int generic)
Sets the generic code for the trap.

Parameters:
generic - The new generic code for the trap.

getSpecific

public int getSpecific()
Returns the specific code for the trap.


setSpecific

public void setSpecific(int spec)
Sets the specific type for the trap.

Parameters:
spec - The new specific identifier.

getTimeStamp

public long getTimeStamp()
Returns the timeticks from the trap.


setTimeStamp

public void setTimeStamp(long ts)
Set's the timeticks in the trap.

Parameters:
ts - The timeticks for the trap.

getLength

public int getLength()
Returns the number of variables contained in the PDU.


addVarBind

public void addVarBind(SnmpVarBind vb)
Adds a new variable to the protocol data unit. The variable is added at the end of the list

Parameters:
vb - The new variable to add

addVarBindAt

public void addVarBindAt(int ndx,
                         SnmpVarBind vb)
Adds a variable at a specific index.

Parameters:
ndx - The index of the variable
vb - The new variable.

getVarBindAt

public SnmpVarBind getVarBindAt(int ndx)
Retrieves the variable at the specific index.

Parameters:
ndx - The index of the variable
Returns:
The variable at the specified index

setVarBindAt

public void setVarBindAt(int ndx,
                         SnmpVarBind vb)
Sets the specific variable at the requested location.

Parameters:
ndx - The location to set
vb - The new variable

removeVarBindAt

public SnmpVarBind removeVarBindAt(int ndx)
Removes the variable as defined by the index

Parameters:
ndx - The index of the variable to remove
Returns:
The removed variable

toVarBindArray

public SnmpVarBind[] toVarBindArray()
Returns a list of all the variables managed by this protocol data unit.

Returns:
An array of the internal variable.

typeId

public byte typeId()
Returns the PDU commmand in an 8-bit format

Specified by:
typeId in interface SnmpSyntax
Returns:
The pdu command

encodeASN

public int encodeASN(byte[] buf,
                     int offset,
                     AsnEncoder encoder)
              throws AsnEncodingException
Encodes the protocol data unit using the passed encoder and stores the results in the passed buffer. An exception is thrown if an error occurs with the encoding of the information.

Specified by:
encodeASN in interface SnmpSyntax
Parameters:
buf - The buffer to write the encoded information.
offset - The offset to start writing information
encoder - The encoder object.
Returns:
The offset of the byte immediantly after the last encoded byte.
Throws:
AsnEncodingException - Thrown if the encoder finds an error in the buffer.

decodeASN

public int decodeASN(byte[] buf,
                     int offset,
                     AsnEncoder encoder)
              throws AsnDecodingException
Decodes the protocol data unit from the passed buffer. If an error occurs during the decoding sequence then an AsnDecodingException is thrown by the method. The value is decoded using the AsnEncoder passed to the object.

Specified by:
decodeASN in interface SnmpSyntax
Parameters:
buf - The encode buffer
offset - The offset byte to begin decoding
encoder - The decoder object.
Returns:
The index of the byte immediantly after the last decoded byte of information.
Throws:
AsnDecodingException - Thrown by the encoder if an error occurs trying to decode the data buffer.

duplicate

public SnmpSyntax duplicate()
Description copied from interface: SnmpSyntax
Creates a duplicate (in memory) object of the caller. Similar to the clone() method.

Specified by:
duplicate in interface SnmpSyntax

clone

public java.lang.Object clone()

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.