com.adventnet.snmp.snmp2.agent
Class AgentUtil

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.agent.AgentUtil

public class AgentUtil
extends java.lang.Object

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
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNMP_ERR_MASKERR

static byte SNMP_ERR_MASKERR

SNMP_REQUEST_TIMEOUT

public static byte SNMP_REQUEST_TIMEOUT
The Snmp Request Timeout Value.

SNMP_PROXY_ERR

static byte SNMP_PROXY_ERR

agentDir

public static java.lang.String agentDir
The AgentDirectory used commonly for all the API Tables stroage details.

snmpLog

public static Log snmpLog
Constructor Detail

AgentUtil

public AgentUtil(SnmpAPI api,
                 BaseSnmpAgent agent)
Constructor for AgentUtil with SnmpAPI and SnmpAgent
Parameters:
api - the SnmpAPI
agent - the SnmpAgent
See Also:
SnmpAPI
Method Detail

setAPI

void setAPI(SnmpAPI api)
set method for SnmpAPI from which we can get the agent related session parameters.

getColumnSnmpOID

public static SnmpOID getColumnSnmpOID(int[] entryOID,
                                       int pos,
                                       int[] inst)
Utility method which creates an SnmpOID

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]

Parameters:
entry - oid (integer array)
int - position of column
inst - instance OID
Returns:
SnmpOID

getInstance

public static int[] getInstance(int[] oid,
                                int pos)
Gets the instanceOID (starting from position pos) where pos is position from which the instance starts
Parameters:
oid - integer array of oid
pos - index of instance starts
Returns:
integer array

stringFirstCharToUpper

public static java.lang.String stringFirstCharToUpper(java.lang.String toChange)
Converts the first character of a string to Upper character.
Parameters:
toChange - string to convert
Returns:
the converted string.

getOctetBytes

public static byte[] getOctetBytes(java.lang.String octetStr)
Utility Method to get the byte Array representation of a String.
Parameters:
octetStr - The String to be converted.
Returns:
The byte[] representation of the String.

getScalarSnmpOID

public static SnmpOID getScalarSnmpOID(int[] oid,
                                       int pos)
Return the SnmpOID after adding the leafnode sub index and instance (".0") for scalar objects.

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]

Parameters:
oid - Integer Array.
pos - The position Value.
Returns:
The created SnmpOID.

getColumnarOid

public static SnmpOID getColumnarOid(int[] oid,
                                     int[] inst)
Creates a columnar OID by adding oid and its intance value.

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]

Parameters:
oid - The OID Value.
inst - The Instance value.
Returns:
The SnmpOID Value obtained.

getColumnarOid

public static SnmpOID getColumnarOid(int[] oid,
                                     int subid,
                                     int[] inst)
Creates a table columnar OID by adding columnar, sub oid and its intance value.

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]

Parameters:
oid - The OID value.
subid - The subId value.
inst - The instance value.
Returns:
The Snmp OID Value created.

getScalarSnmpOID

public static SnmpOID getScalarSnmpOID(int[] oid)
Gets the scalar SnmpOID from the integer array.

For example,

oid = [1,3,6,1,2,1,1,2]

result = SnmpOID with oid [1,3,6,1,2,1,1,2,0]

Parameters:
oid - Integer array.
Returns:
The SnmpOID created.

copyPDUWoVarBinds

public 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.
Parameters:
pdu - a SnmpPDU
Returns:
copied SnmpPDU

byteToInt

public static int byteToInt(byte b)
Utility method which converts byte to int datatype
Parameters:
b - the input byte
Returns:
int value

printOctets

public 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".
Parameters:
data - the byte array
length - the length of the printable byte array
Returns:
the printable String.

copyPDU

static SnmpPDU copyPDU(SnmpPDU pdu)
Copies the SnmpPdU into another new SnmpPDU.
Parameters:
pdu - The SnmpPDU to be copied
Returns:
copied SnmpPDU

copyPDUWdVarbind

public static SnmpPDU copyPDUWdVarbind(SnmpPDU pdu)
Utility method to create a PDU with new instance of varbinds. All other parameters such as RemoteHost etc are copied as it is Useful for rollback feature.
Parameters:
pdu - a SnmpPDU
Returns:
copied SnmpPDU

