SNMP Stack 5_1

uk.co.westhawk.snmp.stack
Class TrapPduv1

java.lang.Object
  |
  +--java.util.Observable
        |
        +--uk.co.westhawk.snmp.stack.Pdu
              |
              +--uk.co.westhawk.snmp.stack.TrapPduv1
Direct Known Subclasses:
OneTrapPduv1, PassiveTrapPduv1

public class TrapPduv1
extends Pdu

This class represents the ASN SNMPv1 Trap PDU object. See RFC1157-SNMP.

Note that the SNMPv1 Trap PDU is the only PDU with a different PDU format. It has additional fields like enterprise, ipAddress, genericTrap, specificTrap and timeTicks.

Version:
$Revision: 3.12 $ $Date: 2006/03/23 14:54:10 $
Author:
Birgit Arkesteijn
See Also:
TrapPduv2

Field Summary
 
Fields inherited from class uk.co.westhawk.snmp.stack.Pdu
added, answered, context, encodedPacket, errind, errstat, msg_type, reqVarbinds, respVarbinds, snmpv3MsgId
 
Constructor Summary
TrapPduv1(SnmpContext con)
          Constructor.
TrapPduv1(SnmpContextPool con)
          Constructor.
 
Method Summary
 java.lang.String getEnterprise()
          Returns the type of object generating the trap.
 int getGenericTrap()
          Returns the generic trap type.
 java.lang.String getGenericTrapString()
          Returns the string representation of the generic trap.
 byte[] getIpAddress()
          Returns the IP Address of the object generating the trap.
 int getSpecificTrap()
          Returns the specific trap code.
 long getTimeTicks()
          Returns the sysUpTime of the agent.
protected  boolean isExpectingResponse()
          Returns that this type of PDU is not expecting a response.
protected  void new_value(int n, varbind res)
          Has no meaning, since there is not response.
 boolean send()
          Sends the TrapPduv1.
 void setEnterprise(java.lang.String var)
          Sets the type of object generating the trap.
 void setGenericTrap(int var)
          Sets the generic trap type.
 void setIpAddress(byte[] var)
          Sets the IP Address of the object generating the trap.
 void setSpecificTrap(int var)
          Sets the specific trap code.
 void setTimeTicks(long var)
          Sets the sysUpTime of the agent.
protected  void tell_them()
          Has no meaning, since there is not response.
 java.lang.String toString()
          Returns the string representation of this object.
 
Methods inherited from class uk.co.westhawk.snmp.stack.Pdu
addOid, addOid, addOid, addOid, addOid, addToTrans, getContext, getErrorIndex, getErrorStatus, getErrorStatusString, getMsgType, getReqId, getRequestVarbinds, getResponseVarbinds, isTimedOut, notifyObservers, printVars, send, send, sendme, setErrorIndex, setErrorStatus, setErrorStatus, setMsgType, setRetryIntervals, toString, waitForSelf
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TrapPduv1

public TrapPduv1(SnmpContext con)
Constructor.

Parameters:
con - The context (v1) of the TrapPduv1
See Also:
SnmpContext

TrapPduv1

public TrapPduv1(SnmpContextPool con)
Constructor.

Parameters:
con - The context pool (v1) of the TrapPduv1
See Also:
SnmpContext
Method Detail

setEnterprise

public void setEnterprise(java.lang.String var)
Sets the type of object generating the trap. This parameter is based on the sysObjectId.


getEnterprise

public java.lang.String getEnterprise()
Returns the type of object generating the trap.


setIpAddress

public void setIpAddress(byte[] var)
Sets the IP Address of the object generating the trap.


getIpAddress

public byte[] getIpAddress()
Returns the IP Address of the object generating the trap.


setGenericTrap

public void setGenericTrap(int var)
Sets the generic trap type. By default the warmStart is sent.

See Also:
SnmpConstants.SNMP_TRAP_COLDSTART, SnmpConstants.SNMP_TRAP_WARMSTART, SnmpConstants.SNMP_TRAP_LINKDOWN, SnmpConstants.SNMP_TRAP_LINKUP, SnmpConstants.SNMP_TRAP_AUTHFAIL, SnmpConstants.SNMP_TRAP_EGPNEIGHBORLOSS, SnmpConstants.SNMP_TRAP_ENTERPRISESPECIFIC

getGenericTrap

public int getGenericTrap()
Returns the generic trap type.


getGenericTrapString

public java.lang.String getGenericTrapString()
Returns the string representation of the generic trap.

Returns:
the generic trap string
See Also:
getGenericTrap()

setSpecificTrap

public void setSpecificTrap(int var)
Sets the specific trap code.


getSpecificTrap

public int getSpecificTrap()
Returns the specific trap code.


setTimeTicks

public void setTimeTicks(long var)
Sets the sysUpTime of the agent.

RFC1155-SMI: TimeTicks:
This application-wide type represents a non-negative integer which counts the time in hundredths of a second since some epoch. When object types are defined in the MIB which use this ASN.1 type, the description of the object type identifies the reference epoch.


getTimeTicks

public long getTimeTicks()
Returns the sysUpTime of the agent.


send

public boolean send()
             throws java.io.IOException,
                    PduException
Sends the TrapPduv1. Since the Trap v1 PDU has a different format (sigh), a different encoding message has to be called. Note that all properties of the context have to be set before this point.

Overrides:
send in class Pdu
java.io.IOException
PduException

toString

public java.lang.String toString()
Returns the string representation of this object.

Overrides:
toString in class Pdu
Returns:
The string of the PDU

new_value

protected void new_value(int n,
                         varbind res)
Has no meaning, since there is not response.

Overrides:
new_value in class Pdu

tell_them

protected void tell_them()
Has no meaning, since there is not response.

Overrides:
tell_them in class Pdu

isExpectingResponse

protected boolean isExpectingResponse()
Returns that this type of PDU is not expecting a response. This method is used in AbstractSnmpContext to help determine whether or not to start a thread that listens for a response when sending this PDU. The default is false.

Overrides:
isExpectingResponse in class Pdu
Returns:
true if a response is expected, false if not.
Since:
4_14

SNMP Stack 5_1