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
FieldsModifier and TypeFieldDescriptionprotected org.snmp4j.smi.OctetStringThe 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
ConstructorsModifierConstructorDescriptionprotectedAgentXContextPDU(byte type, byte flags, int sessionID, int transactionID, int packetID) Creates aAgentXContextPDU.protectedAgentXContextPDU(byte type, org.snmp4j.smi.OctetString context) Create aAgentXPDUfrom its type.protectedAgentXContextPDU(AgentXMessageHeader header) Creates aAgentXContextPDUfrom aAgentXMessageHeader. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidInitialize flags and other things before a PDU is encoded.protected abstract voiddecodeAfterContext(ByteBuffer buf, int length) Decode this PDU after the end of the encoded context.final voiddecodePayload(ByteBuffer buf, int length) Decode the PDU payload from theByteBuffer.protected abstract voidEncode this PDU after already encoded context (thus context will not be encoded by this operation).final voidencodePayload(ByteBuffer buf) Encode this PDU payload to the givenByteBuffer.protected abstract intGets the encoded length after an already encoded context.org.snmp4j.smi.OctetStringGets the context.final intGets the payload length.voidsetContext(org.snmp4j.smi.OctetString context) Sets the context.protected StringReturns 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 aAgentXPDUfrom its type.- Parameters:
type- a AgentX PDU type fromAgentXPDU.AGENTX_OPEN_PDUtoAgentXPDU.AGENTX_RESPONSE_PDU.context- the context.
-
AgentXContextPDU
Creates aAgentXContextPDUfrom 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_PDUtoAgentXPDU.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 fewer 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:
decodePayloadin 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:
encodePayloadin classAgentXPDU- Parameters:
buf- the byte buffer into which to encode the payload.
-
getPayloadLength
public final int getPayloadLength()Gets the payload length.- Specified by:
getPayloadLengthin classAgentXPDU- Returns:
- the number of bytes needed to encode the payload.
-
getContext
public org.snmp4j.smi.OctetString getContext()Gets the context.- Returns:
- an
OctetStringrepresenting the context.
-
setContext
public void setContext(org.snmp4j.smi.OctetString context) Sets the context.- Parameters:
context- anOctetStringrepresenting the context.
-
toStringExtMembers
Description copied from class:AgentXPDUReturns a string representation of the PDU members. An empty string is returned by this base class.- Overrides:
toStringExtMembersin 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:
beforeEncodein classAgentXPDU
-