Default Context

Hi,

Is the default context handled differently than other contexts?

All MOs are registered in a specific context or in the default context. I expected that a request would only be successful if the requested MO was in the same context as specified in the request. But the request is also successful if it specifies a context other than the default context even if the MO is registered in the default context. Is that really correct?

RFC3411 §3.3 is not very clear regarding this but he image shows no special behavior for the default context.

Thanks a lot!

SNMP4J-Agent acts as follows:

  • If a ManagedObject is registered with context null, it will be resolved with any context.
  • If a ManagedObject is registered with context "", it will be resolved with the default context only.
  • If a ManagedObject is registered with context "contextXY", it will be resolved with the default context “contextXY” only.

Hope this helps.

Best regards,
Frank

Hi Frank,

That makes sense. But how can I add a ManagedObject to the default context? DefaultMOServer.register() treats context null equally to context "" (if ((context == null) || (context.length() == 0)) {...}).

Thanks,
Roman

Hi Roman,

I think you are right. I mixed up AGENT++ and SNMP4J-Agent. In the latter we simplified the handling because the more complex differentiation between "" and null confused users when SNMP4J-Agent was introduced, if I remember it correctly.
To use the differentiation anyway, you would need to overwrite the register and unregister methods of the DefaultMOServer to not handle "" as null for the context value when registering and unregistering ManagedObjects.

Best regards,
Frank

Hi Frank,

For me there’s no need to differentiate "" and null currently. It was just to make sure that I understand the context topic correctly.

Thanks,
Roman