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
FieldsModifier and TypeFieldDescriptionstatic final byteThe agentx-AddAgentCaps-PDU ID.static final byteThe agentx-CleanupSet-PDU ID.static final byteThe agentx-Close-PDU ID.static final byteThe agentx-CommitSet-PDU ID.static final byteThe agentx-Get-PDU ID.static final byteThe agentx-GetBulk-PDU ID.static final byteThe agentx-GetNext-PDU ID.static final byteThe agentx-IndexAllocate-PDU ID.static final byteThe agentx-IndexDeallocate-PDU ID.static final byteThe agentx-Notify-PDU ID.static final byteThe agentx-Open-PDU ID.static final byteThe agentx-Ping-PDU ID.static final byteThe agentx-Register-PDU ID.static final byteThe agentx-RemoveAgentCaps-PDU ID.static final byteThe agentx-Response-PDU ID.static final byteThe agentx-TestSet-PDU ID.static final byteThe agentx-UndoSet-PDU ID.static final byteThe agentx-Unregister-PDU ID.protected ByteOrderThe byte order.protected byteFlags (bitwise OR), seeAgentXProtocol.FLAG_INSTANCE_REGISTRATIONfor example.protected intPacket IDstatic final byteThe reserved byte position.protected intSession IDprotected intTransaction ID.protected byteAgentX PDU type.protected byteAgentX protocol version -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAgentXPDU(byte type) Create aAgentXPDUfrom its type.protectedAgentXPDU(byte type, byte flags, int sessionID, int transactionID, int packetID) Create aAgentXPDUfrom type and other header attributes.protectedAgentXPDU(AgentXMessageHeader header) Create aAgentXPDUfrom anAgentXMessageHeader. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddFlag(byte flag) Adds a flag to the existing flags (bit-wise OR).protected abstract voidInitialize flags and other things before a PDU is encoded.static AgentXPDUdecode(ByteBuffer buf) DecodeAgentXPDUfrom a byte buffer.abstract voiddecodePayload(ByteBuffer buf, int length) Decode this PDU's payload.final voidencode(ByteBuffer buf) Encode this PDU into the given byte buffer.protected abstract voidencodePayload(ByteBuffer buf) Encode the payload to the given byte buffer.final ByteOrderGets the byte order.final bytegetFlags()Gets all flags.final intGets the packet ID.abstract intGets the payload length.final intGets the session ID.final intGets the transaction ID.final bytegetType()Get the PDU type.final byteGets the protcol version.final booleanCheck if this PDU is a confirmed PDU (i.e.final booleanisFlagSet(int flag) Check if the specified flag is set, seeAgentXProtocol.FLAG_INSTANCE_REGISTRATIONfor example.voidsetByteOrder(ByteOrder byteOrder) Sets the byte order.voidsetFlags(byte flags) Sets all flags at once.voidsetPacketID(int packetID) Sets the packet ID.voidsetSessionAttributes(AgentXSession<?> session) Sets theAgentXSessionspecific attributes: session ID and byte order.voidsetSessionID(int sessionID) Sets the session ID.voidsetTransactionID(int transactionID) Sets the transaction IDvoidsetType(byte type) Sets the PDU type.voidsetVersion(byte version) Sets the version.toString()protected StringReturns 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_REGISTRATIONfor example. -
byteOrder
The byte order.
-
-
Constructor Details
-
AgentXPDU
protected AgentXPDU(byte type) Create aAgentXPDUfrom its type.- Parameters:
type- a AgentX PDU type fromAGENTX_OPEN_PDUtoAGENTX_RESPONSE_PDU.
-
AgentXPDU
protected AgentXPDU(byte type, byte flags, int sessionID, int transactionID, int packetID) Create aAgentXPDUfrom type and other header attributes.- Parameters:
type- a AgentX PDU type fromAGENTX_OPEN_PDUtoAGENTX_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 aAgentXPDUfrom 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_REGISTRATIONfor example.- Parameters:
flag- the flag to test.- Returns:
trueif 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 theAgentXSessionspecific 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- theByteBufferto 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
DecodeAgentXPDUfrom a byte buffer.- Parameters:
buf- theByteBufferthat 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:
trueif 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
-