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
FieldsModifier and TypeFieldDescriptionstatic final intBad AgentX version.static final intAentX disconnected.static final intAgentX error: duplicate registration.static final intDeprecated.Will be removed in 3.0static final intGeneral error.static final intAgentX error: index already allocated.static final intAgentX error: no index available.static final intAgentX error: index not allocated.static final intAgentX error: index has wrong type.protected static final intNumber of bytes for an AgentX INTEGER.static final intThe maximum OID length for AgentX transported OIDs according to RFC2741 §5.1.static final intNo registration error.static final intAgentX error: not open.static final intAgentX error: open failed.static final intAgentX error: parse error.static final intAgentX error: processing error.static final intAgentX error: request denied.static final intNo error (success).static final intAgentX timeout.static final intAgentX error: unknown agent capabilities.static final intAgentX error: unknown registration.static final intAgentX error: unsupported context.static final intDefault maximum of consecutive timeouts before connection closing.static final intDefault maximum number of parse errors before connection closing.static final byteThe default priority for registrations.static final intDefault AgentX timeout in seconds.static final intAgentX flag: ALLOCATE_INDEX.static final byteAgentX flag: ANY_INDEX.static final byteAgentX flag: INSTANCE_REGISTRATION.static final byteAgentX flag: NETWORK_BYTE_ORDER.static final byteAgentX flag: NEW_INDEX.static final byteAgentX flag: NON_DEFAULT_CONTEXT.static final intAgentX header length = 5 *AGENTX_INT_SIZE.static final intMaximum timeout seconds.static final byteClose 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 byteClose reason: None of the following reasons.static final byteClose reason: Too many AgentX parse errors from peer.static final byteClose reason: Too many AgentX protocol errors from peer.static final byteClose reason: Sending entity is shutting down.static final byteClose reason: Too many timeouts waiting for peer.static final byteAgentX protocol version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentXMessageHeaderdecodeHeader(ByteBuffer buf) Decodes the header of an AgentX message.static org.snmp4j.smi.OctetStringDecode anOctetString.static booleandecodeOID(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.VariabledecodeVariableData(ByteBuffer buf, int syntax) Decode aVariablefrom an AgentX message provided as byte buffer.static voidencodeOctetString(ByteBuffer buf, org.snmp4j.smi.OctetString os) Encode anOctetString.static voidencodeOID(ByteBuffer buf, org.snmp4j.smi.OID oid, boolean include) AgentX encode an OIDstatic voidencodeRanges(ByteBuffer buf, org.snmp4j.agent.MOScope[] searchRanges) Encode search ranges.static voidencodeVariableData(ByteBuffer buf, org.snmp4j.smi.Variable v) Encode aVariable.static voidencodeVaribleBindings(ByteBuffer buf, org.snmp4j.smi.VariableBinding[] vbs) Encode an array ofVariableBindingto an AgentX message buffer.org.snmp4j.transport.MessageLengthGets the encoded message length.intGets the minimum header length.static intgetOctetStringLength(int length) Gets the encoded length of an encodedOctetString.static intgetOIDLength(int[] oid) Get the encoded length of an OID.static intgetOIDLength(org.snmp4j.smi.OID oid) Get the encoded length of an OID.static intgetRangesLength(org.snmp4j.agent.MOScope[] ranges) Gets the encoded length of the given ranges.static intgetVariableBindingsLength(org.snmp4j.smi.VariableBinding[] vbs) Gets the encoded length of the givenVariableBindings.static intgetVariableDataLength(org.snmp4j.smi.Variable v) Gets the encoded variable data length for a givenVariable.static booleanChecks if non-default context support is enabled or not.static voidsetNonDefaultContextsEnabled(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-trueto add include flag andfalseto 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:
trueif the include flag is set,falseotherwise.
-
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 aVariablefrom 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
VariableBindinginstances.
-
encodeVaribleBindings
Encode an array ofVariableBindingto an AgentX message buffer.- Parameters:
buf- the AgentX message (portion) to encode.vbs- an array ofVariableBindinginstances.
-
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- anOctetStringto 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
MOScopeinstances representing the search ranges.
-
decodeRanges
Decode search ranges.- Parameters:
buf- the AgentX message (portion) to decode.lowerAlwaysIncluded-trueto interpret lower bounds as always included,falseto include lower bound if encoded as included.- Returns:
- the decoded array of
MOScopeinstances 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 ofMOScopeinstances 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 givenVariableBindings.- Parameters:
vbs- theVariableBindings.- Returns:
- the encoded length in bytes.
-
getMinHeaderLength
public int getMinHeaderLength()Gets the minimum header length.- Specified by:
getMinHeaderLengthin interfaceorg.snmp4j.transport.MessageLengthDecoder- Returns:
HEADER_LENGTH.
-
getMessageLength
Gets the encoded message length.- Specified by:
getMessageLengthin 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-falseto 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:
trueif non-default context support is enabled (default).
-