Frank:
Thank you very much for your help. As you suggested, the problem is
around the coexistenceInfo within SnmpCommunityMIB, indeed.
I did set the coexistence provider at the CommandProcessor. The
createRow adds a cummunity row entry to coexistenceInfo map.
The statement
"communityMIB.getSnmpCommunityEntry().removeRow(aRow.getIndex());"
removes a community row from Community entry table. But this statement
does not remove the row from coexistenceInfo which is used by
CommandProcessor to check the security name.
Currently, I added a statement "comEntryModel.freeRow(aRow);"
immediately after preivous statement, and this stmt helps.
private void removeOneCommunity(SnmpCommunityMIB communityMIB,
MOTableRow aRow)
{
MOMutableTableModel comEntryModel =
(MOMutableTableModel)communityMIB.getSnmpCommunityEntry().getModel();
communityMIB.getSnmpCommunityEntry().removeRow(aRow.getIndex());
comEntryModel.freeRow(aRow);
}
The SnmpCommunityEntryRowFactory.freeRow() is invoked which removes the
community string from coexistenceInfo.
Is this preferred way to remove a community string?
Thanks again.
Vivi
Frank Fock wrote:
Hi Vivi,
I assume that you did not set the coexistence provider
at the CommandProcessor to your instance of the
SnmpCommunityMIB class.
The CommandProcessor then uses the SNMPv1/v2c community
as security name directly without mapping it to a
security name using the SNMP-COMMUNITY-MIB mapping.
Since you have an equal security name in your VACM
configuration, the request goes through.
For further questions read RFC 3414 and 3415.
Regards,
Frank
Vivi Zhang wrote:
Let me resend the email.
The previous email content was in an attachment. It did not show up
in SNMP4j email archives.
=============================================================================================
Hi,
I would really appreciate any help to find a way to remove an SNMP
community string .
I am using SNMP4j 1.9.3c, and SNMP4j agent 1.2.1d.
I have no problem to add more community string to a running SNMP
agent. But, when I have not been successfully remove a community string.
Following is a section of code which initializes community mib and
other mibs.
vacmMIB = new VacmMIB(new MOServer[] { server });
snmpTargetMIB = new SnmpTargetMIB(dispatcher);
snmpNotificationMIB = new SnmpNotificationMIB();
* snmpCommunityMIB = new SnmpCommunityMIB(snmpTargetMIB);*
this.getServer().addContext(DEFAULTCONTEXT);
initConfigMIB();
notificationOriginator = new NotificationOriginatorImpl(session,
vacmMIB,
snmpv2MIB.getSysUpTime(),
snmpTargetMIB,
snmpNotificationMIB);
snmpv2MIB.setNotificationOriginator(notificationOriginator);
Following is a section of code which add a community string to
community MIB
Variable[] com2sec = new Variable[] {
new OctetString(aCommunity), SECNAMEV1V2,
getContextEngineID(), DEFAULTCONTEXT,
new OctetString(), // transport tag
new Integer32(StorageType.nonVolatile), // storage type
new Integer32(RowStatus.active) // row status
};
MOTableRow row =
communityMIB.getSnmpCommunityEntry().createRow(index,
com2sec);
communityMIB.getSnmpCommunityEntry().addRow(row);
To remove all community strings, I tried following code:
MOMutableTableModel comEntryModel =
(MOMutableTableModel)communityMIB.getSnmpCommunityEntry().getModel();
comEntryModel .clear();
After this call, I expect all community rows are gone, and all SNMP
queries should fail. But this does not happen.
I also try to remove an individual community string using API call
communityMIB.getSnmpCommunityEntry().removeRow(index); where index is
a valid OID for a community string.
In both cases, the row is removed, but the event did not fired since
moTableModelListeners == null.
public synchronized MOTableRow removeRow(OID index) {
*MOTableRow row = (MOTableRow) rows.remove(index);*
if ((row != null) && (moTableModelListeners != null)) {
MOTableModelEvent event =
new MOTableModelEvent(this, MOTableModelEvent.ROW_REMOVED, row);
fireTableModelChanged(event);
}
return row;
}
After the calls, I am still able to query the snmp agent with
"removed" community string.
Wonder if it is expected behavior. Or I need config the
TableModelListeners for SnmpCommunityEntry table.
Please advise.
Vivi
_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j
_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j