本文整理汇总了Java中org.snmp4j.PDU.set方法的典型用法代码示例。如果您正苦于以下问题:Java PDU.set方法的具体用法?Java PDU.set怎么用?Java PDU.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.snmp4j.PDU
的用法示例。
在下文中一共展示了PDU.set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processGet
import org.snmp4j.PDU; //导入方法依赖的package包/类
/**
* @param request
* @return
*/
@SuppressWarnings("unchecked")
private PDU processGet(PDU request) {
PDU response = request;
response.setErrorIndex(0);
response.setErrorStatus(0);
response.setType(PDU.RESPONSE);
Vector<VariableBinding> varBinds = response.getVariableBindings();
for(int i = 0; i < varBinds.size(); i++) {
VariableBinding varBind = varBinds.get(i);
VariableBinding nextVarBind = m_agent.get(varBind.getOid());
if (nextVarBind == null) {
if (response instanceof PDUv1) {
if (response.getErrorIndex() == 0) {
response.setErrorIndex(i+1);
response.setErrorStatus(PDU.noSuchName);
}
} else {
varBind.setVariable(Null.endOfMibView);
}
} else {
response.set(i, nextVarBind);
}
}
return response;
}
示例2: processGetNext
import org.snmp4j.PDU; //导入方法依赖的package包/类
/**
* @param request
* @return
*/
@SuppressWarnings("unchecked")
private PDU processGetNext(PDU request) {
PDU response = request;
response.setErrorIndex(0);
response.setErrorStatus(0);
response.setType(PDU.RESPONSE);
Vector<VariableBinding> varBinds = response.getVariableBindings();
for(int i = 0; i < varBinds.size(); i++) {
VariableBinding varBind = varBinds.get(i);
VariableBinding nextVarBind = m_agent.getNext(varBind.getOid());
if (nextVarBind == null) {
if (response instanceof PDUv1) {
if (response.getErrorIndex() == 0) {
response.setErrorIndex(i+1);
response.setErrorStatus(PDU.noSuchName);
}
} else {
varBind.setVariable(Null.endOfMibView);
}
} else {
response.set(i, nextVarBind);
}
}
return response;
}
示例3: walk
import org.snmp4j.PDU; //导入方法依赖的package包/类
public static List<VariableBinding> walk(Target target, OID oid) {
List<VariableBinding> ret = new ArrayList<VariableBinding>();
PDU requestPDU = new PDU();
requestPDU.add(new VariableBinding(oid));
requestPDU.setType(PDU.GETNEXT);
boolean finished = false;
try{
while (!finished) {
VariableBinding vb = null;
ResponseEvent respEvt = snmp.send(requestPDU, target);
PDU responsePDU = respEvt.getResponse();
if (responsePDU != null) {
vb = responsePDU.get(0);
}
if (responsePDU == null) {
finished = true;
} else if (responsePDU.getErrorStatus() != 0) {
finished = true;
} else if (vb.getOid() == null) {
finished = true;
} else if (vb.getOid().size() < oid.size()) {
finished = true;
} else if (oid.leftMostCompare(oid.size(), vb.getOid()) != 0) {
finished = true;
} else if (Null.isExceptionSyntax(vb.getVariable().getSyntax())) {
finished = true;
} else if (vb.getOid().compareTo(oid) <= 0) {
finished = true;
} else {
ret.add(vb);
// Set up the variable binding for the next entry.
requestPDU.setRequestID(new Integer32(0));
requestPDU.set(0, vb);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return ret;
}