本文整理汇总了Java中com.sun.jmx.snmp.SnmpVarBind类的典型用法代码示例。如果您正苦于以下问题:Java SnmpVarBind类的具体用法?Java SnmpVarBind怎么用?Java SnmpVarBind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SnmpVarBind类属于com.sun.jmx.snmp包,在下文中一共展示了SnmpVarBind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitFrom
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* This method creates a new Vector which does not contain the first
* element up to the specified limit.
*
* @param original The original vector.
* @param limit The limit.
*/
private Vector<SnmpVarBind> splitFrom(Vector<SnmpVarBind> original, int limit) {
int max= original.size();
Vector<SnmpVarBind> result= new Vector<>(max - limit);
int i= limit;
// Ok the loop looks a bit strange. But in order to improve the
// perf, we try to avoid reference to the limit variable from
// within the loop ...
//
for(Enumeration<SnmpVarBind> e= original.elements(); e.hasMoreElements(); --i) {
SnmpVarBind var= e.nextElement();
if (i >0)
continue;
result.addElement(new SnmpVarBind(var.oid, var.value));
}
return result;
}
示例2: newMibRequest
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* This is a factory method for creating new SnmpMibRequest objects.
* @param engine The local engine.
* @param reqPdu The received pdu.
* @param vblist The vector of SnmpVarBind objects in which the
* MIB concerned by this request is involved.
* @param version The protocol version of the SNMP request.
* @param userData User allocated contextual data.
*
* @return A new SnmpMibRequest object.
*
* @since 1.5
**/
public static SnmpMibRequest newMibRequest(SnmpEngine engine,
SnmpPdu reqPdu,
Vector<SnmpVarBind> vblist,
int version,
Object userData,
String principal,
int securityLevel,
int securityModel,
byte[] contextName,
byte[] accessContextName) {
return new SnmpMibRequestImpl(engine,
reqPdu,
vblist,
version,
userData,
principal,
securityLevel,
securityModel,
contextName,
accessContextName);
}
示例3: registerCheckException
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
@Override
public void registerCheckException(SnmpVarBind var,
SnmpStatusException exception)
throws SnmpStatusException {
// The index in the exception must correspond to
// the SNMP index ...
//
// We throw the exception in order to abort the SET operation
// in an atomic way.
final int errorCode = exception.getStatus();
final int mappedErrorCode = mapSetException(errorCode,
version);
if (errorCode != mappedErrorCode)
throw new
SnmpStatusException(mappedErrorCode, getVarIndex(var)+1);
else
throw new SnmpStatusException(exception, getVarIndex(var)+1);
}
示例4: init
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private void init(SnmpAdaptorServer server,
SnmpPdu req,
int nonRepeat,
int maxRepeat,
int R) {
this.server = server;
this.nonRepeat= nonRepeat;
this.maxRepeat= maxRepeat;
this.globalR= R;
final int max= translation.length;
final SnmpVarBind[] list= req.varBindList;
final NonSyncVector<SnmpVarBind> nonSyncVarBind =
((NonSyncVector<SnmpVarBind>)varBind);
for(int i=0; i < max; i++) {
translation[i]= i;
// we need to allocate a new SnmpVarBind. Otherwise the first
// sub request will modify the list...
//
final SnmpVarBind newVarBind =
new SnmpVarBind(list[i].oid, list[i].value);
nonSyncVarBind.addNonSyncElement(newVarBind);
}
}
示例5: registerSetException
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
@Override
public void registerSetException(SnmpVarBind var,
SnmpStatusException exception)
throws SnmpStatusException {
// The index in the exception must correspond to
// the SNMP index ...
//
if (version == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(exception, getVarIndex(var)+1);
// Although the first pass of check() did not fail,
// the set() phase could not be carried out correctly.
// Since we don't know how to make an "undo", and some
// assignation may already have been performed, we're going
// to throw an snmpRspUndoFailed.
//
throw new SnmpStatusException(SnmpDefinitions.snmpRspUndoFailed,
getVarIndex(var)+1);
}
示例6: mergeBulkResponses
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private SnmpVarBind[] mergeBulkResponses(int size) {
// Let's allocate the array for storing the result
//
SnmpVarBind[] result= new SnmpVarBind[size];
for(int i= size-1; i >=0; --i) {
result[i]= new SnmpVarBind();
result[i].value= SnmpVarBind.endOfMibView;
}
// Go through the list of subrequests and concatenate.
// Hopefully, by now all the sub-requests should be finished
//
for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
SnmpSubRequestHandler sub= e.nextElement();
sub.updateResult(result);
}
return result;
}
示例7: newValidResponsePdu
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* Make a response pdu with the specified error status and index.
* NOTE: the response pdu share its varBindList with the request pdu.
*/
private SnmpPduRequest newValidResponsePdu(SnmpPduPacket reqPdu,
SnmpVarBind[] varBindList) {
SnmpPduRequest result = new SnmpPduRequest() ;
result.address = reqPdu.address ;
result.port = reqPdu.port ;
result.version = reqPdu.version ;
result.community = reqPdu.community ;
result.type = SnmpPduRequest.pduGetResponsePdu ;
result.requestId = reqPdu.requestId ;
result.errorStatus = SnmpDefinitions.snmpRspNoError ;
result.errorIndex = 0 ;
result.varBindList = varBindList ;
((SnmpAdaptorServer)adaptorServer).
updateErrorCounters(result.errorStatus) ;
return result ;
}
示例8: SnmpMibRequestImpl
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* @param engine The local engine.
* @param reqPdu The received pdu.
* @param vblist The vector of SnmpVarBind objects in which the
* MIB concerned by this request is involved.
* @param protocolVersion The protocol version of the SNMP request.
* @param userData User allocated contextual data. This object must
* be allocated on a per SNMP request basis through the
* SnmpUserDataFactory registered with the SnmpAdaptorServer,
* and is handed back to the user through SnmpMibRequest objects.
*/
public SnmpMibRequestImpl(SnmpEngine engine,
SnmpPdu reqPdu,
Vector<SnmpVarBind> vblist,
int protocolVersion,
Object userData,
String principal,
int securityLevel,
int securityModel,
byte[] contextName,
byte[] accessContextName) {
varbinds = vblist;
version = protocolVersion;
data = userData;
this.reqPdu = reqPdu;
this.engine = engine;
this.principal = principal;
this.securityLevel = securityLevel;
this.securityModel = securityModel;
this.contextName = contextName;
this.accessContextName = accessContextName;
}
示例9: get
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* Processes a <CODE>get</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests.
*
* @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
*
* @exception SnmpStatusException An error occurred during the operation.
*/
@Override
public void get(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
SnmpErrorHandlerAgent.class.getName(),
"get", "Get in Exception");
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpStatusException.noSuchName);
Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) {
SnmpVarBind varbind = l.nextElement();
varbind.setNoSuchObject();
}
}
示例10: getNext
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* Processes a <CODE>getNext</CODE> operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests..
*
* @param inRequest The SnmpMibRequest object holding the list of variables to be retrieved.
*
* @exception SnmpStatusException An error occurred during the operation.
*/
@Override
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
SnmpErrorHandlerAgent.class.getName(),
"getNext", "GetNext in Exception");
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpStatusException.noSuchName);
Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) {
SnmpVarBind varbind = l.nextElement();
varbind.setEndOfMibView();
}
}
示例11: getBulk
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* Processes a <CODE>getBulk</CODE> operation. It will throw an exception if the request is a V1 one or it will set exceptions within the list for V2 ones.
*
* @param inRequest The SnmpMibRequest object holding the list of variable to be retrieved.
*
* @exception SnmpStatusException An error occurred during the operation.
*/
@Override
public void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat)
throws SnmpStatusException {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
SnmpErrorHandlerAgent.class.getName(),
"getBulk", "GetBulk in Exception");
if(inRequest.getVersion() == SnmpDefinitions.snmpVersionOne)
throw new SnmpStatusException(SnmpDefinitions.snmpRspGenErr, 0);
Enumeration<SnmpVarBind> l = inRequest.getElements();
while(l.hasMoreElements()) {
SnmpVarBind varbind = l.nextElement();
varbind.setEndOfMibView();
}
}
示例12: init
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
private void init(SnmpPdu req, SnmpAdaptorServer server) {
this.server = server;
// The translation table is easy in this case ...
//
final int max= translation.length;
final SnmpVarBind[] list= req.varBindList;
final NonSyncVector<SnmpVarBind> nonSyncVarBind =
((NonSyncVector<SnmpVarBind>)varBind);
for(int i=0; i < max; i++) {
translation[i]= i;
// we need to allocate a new SnmpVarBind. Otherwise the first
// sub request will modify the list...
//
final SnmpVarBind newVarBind =
new SnmpVarBind(list[i].oid, list[i].value);
nonSyncVarBind.addNonSyncElement(newVarBind);
}
}
示例13: makeErrorVarbindPdu
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
SnmpPduPacket makeErrorVarbindPdu(SnmpPduPacket req, int statusTag) {
final SnmpVarBind[] vblist = req.varBindList;
final int length = vblist.length;
switch (statusTag) {
case SnmpDataTypeEnums.errEndOfMibViewTag:
for (int i=0 ; i<length ; i++)
vblist[i].value = SnmpVarBind.endOfMibView;
break;
case SnmpDataTypeEnums.errNoSuchObjectTag:
for (int i=0 ; i<length ; i++)
vblist[i].value = SnmpVarBind.noSuchObject;
break;
case SnmpDataTypeEnums.errNoSuchInstanceTag:
for (int i=0 ; i<length ; i++)
vblist[i].value = SnmpVarBind.noSuchInstance;
break;
default:
return newErrorResponsePdu(req,snmpRspGenErr,1);
}
return newValidResponsePdu(req,vblist);
}
示例14: SnmpSubRequestHandler
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* SNMP V1/V2 The constructor initialize the subrequest with the whole varbind list contained
* in the original request.
*/
@SuppressWarnings("unchecked") // cast to NonSyncVector<SnmpVarBind>
protected SnmpSubRequestHandler(SnmpMibAgent agent,
SnmpPdu req,
boolean nouse) {
this(agent,req);
// The translation table is easy in this case ...
//
int max= translation.length;
SnmpVarBind[] list= req.varBindList;
for(int i=0; i < max; i++) {
translation[i]= i;
((NonSyncVector<SnmpVarBind>)varBind).addNonSyncElement(list[i]);
}
}
示例15: updateResult
import com.sun.jmx.snmp.SnmpVarBind; //导入依赖的package包/类
/**
* 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.
*/
protected void updateResult(SnmpVarBind[] result) {
if (result == null) return;
final int max=varBind.size();
final int len=result.length;
for(int i= 0; i< max ; i++) {
// bugId 4641694: must check position in order to avoid
// ArrayIndexOutOfBoundException
final int pos=translation[i];
if (pos < len) {
result[pos] =
(SnmpVarBind)((NonSyncVector)varBind).elementAtNonSync(i);
} else {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpSubRequestHandler.class.getName(),
"updateResult","Position `"+pos+"' is out of bound...");
}
}
}
}