本文整理汇总了Java中com.sun.jmx.snmp.SnmpDefinitions.pduSetRequestPdu方法的典型用法代码示例。如果您正苦于以下问题:Java SnmpDefinitions.pduSetRequestPdu方法的具体用法?Java SnmpDefinitions.pduSetRequestPdu怎么用?Java SnmpDefinitions.pduSetRequestPdu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jmx.snmp.SnmpDefinitions
的用法示例。
在下文中一共展示了SnmpDefinitions.pduSetRequestPdu方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkPduType
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
/**
* Check the type of the pdu: only the get/set/bulk request
* are accepted.
*/
private boolean checkPduType(SnmpPduPacket pdu) {
boolean result;
switch(pdu.type) {
case SnmpDefinitions.pduGetRequestPdu:
case SnmpDefinitions.pduGetNextRequestPdu:
case SnmpDefinitions.pduSetRequestPdu:
case SnmpDefinitions.pduGetBulkRequestPdu:
result = true ;
break;
default:
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"checkPduType", "cannot respond to this kind of PDU");
}
result = false ;
break;
}
return result ;
}
示例2: checkPduType
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
/**
* Check the type of the pdu: only the get/set/bulk request
* are accepted.
*/
private boolean checkPduType(SnmpPduPacket pdu) {
boolean result = true ;
switch(pdu.type) {
case SnmpDefinitions.pduGetRequestPdu:
case SnmpDefinitions.pduGetNextRequestPdu:
case SnmpDefinitions.pduSetRequestPdu:
case SnmpDefinitions.pduGetBulkRequestPdu:
result = true ;
break;
default:
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"checkPduType", "cannot respond to this kind of PDU");
}
result = false ;
break;
}
return result ;
}
示例3: set
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
/**
* Processes a <CODE>set</CODE> operation.
*
*/
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
@Override
public void set(SnmpMibRequest req) throws SnmpStatusException {
SnmpRequestTree handlers = null;
// Optimization: we're going to get the whole SnmpRequestTree
// built in the "check" method, so that we don't have to rebuild
// it here.
//
if (req instanceof SnmpMibRequestImpl)
handlers = ((SnmpMibRequestImpl)req).getRequestTree();
// Optimization didn't work: we have to rebuild the tree.
//
// Builds the request tree: creation is not allowed, operation
// is atomic.
//
final int reqType = SnmpDefinitions.pduSetRequestPdu;
if (handlers == null) handlers = getHandlers(req,false,true,reqType);
handlers.switchCreationFlag(false);
handlers.setPduType(reqType);
SnmpRequestTree.Handler h;
SnmpMibNode meta;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
"set", "Processing handlers for SET... ");
}
// For each sub-request stored in the request-tree, invoke the
// get() 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 set() operation
meta.set(rqs.nextElement(),depth);
}
}
}
示例4: addVarbind
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
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);
}
示例5: setPduType
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
void setPduType(int pduType) {
type = pduType;
setreqflag = ((pduType == SnmpDefinitions.pduWalkRequest) ||
(pduType == SnmpDefinitions.pduSetRequestPdu));
}
示例6: turboProcessingGetSet
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
/**
* Optimize when there is only one sub request
*/
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
Object userData) {
int errorStatus;
SnmpSubRequestHandler sub = subs.elements().nextElement();
sub.setUserData(userData);
// Indicate to the sub request that a check must be invoked ...
// OK we should have defined out own tag for that !
//
if (req.type == SnmpDefinitions.pduSetRequestPdu) {
sub.type= pduWalkRequest;
sub.run();
sub.type= pduSetRequestPdu;
// Check the error status.
//
errorStatus= sub.getErrorStatus();
if (errorStatus != SnmpDefinitions.snmpRspNoError) {
// No point to go any further.
//
return newErrorResponsePdu(req, errorStatus,
sub.getErrorIndex() + 1) ;
}
}
// process the operation
//
sub.run();
errorStatus= sub.getErrorStatus();
if (errorStatus != SnmpDefinitions.snmpRspNoError) {
// No point to go any further.
//
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"turboProcessingGetSet", "an error occurs");
}
int realIndex= sub.getErrorIndex() + 1;
return newErrorResponsePdu(req, errorStatus, realIndex) ;
}
// So far so good. So we need to concatenate all the answers.
//
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
"turboProcessingGetSet", "build the unified response for request "
+ req.requestId);
}
return mergeResponses(req);
}
示例7: mapErrorStatusToV1
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
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;
}
示例8: mapErrorStatusToV2
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
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;
}
示例9: set
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
/**
* Processes a <CODE>set</CODE> operation.
*
*/
// Implements the method defined in SnmpMibAgent. See SnmpMibAgent
// for java-doc
//
public void set(SnmpMibRequest req) throws SnmpStatusException {
SnmpRequestTree handlers = null;
// Optimization: we're going to get the whole SnmpRequestTree
// built in the "check" method, so that we don't have to rebuild
// it here.
//
if (req instanceof SnmpMibRequestImpl)
handlers = ((SnmpMibRequestImpl)req).getRequestTree();
// Optimization didn't work: we have to rebuild the tree.
//
// Builds the request tree: creation is not allowed, operation
// is atomic.
//
final int reqType = SnmpDefinitions.pduSetRequestPdu;
if (handlers == null) handlers = getHandlers(req,false,true,reqType);
handlers.switchCreationFlag(false);
handlers.setPduType(reqType);
SnmpRequestTree.Handler h = null;
SnmpMibNode meta = null;
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
"set", "Processing handlers for SET... ");
}
// For each sub-request stored in the request-tree, invoke the
// get() method.
for (Enumeration eh=handlers.getHandlers();eh.hasMoreElements();) {
h = (SnmpRequestTree.Handler) 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 rqs=handlers.getSubRequests(h);
rqs.hasMoreElements();) {
// Invoke the set() operation
meta.set((SnmpMibSubRequest)rqs.nextElement(),depth);
}
}
}
示例10: addVarbind
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
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<SnmpVarBind>();
// 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<SnmpVarBind>();
// 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);
}
示例11: turboProcessingGetSet
import com.sun.jmx.snmp.SnmpDefinitions; //导入方法依赖的package包/类
/**
* Optimize when there is only one sub request
*/
private SnmpPduPacket turboProcessingGetSet(SnmpPduRequest req,
Object userData) {
int errorStatus = SnmpDefinitions.snmpRspNoError ;
SnmpSubRequestHandler sub = subs.elements().nextElement();
sub.setUserData(userData);
// Indicate to the sub request that a check must be invoked ...
// OK we should have defined out own tag for that !
//
if (req.type == SnmpDefinitions.pduSetRequestPdu) {
sub.type= pduWalkRequest;
sub.run();
sub.type= pduSetRequestPdu;
// Check the error status.
//
errorStatus= sub.getErrorStatus();
if (errorStatus != SnmpDefinitions.snmpRspNoError) {
// No point to go any further.
//
return newErrorResponsePdu(req, errorStatus,
sub.getErrorIndex() + 1) ;
}
}
// process the operation
//
sub.run();
errorStatus= sub.getErrorStatus();
if (errorStatus != SnmpDefinitions.snmpRspNoError) {
// No point to go any further.
//
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"turboProcessingGetSet", "an error occurs");
}
int realIndex= sub.getErrorIndex() + 1;
return newErrorResponsePdu(req, errorStatus, realIndex) ;
}
// So far so good. So we need to concatenate all the answers.
//
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
"turboProcessingGetSet", "build the unified response for request "
+ req.requestId);
}
return mergeResponses(req);
}