Hi,
I’m trying to implement source address filtering with based on SNMP-COMMUNITY- and SNMP-TARGET-MIB.
I meet an issue that I don’t know how to set snmpTargetAddrTMask and snmpTargetAddrMMS of snmpTargetAddrExtTable.
I can get the snmpTargetAddrExtEntryRow with specified index as below:
MOTableRow snmpTargetExtTableRow = snmpCommunityMIB.getSnmpTargetAddrExtEntry().getModel().getRow(index);
but I can not find API to set snmpTargetAddrTMask and snmpTargetAddrMMS.
Could you please give me some advice? or an example?
Thanks.
Thanks for your quick answer, Frank.
I once have tried to cast the class, but it reported that SnmpTargetAddrExtEntryRow is not visible to me. so I can’t do the cast.
It seems that SnmpTargetAddrExtEntryRow is a package visible class, but our source code is not in org.snmp4j.agent.mo.snmp.
How to handle this situation? Please share your suggestion. Thanks.
Oh, that’s an error. It will be made public in the next releases.
But nevertheless you can easily access the row values by casting the row object to DefaultMOMutableRow2PC and then use the column index constants like the original (unfortunately protected) code does:
public class SnmpTargetAddrExtEntryRow extends DefaultMOMutableRow2PC {
...
public OctetString getSnmpTargetAddrTMask() {
return (OctetString) getValue(idxSnmpTargetAddrTMask);
}
public void setSnmpTargetAddrTMask(OctetString newValue) {
setValue(idxSnmpTargetAddrTMask, newValue);
}
public Integer32 getSnmpTargetAddrMMS() {
return (Integer32) getValue(idxSnmpTargetAddrMMS);
}
public void setSnmpTargetAddrMMS(Integer32 newValue) {
setValue(idxSnmpTargetAddrMMS, newValue);
}