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

The following examples show how to use com.sun.jmx.snmp.SnmpDefinitions#pduWalkRequest() . 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 openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 2
Source File: SnmpSubRequestHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 3
Source File: SnmpRequestTree.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
void setPduType(int pduType) {
    type = pduType;
    setreqflag = ((pduType == SnmpDefinitions.pduWalkRequest) ||
        (pduType == SnmpDefinitions.pduSetRequestPdu));
}
 
Example 4
Source File: SnmpSubRequestHandler.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 5
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 6
Source File: SnmpSubRequestHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 7
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 8
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 9
Source File: SnmpSubRequestHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 10
Source File: SnmpRequestTree.java    From TencentKona-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 11
Source File: SnmpSubRequestHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 12
Source File: SnmpSubRequestHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV2(int errorStatus, int reqPduType) {
    // Map v1 codes onto v2 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    // For get / getNext / getBulk the only global error
    // (PDU-level) possible is genErr.
    //
    if ((reqPduType != SnmpDefinitions.pduSetRequestPdu) &&
        (reqPduType != SnmpDefinitions.pduWalkRequest)) {
        if(errorStatus == SnmpDefinitions.snmpRspAuthorizationError)
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspGenErr;
    }

    // Map to noSuchName
    //      if ((errorStatus == SnmpDefinitions.snmpRspNoSuchName) ||
    //   (errorStatus == SnmpStatusException.noSuchInstance) ||
    //  (errorStatus == SnmpStatusException.noSuchObject))
    //  return SnmpDefinitions.snmpRspNoSuchName;

    // SnmpStatusException.noSuchInstance and
    // SnmpStatusException.noSuchObject can't happen...

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoAccess;

    // Map to notWritable
    if (errorStatus == SnmpDefinitions.snmpRspReadOnly)
            return SnmpDefinitions.snmpRspNotWritable;

    // Map to wrongValue
    if (errorStatus == SnmpDefinitions.snmpRspBadValue)
        return SnmpDefinitions.snmpRspWrongValue;

    // Other valid V2 codes
    if ((errorStatus == SnmpDefinitions.snmpRspNoAccess) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError) ||
        (errorStatus == SnmpDefinitions.snmpRspNotWritable) ||
        (errorStatus == SnmpDefinitions.snmpRspNoCreation) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongType) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongEncoding) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongValue) ||
        (errorStatus == SnmpDefinitions.snmpRspWrongLength) ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentValue) ||
        (errorStatus == SnmpDefinitions.snmpRspResourceUnavailable) ||
        (errorStatus == SnmpDefinitions.snmpRspCommitFailed) ||
        (errorStatus == SnmpDefinitions.snmpRspUndoFailed))
        return errorStatus;

    // Ivalid V2 code => genErr
    return SnmpDefinitions.snmpRspGenErr;
}
 
Example 13
Source File: SnmpSubRequestHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static final int mapErrorStatusToV1(int errorStatus, int reqPduType) {
    // Map v2 codes onto v1 codes
    //
    if (errorStatus == SnmpDefinitions.snmpRspNoError)
        return SnmpDefinitions.snmpRspNoError;

    if (errorStatus == SnmpDefinitions.snmpRspGenErr)
        return SnmpDefinitions.snmpRspGenErr;

    if (errorStatus == SnmpDefinitions.snmpRspNoSuchName)
        return SnmpDefinitions.snmpRspNoSuchName;

    if ((errorStatus == SnmpStatusException.noSuchInstance) ||
        (errorStatus == SnmpStatusException.noSuchObject)   ||
        (errorStatus == SnmpDefinitions.snmpRspNoAccess)    ||
        (errorStatus == SnmpDefinitions.snmpRspInconsistentName) ||
        (errorStatus == SnmpDefinitions.snmpRspAuthorizationError)){

        return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspAuthorizationError)         ||
               (errorStatus == SnmpDefinitions.snmpRspNotWritable)) {

        if (reqPduType == SnmpDefinitions.pduWalkRequest)
            return SnmpDefinitions.snmpRspReadOnly;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspNoCreation)) {

            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus == SnmpDefinitions.snmpRspWrongType)      ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus == SnmpDefinitions.snmpRspWrongEncoding)  ||
               (errorStatus == SnmpDefinitions.snmpRspWrongValue)     ||
               (errorStatus == SnmpDefinitions.snmpRspWrongLength)    ||
               (errorStatus ==
                SnmpDefinitions.snmpRspInconsistentValue)) {

        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return SnmpDefinitions.snmpRspBadValue;
        else
            return SnmpDefinitions.snmpRspNoSuchName;

    } else if ((errorStatus ==
                SnmpDefinitions.snmpRspResourceUnavailable) ||
               (errorStatus ==
                SnmpDefinitions.snmpRspCommitFailed)        ||
               (errorStatus == SnmpDefinitions.snmpRspUndoFailed)) {

        return SnmpDefinitions.snmpRspGenErr;

    }

    // At this point we should have a V1 error code
    //
    if (errorStatus == SnmpDefinitions.snmpRspTooBig)
        return SnmpDefinitions.snmpRspTooBig;

    if( (errorStatus == SnmpDefinitions.snmpRspBadValue) ||
        (errorStatus == SnmpDefinitions.snmpRspReadOnly)) {
        if ((reqPduType == SnmpDefinitions.pduSetRequestPdu) ||
            (reqPduType == SnmpDefinitions.pduWalkRequest))
            return errorStatus;
        else
            return SnmpDefinitions.snmpRspNoSuchName;
    }

    // We have a snmpRspGenErr, or something which is not defined
    // in RFC1905 => return a snmpRspGenErr
    //
    return SnmpDefinitions.snmpRspGenErr;

}
 
