libnetconf2  3.0.17
NETCONF server and client library in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
session_client.h
Go to the documentation of this file.
1 
16 #ifndef NC_SESSION_CLIENT_H_
17 #define NC_SESSION_CLIENT_H_
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <libyang/libyang.h>
24 
25 #ifdef NC_ENABLED_SSH_TLS
26 # include <libssh/libssh.h>
27 # include <openssl/ssl.h>
28 #endif /* NC_ENABLED_SSH_TLS */
29 
30 #include "messages_client.h"
31 #include "netconf.h"
32 #include "session.h"
33 
54 int nc_client_set_schema_searchpath(const char *path);
55 
61 const char *nc_client_get_schema_searchpath(void);
62 
70 int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data);
71 
81 ly_module_imp_clb nc_client_get_schema_callback(void **user_data);
82 
92 
105 void nc_client_set_thread_context(void *context);
106 
113 void *nc_client_get_thread_context(void);
114 
120 int nc_client_init(void);
121 
126 void nc_client_destroy(void);
127 
152 struct nc_session *nc_connect_inout(int fdin, int fdout, struct ly_ctx *ctx);
153 
167 struct nc_session *nc_connect_unix(const char *address, struct ly_ctx *ctx);
168 
171 #ifdef NC_ENABLED_SSH_TLS
172 
187 
198 int nc_client_ssh_set_knownhosts_path(const char *path);
199 
211 void nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
212  void *priv);
213 
221 void nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
222  void **priv);
223 
236 void nc_client_ssh_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction,
237  const char *prompt, int echo, void *priv),
238  void *priv);
239 
247 void nc_client_ssh_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction,
248  const char *prompt, int echo, void *priv),
249  void **priv);
250 
262 void nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
263  void *priv);
264 
272 void nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
273  void **priv);
274 
284 int nc_client_ssh_add_keypair(const char *pub_key, const char *priv_key);
285 
292 int nc_client_ssh_del_keypair(int idx);
293 
300 
309 int nc_client_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key);
310 
322 void nc_client_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref);
323 
331 
338 int nc_client_ssh_set_username(const char *username);
339 
345 const char *nc_client_ssh_get_username(void);
346 
361 struct nc_session *nc_connect_ssh(const char *host, uint16_t port, struct ly_ctx *ctx);
362 
378 struct nc_session *nc_connect_libssh(ssh_session ssh_session, struct ly_ctx *ctx);
379 
390 struct nc_session *nc_connect_ssh_channel(struct nc_session *session, struct ly_ctx *ctx);
391 
410 int nc_client_tls_set_cert_key_paths(const char *client_cert, const char *client_key);
411 
418 void nc_client_tls_get_cert_key_paths(const char **client_cert, const char **client_key);
419 
429 int nc_client_tls_set_trusted_ca_paths(const char *ca_file, const char *ca_dir);
430 
439 void nc_client_tls_get_trusted_ca_paths(const char **ca_file, const char **ca_dir);
440 
448 int nc_client_tls_set_crl_paths(const char *crl_file, const char *crl_dir);
449 
456 void nc_client_tls_get_crl_paths(const char **crl_file, const char **crl_dir);
457 
472 struct nc_session *nc_connect_tls(const char *host, uint16_t port, struct ly_ctx *ctx);
473 
485 struct nc_session *nc_connect_libssl(SSL *tls, struct ly_ctx *ctx);
486 
489 #endif /* NC_ENABLED_SSH_TLS */
490 
502 const char * const *nc_session_get_cpblts(const struct nc_session *session);
503 
511 const char *nc_session_cpblt(const struct nc_session *session, const char *capab);
512 
519 int nc_session_ntf_thread_running(const struct nc_session *session);
520 
541 NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout,
542  struct lyd_node **envp, struct lyd_node **op);
543 
558 NC_MSG_TYPE nc_recv_notif(struct nc_session *session, int timeout, struct lyd_node **envp, struct lyd_node **op);
559 
568 typedef void (*nc_notif_dispatch_clb)(struct nc_session *session, const struct lyd_node *envp, const struct lyd_node *op,
569  void *user_data);
570 
581 int nc_recv_notif_dispatch(struct nc_session *session, nc_notif_dispatch_clb notif_clb);
582 
596 int nc_recv_notif_dispatch_data(struct nc_session *session, nc_notif_dispatch_clb notif_clb, void *user_data,
597  void (*free_data)(void *));
598 
611 NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid);
612 
622 void nc_client_session_set_not_strict(struct nc_session *session);
623 
626 #ifdef __cplusplus
627 }
628 #endif
629 
630 #endif /* NC_SESSION_CLIENT_H_ */
NC_MSG_TYPE
Enumeration of NETCONF message types.
Definition: netconf.h:68
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:31
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.
NETCONF client RPC object.
libnetconf2&#39;s public functions and structures of NETCONF client messages.
NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout, struct lyd_node **envp, struct lyd_node **op)
Receive NETCONF RPC reply.
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_knownhosts_path(const char *path)
Set the path to the known_hosts file.
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.
int nc_client_init(void)
Initialize client for establishing connections.
NC_SSH_KNOWNHOSTS_MODE
Enumeration of host key checking and known_hosts entry adding modes.
Definition: session.h:40
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.
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.
void nc_client_set_new_session_context_autofill(int enabled)
Enable/disable loading of all the YANG modules supported by the server when a new session is created...
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).
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_notif(struct nc_session *session, int timeout, struct lyd_node **envp, struct lyd_node **op)
Receive NETCONF Notification.
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_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...
void nc_client_ssh_set_knownhosts_mode(NC_SSH_KNOWNHOSTS_MODE mode)
Set the behaviour of checking the host key and adding/reading entries to/from the known_hosts file...
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.
void(* nc_notif_dispatch_clb)(struct nc_session *session, const struct lyd_node *envp, const struct lyd_node *op, void *user_data)
Callback for receiving notifications in a separate thread.
int nc_recv_notif_dispatch(struct nc_session *session, nc_notif_dispatch_clb notif_clb)
Receive NETCONF Notifications in a separate thread until the session is terminated or &lt;notificationCo...
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.
int nc_recv_notif_dispatch_data(struct nc_session *session, nc_notif_dispatch_clb notif_clb, void *user_data, void(*free_data)(void *))
Receive NETCONF Notifications in a separate thread until the session is terminated or &lt;notificationCo...
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.