4
我已經創建了一個snmp代理模擬器並在其中實現了概念性行。所以我想在snmp4j的MOTable中添加一個空行。我嘗試了下面的代碼。創建一個空行到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通用錯誤」,有時會產生「錯誤的值」!這裏究竟有什麼錯誤?我如何創建一個空行,如果它不工作?請幫忙?