Loading...
Searching...
No Matches
session_server.h
Go to the documentation of this file.
#ifndef NC_SESSION_SERVER_H_
#define NC_SESSION_SERVER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <libyang/libyang.h>
#include <stdint.h>
#include <sys/types.h>
#include "netconf.h"
#include "session.h"
#ifdef NC_ENABLED_SSH_TLS
# include <libssh/callbacks.h>
# include <libssh/libssh.h>
# include <libssh/server.h>
#endif /* NC_ENABLED_SSH_TLS */
typedef struct nc_server_reply *(*nc_rpc_clb)(struct lyd_node *rpc, struct nc_session *session);
typedef void (*nc_cert_exp_notif_clb)(const char *expiration_time, const char *xpath, void *user_data);
void nc_session_set_term_reason(struct nc_session *session, NC_SESSION_TERM_REASON reason);
void nc_session_set_killed_by(struct nc_session *session, uint32_t sid);
void nc_session_set_status(struct nc_session *session, NC_STATUS status);
void nc_set_global_rpc_clb(nc_rpc_clb clb);
struct nc_server_reply *nc_clb_default_get_schema(struct lyd_node *rpc, struct nc_session *session);
struct nc_server_reply *nc_clb_default_close_session(struct lyd_node *rpc, struct nc_session *session);
int nc_server_init(void);
void nc_server_destroy(void);
int nc_server_init_ctx(struct ly_ctx **ctx);
int nc_server_set_capab_withdefaults(NC_WD_MODE basic_mode, int also_supported);
void nc_server_get_capab_withdefaults(NC_WD_MODE *basic_mode, int *also_supported);
int nc_server_set_capability(const char *value);
void nc_server_set_content_id_clb(char *(*content_id_clb)(void *user_data), void *user_data,
void (*free_user_data)(void *user_data));
char **nc_server_get_cpblts(const struct ly_ctx *ctx);
char **nc_server_get_cpblts_version(const struct ly_ctx *ctx, LYS_VERSION version);
NC_MSG_TYPE nc_accept_inout(int fdin, int fdout, const char *username, const struct ly_ctx *ctx,
struct nc_session **session);
struct nc_pollsession *nc_ps_new(void);
void nc_ps_free(struct nc_pollsession *ps);
int nc_ps_add_session(struct nc_pollsession *ps, struct nc_session *session);
int nc_ps_del_session(struct nc_pollsession *ps, struct nc_session *session);
struct nc_session *nc_ps_get_session(const struct nc_pollsession *ps, uint16_t idx);
typedef int (*nc_ps_session_match_cb)(struct nc_session *session, void *cb_data);
struct nc_session *nc_ps_find_session(const struct nc_pollsession *ps, nc_ps_session_match_cb match_cb, void *cb_data);
uint16_t nc_ps_session_count(struct nc_pollsession *ps);
#define NC_PSPOLL_NOSESSIONS 0x0001
#define NC_PSPOLL_TIMEOUT 0x0002
#define NC_PSPOLL_RPC 0x0004
#define NC_PSPOLL_BAD_RPC 0x0008
#define NC_PSPOLL_REPLY_ERROR 0x0010
#define NC_PSPOLL_SESSION_TERM 0x0020
#define NC_PSPOLL_SESSION_ERROR 0x0040
#define NC_PSPOLL_ERROR 0x0080
#ifdef NC_ENABLED_SSH_TLS
# define NC_PSPOLL_SSH_MSG 0x00100
# define NC_PSPOLL_SSH_CHANNEL 0x0200
#endif /* NC_ENABLED_SSH_TLS */
int nc_ps_poll(struct nc_pollsession *ps, int timeout, struct nc_session **session);
void nc_ps_clear(struct nc_pollsession *ps, int all, void (*data_free)(void *));
int nc_server_endpt_count(void);
int nc_server_add_endpt_unix_socket_listen(const char *endpt_name, const char *unix_socket_path, mode_t mode, uid_t uid, gid_t gid);
void nc_server_del_endpt_unix_socket(const char *endpt_name);
NC_MSG_TYPE nc_accept(int timeout, const struct ly_ctx *ctx, struct nc_session **session);
#ifdef NC_ENABLED_SSH_TLS
NC_MSG_TYPE nc_session_accept_ssh_channel(struct nc_session *orig_session, struct nc_session **session);
NC_MSG_TYPE nc_ps_accept_ssh_channel(struct nc_pollsession *ps, struct nc_session **session);
int nc_server_ssh_set_authkey_path_format(const char *path);
typedef int (*nc_server_ssh_interactive_auth_clb)(const struct nc_session *session,
ssh_session ssh_sess, ssh_message msg, void *user_data);
void nc_server_ssh_set_interactive_auth_clb(nc_server_ssh_interactive_auth_clb auth_clb, void *user_data, void (*free_user_data)(void *user_data));
int nc_server_ssh_kbdint_get_nanswers(const struct nc_session *session, ssh_session libssh_session);
int nc_server_ssh_set_pam_conf_filename(const char *filename);
const void *nc_session_get_client_cert(const struct nc_session *session);
void nc_server_tls_set_verify_clb(int (*verify_clb)(const struct nc_session *session));
#endif /* NC_ENABLED_SSH_TLS */
struct timespec nc_session_get_start_time(const struct nc_session *session);
void nc_session_inc_notif_status(struct nc_session *session);
void nc_session_dec_notif_status(struct nc_session *session);
int nc_session_get_notif_status(const struct nc_session *session);
#ifdef NC_ENABLED_SSH_TLS
int nc_server_notif_cert_expiration_thread_start(nc_cert_exp_notif_clb cert_exp_notif_clb,
void *user_data, void (*free_data)(void *));
void nc_server_notif_cert_expiration_thread_stop(int wait);
#endif /* NC_ENABLED_SSH_TLS */
#ifdef __cplusplus
}
#endif
#endif /* NC_SESSION_SERVER_H_ */
NC_MSG_TYPE
NC_MSG_TYPE
Enumeration of NETCONF message types.
Definition netconf.h:68
NC_WD_MODE
enum NC_WITHDEFAULTS_MODE NC_WD_MODE
Enumeration of NETCONF with-defaults capability modes.
NC_SESSION_TERM_REASON
NC_SESSION_TERM_REASON
Enumeration of reasons of the NETCONF session termination as defined in RFC 6470.
Definition netconf.h:54
nc_server_destroy
void nc_server_destroy(void)
Destroy any dynamically allocated libssh and/or libssl/libcrypto and server resources.
nc_server_get_cpblts
char ** nc_server_get_cpblts(const struct ly_ctx *ctx)
Get all the server capabilities including all the schemas.
nc_server_init_ctx
int nc_server_init_ctx(struct ly_ctx **ctx)
Initialize a context which can serve as a default server context.
nc_server_get_cpblts_version
char ** nc_server_get_cpblts_version(const struct ly_ctx *ctx, LYS_VERSION version)
Get the server capabilities including the schemas with the specified YANG version.
nc_server_endpt_count
int nc_server_endpt_count(void)
Get the number of currently configured listening endpoints. Note that an ednpoint without address and...
nc_server_set_capability
int nc_server_set_capability(const char *value)
Set capability of the server.
nc_server_get_capab_withdefaults
void nc_server_get_capab_withdefaults(NC_WD_MODE *basic_mode, int *also_supported)
Get with-defaults capability extra parameters.
nc_server_add_endpt_unix_socket_listen
int nc_server_add_endpt_unix_socket_listen(const char *endpt_name, const char *unix_socket_path, mode_t mode, uid_t uid, gid_t gid)
Create a new UNIX socket endpoint and start listening.
nc_server_del_endpt_unix_socket
void nc_server_del_endpt_unix_socket(const char *endpt_name)
Deletes a UNIX socket endpoint.
nc_server_init
int nc_server_init(void)
Initialize libssh and/or libssl/libcrypto and the server.
nc_server_set_capab_withdefaults
int nc_server_set_capab_withdefaults(NC_WD_MODE basic_mode, int also_supported)
Set the with-defaults capability extra parameters.
nc_server_set_content_id_clb
void nc_server_set_content_id_clb(char *(*content_id_clb)(void *user_data), void *user_data, void(*free_user_data)(void *user_data))
Set the callback for getting yang-library capability identifier. If none is set, libyang context chan...
nc_session_accept_ssh_channel
NC_MSG_TYPE nc_session_accept_ssh_channel(struct nc_session *orig_session, struct nc_session **session)
Accept a new NETCONF session on an SSH session of a running NETCONF orig_session. Call this function ...
nc_ps_new
struct nc_pollsession * nc_ps_new(void)
Create an empty structure for polling sessions.
nc_ps_poll
int nc_ps_poll(struct nc_pollsession *ps, int timeout, struct nc_session **session)
Poll sessions and process any received RPCs.
nc_ps_session_match_cb
int(* nc_ps_session_match_cb)(struct nc_session *session, void *cb_data)
Callback for finding a session in a pollsession structure.
Definition session_server.h:314
nc_session_set_term_reason
void nc_session_set_term_reason(struct nc_session *session, NC_SESSION_TERM_REASON reason)
Set the termination reason for a session. Use only in nc_rpc_clb callbacks.
nc_clb_default_get_schema
struct nc_server_reply * nc_clb_default_get_schema(struct lyd_node *rpc, struct nc_session *session)
Default RPC callback used for "ietf-netconf-monitoring:get-schema" RPC if no other specific or global...
nc_ps_del_session
int nc_ps_del_session(struct nc_pollsession *ps, struct nc_session *session)
Remove a session from a pollsession structure.
nc_rpc_clb
struct nc_server_reply *(* nc_rpc_clb)(struct lyd_node *rpc, struct nc_session *session)
Prototype of callbacks that are called if some RPCs are received.
Definition session_server.h:56
nc_server_notif_cert_expiration_thread_stop
void nc_server_notif_cert_expiration_thread_stop(int wait)
Stop the certificate expiration notification thread.
nc_ps_find_session
struct nc_session * nc_ps_find_session(const struct nc_pollsession *ps, nc_ps_session_match_cb match_cb, void *cb_data)
Find a session in a pollsession structure using a matching callback.
nc_accept_inout
NC_MSG_TYPE nc_accept_inout(int fdin, int fdout, const char *username, const struct ly_ctx *ctx, struct nc_session **session)
Accept a new session on a pre-established transport session.
nc_set_global_rpc_clb
void nc_set_global_rpc_clb(nc_rpc_clb clb)
Set a global nc_rpc_clb that is called if the particular RPC request is received and the private fiel...
nc_accept
NC_MSG_TYPE nc_accept(int timeout, const struct ly_ctx *ctx, struct nc_session **session)
Accept new sessions on all the listening endpoints.
nc_session_get_start_time
struct timespec nc_session_get_start_time(const struct nc_session *session)
Get session start time.
nc_clb_default_close_session
struct nc_server_reply * nc_clb_default_close_session(struct lyd_node *rpc, struct nc_session *session)
Default RPC callback used for "ietf-netconf:close-session" RPC if no other specific or global callbac...
nc_session_set_status
void nc_session_set_status(struct nc_session *session, NC_STATUS status)
Set the status of a session.
nc_cert_exp_notif_clb
void(* nc_cert_exp_notif_clb)(const char *expiration_time, const char *xpath, void *user_data)
Callback for certificate expiration notification.
Definition session_server.h:71
nc_session_set_killed_by
void nc_session_set_killed_by(struct nc_session *session, uint32_t sid)
Set the session-id of the session responsible for this session's termination.
nc_ps_add_session
int nc_ps_add_session(struct nc_pollsession *ps, struct nc_session *session)
Add a session to a pollsession structure.
nc_ps_free
void nc_ps_free(struct nc_pollsession *ps)
Free a pollsession structure.
nc_ps_session_count
uint16_t nc_ps_session_count(struct nc_pollsession *ps)
Learn the number of sessions in a pollsession structure.
nc_ps_clear
void nc_ps_clear(struct nc_pollsession *ps, int all, void(*data_free)(void *))
Remove sessions from a pollsession structure and call nc_session_free() on them.
nc_ps_accept_ssh_channel
NC_MSG_TYPE nc_ps_accept_ssh_channel(struct nc_pollsession *ps, struct nc_session **session)
Accept a new NETCONF session on an SSH session of a running NETCONF session that was polled in ps....
nc_session_dec_notif_status
void nc_session_dec_notif_status(struct nc_session *session)
Decrease session notification subscription flag count. Supports multiple subscriptions on one session...
nc_session_get_notif_status
int nc_session_get_notif_status(const struct nc_session *session)
Get session notification subscription flag.
nc_session_inc_notif_status
void nc_session_inc_notif_status(struct nc_session *session)
Increase session notification subscription flag count. Supports multiple subscriptions on one session...
nc_ps_get_session
struct nc_session * nc_ps_get_session(const struct nc_pollsession *ps, uint16_t idx)
Get a session from a pollsession structure matching the session ID.
nc_server_notif_cert_expiration_thread_start
int nc_server_notif_cert_expiration_thread_start(nc_cert_exp_notif_clb cert_exp_notif_clb, void *user_data, void(*free_data)(void *))
Start the certificate expiration notification thread.
nc_server_ssh_set_interactive_auth_clb
void nc_server_ssh_set_interactive_auth_clb(nc_server_ssh_interactive_auth_clb auth_clb, void *user_data, void(*free_user_data)(void *user_data))
Set the callback for SSH interactive authentication.
nc_server_ssh_kbdint_get_nanswers
int nc_server_ssh_kbdint_get_nanswers(const struct nc_session *session, ssh_session libssh_session)
Get the number of answers to Keyboard interactive authentication prompts.
nc_server_ssh_interactive_auth_clb
int(* nc_server_ssh_interactive_auth_clb)(const struct nc_session *session, ssh_session ssh_sess, ssh_message msg, void *user_data)
Keyboard interactive authentication callback.
Definition session_server.h:514
nc_server_ssh_set_pam_conf_filename
int nc_server_ssh_set_pam_conf_filename(const char *filename)
Set the name of the PAM configuration file.
nc_server_ssh_set_authkey_path_format
int nc_server_ssh_set_authkey_path_format(const char *path)
Set the format of the path to authorized_keys files.
nc_server_tls_set_verify_clb
void nc_server_tls_set_verify_clb(int(*verify_clb)(const struct nc_session *session))
Set TLS authentication additional verify callback.
nc_session_get_client_cert
const void * nc_session_get_client_cert(const struct nc_session *session)
Get client certificate.
netconf.h
libnetconf2's general public functions and structures definitions.
session.h
libnetconf2 session manipulation
NC_STATUS
NC_STATUS
Enumeration of possible session statuses.
Definition session.h:76