Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetNodeByOID which keeps index #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stampflit
Copy link

This function looks up a node by oid and also returns the part of the oid that have not been used to look up the node. The usecase for this are oids of fields in a table. E.g. IF-MIB::ifDescr.4 (.1.3.6.1.2.1.2.2.1.2.4) will return the oid of ifDescr and a index of 4.

This functionality is hard to just implement anywhere else as the code in smi/node.go interacts with smi/internal. So this functionality is tied closely to gosmi and I can't just implement my own function for this in my own module.

I don't really like the function names and the signature, but I also don't have better ones. I'll gladly change them upon suggestion.

@sleepinggenius2
Copy link
Owner

I'm confused about why this couldn't be implemented directly in your own code. This PR as written appears to be functionally equivalent to:

func GetNodeByOIDWithIndex(oid types.Oid) (node gosmi.SmiNode, index []types.SmiSubId, err error) {
  node, err := gosmi.GetNodeByOID(oid)
  if err != nil {
    return node, nil, err
  }
  return node, oid[len(node.Oid):], nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants