get the hello capability list
After the call to nc_accept_callhome, I get the return as success. How do I get the hello capability list (module list) ?
What capability list are you trying to get, sent from the client? There should only be NETCONF 1.0/1.1 capability, which is automatically selected.
What I wanted to ask was, how do I access the hello capabilities of the server from the client side ? Wanted to print all the module namespace.
Ah, right, it is on the client side. Call nc_session_get_cpblts().
Got it.
For this to work, I need to include #include <session_p.h> which is present in the src directory.
Why would you? Just include nc_client.h and it will be available, you are not supposed to include anything else in a NETCONF client.
If I don't include it then I get compilation error when I deference the nc_session ptr.
You are supposed to use the function nc_session_get_cpblts() I have mentioned, not access the structure directly.
This is the error I get when I compile,
nc_call_home.c: In function ‘main’:
nc_call_home.c:89:83: error: dereferencing pointer to incomplete type ‘struct nc_session’
89 | printf("Session ..... \r\n\tstatus %d, NC version %d, session-id %d\r\n", session->status, session->version, session->id);
| ^~
nc_call_home.c:91:8: error: too few arguments to function ‘nc_session_get_cpblts’
91 | cap = nc_session_get_cpblts();
| ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/nc_client.h:32,
from nc_call_home.c:15:
/usr/local/include/libnetconf2/session_client.h:533:21: note: declared here
533 | const char * const *nc_session_get_cpblts(const struct nc_session *session);
| ^~~~~~~~~~~~~~~~~~~~~
-----COMPILATION ERROR-----
I am not sure what to tell you, your compiler said it all.
Then I need to copy the session_p.h to /usr/local/libnetconf2/ folder for easy use. Is there any other way.
I really do not know why I have to write it all for you but here it goes. This is the same code that you will be able to compile:
printf("Session ..... \r\n\tstatus %d, NC version %d, session-id %u\r\n", nc_session_get_status(session), nc_session_get_version(session), nc_session_get_id(session));
const char * const *capabs = nc_session_get_cpblts(session);
for (int i = 0; capabs[i]; ++i) {
printf("Capability %s\n", capabs[i]);
}