Java Code Examples for com.sun.jmx.snmp.SnmpDefinitions#snmpVersionTwo()

The following examples show how to use com.sun.jmx.snmp.SnmpDefinitions#snmpVersionTwo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnmpSubRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 2
Source File: SnmpSubRequestHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 3
Source File: SnmpSubRequestHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 4
Source File: SnmpSubRequestHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 5
Source File: SnmpSubRequestHandler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 6
Source File: SnmpSubRequestHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 7
Source File: SnmpSubRequestHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static final int mapErrorStatus(int errorStatus,
                                int protocolVersion,
                                int reqPduType) {
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    // Too bad, an error occurs ... we need to translate it ...
    //
    if (protocolVersion == SnmpDefinitions.snmpVersionOne)
        return mapErrorStatusToV1(errorStatus,reqPduType);
    if (protocolVersion == SnmpDefinitions.snmpVersionTwo ||
        protocolVersion == SnmpDefinitions.snmpVersionThree)
        return mapErrorStatusToV2(errorStatus,reqPduType);

    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 8
Source File: SnmpRequestHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 9
Source File: SnmpRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 10
Source File: SnmpRequestHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 11
Source File: SnmpRequestHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 12
Source File: SnmpRequestHandler.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 13
Source File: SnmpRequestHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 14
Source File: SnmpRequestHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
SnmpPduPacket makeNoMibErrorPdu(SnmpPduRequest req, Object userData) {
    // There is no agent registered
    //
    if (req.version == SnmpDefinitions.snmpVersionOne) {
        // Version 1: => NoSuchName
        return
            newErrorResponsePdu(req,snmpRspNoSuchName,1);
    } else if (req.version == SnmpDefinitions.snmpVersionTwo) {
        // Version 2: => depends on PDU type
        switch (req.type) {
        case pduSetRequestPdu :
        case pduWalkRequest :
            // SET request => NoAccess
            return
                newErrorResponsePdu(req,snmpRspNoAccess,1);
        case pduGetRequestPdu :
            // GET request => NoSuchObject
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errNoSuchObjectTag);
        case pduGetNextRequestPdu :
        case pduGetBulkRequestPdu :
            // GET-NEXT or GET-BULK => EndOfMibView
            return
                makeErrorVarbindPdu(req,SnmpDataTypeEnums.
                                    errEndOfMibViewTag);
        default:
        }
    }
    // Something wrong here: => snmpRspGenErr
    return newErrorResponsePdu(req,snmpRspGenErr,1);
}
 
Example 15
Source File: SnmpMibAgent.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation using call to
 * <CODE>getNext</CODE>.
 * The method implements the <CODE>getBulk</CODE> operation by calling
 * appropriately the <CODE>getNext</CODE> method.
 *
 * @param req The SnmpMibRequest containing the variable list to be
 *        retrieved.
 *
 * @param nonRepeat The number of variables, starting with the first
 *    variable in the variable-bindings, for which a single lexicographic
 *    successor is requested.
 *
 * @param maxRepeat The number of lexicographic successors
 *    requested for each of the last R variables. R is the number of
 *    variables following the first nonRepeat variables for which
 *    multiple lexicographic successors are requested.
 *
 * @return The variable list containing returned values.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */
void getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {
    final Vector<SnmpVarBind> list = req.getSubList();

    // RFC 1905, Section 4.2.3, p14
    final int L = list.size() ;
    final int N = Math.max(Math.min(nonRepeat, L), 0) ;
    final int M = Math.max(maxRepeat, 0) ;
    final int R = L - N ;

    // Let's build the varBindList for the response pdu
    //
    // int errorStatus = SnmpDefinitions.snmpRspNoError ;
    // int errorIndex = 0 ;
    if (L != 0) {

        // Non-repeaters and first row of repeaters
        //
        getNext(req);

        // Now the remaining repeaters
        //
        Vector<SnmpVarBind> repeaters= splitFrom(list, N);
        SnmpMibRequestImpl repeatedReq =
            new SnmpMibRequestImpl(req.getEngine(),
                                   req.getPdu(),
                                   repeaters,
                                   SnmpDefinitions.snmpVersionTwo,
                                   req.getUserData(),
                                   req.getPrincipal(),
                                   req.getSecurityLevel(),
                                   req.getSecurityModel(),
                                   req.getContextName(),
                                   req.getAccessContextName());
        for (int i = 2 ; i <= M ; i++) {
            getNext(repeatedReq);
            concatVector(req, repeaters);
        }
    }
}
 
Example 16
Source File: SnmpMibAgent.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation using call to
 * <CODE>getNext</CODE>.
 * The method implements the <CODE>getBulk</CODE> operation by calling
 * appropriately the <CODE>getNext</CODE> method.
 *
 * @param req The SnmpMibRequest containing the variable list to be
 *        retrieved.
 *
 * @param nonRepeat The number of variables, starting with the first
 *    variable in the variable-bindings, for which a single lexicographic
 *    successor is requested.
 *
 * @param maxRepeat The number of lexicographic successors
 *    requested for each of the last R variables. R is the number of
 *    variables following the first nonRepeat variables for which
 *    multiple lexicographic successors are requested.
 *
 * @return The variable list containing returned values.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */
void getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {
    final Vector<SnmpVarBind> list = req.getSubList();

    // RFC 1905, Section 4.2.3, p14
    final int L = list.size() ;
    final int N = Math.max(Math.min(nonRepeat, L), 0) ;
    final int M = Math.max(maxRepeat, 0) ;
    final int R = L - N ;

    // Let's build the varBindList for the response pdu
    //
    // int errorStatus = SnmpDefinitions.snmpRspNoError ;
    // int errorIndex = 0 ;
    if (L != 0) {

        // Non-repeaters and first row of repeaters
        //
        getNext(req);

        // Now the remaining repeaters
        //
        Vector<SnmpVarBind> repeaters= splitFrom(list, N);
        SnmpMibRequestImpl repeatedReq =
            new SnmpMibRequestImpl(req.getEngine(),
                                   req.getPdu(),
                                   repeaters,
                                   SnmpDefinitions.snmpVersionTwo,
                                   req.getUserData(),
                                   req.getPrincipal(),
                                   req.getSecurityLevel(),
                                   req.getSecurityModel(),
                                   req.getContextName(),
                                   req.getAccessContextName());
        for (int i = 2 ; i <= M ; i++) {
            getNext(repeatedReq);
            concatVector(req, repeaters);
        }
    }
}
 
Example 17
Source File: SnmpMibAgent.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation using call to
 * <CODE>getNext</CODE>.
 * The method implements the <CODE>getBulk</CODE> operation by calling
 * appropriately the <CODE>getNext</CODE> method.
 *
 * @param req The SnmpMibRequest containing the variable list to be
 *        retrieved.
 *
 * @param nonRepeat The number of variables, starting with the first
 *    variable in the variable-bindings, for which a single lexicographic
 *    successor is requested.
 *
 * @param maxRepeat The number of lexicographic successors
 *    requested for each of the last R variables. R is the number of
 *    variables following the first nonRepeat variables for which
 *    multiple lexicographic successors are requested.
 *
 * @return The variable list containing returned values.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */
void getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {
    final Vector<SnmpVarBind> list = req.getSubList();

    // RFC 1905, Section 4.2.3, p14
    final int L = list.size() ;
    final int N = Math.max(Math.min(nonRepeat, L), 0) ;
    final int M = Math.max(maxRepeat, 0) ;
    final int R = L - N ;

    // Let's build the varBindList for the response pdu
    //
    // int errorStatus = SnmpDefinitions.snmpRspNoError ;
    // int errorIndex = 0 ;
    if (L != 0) {

        // Non-repeaters and first row of repeaters
        //
        getNext(req);

        // Now the remaining repeaters
        //
        Vector<SnmpVarBind> repeaters= splitFrom(list, N);
        SnmpMibRequestImpl repeatedReq =
            new SnmpMibRequestImpl(req.getEngine(),
                                   req.getPdu(),
                                   repeaters,
                                   SnmpDefinitions.snmpVersionTwo,
                                   req.getUserData(),
                                   req.getPrincipal(),
                                   req.getSecurityLevel(),
                                   req.getSecurityModel(),
                                   req.getContextName(),
                                   req.getAccessContextName());
        for (int i = 2 ; i <= M ; i++) {
            getNext(repeatedReq);
            concatVector(req, repeaters);
        }
    }
}
 
Example 18
Source File: SnmpMibAgent.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation using call to
 * <CODE>getNext</CODE>.
 * The method implements the <CODE>getBulk</CODE> operation by calling
 * appropriately the <CODE>getNext</CODE> method.
 *
 * @param req The SnmpMibRequest containing the variable list to be
 *        retrieved.
 *
 * @param nonRepeat The number of variables, starting with the first
 *    variable in the variable-bindings, for which a single lexicographic
 *    successor is requested.
 *
 * @param maxRepeat The number of lexicographic successors
 *    requested for each of the last R variables. R is the number of
 *    variables following the first nonRepeat variables for which
 *    multiple lexicographic successors are requested.
 *
 * @return The variable list containing returned values.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */
void getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {
    final Vector<SnmpVarBind> list = req.getSubList();

    // RFC 1905, Section 4.2.3, p14
    final int L = list.size() ;
    final int N = Math.max(Math.min(nonRepeat, L), 0) ;
    final int M = Math.max(maxRepeat, 0) ;
    final int R = L - N ;

    // Let's build the varBindList for the response pdu
    //
    // int errorStatus = SnmpDefinitions.snmpRspNoError ;
    // int errorIndex = 0 ;
    if (L != 0) {

        // Non-repeaters and first row of repeaters
        //
        getNext(req);

        // Now the remaining repeaters
        //
        Vector<SnmpVarBind> repeaters= splitFrom(list, N);
        SnmpMibRequestImpl repeatedReq =
            new SnmpMibRequestImpl(req.getEngine(),
                                   req.getPdu(),
                                   repeaters,
                                   SnmpDefinitions.snmpVersionTwo,
                                   req.getUserData(),
                                   req.getPrincipal(),
                                   req.getSecurityLevel(),
                                   req.getSecurityModel(),
                                   req.getContextName(),
                                   req.getAccessContextName());
        for (int i = 2 ; i <= M ; i++) {
            getNext(repeatedReq);
            concatVector(req, repeaters);
        }
    }
}
 
Example 19
Source File: SnmpMibAgent.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation using call to
 * <CODE>getNext</CODE>.
 * The method implements the <CODE>getBulk</CODE> operation by calling
 * appropriately the <CODE>getNext</CODE> method.
 *
 * @param req The SnmpMibRequest containing the variable list to be
 *        retrieved.
 *
 * @param nonRepeat The number of variables, starting with the first
 *    variable in the variable-bindings, for which a single lexicographic
 *    successor is requested.
 *
 * @param maxRepeat The number of lexicographic successors
 *    requested for each of the last R variables. R is the number of
 *    variables following the first nonRepeat variables for which
 *    multiple lexicographic successors are requested.
 *
 * @return The variable list containing returned values.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */
void getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {
    final Vector<SnmpVarBind> list = req.getSubList();

    // RFC 1905, Section 4.2.3, p14
    final int L = list.size() ;
    final int N = Math.max(Math.min(nonRepeat, L), 0) ;
    final int M = Math.max(maxRepeat, 0) ;
    final int R = L - N ;

    // Let's build the varBindList for the response pdu
    //
    // int errorStatus = SnmpDefinitions.snmpRspNoError ;
    // int errorIndex = 0 ;
    if (L != 0) {

        // Non-repeaters and first row of repeaters
        //
        getNext(req);

        // Now the remaining repeaters
        //
        Vector<SnmpVarBind> repeaters= splitFrom(list, N);
        SnmpMibRequestImpl repeatedReq =
            new SnmpMibRequestImpl(req.getEngine(),
                                   req.getPdu(),
                                   repeaters,
                                   SnmpDefinitions.snmpVersionTwo,
                                   req.getUserData(),
                                   req.getPrincipal(),
                                   req.getSecurityLevel(),
                                   req.getSecurityModel(),
                                   req.getContextName(),
                                   req.getAccessContextName());
        for (int i = 2 ; i <= M ; i++) {
            getNext(repeatedReq);
            concatVector(req, repeaters);
        }
    }
}
 
Example 20
Source File: SnmpMibAgent.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Processes a <CODE>getBulk</CODE> operation using call to
 * <CODE>getNext</CODE>.
 * The method implements the <CODE>getBulk</CODE> operation by calling
 * appropriately the <CODE>getNext</CODE> method.
 *
 * @param req The SnmpMibRequest containing the variable list to be
 *        retrieved.
 *
 * @param nonRepeat The number of variables, starting with the first
 *    variable in the variable-bindings, for which a single lexicographic
 *    successor is requested.
 *
 * @param maxRepeat The number of lexicographic successors
 *    requested for each of the last R variables. R is the number of
 *    variables following the first nonRepeat variables for which
 *    multiple lexicographic successors are requested.
 *
 * @return The variable list containing returned values.
 *
 * @exception SnmpStatusException An error occurred during the operation.
 */
void getBulkWithGetNext(SnmpMibRequest req, int nonRepeat, int maxRepeat)
    throws SnmpStatusException {
    final Vector<SnmpVarBind> list = req.getSubList();

    // RFC 1905, Section 4.2.3, p14
    final int L = list.size() ;
    final int N = Math.max(Math.min(nonRepeat, L), 0) ;
    final int M = Math.max(maxRepeat, 0) ;
    final int R = L - N ;

    // Let's build the varBindList for the response pdu
    //
    // int errorStatus = SnmpDefinitions.snmpRspNoError ;
    // int errorIndex = 0 ;
    if (L != 0) {

        // Non-repeaters and first row of repeaters
        //
        getNext(req);

        // Now the remaining repeaters
        //
        Vector<SnmpVarBind> repeaters= splitFrom(list, N);
        SnmpMibRequestImpl repeatedReq =
            new SnmpMibRequestImpl(req.getEngine(),
                                   req.getPdu(),
                                   repeaters,
                                   SnmpDefinitions.snmpVersionTwo,
                                   req.getUserData(),
                                   req.getPrincipal(),
                                   req.getSecurityLevel(),
                                   req.getSecurityModel(),
                                   req.getContextName(),
                                   req.getAccessContextName());
        for (int i = 2 ; i <= M ; i++) {
            getNext(repeatedReq);
            concatVector(req, repeaters);
        }
    }
}