libnetconf2 icon indicating copy to clipboard operation
libnetconf2 copied to clipboard

Differentiating logs from callback set with nc_set_print_clb(), received from different servers

Open catalinvlad192 opened this issue 4 years ago • 7 comments

Hi!

I am using libnetconf2, version 1.1.36, and I am setting a callback (by nc_set_print_clb()) where I save every message in some files. In my project, a client can connect to multiple servers and I noticed that servers can create sessions with the same session number. Since in the callback we only receive the session number, is there a possibility to determine which log comes from which server? |Server 1| <-----Session 7-----> |Netconf Client| <-----Session 7-----> |Server 2|

Can you please help me with this issue? Thank you very much!

catalinvlad192 avatar Jun 03 '21 08:06 catalinvlad192

Right, it makes sense in your use-case, we do not have an implementation of multi-session NETCONF client. So I have added it but only to v2.

michalvasko avatar Jun 03 '21 10:06 michalvasko

Hello again!

I am trying to upgrade from version 1.1.36 to version 2.0.1 but I have some troubles and I have some questions if you can please help me:

  1. Did the API change on version 2 because there are some functions that I cannot find anymore. Do you have some kind of guideline on how to switch to this newer version?
  2. After we upgrade to 2.0.1, can we apply your patch to it so we can solve the initial problem?

Thank you very much and have a great day.

catalinvlad192 avatar Jun 08 '21 14:06 catalinvlad192

  1. Yes, there were some minor changes but you should have no trouble migrating from previous versions. Just look into the documentation for the function.
  2. The feature is already there, no patch needed.

michalvasko avatar Jun 08 '21 14:06 michalvasko

Hi Michal,

I see that in v2 API nc_recv_reply does not give us nc_reply anymore , instead it fills 2 new parameters: struct lyd_node ** envp, struct lyd_node ** op in https://netopeer.liberouter.org/doc/libnetconf2 is said that "op" contains the data reply (if any) but how do I extract the reply type ?

Also same problem for API nc_recv_notif , how do I extract the event time ?

Thank you.

BogdanF01 avatar Jun 14 '21 08:06 BogdanF01

You now need to work with the data trees manually (using libyang) but can always expect the correct data. Best is to simply print the trees and you should understand what is there exactly even though I tried to document it. Here is the processing of a reply and here notification event time printed. Those returned trees should exactly represent the definitions of rpc-reply and notification.

michalvasko avatar Jun 17 '21 06:06 michalvasko

Thank you. question: if server uses v1 and client v2 will there be communication issues ?

BogdanF01 avatar Jun 21 '21 06:06 BogdanF01

There should not be since both communicate by NETCONF.

michalvasko avatar Jun 21 '21 06:06 michalvasko