Question about v3 context

I am new to v3. What I figured out so far is that in order to use a context other than the default “”, I need to add mib with the specific context:
mib.add(“testContext”, new snmpGroup()); and of course
vacm->addNewContext("");
vacm->addNewContext(“testContext”);

After doing above, I was able to send v3 requests with context “testContext”.
But the problem is, when I send v1 or v2c request, it doesn’t work anymore, because the mib was added not in “” context. What I have to do is when adding mid, do again with “” context:
mib.add("", new snmpGroup());

Then I can send v1, v2c and v3 requests.

Is above the correct way to do things? I feel weird to add the same mib twice. Should agent++ ignore checking context in case of v1 and v2c requests?

Thanks.
Simon

Hi Simon,

For SNMPv1 and v2c there is the SNMP-COMMUNITY-MIB where you can define the mapping from an incoming community to an SNMPv3 context name and context engine ID.

Thus, you can add several MIB instances of the same MIB class (i.e. module definition) in several contexts, but you do not necessarily need to do that to support community based access.

Best regards,
Frank

Added snmp_community_mib and snmp_target_mib, and my issues were resolved.
Thank you.
Simon