libnetconf2  4.6.6
NETCONF server and client library in C.
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 #include "messages_client.h"
26 #include "netconf.h"
27 #include "session.h"
28 
29 #ifdef NC_ENABLED_SSH_TLS
30 # include <libssh/libssh.h>
31 #endif /* NC_ENABLED_SSH_TLS */
32 
53 int nc_client_set_schema_searchpath(const char *path);
54 
61 
69 int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data);
70 
80 ly_module_imp_clb nc_client_get_schema_callback(void **user_data);
81 
91 
98 int nc_client_unix_set_username(const char *username);
99 
106 int nc_client_set_capability(const char *value);
107 
116 int nc_client_set_new_session_context_schema_mount(struct nc_session *session);
117 
130 void nc_client_set_thread_context(void *context);
131 
139 
145 int nc_client_init(void);
146 
151 void nc_client_destroy(void);
152 
177 struct nc_session *nc_connect_inout(int fdin, int fdout, struct ly_ctx *ctx);
178 
192 struct nc_session *nc_connect_unix(const char *address, struct ly_ctx *ctx);
193 
196 #ifdef NC_ENABLED_SSH_TLS
197 
214 
225 int nc_client_ssh_set_knownhosts_path(const char *path);
226 
238 void nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
239  void *priv);
240 
248 void nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
249  void **priv);
250 
263 void nc_client_ssh_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction,
264  const char *prompt, int echo, void *priv),
265  void *priv);
266 
274 void nc_client_ssh_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction,
275  const char *prompt, int echo, void *priv),
276  void **priv);
277 
289 void nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
290  void *priv);
291 
299 void nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
300  void **priv);
301 
311 int nc_client_ssh_add_keypair(const char *pub_key, const char *priv_key);
312 
320 
327 
336 int nc_client_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key);
337 
349 void nc_client_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref);
350 
358 
365 int nc_client_ssh_set_username(const char *username);
366 
372 const char *nc_client_ssh_get_username(void);
373 
388 struct nc_session *nc_connect_ssh(const char *host, uint16_t port, struct ly_ctx *ctx);
389 
405 struct nc_session *nc_connect_libssh(ssh_session ssh_session, struct ly_ctx *ctx);
406 
417 struct nc_session *nc_connect_ssh_channel(struct nc_session *session, struct ly_ctx *ctx);
418 
437 int nc_client_tls_set_cert_key_paths(const char *client_cert, const char *client_key);
438 
445 void nc_client_tls_get_cert_key_paths(const char **client_cert, const char **client_key);
446 
456 int nc_client_tls_set_trusted_ca_paths(const char *ca_file, const char *ca_dir);
457 
466 void nc_client_tls_get_trusted_ca_paths(const char **ca_file, const char **ca_dir);
467 
481 struct nc_session *nc_connect_tls(const char *host, uint16_t port, struct ly_ctx *ctx);
482 
485 #endif /* NC_ENABLED_SSH_TLS */
486 
498 int nc_session_ntf_thread_running(const struct nc_session *session);
499 
518 NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout,
519  struct lyd_node **envp, struct lyd_node **op);
520 
535 NC_MSG_TYPE nc_recv_notif(struct nc_session *session, int timeout, struct lyd_node **envp, struct lyd_node **op);
536 
545 typedef void (*nc_notif_dispatch_clb)(struct nc_session *session, const struct lyd_node *envp, const struct lyd_node *op,
546  void *user_data);
547 
558 int nc_recv_notif_dispatch(struct nc_session *session, nc_notif_dispatch_clb notif_clb);
559 
573 int nc_recv_notif_dispatch_data(struct nc_session *session, nc_notif_dispatch_clb notif_clb, void *user_data,
574  void (*free_data)(void *));
575 
592 int nc_recv_msg(struct nc_session *session, int timeout, char **msg);
593 
606 NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid);
607 
624 NC_MSG_TYPE nc_send_msg(struct nc_session *session, const char *msg, uint32_t msg_len, int timeout, uint64_t *msgid);
625 
635 void nc_client_session_set_not_strict(struct nc_session *session);
636 
645 typedef void (*nc_client_monitoring_clb)(struct nc_session *session, void *user_data);
646 
667 int nc_client_monitoring_thread_start(nc_client_monitoring_clb monitoring_clb, void *user_data, void (*free_data)(void *));
668 
673 
685 
693 void nc_client_set_tcp_keepalives(uint16_t idle_time, uint16_t max_probes, uint16_t probe_interval);
694 
697 #ifdef __cplusplus
698 }
699 #endif
700 
701 #endif /* NC_SESSION_CLIENT_H_ */
NETCONF client RPC object.
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 <notificationCo...
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_session_ntf_thread_running(const struct nc_session *session)
Check whether the session has a notification thread running.
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_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.
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.
int nc_recv_msg(struct nc_session *session, int timeout, char **msg)
Receive a reply message.
void nc_client_monitoring_thread_stop(void)
Stop the client session monitoring thread.
void nc_client_set_tcp_keepalives(uint16_t idle_time, uint16_t max_probes, uint16_t probe_interval)
Set TCP keepalive options.
int nc_client_monitoring_thread_start(nc_client_monitoring_clb monitoring_clb, void *user_data, void(*free_data)(void *))
Start a thread that monitors client sessions.
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 <notificationCo...
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,...
NC_MSG_TYPE nc_send_msg(struct nc_session *session, const char *msg, uint32_t msg_len, int timeout, uint64_t *msgid)
Send a message via the session.
struct nc_session * nc_connect_unix(const char *address, struct ly_ctx *ctx)
Connect to the NETCONF server via unix socket.
void nc_client_enable_tcp_keepalives(int enable)
Enable or disable TCP keepalives. Only affects new sessions.
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_client_monitoring_clb)(struct nc_session *session, void *user_data)
Callback for monitoring client sessions.
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_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.
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.
int16_t nc_client_ssh_get_auth_pref(NC_SSH_AUTH_TYPE auth_type)
Get SSH authentication method preference.
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).
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_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_set_username(const char *username)
Set client SSH username used for authentication.
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_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref)
Set SSH authentication method preference.
int nc_client_ssh_set_knownhosts_path(const char *path)
Set the path to the known_hosts file.
int nc_client_ssh_del_keypair(int idx)
Remove an SSH public and private key pair that was used for client authentication.
const char * nc_client_ssh_get_username(void)
Get client SSH username used for authentication.
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.
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_client_ssh_get_keypair_count(void)
Get the number of public an private key pairs set to be used for client authentication.
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...
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_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_tls_get_cert_key_paths(const char **client_cert, const char **client_key)
Get client authentication identity - a certificate and a private key.
int nc_client_tls_set_trusted_ca_paths(const char *ca_file, const char *ca_dir)
Set client trusted CA certificates paths.
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)
void nc_client_tls_get_trusted_ca_paths(const char **ca_file, const char **ca_dir)
Get client trusted CA certificates paths.
int nc_client_set_capability(const char *value)
Set capability of the client.
int nc_client_set_new_session_context_schema_mount(struct nc_session *session)
Set client session context to support schema-mount, if possible.
int nc_client_unix_set_username(const char *username)
Set the NETCONF user of a UNIX socket connection. By default it is the system user of the client proc...
int nc_client_set_schema_searchpath(const char *path)
Set location where libnetconf tries to search for YANG/YIN 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 * nc_client_get_schema_searchpath(void)
Get schema searchpath that was set by nc_client_set_schema_searchpath().
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....
int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data)
Set callback function to get missing schemas.
ly_module_imp_clb nc_client_get_schema_callback(void **user_data)
Get callback function used to get missing schemas.
int nc_client_init(void)
Initialize client for establishing connections.
void nc_client_set_thread_context(void *context)
Use the provided thread-specific client's context in the current thread.
void * nc_client_get_thread_context(void)
Get thread-specific client context for sharing with some other thread using nc_client_set_thread_cont...
NC_MSG_TYPE
Enumeration of NETCONF message types.
Definition: netconf.h:69
libnetconf2's public functions and structures of NETCONF client messages.
libnetconf2's general public functions and structures definitions.
libnetconf2 session manipulation
NC_SSH_KNOWNHOSTS_MODE
Enumeration of host key checking and known_hosts entry adding modes.
Definition: session.h:40
NC_SSH_AUTH_TYPE
Enumeration of NETCONF SSH authentication methods.
Definition: session.h:31