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

Parsing RPC reply difference from libyang 1 to libyang 2 #2245

Open
omarreng opened this issue May 27, 2024 · 1 comment
Open

Parsing RPC reply difference from libyang 1 to libyang 2 #2245

omarreng opened this issue May 27, 2024 · 1 comment
Labels
is:question Issue is actually a question.

Comments

@omarreng
Copy link

Hi,

I am facing an issue regarding how to parse a simple RPC reply string. Namely, the string literal I am trying to parse is <ok/> (a basic rpc-reply).

I am updating some code that was previously written using libyang 1, and this string was previously parsed using lyxml_parse_mem without problems. Since the lyxml_* API is removed in libyang 2 I have tried parsing this string using lyd_parse_data, lyd_parse_data_mem and lyd_parse_op. However, I get errors regarding a missing XML namespace (rightfully so, since there is no xmlns tag in the string) and If I try to add an XML namespace the error message simply says that the node I am trying to parse is missing from the corresponding module. All of this is done with the same context as before, which was working fine using lyxml_parse_mem.

My question is whether there is a way to parse a string like this one (or even a more complex rpc-reply) with libyang to be able to traverse the XML tree (possibly in the form of lyd_nodes)? I have tried using the LYD_PARSE_OPAQ parsing option, but the lyd_node being output from the several parsing methods is NULL, so I can't cast them to lyd_node_opaq.

Could I get some guidance regarding whether if I can achieve the same functionality using libyang 2?

Thanks in advance!

@michalvasko
Copy link
Member

I have tried parsing this string using lyd_parse_data, lyd_parse_data_mem and lyd_parse_op.

lyd_parse_op() is the function you want to use with LYD_TYPE_REPLY_NETCONF for parsing the whole NETCONF reply meaning

<rpc-reply ....>
  <ok/>
</rpc-reply>

That is the preferred way libyang v2 is parsing NETCONF replies.

Parsing only the nested data of rpc-reply is not directly supported but should work with lyd_parse_data*() and the LYD_PARSE_OPAQ option.

@michalvasko michalvasko added the is:question Issue is actually a question. label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:question Issue is actually a question.
Projects
None yet
Development

No branches or pull requests

2 participants