|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.adventnet.snmp.snmp2.agent.AgentUtil
This class contains some utility Routines which the SnmpAgent uses for processing a PDU.
API users can use this class methods for their agent instrumentation.
| Field Summary | |
static java.lang.String |
agentDir
The AgentDirectory used commonly for all the API Tables stroage details. |
(package private) static byte |
SNMP_ERR_MASKERR
|
(package private) static byte |
SNMP_PROXY_ERR
|
static byte |
SNMP_REQUEST_TIMEOUT
The Snmp Request Timeout Value. |
static Log |
snmpLog
|
| Constructor Summary | |
AgentUtil(SnmpAPI api,
BaseSnmpAgent agent)
Constructor for AgentUtil with SnmpAPI and SnmpAgent |
|
| Method Summary | |
static int |
byteToInt(byte b)
Utility method which converts byte to int datatype |
static int |
compareTo(int[] oid1,
int[] oid2)
Compares two Integer arrays |
static AgentSnmpException |
convertToAgentSnmpException(int version,
AgentException ae)
Throws AgentSnmpException from the received AgentException. |
(package private) static java.lang.String |
convertToHex(int asciiVal)
|
static java.lang.String[] |
convertToHexFormat(java.lang.String s)
Utility Method to convert the String to Hex format. |
(package private) static SnmpPDU |
copyPDU(SnmpPDU pdu)
Copies the SnmpPdU into another new SnmpPDU. |
static SnmpPDU |
copyPDUWdVarbind(SnmpPDU pdu)
Utility method to create a PDU with new instance of varbinds. |
static SnmpPDU |
copyPDUWoVarBinds(SnmpPDU pdu)
Utility method to create a PDU without the varbinds All other parameters such as RemoteHost etc are copied as it is Useful for Proxying. |
static void |
createLogger()
|
static byte[] |
genEngineID(java.lang.String ipAddress,
int port)
Utility method that generates the engineID. |
static java.lang.String |
getAgentDir()
Getter for the Agent Directory Location. |
static byte[] |
getBytes(java.lang.String dateTime)
This method is to convert the Snmp Date and Time form in to a Byte Array. |
static SnmpOID |
getColumnarOid(int[] oid,
int[] inst)
Creates a columnar OID by adding oid and its intance value. |
static SnmpOID |
getColumnarOid(int[] oid,
int subid,
int[] inst)
Creates a table columnar OID by adding columnar, sub oid and its intance value. |
static SnmpOID |
getColumnSnmpOID(int[] entryOID,
int pos,
int[] inst)
Utility method which creates an SnmpOID |
static int[] |
getInstance(int[] oid,
int pos)
Gets the instanceOID (starting from position pos) where pos is position from which the instance starts |
(package private) static int |
getMinSize(int[] oid1,
int[] oid2)
Give the minimum size of two oid. |
static int |
getNextIdentifier(int[] subidList,
int pos)
Gets the Next Identifier based on the position supplied for eg: subidList = [1,2, 5,6] pos = 3 would return 5 return -1 if end of subidList |
static byte[] |
getOctetBytes(java.lang.String octetStr)
Utility Method to get the byte Array representation of a String. |
static SnmpOID |
getScalarSnmpOID(int[] oid)
Gets the scalar SnmpOID from the integer array. |
static SnmpOID |
getScalarSnmpOID(int[] oid,
int pos)
Return the SnmpOID after adding the leafnode sub index and instance (".0") for scalar objects. |
static java.lang.String |
getString(byte[] bArray)
This method is to convert the given Byte array in to String value. |
static boolean |
isConsistentInetVal(java.util.Vector varbList,
int start,
java.lang.String[] oidArray)
This method checks if the InetAddressType value and the InetAddress values in the given VarBindRequestEvent are consistent. |
static boolean |
isInSubTree(int[] rootoid,
int[] oid)
Check if object id has rootoid as an ancestor. |
static boolean |
isNoMiddleTree(java.lang.Object obj,
java.lang.Object obj1)
Utility method to find if there is any possible tree in the middle of both the given Keys |
static boolean |
isValidDateAndTime(java.lang.String dateStr)
Checks whether the given Date Strring is a Valid one or not. |
static boolean |
isValidInetAddress(int inetType,
java.lang.String inetAddrs)
Checks if the given InetAddress is valid for the given InetAddressType. |
static int |
makeInstanceOIDWithoutLength(int[] inst,
byte[] type,
boolean[] isImplied,
int[] newIntArr)
Utility Method to create the InstanceOID with the inst array. |
static java.lang.String |
printOctets(byte[] data,
int length)
Utility method especially useful in printing the raw data in SnmpPDU.getData() or any octets with size "length". |
static SnmpVar[] |
resolveIndex(int[] inst,
byte[] type)
Resolves the multiple index from the given instance. |
static SnmpVar[] |
resolveIndex(int[] inst,
byte[] type,
boolean[] isImplied)
Resolves the multiple index from the given instance. |
static SnmpVar[] |
resolveIndex(int[] inst,
byte[] type,
java.lang.String[] syntax)
Resolves the multiple index from the given instance. |
static SnmpVar[] |
resolveIndex(int[] inst,
byte[] type,
java.lang.String[] syntax,
boolean[] isImplied)
Resolves the multiple index from the given instance. |
static void |
setAgentDir(java.lang.String dir)
Method to set the AgentDir location. |
(package private) void |
setAPI(SnmpAPI api)
set method for SnmpAPI from which we can get the agent related session parameters. |
(package private) static void |
setErrIndexAndErrStat(SnmpPDU pdu,
int errIndex,
int errStat)
Uility method to set errIndex and errStat values of pdu by SnmpAgent |
static java.lang.String |
stringFirstCharToUpper(java.lang.String toChange)
Converts the first character of a string to Upper character. |
static void |
throwBadValue()
Throws a bad value AgentSnmpException. |
static void |
throwBadValue(java.lang.String s)
Throws a bad value AgentSnmpException. |
static void |
throwCommitFailed(int version)
Throws a Commit Failed exception. |
static void |
throwEndOfMibView(int version)
Throws a end of mib view AgentSnmpException for End Of Mib View |
static void |
throwGenErr()
Throws a general error AgentSnmpException. |
static void |
throwGenErr(int version)
Throws a general error AgentSnmpException. |
static void |
throwInconsistentName(int version)
Throws a Inconsistent Name exception. |
static void |
throwInconsistentValue()
Throws a Inconsistent value AgentSnmpException. |
static void |
throwInconsistentValue(int version)
Throws a Inconsistent Value exception. |
static void |
throwInconsistentValue(java.lang.String s)
Throws a Inconsistent value AgentSnmpException. |
(package private) static void |
throwMaskErr()
Throws a mask error AgentSnmpException. |
static void |
throwNoAccess(int version)
Throws no access AgentSnmpException for End Of Mib View |
static void |
throwNoCreation(int version)
Throws a No Creation exception. |
void |
throwNoNextNode(int version)
API users can use this method when they need to throw a No Next Object exception |
static void |
throwNoNextObject()
API users can use this method when they need to throw a No Next Object exception |
static void |
throwNoSuchInstance()
Throws a no such instance exception. |
static void |
throwNoSuchInstance(int version)
Throws a no such instance exception. |
static void |
throwNoSuchObject()
Throws a AgentSnmpException with a message Fills both errstat and errvalues and expects SnmpAgent to handle based on version |
static void |
throwNoSuchObject(int version)
Throws no such object exception |
static void |
throwNotWritable(int version)
Throws a Not Writable exception. |
static void |
throwReadOnly(int version)
Throws ReadOnly AgentSnmpException. |
static void |
throwResourceUnavailable(int version)
Throws a Resource Unavailable exception. |
static void |
throwTooBig(int version)
Throws TooBig AgentSnmpException. |
static void |
throwUndoFailed(int version)
Throws a Undo Failed exception. |
static void |
throwWrongLength(int version)
Throws a Wrong Length exception. |
static void |
throwWrongType(int version)
Throws a Wrong Type exception. |
static void |
throwWrongValue(int version)
Throws a Wrong Value exception. |
static boolean |
validateAndSetRowStatus(SnmpVar var,
VarBindRequestEvent pe,
java.util.Hashtable virtualEntries,
RowStatusHandlerInterface entry,
RowStatusHandlerInterface entryToAdd,
int[] inst,
AgentTableModel tModelComplete,
int columnCount,
BaseSnmpAgent agentName,
java.lang.String reqHandlerName)
Method to validate and set the RowStauts columns in a Table. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static byte SNMP_ERR_MASKERR
public static byte SNMP_REQUEST_TIMEOUT
static byte SNMP_PROXY_ERR
public static java.lang.String agentDir
public static Log snmpLog
| Constructor Detail |
public AgentUtil(SnmpAPI api,
BaseSnmpAgent agent)
api - the SnmpAPIagent - the SnmpAgentSnmpAPI| Method Detail |
void setAPI(SnmpAPI api)
public static SnmpOID getColumnSnmpOID(int[] entryOID,
int pos,
int[] inst)
For example,
entryOID = [1,3,6,1,2,1,2,2,1]
pos = 2
inst = [1]
result = SnmpOID with oid [1,3,6,1,2,1,2,2,1,2,1]
entry - oid (integer array)int - position of columninst - instance OID
public static int[] getInstance(int[] oid,
int pos)
oid - integer array of oidpos - index of instance startspublic static java.lang.String stringFirstCharToUpper(java.lang.String toChange)
toChange - string to convertpublic static byte[] getOctetBytes(java.lang.String octetStr)
octetStr - The String to be converted.
public static SnmpOID getScalarSnmpOID(int[] oid,
int pos)
For example,
oid = [1,3,6,1,2,1,1]
pos = 2
result = SnmpOID with oid [1,3,6,1,2,1,1,2,0]
oid - Integer Array.pos - The position Value.
public static SnmpOID getColumnarOid(int[] oid,
int[] inst)
For example,
oid = [1,3,6,1,4,6,1,1,2]
inst(IpAddress) = [255,255,255,0]
result = SnmpOID with oid [1,3,6,1,4,6,1,1,2,255,255,255,0]
oid - The OID Value.inst - The Instance value.
public static SnmpOID getColumnarOid(int[] oid,
int subid,
int[] inst)
For example,
oid = [1,3,6,1,4,6,1,1]
subid = 2
inst(IpAddress) = [255,255,255,0]
result = SnmpOID with oid [1,3,6,1,4,6,1,1,2,255,255,255,0]
oid - The OID value.subid - The subId value.inst - The instance value.public static SnmpOID getScalarSnmpOID(int[] oid)
For example,
oid = [1,3,6,1,2,1,1,2]
result = SnmpOID with oid [1,3,6,1,2,1,1,2,0]
oid - Integer array.public static SnmpPDU copyPDUWoVarBinds(SnmpPDU pdu)
pdu - a SnmpPDUpublic static int byteToInt(byte b)
b - the input byte
public static java.lang.String printOctets(byte[] data,
int length)
data - the byte arraylength - the length of the printable byte arraystatic SnmpPDU copyPDU(SnmpPDU pdu)
pdu - The SnmpPDU to be copiedpublic static SnmpPDU copyPDUWdVarbind(SnmpPDU pdu)
pdu - a SnmpPDU
static void setErrIndexAndErrStat(SnmpPDU pdu,
int errIndex,
int errStat)
pdu - the SnmpPDU to set error index and error statuserrIndex - error indexerrStat - error status
public static void throwNoSuchInstance(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME,
com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP
public static void throwNoSuchInstance()
throws AgentSnmpException
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME,
com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP
public static void throwNoSuchObject(int version)
throws AgentSnmpException
version - the Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME,
com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP
public static void throwNoSuchObject()
throws AgentSnmpException
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME,
com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP
public static void throwEndOfMibView(int version)
throws AgentSnmpException
version - the Snmp version.com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME,
com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP
public static void throwNoNextObject()
throws AgentSnmpException
static void throwMaskErr()
throws AgentSnmpException
public void throwNoNextNode(int version)
throws AgentSnmpException
version - the SnmpVersion
public static void throwNoAccess(int version)
throws AgentSnmpException
version - the Snmp version.com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME,
com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP
public static void throwReadOnly(int version)
throws AgentSnmpException
version - The Snmp version.com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_READONLY
public static void throwTooBig(int version)
throws AgentSnmpException
version - the Snmp version.com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_TOOBIG
public static void throwGenErr(int version)
throws AgentSnmpException
version - the Snmp version.
public static void throwGenErr()
throws AgentSnmpException
public static void throwBadValue()
throws AgentSnmpException
public static void throwBadValue(java.lang.String s)
throws AgentSnmpException
s - the description of the exception.
public static void throwInconsistentValue()
throws AgentSnmpException
public static void throwInconsistentValue(java.lang.String s)
throws AgentSnmpException
s - the description of the exception.
public static int compareTo(int[] oid1,
int[] oid2)
oid1 - array of integer of oidoid2 - array of integer of oid
public static int getNextIdentifier(int[] subidList,
int pos)
subidList - array of integer of the subid listpos - the index in the array to start search
public static boolean isInSubTree(int[] rootoid,
int[] oid)
rootoid - array of integer for root oid.oid - array of integer for oid.
public static boolean isNoMiddleTree(java.lang.Object obj,
java.lang.Object obj1)
obj - the preceding keyobj1 - the succeeding key
static int getMinSize(int[] oid1,
int[] oid2)
oid1 - array of integeroid2 - array of integer
public static byte[] genEngineID(java.lang.String ipAddress,
int port)
ipAddress - host ipAddress of the SNMP Engineport - where the SNMP engine is running
public static boolean isConsistentInetVal(java.util.Vector varbList,
int start,
java.lang.String[] oidArray)
throws AgentException
pe - VarbindRequestEvent that contains the
InetAddress and InetAddressType varbindsoidArray - an array containing the OIDs for
InetAddress and InetAddressType nodestrue if values are consistent; false otherwise.
public static boolean isValidInetAddress(int inetType,
java.lang.String inetAddrs)
throws AgentException
an - InetAddressType valuean - InetAddress value to be checkedtrue if the InetAddress is valid for the given InetAddressType; false otherwise.
public static SnmpVar[] resolveIndex(int[] inst,
byte[] type)
Handles only if indexes are String, Integer, IpAddress, Oid.
For example
inst - int[] which says the instance oidtype - byte[] which gives the list of indexes type.
public static SnmpVar[] resolveIndex(int[] inst,
byte[] type,
java.lang.String[] syntax)
Handles only if indexes are String, Integer, IpAddress, Oid.
For example
inst - int[] which says the instance oidtype - byte[] which gives the list of indexes type.syntax - String[] which gives the Mib syntax of the indexes.
public static SnmpVar[] resolveIndex(int[] inst,
byte[] type,
boolean[] isImplied)
Handles only if indexes are String, Integer, IpAddress, Oid.
For example
inst - int[] which says the instance oid.type - byte[] which gives the list of indexes type.isImplied - The Boolean array to tell whether the Index is an Implied Index or not.
public static SnmpVar[] resolveIndex(int[] inst,
byte[] type,
java.lang.String[] syntax,
boolean[] isImplied)
Handles only if indexes are String, Integer, IpAddress, Oid.
For example
inst - int[] which says the instance oid.type - byte[] which gives the list of index types.sytax - String[] which has the list of MIB syntaxes for the indicesisImplied - The Boolean array to tell whether the Index is an Implied Index or not.public static boolean isValidDateAndTime(java.lang.String dateStr)
dateStr - The String to be checked.
public static java.lang.String getString(byte[] bArray)
throws java.lang.IllegalArgumentException
The - Byte array to be converted.public static byte[] getBytes(java.lang.String dateTime)
The Snmp dateTime Form (eg) "1999-9-1,1:3:1.0,-1:2".
dateTime - The Snmp Date Time Form to be converted as Byte Array.
public static void throwWrongType(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_WRONGTYPE,
com.adventnet.snmp.snmp2.SnmpAPI.GENERR
public static void throwNoCreation(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOCREATION,
com.adventnet.snmp.snmp2.SnmpAPI.GENERR
public static void throwNotWritable(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOTWRITABLE,
com.adventnet.snmp.snmp2.SnmpAPI.GENERR
public static void throwWrongLength(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_WRONGLENGTH,
com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE
public static void throwWrongValue(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_WRONGVALUE,
com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE
public static void throwInconsistentName(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_INCONSISTENTNAME,
com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE
public static void throwInconsistentValue(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_INCONSISTENTVALUE,
com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE
public static void throwResourceUnavailable(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_RESOURCEUNAVAILABLE,
com.adventnet.snmp.snmp2.SnmpAPI.GENERR
public static void throwCommitFailed(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_COMMITFAILED,
com.adventnet.snmp.snmp2.SnmpAPI.GENERR
public static void throwUndoFailed(int version)
throws AgentSnmpException
version - Snmp versioncom.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_UNDOFAILED,
com.adventnet.snmp.snmp2.SnmpAPI.GENERR
public static AgentSnmpException convertToAgentSnmpException(int version,
AgentException ae)
version - The SNMP version integer value.ae - The AgentException thrown from Agent Instrumentation.com.adventnet.agent.utlities.common.AgentException
public static boolean validateAndSetRowStatus(SnmpVar var,
VarBindRequestEvent pe,
java.util.Hashtable virtualEntries,
RowStatusHandlerInterface entry,
RowStatusHandlerInterface entryToAdd,
int[] inst,
AgentTableModel tModelComplete,
int columnCount,
BaseSnmpAgent agentName,
java.lang.String reqHandlerName)
throws AgentSnmpException
var - The SnmpVar created for the Requestpe - The VarBindRequestEvent created for this requestvirtualEntries - The Virtual entries Hashtable of
the RequestHanderentry - The RowStatusHandlerInterface instanceentryToAdd - The RowStatusHandlerInterface instnceinst - The instance int[] of the request.tModelComplete - The AgentTableModel associated with the tablecolumnCount - The column count intagentName - The SnmpAgent referencereqHandlerName - The RequestHandler Name in Stringpublic static void setAgentDir(java.lang.String dir)
dir - the AgentDirectory specification.public static java.lang.String getAgentDir()
public static int makeInstanceOIDWithoutLength(int[] inst,
byte[] type,
boolean[] isImplied,
int[] newIntArr)
inst - The instance valuetype - the byte array representing the index types.isImplied - boolean[] of value as true if the index is implied.newIntArr - a new Int Array.public static java.lang.String[] convertToHexFormat(java.lang.String s)
s - the string to be converted.static java.lang.String convertToHex(int asciiVal)
public static void createLogger()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||