client session CHANGE one destroy function for the client
diff --git a/src/session_client.c b/src/session_client.c
index c429b99..be4ae06 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -936,6 +936,21 @@
#endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */
+API void
+nc_client_destroy(void)
+{
+ nc_client_schema_searchpath(NULL);
+#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+ nc_client_ch_del_bind(NULL, 0, 0);
+#endif
+#ifdef NC_ENABLED_SSH
+ nc_client_ssh_destroy_opts();
+#endif
+#ifdef NC_ENABLED_SSH
+ nc_client_tls_destroy_opts();
+#endif
+}
+
API 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)
{
diff --git a/src/session_client.h b/src/session_client.h
index 121dab2..54f9583 100644
--- a/src/session_client.h
+++ b/src/session_client.h
@@ -47,6 +47,11 @@
int nc_client_schema_searchpath(const char *path);
/**
+ * @brief Destroy all the client options, for both SSH and TLS, and for Call Home too.
+ */
+void nc_client_destroy(void);
+
+/**
* @brief Connect to the NETCONF server via proviaded input/output file descriptors.
*
* Transport layer is supposed to be already set. Function do not cover authentication
@@ -180,13 +185,6 @@
const char *nc_client_ssh_get_username(void);
/**
- * @brief Destroy any dynamically allocated SSH-specific client context (including Call Home).
- *
- * Function is provided only via nc_client.h header file and only when libnetconf2 is compiled with libssh support.
- */
-void nc_client_ssh_destroy_opts(void);
-
-/**
* @brief Connect to the NETCONF server using SSH transport (via libssh).
*
* SSH session is created with default options. If the caller needs to use specific SSH session properties,
@@ -314,13 +312,6 @@
void nc_client_tls_get_crl_paths(const char **crl_file, const char **crl_dir);
/**
- * @brief Destroy any dynamically allocated TLS-specific client data (including Call Home).
- *
- * Function is provided only via nc_client.h header file and only when libnetconf2 is compiled with TLS support.
- */
-void nc_client_tls_destroy_opts(void);
-
-/**
* @brief Connect to the NETCONF server using TLS transport (via libssl)
*
* TLS session is created with the certificates set using nc_client_init_tls(), which must be called beforehand!
diff --git a/src/session_client_ssh.c b/src/session_client_ssh.c
index 7c05b43..2461223 100644
--- a/src/session_client_ssh.c
+++ b/src/session_client_ssh.c
@@ -78,7 +78,7 @@
free(opts->username);
}
-API void
+void
nc_client_ssh_destroy_opts(void)
{
_nc_client_ssh_destroy_opts(&ssh_opts);
diff --git a/src/session_client_tls.c b/src/session_client_tls.c
index 960ae78..293bd4d 100644
--- a/src/session_client_tls.c
+++ b/src/session_client_tls.c
@@ -140,7 +140,7 @@
X509_STORE_free(opts->crl_store);
}
-API void
+void
nc_client_tls_destroy_opts(void)
{
_nc_client_tls_destroy_opts(&tls_opts);
diff --git a/src/session_p.h b/src/session_p.h
index 1b4df31..700ffb9 100644
--- a/src/session_p.h
+++ b/src/session_p.h
@@ -476,14 +476,14 @@
*/
int nc_ssh_pollin(struct nc_session *session, int *timeout);
-/* TODO */
void nc_server_ssh_clear_opts(struct nc_server_ssh_opts *opts);
+void nc_client_ssh_destroy_opts(void);
+
#endif /* NC_ENABLED_SSH */
#ifdef NC_ENABLED_TLS
-/* TODO */
struct nc_session *nc_accept_callhome_tls_sock(int sock, const char *host, uint16_t port, struct ly_ctx *ctx);
/**
@@ -497,9 +497,10 @@
*/
int nc_accept_tls_session(struct nc_session *session, int sock, int timeout);
-/* TODO */
void nc_server_tls_clear_opts(struct nc_server_tls_opts *opts);
+void nc_client_tls_destroy_opts(void);
+
#endif /* NC_ENABLED_TLS */
/**
diff --git a/tests/test_server_thread.c b/tests/test_server_thread.c
index 17e702f..0a788d4 100644
--- a/tests/test_server_thread.c
+++ b/tests/test_server_thread.c
@@ -282,8 +282,6 @@
nc_session_free(session);
- nc_client_ssh_destroy_opts();
-
nc_thread_destroy();
return NULL;
}
@@ -597,8 +595,6 @@
nc_session_free(session);
- nc_client_tls_destroy_opts();
-
nc_thread_destroy();
return NULL;
}
@@ -806,7 +802,7 @@
pthread_barrier_destroy(&barrier);
- nc_client_schema_searchpath(NULL);
+ nc_client_destroy();
nc_server_destroy();
ly_ctx_destroy(ctx, NULL);