Example 14
Source File: SnmpRequestTree.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
void setPduType(int pduType) {
    type = pduType;
    setreqflag = ((pduType == SnmpDefinitions.pduWalkRequest) ||
        (pduType == SnmpDefinitions.pduSetRequestPdu));
}
 
Example 15
Source File: SnmpRequestTree.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void setPduType(int pduType) {
    type = pduType;
    setreqflag = ((pduType == SnmpDefinitions.pduWalkRequest) ||
        (pduType == SnmpDefinitions.pduSetRequestPdu));
}
 
Example 16
Source File: SnmpMib.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks if a <CODE>set</CODE> operation can be performed.
 * If the operation cannot be performed, the method will raise a
 * <CODE>SnmpStatusException</CODE>.
 *
 */
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
@Override
public void check(SnmpMibRequest req) throws SnmpStatusException {

    final int reqType = SnmpDefinitions.pduWalkRequest;
    // Builds the request tree: creation is allowed, operation
    // is atomic.
    SnmpRequestTree handlers = getHandlers(req,true,true,reqType);

    SnmpRequestTree.Handler h;
    SnmpMibNode meta;

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
                "check", "Processing handlers for CHECK... ");
    }

    // For each sub-request stored in the request-tree, invoke the
    // check() method.
    for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
        h = eh.nextElement();

        // Gets the Meta node. It can be either a Group Meta or a
        // Table Meta.
        //
        meta = handlers.getMetaNode(h);

        // Gets the depth of the Meta node in the OID tree
        final int depth = handlers.getOidDepth(h);

        for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
             rqs.hasMoreElements();) {

            // Invoke the check() operation
            meta.check(rqs.nextElement(),depth);
        }
    }

    // Optimization: we're going to pass the whole SnmpRequestTree
    // to the "set" method, so that we don't have to rebuild it there.
    //
    if (req instanceof SnmpMibRequestImpl) {
        ((SnmpMibRequestImpl)req).setRequestTree(handlers);
    }

}
 
Example 17
Source File: SnmpMib.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Checks if a <CODE>set</CODE> operation can be performed.
 * If the operation cannot be performed, the method will raise a
 * <CODE>SnmpStatusException</CODE>.
 *
 */
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
@Override
public void check(SnmpMibRequest req) throws SnmpStatusException {

    final int reqType = SnmpDefinitions.pduWalkRequest;
    // Builds the request tree: creation is allowed, operation
    // is atomic.
    SnmpRequestTree handlers = getHandlers(req,true,true,reqType);

    SnmpRequestTree.Handler h;
    SnmpMibNode meta;

    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
                "check", "Processing handlers for CHECK... ");
    }

    // For each sub-request stored in the request-tree, invoke the
    // check() method.
    for (Enumeration<SnmpRequestTree.Handler> eh=handlers.getHandlers();eh.hasMoreElements();) {
        h = eh.nextElement();

        // Gets the Meta node. It can be either a Group Meta or a
        // Table Meta.
        //
        meta = handlers.getMetaNode(h);

        // Gets the depth of the Meta node in the OID tree
        final int depth = handlers.getOidDepth(h);

        for (Enumeration<SnmpMibSubRequest> rqs=handlers.getSubRequests(h);
             rqs.hasMoreElements();) {

            // Invoke the check() operation
            meta.check(rqs.nextElement(),depth);
        }
    }

    // Optimization: we're going to pass the whole SnmpRequestTree
    // to the "set" method, so that we don't have to rebuild it there.
    //
    if (req instanceof SnmpMibRequestImpl) {
        ((SnmpMibRequestImpl)req).setRequestTree(handlers);
    }

}
 
Example 18
Source File: SnmpRequestTree.java    From openjdk-8-source 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 19
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 20
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);
        }