setErrIndexAndErrStat

static void setErrIndexAndErrStat(SnmpPDU pdu,
                                  int errIndex,
                                  int errStat)
Uility method to set errIndex and errStat values of pdu by SnmpAgent
Parameters:
pdu - the SnmpPDU to set error index and error status
errIndex - error index
errStat - error status

throwNoSuchInstance

public static void throwNoSuchInstance(int version)
                                throws AgentSnmpException
Throws a no such instance exception.
Parameters:
version - Snmp version
Throws:
AgentSnmpException - throws "No such instance" error
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME, com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP

throwNoSuchInstance

public static void throwNoSuchInstance()
                                throws AgentSnmpException
Throws a no such instance exception. Fills both errstat and errvalues and expects SnmpAgent to handle based on version
Throws:
AgentSnmpException - throws "No such instance" error
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME, com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP

throwNoSuchObject

public static void throwNoSuchObject(int version)
                              throws AgentSnmpException
Throws no such object exception
Parameters:
version - the Snmp version
Throws:
AgentSnmpException - with a message "No such Object in the MIB"
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME, com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP

throwNoSuchObject

public static void throwNoSuchObject()
                              throws AgentSnmpException
Throws a AgentSnmpException with a message Fills both errstat and errvalues and expects SnmpAgent to handle based on version
Throws:
AgentSnmpException - throws "No such Object in the MIB"
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME, com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP

throwEndOfMibView

public static void throwEndOfMibView(int version)
                              throws AgentSnmpException
Throws a end of mib view AgentSnmpException for End Of Mib View
Parameters:
version - the Snmp version.
Throws:
AgentSnmpException - throws "End of Mib encountered"
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME, com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP

throwNoNextObject

public static void throwNoNextObject()
                              throws AgentSnmpException
API users can use this method when they need to throw a No Next Object exception
Throws:
AgentSnmpException - throws "No Next Object" exception.

throwMaskErr

static void throwMaskErr()
                  throws AgentSnmpException
Throws a mask error AgentSnmpException.
Throws:
AgentSnmpException - for mask error

throwNoNextNode

public void throwNoNextNode(int version)
                     throws AgentSnmpException
API users can use this method when they need to throw a No Next Object exception
Parameters:
version - the SnmpVersion
Throws:
AgentSnmpException - throws no next object exception.

throwNoAccess

public static void throwNoAccess(int version)
                          throws AgentSnmpException
Throws no access AgentSnmpException for End Of Mib View
Parameters:
version - the Snmp version.
Throws:
AgentSnmpException - for end of mib file view
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOSUCHNAME, com.adventnet.snmp.snmp2.SnmpAPI.NOSUCHINSTANCEEXP

throwReadOnly

public static void throwReadOnly(int version)
                          throws AgentSnmpException
Throws ReadOnly AgentSnmpException.
Parameters:
version - The Snmp version.
Throws:
AgentSnmpException - If the File is Read Only accessible.
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_READONLY

throwTooBig

public static void throwTooBig(int version)
                        throws AgentSnmpException
Throws TooBig AgentSnmpException.
Parameters:
version - the Snmp version.
Throws:
AgentSnmpException - For TooBig error Values.
See Also:
com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_TOOBIG

throwGenErr

public static void throwGenErr(int version)
                        throws AgentSnmpException
Throws a general error AgentSnmpException.
Parameters:
version - the Snmp version.
Throws:
AgentSnmpException - for general error

throwGenErr

public static void throwGenErr()
                        throws AgentSnmpException
Throws a general error AgentSnmpException.
Throws:
AgentSnmpException - for general error

throwBadValue

public static void throwBadValue()
                          throws AgentSnmpException
Throws a bad value AgentSnmpException. with the empty description.
Throws:
AgentSnmpException - for bad value error

throwBadValue

public static void throwBadValue(java.lang.String s)
                          throws AgentSnmpException
Throws a bad value AgentSnmpException. with the given description.
Parameters:
s - the description of the exception.
Throws:
AgentSnmpException - for bad value error

throwInconsistentValue

public static void throwInconsistentValue()
                                   throws AgentSnmpException
Throws a Inconsistent value AgentSnmpException. with the empty description.
Throws:
AgentSnmpException - for Inconsistent value error

