Searching for objects

I know from the description of the API in smi_node(3) that one can retrieve information about an object given its name either by searching the entire MIB tree or by containing the search to a specific module.
The application for which I plan on using libsmi would benefit from the convenience of being able to specify the root of a subtree to which the search for the given object should be restriced.
From my understanding of the API, there isn't a way to do this? Am
I right? If so, would the maintainers consider adding such an interface in a future release?
Saurabh

Saurabh Jang writes:
Saurabh> I know from the description of the API in smi_node(3) that Saurabh> one can retrieve information about an object given its name Saurabh> either by searching the entire MIB tree or by containing the Saurabh> search to a specific module.
Saurabh> The application for which I plan on using libsmi would Saurabh> benefit from the convenience of being able to specify the Saurabh> root of a subtree to which the search for the given object Saurabh> should be restriced.
Saurabh> From my understanding of the API, there isn't a way to do this? Am Saurabh> I right? If so, would the maintainers consider adding such an Saurabh> interface in a future release?
Lets say it differently: The API does not support such a lookup. It is certainly possible to write your own little function to implement what you are looking for. You simply recursively iterate over a subtree and search for nodes that match the name. It probably takes 10 lines of C code to do this.
Now, the question is whether this should be done in the library or not. My personal opinion is to not do it in the library. There are basically two reasons:
(a) Keep the API as small as possible. Do not add new interfaces if it is already easy to do the same things with the existing API.
(b) There is a common misinterpretation of the importance of the OID tree and the OID is in fact not a good scoping mechanism. The natural scope for identifiers are SMI modules not OID subtrees. I think the libsmi should not promote this flaky view of the world.
/js

Juergen Schoenwaelder writes:
Juergen> You simply recursively iterate over a subtree and search for Juergen> nodes that match the name.
Small correction: You do not even need recursion since you can use smiGetNextNode(). See the smisubtree example in the tools directory.
/js
participants (2)
-
jangļ¼ eis.comm.mot.com
-
Juergen Schoenwaelder