Java Code Examples for com.sun.jmx.snmp.SnmpStatusException#snmpRspInconsistentValue()

The following examples show how to use com.sun.jmx.snmp.SnmpStatusException#snmpRspInconsistentValue() . 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: SnmpRequestTree.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 2
Source File: SnmpRequestTree.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 3
Source File: SnmpRequestTree.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 4
Source File: SnmpRequestTree.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        mappedErrorCode = errorCode;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
Example 5
Source File: SnmpRequestTree.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 6
Source File: SnmpRequestTree.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        mappedErrorCode = errorCode;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
Example 7
Source File: SnmpRequestTree.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        mappedErrorCode = errorCode;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
Example 8
Source File: SnmpRequestTree.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        mappedErrorCode = errorCode;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
Example 9
Source File: SnmpRequestTree.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 10
Source File: SnmpRequestTree.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static int mapGetException(int errorStatus, int version)
    throws SnmpStatusException {

    final int errorCode = errorStatus;
    if (version == SnmpDefinitions.snmpVersionOne)
        return errorCode;

    int mappedErrorCode = errorCode;

    // Now take care of V2 errorCodes that can be stored
    // in the varbind itself:
    if (errorCode ==
        SnmpStatusException.noSuchObject)
        // noSuchObject => noSuchObject
        mappedErrorCode = errorCode;

    else if (errorCode ==
             SnmpStatusException.noSuchInstance)
        // noSuchInstance => noSuchInstance
        mappedErrorCode = errorCode;

    // Now we're going to try to transform every other
    // global code in either noSuchInstance or noSuchObject,
    // so that the get can return a partial result.
    //
    // Only noSuchInstance or noSuchObject can be stored
    // in the varbind itself.
    //

    // According to RFC 1905: noAccess is emitted when the
    // the access is denied because it is not in the MIB view...
    //
    else if (errorCode ==
             SnmpStatusException.noAccess)
        // noAccess => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // According to RFC 1905: (my interpretation because it is not
    // really clear) The specified variable name exists - but the
    // variable does not exists and cannot be created under the
    // present circumstances (probably because the request specifies
    // another variable/value which is incompatible, or because the
    // value of some other variable in the MIB prevents the creation)
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
        // inconsistentName => noSuchInstance
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // All the errors comprised between snmpRspWrongType and
    // snmpRspInconsistentValue concern values: so we're going
    // to assume the OID was correct, and reply with noSuchInstance.
    //
    // Note that this error should never be raised in a GET context
    // but who knows?
    //
    else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
             (errorCode <= SnmpStatusException.snmpRspInconsistentValue))
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // We're going to assume the OID was correct, and reply
    // with noSuchInstance.
    //
    else if (errorCode == SnmpStatusException.readOnly)
        mappedErrorCode = SnmpStatusException.noSuchInstance;

    // For all other errors but genErr, we're going to reply with
    // noSuchObject
    //
    else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
             errorCode != SnmpStatusException.snmpRspGenErr)
        mappedErrorCode = SnmpStatusException.noSuchObject;

    // Only genErr will abort the GET and be returned as global
    // error.
    //
    return mappedErrorCode;

}
 
Example 11
Source File: SnmpRequestTree.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 12
Source File: SnmpRequestTree.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 13
Source File: SnmpRequestTree.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void addVarbind(SnmpVarBind varbind, SnmpOid entryoid,
                               boolean isnew, SnmpVarBind statusvb)
            throws SnmpStatusException {
            Vector<SnmpVarBind> v = null;
            SnmpVarBind rs = statusvb;

            if (entryoids == null) {
//              entryoids = new ArrayList();
//              entrylists = new ArrayList();
//              isentrynew = new ArrayList();
                v = new Vector<>();
//              entryoids.add(entryoid);
//              entrylists.add(v);
//              isentrynew.add(new Boolean(isnew));
                add(0,entryoid,v,isnew,rs);
            } else {
                // int pos = findOid(entryoids,entryoid);
                // int pos = findOid(entryoids,entrycount,entryoid);
                final int pos =
                    getInsertionPoint(entryoids,entrycount,entryoid);
                if (pos > -1 && pos < entrycount &&
                    entryoid.compareTo(entryoids[pos]) == 0) {
                    v  = entrylists[pos];
                    rs = rowstatus[pos];
                } else {
                    // if (pos == -1 || pos >= entryoids.size() ) {
                    // if (pos == -1 || pos >= entrycount ) {
                    // pos = getInsertionPoint(entryoids,entryoid);
                    // pos = getInsertionPoint(entryoids,entrycount,entryoid);
                    v = new Vector<>();
//                  entryoids.add(pos,entryoid);
//                  entrylists.add(pos,v);
//                  isentrynew.add(pos,new Boolean(isnew));
                    add(pos,entryoid,v,isnew,rs);
                }
//              } else v = (Vector) entrylists.get(pos);
                    // } else v = entrylists[pos];
                if (statusvb != null) {
                    if ((rs != null) && (rs != statusvb) &&
                        ((type == SnmpDefinitions.pduWalkRequest) ||
                         (type == SnmpDefinitions.pduSetRequestPdu))) {
                        throw new SnmpStatusException(
                              SnmpStatusException.snmpRspInconsistentValue);
                    }
                    rowstatus[pos] = statusvb;
                }
            }

            // We do not include the status variable in the varbind,
            // because we're going to set it separately...
            //
            if (statusvb != varbind)
                v.addElement(varbind);
        }
 
Example 14
Source File: SnmpMibTable.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}
 
Example 15
Source File: SnmpMibTable.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}
 
Example 16
Source File: SnmpMibTable.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}
 
Example 17
Source File: SnmpMibTable.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}
 
Example 18
Source File: SnmpMibTable.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}
 
Example 19
Source File: SnmpMibTable.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}
 
Example 20
Source File: SnmpMibTable.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Map the value of the <code>vbstatus</code> varbind to the
 * corresponding RowStatus code defined in
 * {@link com.sun.jmx.snmp.EnumRowStatus}.
 * These codes correspond to RowStatus codes as defined in RFC 2579,
 * plus the <i>unspecified</i> value which is SNMP Runtime specific.
 * <p>
 * By default, this method assumes that the control variable is
 * an Integer, and it simply returns its value without further
 * analysis.
 * <p>
 * If this table was defined using SMIv2, and if it contains a
 * control variable with RowStatus syntax, <code>mibgen</code>
 * will generate a non default implementation for this method.
 * <p>
 * You will have to redefine this method if you need to implement
 * control variables that do not conform to RFC 2579 RowStatus
 * TEXTUAL-CONVENTION.
 *
 * <p>
 * @param rowOid The <CODE>SnmpOid</CODE> identifying the table
 *               row involved in the operation.
 *
 * @param vbstatus The SnmpVarBind containing the value of the control
 *           variable, as identified by the isRowStatus() method.
 *
 * @param userData A contextual object containing user-data.
 *        This object is allocated through the <code>
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 *        for each incoming SNMP request.
 *
 * @return The RowStatus code mapped from the value contained
 *     in <code>vbstatus</code>.
 *
 * @exception SnmpStatusException if the value of the control variable
 *            could not be mapped to a RowStatus code.
 *
 * @see com.sun.jmx.snmp.EnumRowStatus
 **/
protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,
                           Object userData)
    throws SnmpStatusException {
    final SnmpValue rsvalue = vbstatus.value;

    if (rsvalue instanceof SnmpInt)
        return ((SnmpInt)rsvalue).intValue();
    else
        throw new SnmpStatusException(
                   SnmpStatusException.snmpRspInconsistentValue);
}