我创建了一个 snmp 代理模拟器并在其中实现了概念行。所以我想在 snmp4j 中的 MOTable 中添加一个空行。我尝试了下面的代码。
private MOTableRow createEmptyRow(MOTable motable, OID index)
{
Variable[] vars = new Variable[motable.getColumnCount()];
// Arrays.fill(vars, new Integer32(1));
int i = 0;
for (MOColumn column : motable.getColumns()) {
switch (column.getSyntax()) {
case MibConstants.OCTET_STRING: {
vars[i++] = new OctetString();
break;
}
case MibConstants.INTEGER:
case MibConstants.INTEGER32: {
vars[i++] = new Integer32();
break;
}
case MibConstants.COUNTER:
case MibConstants.COUNTER32: {
vars[i++] = new Counter32();
break;
}
case MibConstants.COUNTER64: {
vars[i++] = new Counter64();
break;
}
case MibConstants.IPADDRESS: {
vars[i++] = new IpAddress();
break;
}
case MibConstants.DISPLAYSTRING: {
vars[i++] = new OctetString();
break;
}
case MibConstants.GAUGE:
case MibConstants.GAUGE32: {
vars[i++] = new Gauge32();
break;
}
case MibConstants.OID: {
vars[i++] = new OID();
break;
}
case MibConstants.ROW_STATUS: {
vars[i++] = new Integer32(RowStatus.active);
break;
}
default: {
vars[i++] = new OctetString();
break;
}
}
}
MOTableRow row = DefaultMOFactory.getInstance().createRow(index, vars);
return row;
}
但它有时会产生“Snmp 一般错误”,有时会产生“错误值”!这里到底出了什么问题?如果它不起作用,我如何创建一个空行?请帮忙?