libnetconf2  1.1.48
NETCONF library for clients and servers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
session_client.h
Go to the documentation of this file.
1 
15 #ifndef NC_SESSION_CLIENT_H_
16 #define NC_SESSION_CLIENT_H_
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #include <libyang/libyang.h>
23 
24 #ifdef NC_ENABLED_SSH
25 
26 #include <libssh/libssh.h>
27 
28 #endif
29 
30 #ifdef NC_ENABLED_TLS
31 
32 #include <openssl/ssl.h>
33 
34 #endif
35 
36 #include "session.h"
37 #include "netconf.h"
38 #include "messages_client.h"
39 
60 int nc_client_set_schema_searchpath(const char *path);
61 
67 const char *nc_client_get_schema_searchpath(void);
68 
76 int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data);
77 
87 ly_module_imp_clb nc_client_get_schema_callback(void **user_data);
88 
101 void nc_client_set_thread_context(void *context);
102 
109 void *nc_client_get_thread_context(void);
110 
114 void nc_client_init(void);
115 
120 void nc_client_destroy(void);
121 
150 struct nc_session *nc_connect_inout(int fdin, int fdout, struct ly_ctx *ctx);
151 
169 struct nc_session *nc_connect_unix(const char *address, struct ly_ctx *ctx);
170 
173 #ifdef NC_ENABLED_SSH
174 
194 void nc_client_ssh_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
195  void *priv);
196 
204 void nc_client_ssh_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
205  void **priv);
206 
218 void nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
219  void *priv);
220 
228 void nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
229  void **priv);
230 
243 void nc_client_ssh_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction,
244  const char *prompt, int echo, void *priv),
245  void *priv);
246 
254 void nc_client_ssh_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction,
255  const char *prompt, int echo, void *priv),
256  void **priv);
257 
269 void nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
270  void *priv);
271 
279 void nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
280  void **priv);
281 
291 int nc_client_ssh_add_keypair(const char *pub_key, const char *priv_key);
292 
299 int nc_client_ssh_del_keypair(int idx);
300 
307 
316 int nc_client_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key);
317 
329 void nc_client_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref);
330 
338 
345 int nc_client_ssh_set_username(const char *username);
346 
352 const char *nc_client_ssh_get_username(void);
353 
372 struct nc_session *nc_connect_ssh(const char *host, uint16_t port, struct ly_ctx *ctx);
373 
393 struct nc_session *nc_connect_libssh(ssh_session ssh_session, struct ly_ctx *ctx);
394 
409 struct nc_session *nc_connect_ssh_channel(struct nc_session *session, struct ly_ctx *ctx);
410 
413 #endif /* NC_ENABLED_SSH */
414 
415 #ifdef NC_ENABLED_TLS
416 
433 int nc_client_tls_set_cert_key_paths(const char *client_cert, const char *client_key);
434 
441 void nc_client_tls_get_cert_key_paths(const char **client_cert, const char **client_key);
442 
452 int nc_client_tls_set_trusted_ca_paths(const char *ca_file, const char *ca_dir);
453 
462 void nc_client_tls_get_trusted_ca_paths(const char **ca_file, const char **ca_dir);
463 
471 int nc_client_tls_set_crl_paths(const char *crl_file, const char *crl_dir);
472 
479 void nc_client_tls_get_crl_paths(const char **crl_file, const char **crl_dir);
480 
499 struct nc_session *nc_connect_tls(const char *host, uint16_t port, struct ly_ctx *ctx);
500 
516 struct nc_session *nc_connect_libssl(SSL *tls, struct ly_ctx *ctx);
517 
520 #endif /* NC_ENABLED_TLS */
521 
533 const char * const *nc_session_get_cpblts(const struct nc_session *session);
534 
542 const char *nc_session_cpblt(const struct nc_session *session, const char *capab);
543 
550 int nc_session_ntf_thread_running(const struct nc_session *session);
551 
576 NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout,
577  int parseroptions, struct nc_reply **reply);
578 
592 NC_MSG_TYPE nc_recv_notif(struct nc_session* session, int timeout, struct nc_notif **notif);
593 
604 int nc_recv_notif_dispatch(struct nc_session *session,
605  void (*notif_clb)(struct nc_session *session, const struct nc_notif *notif));
606 
620 NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid);
621 
631 void nc_client_session_set_not_strict(struct nc_session *session);
632 
635 #ifdef __cplusplus
636 }
637 #endif
638 
639 #endif /* NC_SESSION_CLIENT_H_ */
NC_MSG_TYPE
Enumeration of NETCONF message types.
Definition: netconf.h:69
int nc_client_set_schema_searchpath(const char *path)
Set location where libnetconf tries to search for YANG/YIN schemas.
void nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv), void **priv)
Get currently set SSH publickey authentication encrypted private key passphrase callback and its priv...
int16_t nc_client_ssh_get_auth_pref(NC_SSH_AUTH_TYPE auth_type)
Get SSH authentication method preference.
void nc_client_tls_get_cert_key_paths(const char **client_cert, const char **client_key)
Get client authentication identity - a certificate and a private key.
NC_SSH_AUTH_TYPE
Enumeration of NETCONF SSH authentication methods.
Definition: session.h:29
void nc_client_ssh_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction, const char *prompt, int echo, void *priv), void *priv)
Set SSH interactive authentication callback.
void nc_client_session_set_not_strict(struct nc_session *session)
Make a session not strict when sending RPCs and receiving RPC replies. In other words, it will silently skip unknown nodes without an error.
int nc_client_tls_set_trusted_ca_paths(const char *ca_file, const char *ca_dir)
Set client trusted CA certificates paths.
void nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv), void *priv)
Set SSH publickey authentication encrypted private key passphrase callback.
libnetconf2&#39;s public functions and structures of NETCONF client messages.
void * nc_client_get_thread_context(void)
Get thread-specific client context for sharing with some other thread using nc_client_set_thread_cont...
int nc_client_ssh_get_keypair_count(void)
Get the number of public an private key pairs set to be used for client authentication.
libnetconf2 session manipulation
struct nc_session * nc_connect_tls(const char *host, uint16_t port, struct ly_ctx *ctx)
Connect to the NETCONF server using TLS transport (via libssl)
int nc_session_ntf_thread_running(const struct nc_session *session)
Check whether the session has a notification thread running.
int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data)
Set callback function to get missing schemas.
void nc_client_destroy(void)
Destroy all libssh and/or libssl/libcrypto dynamic memory and the client options, for both SSH and TL...
const char *const * nc_session_get_cpblts(const struct nc_session *session)
Get session capabilities.
const char * nc_session_cpblt(const struct nc_session *session, const char *capab)
Check capability presence in a session.
const char * nc_client_ssh_get_username(void)
Get client SSH username used for authentication.
int nc_client_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key)
Get a specific keypair set to be used for client authentication.
int nc_client_ssh_set_username(const char *username)
Set client SSH username used for authentication.
struct nc_session * nc_connect_libssl(SSL *tls, struct ly_ctx *ctx)
Connect to the NETCONF server using the provided TLS (libssl) session.
void nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv), void *priv)
Set SSH password authentication callback.
struct nc_session * nc_connect_inout(int fdin, int fdout, struct ly_ctx *ctx)
Connect to the NETCONF server via proviaded input/output file descriptors.
struct nc_session * nc_connect_unix(const char *address, struct ly_ctx *ctx)
Connect to the NETCONF server via unix socket.
NETCONF client notification object.
const char * nc_client_get_schema_searchpath(void)
Get schema searchpath that was set by nc_client_set_schema_searchpath().
void nc_client_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref)
Set SSH authentication method preference.
int nc_client_ssh_del_keypair(int idx)
Remove an SSH public and private key pair that was used for client authentication.
struct nc_session * nc_connect_ssh(const char *host, uint16_t port, struct ly_ctx *ctx)
Connect to the NETCONF server using SSH transport (via libssh).
void nc_client_ssh_set_auth_hostkey_check_clb(int(*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv), void *priv)
Set SSH authentication hostkey check (knownhosts) callback.
ly_module_imp_clb nc_client_get_schema_callback(void **user_data)
Get callback function used to get missing schemas.
NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout, int parseroptions, struct nc_reply **reply)
Receive NETCONF RPC reply.
int nc_client_tls_set_cert_key_paths(const char *client_cert, const char *client_key)
Set client authentication identity - a certificate and a private key.
void nc_client_set_thread_context(void *context)
Use the provided thread-specific client&#39;s context in the current thread.
void nc_client_ssh_get_auth_hostkey_check_clb(int(**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv), void **priv)
Get currently set SSH authentication hostkey check (knownhosts) callback and its private data previou...
void nc_client_tls_get_crl_paths(const char **crl_file, const char **crl_dir)
Get client Certificate Revocation List paths.
void nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv), void **priv)
Get currently set SSH password authentication callback and its private data previously set by nc_clie...
int nc_recv_notif_dispatch(struct nc_session *session, void(*notif_clb)(struct nc_session *session, const struct nc_notif *notif))
Receive NETCONF Notifications in a separate thread until the session is terminated or &lt;notificationCo...
NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid)
Send NETCONF RPC message via the session.
NETCONF client rpc-reply object.
NC_MSG_TYPE nc_recv_notif(struct nc_session *session, int timeout, struct nc_notif **notif)
Receive NETCONF Notification.
struct nc_session * nc_connect_libssh(ssh_session ssh_session, struct ly_ctx *ctx)
Connect to the NETCONF server using the provided SSH (libssh) session.
void nc_client_ssh_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction, const char *prompt, int echo, void *priv), void **priv)
Get currently set SSH interactive authentication callback and its private data previously set by nc_c...
struct nc_session * nc_connect_ssh_channel(struct nc_session *session, struct ly_ctx *ctx)
Create another NETCONF session on existing SSH session using separated SSH channel.
int nc_client_ssh_add_keypair(const char *pub_key, const char *priv_key)
Add an SSH public and private key pair to be used for client authentication.
void nc_client_tls_get_trusted_ca_paths(const char **ca_file, const char **ca_dir)
Get client trusted CA certificates paths.
libnetconf2&#39;s general public functions and structures definitions.
int nc_client_tls_set_crl_paths(const char *crl_file, const char *crl_dir)
Set client Certificate Revocation List paths.
void nc_client_init(void)
Initialize libssh and/or libssl/libcrypto for use in the client.