|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.management.snmp.agent.SnmpTrap
public class SnmpTrap
This class represents an SNMP trap. It is not protocol-dependent.
Once created, any SNMP trap can be sent in either SNMP V1, V2 or V3.
SNMP traps use a SnmpAdaptorServer
to send,
which you must provide. (SnmpAdaptorServer
implements the notification dispatching interface).
An instance of SnmpTrap can be reused multiple time with the same parameters.
Field Summary | |
---|---|
static SnmpOid |
authenticationFailureOid
authenticationFailure Oid as defined in RFC 1907. |
static SnmpOid |
coldStartOid
coldStart Oid as defined in RFC 1907. |
static SnmpOid |
egpNeighborLossOid
egpNeighborLoss Oid as defined in RFC 1907. |
static SnmpOid |
linkDownOid
linkDown Oid as defined in RFC 1907. |
static SnmpOid |
linkUpOid
linkUp Oid as defined in RFC 1907. |
static SnmpOid |
snmpTrapAddressOid
snmpTrapAddress Oid as defined in RFC 2576. |
static SnmpOid |
snmpTrapCommunityOid
snmpTrapCommunity Oid as defined in RFC 2576. |
static SnmpOid |
snmpTrapEnterpriseOid
snmpTrapEnterprise Oid as defined in RFC 1907. |
static SnmpOid |
snmpTrapOid
snmpTrapOid Oid as defined in RFC 1907. |
static SnmpOid |
snmpTrapsOid
snmpTraps Oid as defined in RFC 1907. |
static SnmpOid |
snmpTrapSysUpTimeOid
snmpSysUpTime Oid as defined in RFC 1907. |
static SnmpOid |
warmStartOid
warmStart Oid as defined in RFC 1907. |
Constructor Summary | |
---|---|
SnmpTrap(InetAddress addr,
String cs,
int gen,
int specific,
SnmpVarBindList varBindList)
Initializes this SNMP trap with SNMP V1 style parameters. |
|
SnmpTrap(InetAddress addr,
String cs,
SnmpOid trapOid,
SnmpVarBindList varBindList)
Initializes this SNMP trap with SNMP V2 style parameters. |
|
SnmpTrap(int gen,
int specific,
SnmpVarBindList varBindList)
Initializes this SNMP trap with SNMP V1 style parameters |
|
SnmpTrap(SnmpOid trapOid,
SnmpVarBindList varBindList)
Initializes this SNMP trap with SNMP V2 style parameters. |
|
SnmpTrap(SnmpPduRequest trap)
Initializes this SNMP trap with an SNMP request PDU. |
|
SnmpTrap(SnmpPduTrap trap)
Initializes this SNMP trap with an SNMP V1 trap PDU. |
|
SnmpTrap(SnmpScopedPduRequest scopedTrap)
Initializes this SNMP trap with an SNMP V3 scoped PDU. |
Method Summary | |
---|---|
SnmpPdu |
getPdu()
If the trap has been created with a PDU (SNMP V1 / V2 or V3), the received PDU is returned. |
InetAddress |
getSourceAddress()
If the trap has been created with a PDU (SNMP V1 / V2 or V3), the source address located in this PDU is returned. |
boolean |
isOriginatorWay()
By default a trap is sent as a notification originator. |
boolean |
isProxyWay()
By default a trap is sent as a notification originator. |
void |
sendAsNotificationOriginator()
By default a trap is sent as a notification originator. |
void |
sendAsProxy()
By default a trap is sent as a notification originator. |
void |
sendV1(SnmpAdaptorServer server)
Send this trap. |
void |
sendV2(SnmpAdaptorServer server)
Send as a V2 trap. |
void |
sendV3(SnmpV3AdaptorServer server)
Send as a V3 trap. |
void |
sendV3Usm(SnmpV3AdaptorServer server,
String principal,
int securityLevel,
String contextName)
Send as a V3 trap. |
void |
setCommunityString(String cs)
Sets the community string. |
void |
setDestinationAddress(InetAddress address)
Sets the trap destination address. |
void |
setDestinationPort(int port)
Sets the trap destination port. |
void |
setEnterpriseOid(String oid)
Sets the enterprise OID. |
void |
setPduSourceAddress(InetAddress addr)
When a trap is received, localhost is set as the source of the sent trap. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final SnmpOid coldStartOid
public static final SnmpOid warmStartOid
public static final SnmpOid linkDownOid
public static final SnmpOid linkUpOid
public static final SnmpOid authenticationFailureOid
public static final SnmpOid egpNeighborLossOid
public static final SnmpOid snmpTrapSysUpTimeOid
public static final SnmpOid snmpTrapOid
public static final SnmpOid snmpTrapAddressOid
public static final SnmpOid snmpTrapEnterpriseOid
public static final SnmpOid snmpTrapsOid
public static final SnmpOid snmpTrapCommunityOid
Constructor Detail |
---|
public SnmpTrap(int gen, int specific, SnmpVarBindList varBindList)
gen
- The generic number of the trap.specific
- The specific number of the trap.varBindList
- A list of SnmpVarBind
.public SnmpTrap(InetAddress addr, String cs, int gen, int specific, SnmpVarBindList varBindList)
addr
- The InetAddress
destination of the trap.cs
- The community string to be used for the trap.gen
- The generic number of the trap.specific
- The specific number of the trap.varBindList
- A list of SnmpVarBind
.public SnmpTrap(SnmpOid trapOid, SnmpVarBindList varBindList)
trapOid
- The trap oid.varBindList
- A list of SnmpVarBind
.public SnmpTrap(InetAddress addr, String cs, SnmpOid trapOid, SnmpVarBindList varBindList)
addr
- The InetAddress
destination of the trap.cs
- The community string to be used for the trap.trapOid
- The trap oid.varBindList
- A list of SnmpVarBind
.public SnmpTrap(SnmpPduTrap trap)
SnmpTrapListener
.
trap
- The SNMP V1 trap pdu.public SnmpTrap(SnmpScopedPduRequest scopedTrap)
SnmpTrapListener
.
scopedTrap
- The SNMP V3 trap pdu.public SnmpTrap(SnmpPduRequest trap)
SnmpTrapListener
.
trap
- The SNMP request pdu.Method Detail |
---|
public InetAddress getSourceAddress()
public SnmpPdu getPdu()
SnmpPdu
can be of the class : SnmpPduRequest
,
SnmpScopedPduRequest
or SnmpPduTrap
.
public void setEnterpriseOid(String oid)
oid
- The OID in string format "x.x.x.x".
IllegalArgumentException
- The string format is incorrectpublic void setDestinationAddress(InetAddress address)
address
- The trap destination address.public void setDestinationPort(int port)
port
- The trap destination port.public void setCommunityString(String cs)
cs
- The community string to use.public void sendV3(SnmpV3AdaptorServer server) throws IOException, SnmpStatusException
SnmpTrap
has been instantiated with the constructor
SnmpTrap(SnmpScopedPduRequest)
server
- The SNMP V3 adaptor to use.
IOException
SnmpStatusException
public void sendV3Usm(SnmpV3AdaptorServer server, String principal, int securityLevel, String contextName) throws IOException, SnmpStatusException
server
- The SNMP V3 adaptor to use.principal
- The user name to use.securityLevel
- The V3 message flags.contextName
- The V3 context name. If null is provided and if
a community string has been provided, it will be reused as the
contextName. The contextEngineId
is the local engine Id.
IOException
SnmpStatusException
public void sendV2(SnmpAdaptorServer server) throws IOException, SnmpStatusException
server
- The SNMP adaptor to use.
IOException
- An I/O error occurred while sending the trap.
SnmpStatusException
- If the trap exceeds the limit
defined by bufferSize
.public void sendV1(SnmpAdaptorServer server) throws IOException, SnmpStatusException
server
- The SNMP adaptor to use.
IOException
- An I/O error occurred while sending the trap.
SnmpStatusException
- If the trap exceeds the limit defined
by bufferSize
.public void sendAsNotificationOriginator()
public void sendAsProxy()
public boolean isOriginatorWay()
public boolean isProxyWay()
public void setPduSourceAddress(InetAddress addr)
isProxyWay
returns true, the source
address is the one received.
addr
- The source address to use when forwarding the trap.
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |