CESNET / libnetconf2

C NETCONF library
BSD 3-Clause "New" or "Revised" License
203 stars 147 forks source link

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

Closed catalinvlad192 closed 2 years ago

catalinvlad192 commented 3 years ago

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!

michalvasko commented 3 years ago

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.

catalinvlad192 commented 3 years ago

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.

michalvasko commented 3 years ago
  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.
BogdanF01 commented 3 years ago

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.

michalvasko commented 3 years ago

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.

BogdanF01 commented 3 years ago

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

michalvasko commented 3 years ago

There should not be since both communicate by NETCONF.