Package org.snmp4j.agent.agentx
Class AgentXProtocol
java.lang.Object
org.snmp4j.agent.agentx.AgentXProtocol
- All Implemented Interfaces:
org.snmp4j.transport.MessageLengthDecoder
The
AgentXProtocol
class defines constants and operations specific to the AgentX protocol as defined
by RFC 2741.- Author:
- Frank Fock
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Bad AgentX version.static final int
AentX disconnected.static final int
AgentX error: duplicate registration.static final int
Deprecated.Will be removed in 3.0static final int
General error.static final int
AgentX error: index already allocated.static final int
AgentX error: no index available.static final int
AgentX error: index not allocated.static final int
AgentX error: index has wrong type.protected static final int
Number of bytes for an AgentX INTEGER.static final int
The maximum OID length for AgentX transported OIDs according to RFC2741 §5.1.static final int
No registration error.static final int
AgentX error: not open.static final int
AgentX error: open failed.static final int
AgentX error: parse error.static final int
AgentX error: processing error.static final int
AgentX error: request denied.static final int
No error (success).static final int
AgentX timeout.static final int
AgentX error: unknown agent capabilities.static final int
AgentX error: unknown registration.static final int
AgentX error: unsupported context.static final int
Default maximum of consecutive timeouts before connection closing.static final int
Default maximum number of parse errors before connection closing.static final byte
The default priority for registrations.static final int
Default AgentX timeout in seconds.static final int
AgentX flag: ALLOCATE_INDEX.static final byte
AgentX flag: ANY_INDEX.static final byte
AgentX flag: INSTANCE_REGISTRATION.static final byte
AgentX flag: NETWORK_BYTE_ORDER.static final byte
AgentX flag: NEW_INDEX.static final byte
AgentX flag: NON_DEFAULT_CONTEXT.static final int
AgentX header length = 5 *AGENTX_INT_SIZE
.static final int
Maximum timeout seconds.static final byte
Close reason: Due to Set operation; this reason code can be used only by the master agent, in response to an SNMP management request.static final byte
Close reason: None of the following reasons.static final byte
Close reason: Too many AgentX parse errors from peer.static final byte
Close reason: Too many AgentX protocol errors from peer.static final byte
Close reason: Sending entity is shutting down.static final byte
Close reason: Too many timeouts waiting for peer.static final byte
AgentX protocol version. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic AgentXMessageHeader
decodeHeader
(ByteBuffer buf) Decodes the header of an AgentX message.static org.snmp4j.smi.OctetString
Decode anOctetString
.static boolean
decodeOID
(ByteBuffer buf, org.snmp4j.smi.OID oid) Decode an OID from an AgentX encoded message (byte buffer)static org.snmp4j.agent.MOScope[]
decodeRanges
(ByteBuffer buf) Decode search ranges.static org.snmp4j.agent.MOScope[]
decodeRanges
(ByteBuffer buf, boolean lowerAlwaysIncluded) Decode search ranges.static org.snmp4j.smi.VariableBinding[]
Decode an array ofVariableBinding
.static org.snmp4j.smi.Variable
decodeVariableData
(ByteBuffer buf, int syntax) Decode aVariable
from an AgentX message provided as byte buffer.static void
encodeOctetString
(ByteBuffer buf, org.snmp4j.smi.OctetString os) Encode anOctetString
.static void
encodeOID
(ByteBuffer buf, org.snmp4j.smi.OID oid, boolean include) AgentX encode an OIDstatic void
encodeRanges
(ByteBuffer buf, org.snmp4j.agent.MOScope[] searchRanges) Encode search ranges.static void
encodeVariableData
(ByteBuffer buf, org.snmp4j.smi.Variable v) Encode aVariable
.static void
encodeVaribleBindings
(ByteBuffer buf, org.snmp4j.smi.VariableBinding[] vbs) Encode an array ofVariableBinding
to an AgentX message buffer.org.snmp4j.transport.MessageLength
Gets the encoded message length.int
Gets the minimum header length.static int
getOctetStringLength
(int length) Gets the encoded length of an encodedOctetString
.static int
getOIDLength
(int[] oid) Get the encoded length of an OID.static int
getOIDLength
(org.snmp4j.smi.OID oid) Get the encoded length of an OID.static int
getRangesLength
(org.snmp4j.agent.MOScope[] ranges) Gets the encoded length of the given ranges.static int
getVariableBindingsLength
(org.snmp4j.smi.VariableBinding[] vbs) Gets the encoded length of the givenVariableBinding
s.static int
getVariableDataLength
(org.snmp4j.smi.Variable v) Gets the encoded variable data length for a givenVariable
.static boolean
Checks if non-default context support is enabled or not.static void
setNonDefaultContextsEnabled
(boolean enabled) Activate/deactivate non-default context support.
-
Field Details
-
VERSION_1_0
public static final byte VERSION_1_0AgentX protocol version.- See Also:
-
REASON_OTHER
public static final byte REASON_OTHERClose reason: None of the following reasons.- See Also:
-
REASON_PARSE_ERROR
public static final byte REASON_PARSE_ERRORClose reason: Too many AgentX parse errors from peer.- See Also:
-
REASON_PROTOCOL_ERROR
public static final byte REASON_PROTOCOL_ERRORClose reason: Too many AgentX protocol errors from peer.- See Also:
-
REASON_TIMEOUTS
public static final byte REASON_TIMEOUTSClose reason: Too many timeouts waiting for peer.- See Also:
-
REASON_SHUTDOWN
public static final byte REASON_SHUTDOWNClose reason: Sending entity is shutting down.- See Also:
-
REASON_BY_MANAGER
public static final byte REASON_BY_MANAGERClose reason: Due to Set operation; this reason code can be used only by the master agent, in response to an SNMP management request.- See Also:
-
AGENTX_OPEN_FAILED
public static final int AGENTX_OPEN_FAILEDAgentX error: open failed.- See Also:
-
AGENTX_NOT_OPEN
public static final int AGENTX_NOT_OPENAgentX error: not open.- See Also:
-
AGENTX_INDEX_WRONG_TYPE
public static final int AGENTX_INDEX_WRONG_TYPEAgentX error: index has wrong type.- See Also:
-
AGENTX_INDEX_ALREADY_ALLOCATED
public static final int AGENTX_INDEX_ALREADY_ALLOCATEDAgentX error: index already allocated.- See Also:
-
AGENTX_INDEX_NONE_AVAILABLE
public static final int AGENTX_INDEX_NONE_AVAILABLEAgentX error: no index available.- See Also:
-
AGENTX_INDEX_NOT_ALLOCATED
public static final int AGENTX_INDEX_NOT_ALLOCATEDAgentX error: index not allocated.- See Also:
-
AGENTX_UNSUPPORTED_CONTEXT
public static final int AGENTX_UNSUPPORTED_CONTEXTAgentX error: unsupported context.- See Also:
-
AGENTX_DUPLICATE_REGISTRATION
public static final int AGENTX_DUPLICATE_REGISTRATIONAgentX error: duplicate registration.- See Also:
-
AGENTX_UNKNOWN_REGISTRATION
public static final int AGENTX_UNKNOWN_REGISTRATIONAgentX error: unknown registration.- See Also:
-
AGENTX_UNKNOWN_AGENTCAPS
public static final int AGENTX_UNKNOWN_AGENTCAPSAgentX error: unknown agent capabilities.- See Also:
-
AGENTX_PARSE_ERROR
public static final int AGENTX_PARSE_ERRORAgentX error: parse error.- See Also:
-
AGENTX_REQUEST_DENIED
public static final int AGENTX_REQUEST_DENIEDAgentX error: request denied.- See Also:
-
AGENTX_PROCESSING_ERROR
public static final int AGENTX_PROCESSING_ERRORAgentX error: processing error.- See Also:
-
AGENTX_MAX_OID_LENGTH
public static final int AGENTX_MAX_OID_LENGTHThe maximum OID length for AgentX transported OIDs according to RFC2741 §5.1.- See Also:
-
AGENTX_SUCCESS
public static final int AGENTX_SUCCESSNo error (success).- See Also:
-
AGENTX_ERROR
public static final int AGENTX_ERRORGeneral error.- See Also:
-
AGENTX_DISCONNECT
public static final int AGENTX_DISCONNECTAentX disconnected.- See Also:
-
AGENTX_BADVER
public static final int AGENTX_BADVERBad AgentX version.- See Also:
-
AGENTX_TIMEOUT
public static final int AGENTX_TIMEOUTAgentX timeout.- See Also:
-
AGENTX_NOREG
public static final int AGENTX_NOREGNo registration error.- See Also:
-
AGENTX_DUPMAP
public static final int AGENTX_DUPMAPDeprecated.Will be removed in 3.0Duplicate mapping (not used)- See Also:
-
FLAG_ALLOCATE_INDEX
public static final int FLAG_ALLOCATE_INDEXAgentX flag: ALLOCATE_INDEX.- See Also:
-
FLAG_INSTANCE_REGISTRATION
public static final byte FLAG_INSTANCE_REGISTRATIONAgentX flag: INSTANCE_REGISTRATION.- See Also:
-
FLAG_NEW_INDEX
public static final byte FLAG_NEW_INDEXAgentX flag: NEW_INDEX.- See Also:
-
FLAG_ANY_INDEX
public static final byte FLAG_ANY_INDEXAgentX flag: ANY_INDEX.- See Also:
-
FLAG_NON_DEFAULT_CONTEXT
public static final byte FLAG_NON_DEFAULT_CONTEXTAgentX flag: NON_DEFAULT_CONTEXT.- See Also:
-
FLAG_NETWORK_BYTE_ORDER
public static final byte FLAG_NETWORK_BYTE_ORDERAgentX flag: NETWORK_BYTE_ORDER.- See Also:
-
AGENTX_INT_SIZE
protected static final int AGENTX_INT_SIZENumber of bytes for an AgentX INTEGER.- See Also:
-
HEADER_LENGTH
public static final int HEADER_LENGTHAgentX header length = 5 *AGENTX_INT_SIZE
.- See Also:
-
DEFAULT_TIMEOUT_SECONDS
public static final int DEFAULT_TIMEOUT_SECONDSDefault AgentX timeout in seconds.- See Also:
-
DEFAULT_MAX_CONSECUTIVE_TIMEOUTS
public static final int DEFAULT_MAX_CONSECUTIVE_TIMEOUTSDefault maximum of consecutive timeouts before connection closing.- See Also:
-
DEFAULT_MAX_PARSE_ERRORS
public static final int DEFAULT_MAX_PARSE_ERRORSDefault maximum number of parse errors before connection closing.- See Also:
-
MAX_TIMEOUT_SECONDS
public static final int MAX_TIMEOUT_SECONDSMaximum timeout seconds.- See Also:
-
DEFAULT_PRIORITY
public static final byte DEFAULT_PRIORITYThe default priority for registrations.- See Also:
-
-
Constructor Details
-
AgentXProtocol
public AgentXProtocol()
-
-
Method Details
-
encodeOID
AgentX encode an OID- Parameters:
buf
- the target byte buffer.oid
- the OID to encodeinclude
-true
to add include flag andfalse
to set it to 0.
-
getOIDLength
public static int getOIDLength(org.snmp4j.smi.OID oid) Get the encoded length of an OID.- Parameters:
oid
- the OID.- Returns:
- the encoding length.
-
getOIDLength
public static int getOIDLength(int[] oid) Get the encoded length of an OID.- Parameters:
oid
- the OID.- Returns:
- the encoding length.
-
decodeOID
Decode an OID from an AgentX encoded message (byte buffer)- Parameters:
buf
- the byte buffer containing the encoded OID.oid
- the OID to return (data will be written into this object).- Returns:
true
if the include flag is set,false
otherwise.
-
encodeVariableData
Encode aVariable
.- Parameters:
buf
- the target byte buffer.v
- the variable to encode.
-
getVariableDataLength
public static int getVariableDataLength(org.snmp4j.smi.Variable v) Gets the encoded variable data length for a givenVariable
.- Parameters:
v
- theVariable
.- Returns:
- the encoded length of the given variable.
-
decodeVariableData
Decode aVariable
from an AgentX message provided as byte buffer.- Parameters:
buf
- the AgentX message (portion) to decode.syntax
- the syntax ID specifying the variable type.- Returns:
- the decoded
Variable
.
-
decodeVariableBindings
Decode an array ofVariableBinding
.- Parameters:
buf
- the AgentX message (portion) to decode.- Returns:
- the decoded array of
VariableBinding
instances.
-
encodeVaribleBindings
Encode an array ofVariableBinding
to an AgentX message buffer.- Parameters:
buf
- the AgentX message (portion) to encode.vbs
- an array ofVariableBinding
instances.
-
encodeRanges
Encode search ranges.- Parameters:
buf
- the AgentX message (portion) to encode.searchRanges
- an array of search ranges.
-
getOctetStringLength
public static int getOctetStringLength(int length) Gets the encoded length of an encodedOctetString
.- Parameters:
length
- the length in bytes of theOctetString
.- Returns:
- the encoded length in bytes.
-
encodeOctetString
Encode anOctetString
.- Parameters:
buf
- the AgentX message (portion) to encode.os
- anOctetString
to encode.
-
decodeOctetString
Decode anOctetString
.- Parameters:
buf
- the AgentX message (portion) to decode.- Returns:
- os
the decoded
OctetString
.
-
decodeRanges
Decode search ranges.- Parameters:
buf
- the AgentX message (portion) to decode.- Returns:
- the decoded array of
MOScope
instances representing the search ranges.
-
decodeRanges
Decode search ranges.- Parameters:
buf
- the AgentX message (portion) to decode.lowerAlwaysIncluded
-true
to interpret lower bounds as always included,false
to include lower bound if encoded as included.- Returns:
- the decoded array of
MOScope
instances representing the search ranges.
-
getRangesLength
public static int getRangesLength(org.snmp4j.agent.MOScope[] ranges) Gets the encoded length of the given ranges.- Parameters:
ranges
- an array ofMOScope
instances representing search ranges.- Returns:
- the encoded length in bytes.
-
getVariableBindingsLength
public static int getVariableBindingsLength(org.snmp4j.smi.VariableBinding[] vbs) Gets the encoded length of the givenVariableBinding
s.- Parameters:
vbs
- theVariableBinding
s.- Returns:
- the encoded length in bytes.
-
getMinHeaderLength
public int getMinHeaderLength()Gets the minimum header length.- Specified by:
getMinHeaderLength
in interfaceorg.snmp4j.transport.MessageLengthDecoder
- Returns:
HEADER_LENGTH
.
-
getMessageLength
Gets the encoded message length.- Specified by:
getMessageLength
in interfaceorg.snmp4j.transport.MessageLengthDecoder
- Parameters:
buf
- the AgentX message buffer containing the AgentX message to decode.- Returns:
- the length of the message.
- Throws:
IOException
- if the header could not be decoded.
-
decodeHeader
Decodes the header of an AgentX message.- Parameters:
buf
- the AgentX message buffer containing the AgentX message to decode.- Returns:
- the decoded
AgentXMessageHeader
. - Throws:
IOException
- if the header could not be decoded.
-
setNonDefaultContextsEnabled
public static void setNonDefaultContextsEnabled(boolean enabled) Activate/deactivate non-default context support.- Parameters:
enabled
-false
to disable non-default context support for thisAgentXProtocol
, enabled is the default.
-
isNonDefaultContextsEnabled
public static boolean isNonDefaultContextsEnabled()Checks if non-default context support is enabled or not.- Returns:
true
if non-default context support is enabled (default).
-