Package org.snmp4j.agent.agentx
Class AgentXContextPDU
java.lang.Object
org.snmp4j.agent.agentx.AgentXPDU
org.snmp4j.agent.agentx.AgentXContextPDU
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AgentXAddAgentCapsPDU
,AgentXPingPDU
,AgentXRegisterPDU
,AgentXRemoveAgentCapsPDU
,AgentXRequestPDU
,AgentXVariableBindingPDU
A
AgentXContextPDU
is a AgentXPDU
with context support.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.snmp4j.smi.OctetString
The SNMPv43 context.Fields inherited from class org.snmp4j.agent.agentx.AgentXPDU
AGENTX_ADDAGENTCAPS_PDU, AGENTX_CLEANUPSET_PDU, AGENTX_CLOSE_PDU, AGENTX_COMMITSET_PDU, AGENTX_GET_PDU, AGENTX_GETBULK_PDU, AGENTX_GETNEXT_PDU, AGENTX_INDEXALLOCATE_PDU, AGENTX_INDEXDEALLOCATE_PDU, AGENTX_NOTIFY_PDU, AGENTX_OPEN_PDU, AGENTX_PING_PDU, AGENTX_REGISTER_PDU, AGENTX_REMOVEAGENTCAPS_PDU, AGENTX_RESPONSE_PDU, AGENTX_TESTSET_PDU, AGENTX_UNDOSET_PDU, AGENTX_UNREGISTER_PDU, byteOrder, flags, packetID, RESERVED, sessionID, transactionID, type, version
-
Constructor Summary
ModifierConstructorDescriptionprotected
AgentXContextPDU
(byte type, byte flags, int sessionID, int transactionID, int packetID) Creates aAgentXContextPDU
.protected
AgentXContextPDU
(byte type, org.snmp4j.smi.OctetString context) Create aAgentXPDU
from its type.protected
AgentXContextPDU
(AgentXMessageHeader header) Creates aAgentXContextPDU
from aAgentXMessageHeader
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Initialize flags and other things before a PDU is encoded.protected abstract void
decodeAfterContext
(ByteBuffer buf, int length) Decode this PDU after the end of the encoded context.final void
decodePayload
(ByteBuffer buf, int length) Decode the PDU payload from theByteBuffer
.protected abstract void
Encode this PDU after already encoded context (thus context will not be encoded by this operation).final void
encodePayload
(ByteBuffer buf) Encode this PDU payload to the givenByteBuffer
.protected abstract int
Gets the encoded length after an already encoded context.org.snmp4j.smi.OctetString
Gets the context.final int
Gets the payload length.void
setContext
(org.snmp4j.smi.OctetString context) Sets the context.protected String
Returns a string representation of the PDU members.Methods inherited from class org.snmp4j.agent.agentx.AgentXPDU
addFlag, decode, encode, getByteOrder, getFlags, getPacketID, getSessionID, getTransactionID, getType, getVersion, isConfirmedPDU, isFlagSet, setByteOrder, setFlags, setPacketID, setSessionAttributes, setSessionID, setTransactionID, setType, setVersion, toString
-
Field Details
-
context
protected org.snmp4j.smi.OctetString contextThe SNMPv43 context.
-
-
Constructor Details
-
AgentXContextPDU
protected AgentXContextPDU(byte type, org.snmp4j.smi.OctetString context) Create aAgentXPDU
from its type.- Parameters:
type
- a AgentX PDU type fromAgentXPDU.AGENTX_OPEN_PDU
toAgentXPDU.AGENTX_RESPONSE_PDU
.context
- the context.
-
AgentXContextPDU
Creates aAgentXContextPDU
from aAgentXMessageHeader
.- Parameters:
header
- the message header.
-
AgentXContextPDU
protected AgentXContextPDU(byte type, byte flags, int sessionID, int transactionID, int packetID) Creates aAgentXContextPDU
.- Parameters:
type
- a AgentX PDU type fromAgentXPDU.AGENTX_OPEN_PDU
toAgentXPDU.AGENTX_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.
-
-
Method Details
-
decodeAfterContext
Decode this PDU after the end of the encoded context.- 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.
-
encodeAfterContext
Encode this PDU after already encoded context (thus context will not be encoded by this operation).- Parameters:
buf
- the target buffer.
-
getAfterContextLength
protected abstract int getAfterContextLength()Gets the encoded length after an already encoded context.- Returns:
- the BER encoded length (without context).
-
decodePayload
Decode the PDU payload from theByteBuffer
.- Specified by:
decodePayload
in classAgentXPDU
- Parameters:
buf
- the byte buffer from which to decode the payload.length
- the length of the payload to decode.- Throws:
IOException
- if the byte bufferdoes not contain the expected data.
-
encodePayload
Encode this PDU payload to the givenByteBuffer
.- Specified by:
encodePayload
in classAgentXPDU
- Parameters:
buf
- the byte buffer into which to encode the payload.
-
getPayloadLength
public final int getPayloadLength()Gets the payload length.- Specified by:
getPayloadLength
in classAgentXPDU
- Returns:
- the number of bytes needed to encode the payload.
-
getContext
public org.snmp4j.smi.OctetString getContext()Gets the context.- Returns:
- an
OctetString
representing the context.
-
setContext
public void setContext(org.snmp4j.smi.OctetString context) Sets the context.- Parameters:
context
- anOctetString
representing the context.
-
toStringExtMembers
Description copied from class:AgentXPDU
Returns a string representation of the PDU members. An empty string is returned by this base class.- Overrides:
toStringExtMembers
in classAgentXPDU
- Returns:
- a string representation of the PDU members.
-
beforeEncode
protected void beforeEncode()Initialize flags and other things before a PDU is encoded.- Specified by:
beforeEncode
in classAgentXPDU
-