/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// java import
//
// jmx imports
//
// SNMP Runtime import
//
/**
* V3 enabled Adaptor. Each Oid is added using updateRequest method.
*/
}
/**
* V3 enabled Adaptor.
*/
boolean nouse) {
}
/**
*/
}
// We get a ref on the pdu in order to pass it to SnmpMibRequest.
//Pre-allocate room for storing varbindlist and translation table.
//
translation= new int[length];
}
/**
* in the original request.
*/
boolean nouse) {
// The translation table is easy in this case ...
//
for(int i=0; i < max; i++) {
translation[i]= i;
}
}
int protocolVersion,
// This is an optimization:
// The SnmpMibRequest created in the check() phase is
// reused in the set() phase.
//
return mibRequest;
//This is a request comming from an SnmpV3AdaptorServer.
//Full power.
if(incRequest != null) {
} else {
userData);
}
// If we're doing the check() phase, we store the SnmpMibRequest
// so that we can reuse it in the set() phase.
//
if (type == pduWalkRequest)
mibRequest = result;
return result;
}
}
public void run() {
try {
final ThreadContext oldContext =
try {
switch(type) {
case pduGetRequestPdu:
// Invoke a get operation
//
}
break;
case pduGetNextRequestPdu:
}
//#ifdef DEBUG
break;
case pduSetRequestPdu:
}
break;
case pduWalkRequest:
}
break;
default:
agent.getMibName());
}
errorIndex= 1;
break;
}// end of switch
} finally {
}
} catch(SnmpStatusException x) {
errorStatus = x.getStatus() ;
errorIndex= x.getErrorIndex();
"]:an Snmp error occured during the operation", x);
}
}
catch(Exception x) {
"]:a generic error occured during the operation", x);
}
}
}
}
// -------------------------------------------------------------
//
// This function does a best-effort to map global error status
// to SNMP v1 valid global error status.
//
// An SnmpStatusException can contain either:
// <li> v2 local error codes (that should be stored in the varbind)</li>
// <li> v2 global error codes </li>
// <li> v1 global error codes </li>
//
// v2 local error codes (noSuchInstance, noSuchObject) are
// transformed in a global v1 snmpRspNoSuchName error.
//
// v2 global error codes are transformed in the following way:
//
// snmpRspNoSuchName or snmpRspGenErr is returned.
//
// Otherwise:
// snmpRspNoAccess, snmpRspInconsistentName
// => snmpRspNoSuchName
// snmpRspAuthorizationError, snmpRspNotWritable, snmpRspNoCreation
// snmpRspWrong*
// snmpRspResourceUnavailable, snmpRspRspCommitFailed,
// snmpRspUndoFailed
// => snmpRspGenErr
//
// -------------------------------------------------------------
//
// Map v2 codes onto v1 codes
//
return SnmpDefinitions.snmpRspNoError;
return SnmpDefinitions.snmpRspGenErr;
return SnmpDefinitions.snmpRspNoSuchName;
return SnmpDefinitions.snmpRspNoSuchName;
} else if ((errorStatus ==
return SnmpDefinitions.snmpRspReadOnly;
else
return SnmpDefinitions.snmpRspNoSuchName;
return SnmpDefinitions.snmpRspNoSuchName;
(errorStatus ==
return SnmpDefinitions.snmpRspBadValue;
else
return SnmpDefinitions.snmpRspNoSuchName;
} else if ((errorStatus ==
(errorStatus ==
return SnmpDefinitions.snmpRspGenErr;
}
// At this point we should have a V1 error code
//
return SnmpDefinitions.snmpRspTooBig;
return errorStatus;
else
return SnmpDefinitions.snmpRspNoSuchName;
}
// We have a snmpRspGenErr, or something which is not defined
// in RFC1905 => return a snmpRspGenErr
//
return SnmpDefinitions.snmpRspGenErr;
}
// -------------------------------------------------------------
//
// This function does a best-effort to map global error status
// to SNMP v2 valid global error status.
//
// An SnmpStatusException can contain either:
// <li> v2 local error codes (that should be stored in the varbind)</li>
// <li> v2 global error codes </li>
// <li> v1 global error codes </li>
//
// v2 local error codes (noSuchInstance, noSuchObject)
// should not raise this level: they should have been stored in the
// varbind earlier. If they, do there is nothing much we can do except
// to transform them into:
// <li> a global snmpRspNoSuchName otherwise. </li>
//
// v2 global error codes are transformed in the following way:
//
// (snmpRspGenErr is the only global error that is expected to be
//
// Otherwise the v2 code itself is returned
//
// v1 global error codes are transformed in the following way:
//
// snmpRspNoSuchName
// snmpRspReadOnly
// snmpRspBadValue
//
// -------------------------------------------------------------
//
// Map v1 codes onto v2 codes
//
return SnmpDefinitions.snmpRspNoError;
return SnmpDefinitions.snmpRspGenErr;
return SnmpDefinitions.snmpRspTooBig;
// For get / getNext / getBulk the only global error
// (PDU-level) possible is genErr.
//
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...
return SnmpDefinitions.snmpRspNoAccess;
// Map to notWritable
return SnmpDefinitions.snmpRspNotWritable;
// Map to wrongValue
return SnmpDefinitions.snmpRspWrongValue;
// Other valid V2 codes
return errorStatus;
// Ivalid V2 code => genErr
return SnmpDefinitions.snmpRspGenErr;
}
int protocolVersion,
int reqPduType) {
return SnmpDefinitions.snmpRspNoError;
// Too bad, an error occurs ... we need to translate it ...
//
return SnmpDefinitions.snmpRspGenErr;
}
/**
* The method returns the error status of the operation.
* The method takes into account the protocol version.
*/
protected int getErrorStatus() {
if (errorStatus == snmpRspNoError)
return snmpRspNoError;
}
/**
* The method returns the error index as a position in the var bind list.
* The value returned by the method corresponds to the index in the original
* var bind list as received by the SNMP protocol adaptor.
*/
protected int getErrorIndex() {
if (errorStatus == snmpRspNoError)
return -1;
// An error occurs. We need to be carefull because the index
// we are getting is a valid SNMP index (so range starts at 1).
// FIX ME: Shall we double-check the range here ?
// The response is : YES :
errorIndex = 1;
}
/**
* The method updates the varbind list of the subrequest.
*/
}
/**
* The method updates a given var bind list with the result of a
* previsouly invoked operation.
* Prior to calling the method, one must make sure that the operation was
* successful. As such the method getErrorIndex or getErrorStatus should be
* called.
*/
for(int i= 0; i< max ; i++) {
// bugId 4641694: must check position in order to avoid
// ArrayIndexOutOfBoundException
final int pos=translation[i];
} else {
}
}
}
}
this.incRequest = incRequest;
}
// PRIVATE VARIABLES
//------------------
/**
* Store the protocol version to handle
*/
/**
* Store the operation type. Remember if the type is Walk, it means
* that we have to invoke the check method ...
*/
/**
* Agent directly handled by the sub-request handler.
*/
/**
* Error status.
*/
/**
* Index of error.
* A value of -1 means no error.
*/
/**
* The varbind list specific to the current sub request.
* The vector must contain object of type SnmpVarBind.
*/
/**
* The array giving the index translation between the content of
* <VAR>varBind</VAR> and the varbind list as specified in the request.
*/
protected int[] translation;
/**
* Contextual object allocated by the SnmpUserDataFactory.
**/
/**
* The SnmpMibRequest that will be passed to the agent.
*
**/
/**
* The SnmpPdu that will be passed to the request.
*
**/
// All the methods of the Vector class are synchronized.
// Synchronization is a very expensive operation. In our case it is not always
// required...
//
super(size);
}
}
return (E) elementData[index];
}
};
}