throwInconsistentValue

public static void throwInconsistentValue(java.lang.String s)
                                   throws AgentSnmpException
Throws a Inconsistent value AgentSnmpException. with the given description.
Parameters:
s - the description of the exception.
Throws:
AgentSnmpException - for Inconsistent value error

compareTo

public static int compareTo(int[] oid1,
                            int[] oid2)
Compares two Integer arrays
Parameters:
oid1 - array of integer of oid
oid2 - array of integer of oid
Returns:
  • -1 if first param is lesser than second
  • 0 if equal
  • 1 if first param is greater than the second param

  • getNextIdentifier

    public 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
    Parameters:
    subidList - array of integer of the subid list
    pos - the index in the array to start search
    Returns:
    -1 if subid list is null ; otherwise the value next to the index in the subid list

    isInSubTree

    public static boolean isInSubTree(int[] rootoid,
                                      int[] oid)
    Check if object id has rootoid as an ancestor.
    Parameters:
    rootoid - array of integer for root oid.
    oid - array of integer for oid.
    Returns:
    True if the OID has a rootOID else False.

    isNoMiddleTree

    public 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
    Parameters:
    obj - the preceding key
    obj1 - the succeeding key
    Returns:
    true for invalid Object Keys and false if there might be a middle tree

    getMinSize

    static int getMinSize(int[] oid1,
                          int[] oid2)
    Give the minimum size of two oid.
    Parameters:
    oid1 - array of integer
    oid2 - array of integer
    Returns:
    the minimum length of the given oids

    genEngineID

    public static byte[] genEngineID(java.lang.String ipAddress,
                                     int port)
    Utility method that generates the engineID. This method generates the engineID for an SNMP engine based on the ipAddress and the port
    Parameters:
    ipAddress - host ipAddress of the SNMP Engine
    port - where the SNMP engine is running
    Returns:
    byte[] representing the engineID of the agent

    isConsistentInetVal

    public static boolean isConsistentInetVal(java.util.Vector varbList,
                                              int start,
                                              java.lang.String[] oidArray)
                                       throws AgentException
    This method checks if the InetAddressType value and the InetAddress values in the given VarBindRequestEvent are consistent.
    Parameters:
    pe - VarbindRequestEvent that contains the InetAddress and InetAddressType varbinds
    oidArray - an array containing the OIDs for InetAddress and InetAddressType nodes
    Returns:
    true if values are consistent; false otherwise.
    Throws:
    AgentException - Exception is thrown,if wrong value is given for InetAddress

    isValidInetAddress

    public static boolean isValidInetAddress(int inetType,
                                             java.lang.String inetAddrs)
                                      throws AgentException
    Checks if the given InetAddress is valid for the given InetAddressType.
    Parameters:
    an - InetAddressType value
    an - InetAddress value to be checked
    Returns:
    true if the InetAddress is valid for the given InetAddressType; false otherwise.
    Throws:
    AgentException - Exception is thrown if, wrong value is given for InetAddress

    resolveIndex

    public static SnmpVar[] resolveIndex(int[] inst,
                                         byte[] type)
    Resolves the multiple index from the given instance.

    Handles only if indexes are String, Integer, IpAddress, Oid.

    For example

  • inst = [255.255.255.0.6.1.3.6.1.2.1]
  • type[0] = SnmpAPI.IPADDRESS
  • type[1] = SnmpAPI.OBJID
  • result = SnmpIpAddress with value 255.255.255.0 , returned as SnmpVar[0]
  • SnmpOID with value .1.3.6.1.2.1 , returned as SnmpVar[1].
    Parameters:
    inst - int[] which says the instance oid
    type - byte[] which gives the list of indexes type.
    Returns:
    SnmpVar[] corresponding to the list of indexes type passed as parameter .

  • resolveIndex

    public static SnmpVar[] resolveIndex(int[] inst,
                                         byte[] type,
                                         java.lang.String[] syntax)
    Resolves the multiple index from the given instance.

    Handles only if indexes are String, Integer, IpAddress, Oid.

    For example

  • inst = [255.255.255.0.6.1.3.6.1.2.1]
  • type[0] = SnmpAPI.IPADDRESS
  • type[1] = SnmpAPI.OBJID
  • result = SnmpIpAddress with value 255.255.255.0 , returned as SnmpVar[0]
  • SnmpOID with value .1.3.6.1.2.1 , returned as SnmpVar[1].
    Parameters:
    inst - int[] which says the instance oid
    type - byte[] which gives the list of indexes type.
    syntax - String[] which gives the Mib syntax of the indexes.
    Returns:
    SnmpVar[] corresponding to the list of indexes type passed as parameter .

  • resolveIndex

    public static SnmpVar[] resolveIndex(int[] inst,
                                         byte[] type,
                                         boolean[] isImplied)
    Resolves the multiple index from the given instance.

    Handles only if indexes are String, Integer, IpAddress, Oid.

    For example

  • inst = [255.255.255.0.6.1.3.6.1.2.1]
  • type[0] = SnmpAPI.IPADDRESS
  • type[1] = SnmpAPI.OBJID
  • result = SnmpIpAddress with value 255.255.255.0 , returned as SnmpVar[0]
  • SnmpOID with value .1.3.6.1.2.1 , returned as SnmpVar[1].
    Parameters:
    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.
    Returns:
    SnmpVar[] corresponding to the list of indexes type passed as parameter.

  • resolveIndex

    public static SnmpVar[] resolveIndex(int[] inst,
                                         byte[] type,
                                         java.lang.String[] syntax,
                                         boolean[] isImplied)
    Resolves the multiple index from the given instance.

    Handles only if indexes are String, Integer, IpAddress, Oid.

    For example

  • inst = [255.255.255.0.6.1.3.6.1.2.1]
  • type[0] = SnmpAPI.IPADDRESS
  • type[1] = SnmpAPI.OBJID
  • result = SnmpIpAddress with value 255.255.255.0 , returned as SnmpVar[0]
  • SnmpOID with value .1.3.6.1.2.1 , returned as SnmpVar[1].
    Parameters:
    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 indices
    isImplied - The Boolean array to tell whether the Index is an Implied Index or not.
    Returns:
    SnmpVar[] corresponding to the list of indexes type passed as parameter.

  • isValidDateAndTime

    public static boolean isValidDateAndTime(java.lang.String dateStr)
    Checks whether the given Date Strring is a Valid one or not.
    Parameters:
    dateStr - The String to be checked.
    Returns:
    True If the String is a valid one, else False.

    getString

    public static java.lang.String getString(byte[] bArray)
                                      throws java.lang.IllegalArgumentException
    This method is to convert the given Byte array in to String value.
    Parameters:
    The - Byte array to be converted.
    Returns:
    The converted String value.
    Throws:
    java.lang.IllegalArgumentException - If the Byte array length is not 8 or 11.

    getBytes

    public static byte[] getBytes(java.lang.String dateTime)
    This method is to convert the Snmp Date and Time form in to a Byte Array.

    The Snmp dateTime Form (eg) "1999-9-1,1:3:1.0,-1:2".

    Parameters:
    dateTime - The Snmp Date Time Form to be converted as Byte Array.
    Returns:
    The Byte Array Equivalent.

    throwWrongType

    public static void throwWrongType(int version)
                               throws AgentSnmpException
    Throws a Wrong Type exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Wrong Type" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_WRONGTYPE, com.adventnet.snmp.snmp2.SnmpAPI.GENERR

    throwNoCreation

    public static void throwNoCreation(int version)
                                throws AgentSnmpException
    Throws a No Creation exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "No Creation" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOCREATION, com.adventnet.snmp.snmp2.SnmpAPI.GENERR

    throwNotWritable

    public static void throwNotWritable(int version)
                                 throws AgentSnmpException
    Throws a Not Writable exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Not Writable" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_NOTWRITABLE, com.adventnet.snmp.snmp2.SnmpAPI.GENERR

    throwWrongLength

    public static void throwWrongLength(int version)
                                 throws AgentSnmpException
    Throws a Wrong Length exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Wrong Length" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_WRONGLENGTH, com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE

    throwWrongValue

    public static void throwWrongValue(int version)
                                throws AgentSnmpException
    Throws a Wrong Value exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Wrong Value" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_WRONGVALUE, com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE

    throwInconsistentName

    public static void throwInconsistentName(int version)
                                      throws AgentSnmpException
    Throws a Inconsistent Name exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Inconsistent Name" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_INCONSISTENTNAME, com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE

    throwInconsistentValue

    public static void throwInconsistentValue(int version)
                                       throws AgentSnmpException
    Throws a Inconsistent Value exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Inconsistent Value" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_INCONSISTENTVALUE, com.adventnet.snmp.snmp2.SnmpAPI.BADVALUE

    throwResourceUnavailable

    public static void throwResourceUnavailable(int version)
                                         throws AgentSnmpException
    Throws a Resource Unavailable exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Resource Unavailable" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_RESOURCEUNAVAILABLE, com.adventnet.snmp.snmp2.SnmpAPI.GENERR

    throwCommitFailed

    public static void throwCommitFailed(int version)
                                  throws AgentSnmpException
    Throws a Commit Failed exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Commit Failed" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_COMMITFAILED, com.adventnet.snmp.snmp2.SnmpAPI.GENERR

    throwUndoFailed

    public static void throwUndoFailed(int version)
                                throws AgentSnmpException
    Throws a Undo Failed exception.
    Parameters:
    version - Snmp version
    Throws:
    AgentSnmpException - throws "Undo Failed" error
    See Also:
    com.adventnet.snmp.snmp2.SnmpAPI.SNMP_ERR_UNDOFAILED, com.adventnet.snmp.snmp2.SnmpAPI.GENERR

    convertToAgentSnmpException

    public static AgentSnmpException convertToAgentSnmpException(int version,
                                                                 AgentException ae)
    Throws AgentSnmpException from the received AgentException.
    Parameters:
    version - The SNMP version integer value.
    ae - The AgentException thrown from Agent Instrumentation.
    Returns:
    The Agent Snmp Exception obtained.
    See Also:
    com.adventnet.agent.utlities.common.AgentException

    validateAndSetRowStatus

    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
    Method to validate and set the RowStauts columns in a Table. This method will be called from the generated RequestHandler's
    Parameters:
    var - The SnmpVar created for the Request
    pe - The VarBindRequestEvent created for this request
    virtualEntries - The Virtual entries Hashtable of the RequestHander
    entry - The RowStatusHandlerInterface instance
    entryToAdd - The RowStatusHandlerInterface instnce
    inst - The instance int[] of the request.
    tModelComplete - The AgentTableModel associated with the table
    columnCount - The column count int
    agentName - The SnmpAgent reference
    reqHandlerName - The RequestHandler Name in String
    Returns:
    true if the Row is creatabe else a false.
    Throws:
    AgentSnmpException - this wraps all the errors during this validation.

    setAgentDir

    public static void setAgentDir(java.lang.String dir)
    Method to set the AgentDir location.
    Parameters:
    dir - the AgentDirectory specification.

    getAgentDir

    public static java.lang.String getAgentDir()
    Getter for the Agent Directory Location.
    Returns:
    The Agent Directory as a String.

    makeInstanceOIDWithoutLength

    public static int makeInstanceOIDWithoutLength(int[] inst,
                                                   byte[] type,
                                                   boolean[] isImplied,
                                                   int[] newIntArr)
    Utility Method to create the InstanceOID with the inst array. API users can use this method to get the Instance OID's with out The length for the String datatype indexes.
    Parameters:
    inst - The instance value
    type - the byte array representing the index types.
    isImplied - boolean[] of value as true if the index is implied.
    newIntArr - a new Int Array.
    Returns:
    The method will return -1, 0, 1 based on the inst param and resolving them.
  • If the type is 3 i.e., the Table having 3 indexes and if the inst value has two index values completely it will return a 0.
  • It will return a -1 if any of the index is half filled for String indexes.
  • 1 will be returned if all the indexes were given right. The newIntArr will get Updated with the found Instance.

  • convertToHexFormat

    public static java.lang.String[] convertToHexFormat(java.lang.String s)
    Utility Method to convert the String to Hex format.
    Parameters:
    s - the string to be converted.
    Returns:
    the String[] converted.

    convertToHex

    static java.lang.String convertToHex(int asciiVal)

    createLogger

    public static void createLogger()