libnetconf2  2.0.24
NETCONF server and client library in C.
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 # include <libssh/libssh.h>
26 #endif
27 
28 #ifdef NC_ENABLED_TLS
29 # include <openssl/ssl.h>
30 #endif
31 
32 #include "messages_client.h"
33 #include "netconf.h"
34 #include "session.h"
35 
56 int nc_client_set_schema_searchpath(const char *path);
57 
64 
72 int nc_client_set_schema_callback(ly_module_imp_clb clb, void *user_data);
73 
83 ly_module_imp_clb nc_client_get_schema_callback(void **user_data);
84 
97 void nc_client_set_thread_context(void *context);
98 
106 
110 void nc_client_init(void);
111 
116 void nc_client_destroy(void);
117 
146 struct nc_session *nc_connect_inout(int fdin, int fdout, struct ly_ctx *ctx);
147 
165 struct nc_session *nc_connect_unix(const char *address, struct ly_ctx *ctx);
166 
169 #ifdef NC_ENABLED_SSH
170 
190 void nc_client_ssh_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
191  void *priv);
192 
200 void nc_client_ssh_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
201  void **priv);
202 
214 void nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
215  void *priv);
216 
224 void nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
225  void **priv);
226 
239 void nc_client_ssh_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction,
240  const char *prompt, int echo, void *priv),
241  void *priv);
242 
250 void nc_client_ssh_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction,
251  const char *prompt, int echo, void *priv),
252  void **priv);
253 
265 void nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
266  void *priv);
267 
275 void nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
276  void **priv);
277 
287 int nc_client_ssh_add_keypair(const char *pub_key, const char *priv_key);
288 
296 
303 
312 int nc_client_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key);
313 
325 void nc_client_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref);
326 
334 
341 int nc_client_ssh_set_username(const char *username);
342 
348 const char *nc_client_ssh_get_username(void);
349 
368 struct nc_session *nc_connect_ssh(const char *host, uint16_t port, struct ly_ctx *ctx);
369 
389 struct nc_session *nc_connect_libssh(ssh_session ssh_session, struct ly_ctx *ctx);
390 
405 struct nc_session *nc_connect_ssh_channel(struct nc_session *session, struct ly_ctx *ctx);
406 
409 #endif /* NC_ENABLED_SSH */
410 
411 #ifdef NC_ENABLED_TLS
412 
429 int nc_client_tls_set_cert_key_paths(const char *client_cert, const char *client_key);
430 
437 void nc_client_tls_get_cert_key_paths(const char **client_cert, const char **client_key);
438 
448 int nc_client_tls_set_trusted_ca_paths(const char *ca_file, const char *ca_dir);
449 
458 void nc_client_tls_get_trusted_ca_paths(const char **ca_file, const char **ca_dir);
459 
467 int nc_client_tls_set_crl_paths(const char *crl_file, const char *crl_dir);
468 
475 void nc_client_tls_get_crl_paths(const char **crl_file, const char **crl_dir);
476 
495 struct nc_session *nc_connect_tls(const char *host, uint16_t port, struct ly_ctx *ctx);
496 
512 struct nc_session *nc_connect_libssl(SSL *tls, struct ly_ctx *ctx);
513 
516 #endif /* NC_ENABLED_TLS */
517 
529 const char * const *nc_session_get_cpblts(const struct nc_session *session);
530 
538 const char *nc_session_cpblt(const struct nc_session *session, const char *capab);
539 
546 int nc_session_ntf_thread_running(const struct nc_session *session);
547 
568 NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout,
569  struct lyd_node **envp, struct lyd_node **op);
570 
585 NC_MSG_TYPE nc_recv_notif(struct nc_session *session, int timeout, struct lyd_node **envp, struct lyd_node **op);
586 
597 int nc_recv_notif_dispatch(struct nc_session *session,
598  void (*notif_clb)(struct nc_session *session, const struct lyd_node *envp, const struct lyd_node *op));
599 
612 NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid);
613 
623 void nc_client_session_set_not_strict(struct nc_session *session);
624 
627 #ifdef __cplusplus
628 }
629 #endif
630 
631 #endif /* NC_SESSION_CLIENT_H_ */
NETCONF client RPC object.
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.
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.
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.
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.
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,...
struct nc_session * nc_connect_unix(const char *address, struct ly_ctx *ctx)
Connect to the NETCONF server via unix socket.
int nc_recv_notif_dispatch(struct nc_session *session, void(*notif_clb)(struct nc_session *session, const struct lyd_node *envp, const struct lyd_node *op))
Receive NETCONF Notifications in a separate thread until the session is terminated or <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.
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_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).
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.
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_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_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.
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_tls_set_crl_paths(const char *crl_file, const char *crl_dir)
Set client Certificate Revocation List paths.
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_tls_get_crl_paths(const char **crl_file, const char **crl_dir)
Get client Certificate Revocation List paths.
void nc_client_init(void)
Initialize libssh and/or libssl/libcrypto for use in the client.
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().
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.
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_AUTH_TYPE
Enumeration of NETCONF SSH authentication methods.
Definition: session.h:29