Package org.snmp4j.agent.agentx
Class AgentXPDU
java.lang.Object
org.snmp4j.agent.agentx.AgentXPDU
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AgentXCleanupSetPDU
,AgentXClosePDU
,AgentXCommitSetPDU
,AgentXContextPDU
,AgentXOpenPDU
,AgentXResponsePDU
,AgentXUndoSetPDU
The
AgentXPDU
implements the common characteristics of all AgentX PDUs (see RFC 2741).- Author:
- Frank Fock
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final byte
The agentx-AddAgentCaps-PDU ID.static final byte
The agentx-CleanupSet-PDU ID.static final byte
The agentx-Close-PDU ID.static final byte
The agentx-CommitSet-PDU ID.static final byte
The agentx-Get-PDU ID.static final byte
The agentx-GetBulk-PDU ID.static final byte
The agentx-GetNext-PDU ID.static final byte
The agentx-IndexAllocate-PDU ID.static final byte
The agentx-IndexDeallocate-PDU ID.static final byte
The agentx-Notify-PDU ID.static final byte
The agentx-Open-PDU ID.static final byte
The agentx-Ping-PDU ID.static final byte
The agentx-Register-PDU ID.static final byte
The agentx-RemoveAgentCaps-PDU ID.static final byte
The agentx-Response-PDU ID.static final byte
The agentx-TestSet-PDU ID.static final byte
The agentx-UndoSet-PDU ID.static final byte
The agentx-Unregister-PDU ID.protected ByteOrder
The byte order.protected byte
Flags (bitwise OR), seeAgentXProtocol.FLAG_INSTANCE_REGISTRATION
for example.protected int
Packet IDstatic final byte
The reserved byte position.protected int
Session IDprotected int
Transaction ID.protected byte
AgentX PDU type.protected byte
AgentX protocol version -
Constructor Summary
ModifierConstructorDescriptionprotected
AgentXPDU
(byte type) Create aAgentXPDU
from its type.protected
AgentXPDU
(byte type, byte flags, int sessionID, int transactionID, int packetID) Create aAgentXPDU
from type and other header attributes.protected
AgentXPDU
(AgentXMessageHeader header) Create aAgentXPDU
from anAgentXMessageHeader
. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addFlag
(byte flag) Adds a flag to the existing flags (bit-wise OR).protected abstract void
Initialize flags and other things before a PDU is encoded.static AgentXPDU
decode
(ByteBuffer buf) DecodeAgentXPDU
from a byte buffer.abstract void
decodePayload
(ByteBuffer buf, int length) Decode this PDU's payload.final void
encode
(ByteBuffer buf) Encode this PDU into the given byte buffer.protected abstract void
encodePayload
(ByteBuffer buf) Encode the payload to the given byte buffer.final ByteOrder
Gets the byte order.final byte
getFlags()
Gets all flags.final int
Gets the packet ID.abstract int
Gets the payload length.final int
Gets the session ID.final int
Gets the transaction ID.final byte
getType()
Get the PDU type.final byte
Gets the protcol version.final boolean
Check if this PDU is a confirmed PDU (i.e.final boolean
isFlagSet
(int flag) Check if the specified flag is set, seeAgentXProtocol.FLAG_INSTANCE_REGISTRATION
for example.void
setByteOrder
(ByteOrder byteOrder) Sets the byte order.void
setFlags
(byte flags) Sets all flags at once.void
setPacketID
(int packetID) Sets the packet ID.void
setSessionAttributes
(AgentXSession<?> session) Sets theAgentXSession
specific attributes: session ID and byte order.void
setSessionID
(int sessionID) Sets the session ID.void
setTransactionID
(int transactionID) Sets the transaction IDvoid
setType
(byte type) Sets the PDU type.void
setVersion
(byte version) Sets the version.toString()
protected String
Returns a string representation of the PDU members.
-
Field Details
-
RESERVED
public static final byte RESERVEDThe reserved byte position.- See Also:
-
AGENTX_OPEN_PDU
public static final byte AGENTX_OPEN_PDUThe agentx-Open-PDU ID.- See Also:
-
AGENTX_CLOSE_PDU
public static final byte AGENTX_CLOSE_PDUThe agentx-Close-PDU ID.- See Also:
-
AGENTX_REGISTER_PDU
public static final byte AGENTX_REGISTER_PDUThe agentx-Register-PDU ID.- See Also:
-
AGENTX_UNREGISTER_PDU
public static final byte AGENTX_UNREGISTER_PDUThe agentx-Unregister-PDU ID.- See Also:
-
AGENTX_GET_PDU
public static final byte AGENTX_GET_PDUThe agentx-Get-PDU ID.- See Also:
-
AGENTX_GETNEXT_PDU
public static final byte AGENTX_GETNEXT_PDUThe agentx-GetNext-PDU ID.- See Also:
-
AGENTX_GETBULK_PDU
public static final byte AGENTX_GETBULK_PDUThe agentx-GetBulk-PDU ID.- See Also:
-
AGENTX_TESTSET_PDU
public static final byte AGENTX_TESTSET_PDUThe agentx-TestSet-PDU ID.- See Also:
-
AGENTX_COMMITSET_PDU
public static final byte AGENTX_COMMITSET_PDUThe agentx-CommitSet-PDU ID.- See Also:
-
AGENTX_UNDOSET_PDU
public static final byte AGENTX_UNDOSET_PDUThe agentx-UndoSet-PDU ID.- See Also:
-
AGENTX_CLEANUPSET_PDU
public static final byte AGENTX_CLEANUPSET_PDUThe agentx-CleanupSet-PDU ID.- See Also:
-
AGENTX_NOTIFY_PDU
public static final byte AGENTX_NOTIFY_PDUThe agentx-Notify-PDU ID.- See Also:
-
AGENTX_PING_PDU
public static final byte AGENTX_PING_PDUThe agentx-Ping-PDU ID.- See Also:
-
AGENTX_INDEXALLOCATE_PDU
public static final byte AGENTX_INDEXALLOCATE_PDUThe agentx-IndexAllocate-PDU ID.- See Also:
-
AGENTX_INDEXDEALLOCATE_PDU
public static final byte AGENTX_INDEXDEALLOCATE_PDUThe agentx-IndexDeallocate-PDU ID.- See Also:
-
AGENTX_ADDAGENTCAPS_PDU
public static final byte AGENTX_ADDAGENTCAPS_PDUThe agentx-AddAgentCaps-PDU ID.- See Also:
-
AGENTX_REMOVEAGENTCAPS_PDU
public static final byte AGENTX_REMOVEAGENTCAPS_PDUThe agentx-RemoveAgentCaps-PDU ID.- See Also:
-
AGENTX_RESPONSE_PDU
public static final byte AGENTX_RESPONSE_PDUThe agentx-Response-PDU ID.- See Also:
-
type
protected byte typeAgentX PDU type. -
version
protected byte versionAgentX protocol version -
sessionID
protected int sessionIDSession ID -
transactionID
protected int transactionIDTransaction ID. -
packetID
protected int packetIDPacket ID -
flags
protected byte flagsFlags (bitwise OR), seeAgentXProtocol.FLAG_INSTANCE_REGISTRATION
for example. -
byteOrder
The byte order.
-
-
Constructor Details
-
AgentXPDU
protected AgentXPDU(byte type) Create aAgentXPDU
from its type.- Parameters:
type
- a AgentX PDU type fromAGENTX_OPEN_PDU
toAGENTX_RESPONSE_PDU
.
-
AgentXPDU
protected AgentXPDU(byte type, byte flags, int sessionID, int transactionID, int packetID) Create aAgentXPDU
from type and other header attributes.- Parameters:
type
- a AgentX PDU type fromAGENTX_OPEN_PDU
toAGENTX_RESPONSE_PDU
.flags
- a set of flags (bit-or), see alsoAgentXProtocol.FLAG_NETWORK_BYTE_ORDER
.sessionID
- a session ID.transactionID
- a transaction ID.packetID
- a packet ID.
-
AgentXPDU
Create aAgentXPDU
from anAgentXMessageHeader
.- Parameters:
header
- anAgentXMessageHeader
.
-
-
Method Details
-
addFlag
public final void addFlag(byte flag) Adds a flag to the existing flags (bit-wise OR).- Parameters:
flag
- a AgentX flag, seeAgentXProtocol.FLAG_NETWORK_BYTE_ORDER
-
isFlagSet
public final boolean isFlagSet(int flag) Check if the specified flag is set, seeAgentXProtocol.FLAG_INSTANCE_REGISTRATION
for example.- Parameters:
flag
- the flag to test.- Returns:
true
if it is set.
-
getFlags
public final byte getFlags()Gets all flags.- Returns:
- a bit-wise OR flag set.
-
getPacketID
public final int getPacketID()Gets the packet ID.- Returns:
- the packet ID.
-
getSessionID
public final int getSessionID()Gets the session ID.- Returns:
- the session ID.
-
getType
public final byte getType()Get the PDU type.- Returns:
- the type like
AGENTX_OPEN_PDU
.
-
getVersion
public final byte getVersion()Gets the protcol version.- Returns:
- the version info.
-
getByteOrder
Gets the byte order.- Returns:
- the byte order.
-
getTransactionID
public final int getTransactionID()Gets the transaction ID.- Returns:
- the transaction ID.
-
setFlags
public void setFlags(byte flags) Sets all flags at once.- Parameters:
flags
- a bit-wise OR combinaed set of flags.
-
setPacketID
public void setPacketID(int packetID) Sets the packet ID.- Parameters:
packetID
- the packet ID.
-
setSessionID
public void setSessionID(int sessionID) Sets the session ID.- Parameters:
sessionID
- the session ID.
-
setType
public void setType(byte type) Sets the PDU type.- Parameters:
type
- the type.
-
setVersion
public void setVersion(byte version) Sets the version.- Parameters:
version
- the version.
-
setByteOrder
Sets the byte order.- Parameters:
byteOrder
- the byte order.
-
setTransactionID
public void setTransactionID(int transactionID) Sets the transaction ID- Parameters:
transactionID
- the transaction ID.
-
setSessionAttributes
Sets theAgentXSession
specific attributes: session ID and byte order.- Parameters:
session
- anAgentXSession
.
-
encodePayload
Encode the payload to the given byte buffer.- Parameters:
buf
- the buffer.
-
getPayloadLength
public abstract int getPayloadLength()Gets the payload length.- Returns:
- the payload length.
-
encode
Encode this PDU into the given byte buffer.- Parameters:
buf
- theByteBuffer
to hold the BER encoded PDU.
-
beforeEncode
protected abstract void beforeEncode()Initialize flags and other things before a PDU is encoded. -
decodePayload
Decode this PDU's payload.- Parameters:
buf
- the buffer positioned at the end of the encoded context.length
- the length of the PDU to be decoded.- Throws:
IOException
- if the buffer contains less data than expected.
-
decode
DecodeAgentXPDU
from a byte buffer.- Parameters:
buf
- theByteBuffer
that contains the BER encoded PDU.- Returns:
- the decoded
AgentXPDU
. - Throws:
IOException
- if the buffer contains less than encoded data or if the is a parse error.
-
isConfirmedPDU
public final boolean isConfirmedPDU()Check if this PDU is a confirmed PDU (i.e. requires a response).- Returns:
true
if a repsone is required.
-
toStringExtMembers
Returns a string representation of the PDU members. An empty string is returned by this base class.- Returns:
- a string representation of the PDU members.
-
toString
-