libnetconf2 REFACTOR formatting
diff --git a/compat/compat.c b/compat/compat.c
index 71e8176..bf75c74 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -175,6 +175,7 @@
strchrnul(const char *s, int c)
{
char *p = strchr(s, c);
+
return p ? p : (char *)s + strlen(s);
}
diff --git a/src/io.c b/src/io.c
index 9a18ed1..d7ae67d 100644
--- a/src/io.c
+++ b/src/io.c
@@ -15,14 +15,14 @@
#define _GNU_SOURCE /* asprintf, signals */
#include <assert.h>
#include <errno.h>
-#include <poll.h>
#include <inttypes.h>
+#include <poll.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <signal.h>
#include <time.h>
+#include <unistd.h>
#ifdef NC_ENABLED_TLS
# include <openssl/err.h>
@@ -125,14 +125,14 @@
break;
} else {
ERR("Session %u: reading from file descriptor (%d) failed (%s).",
- session->id, fd, strerror(errno));
+ session->id, fd, strerror(errno));
session->status = NC_STATUS_INVALID;
session->term_reason = NC_SESSION_TERM_OTHER;
return -1;
}
} else if (r == 0) {
ERR("Session %u: communication file descriptor (%d) unexpectedly closed.",
- session->id, fd);
+ session->id, fd);
session->status = NC_STATUS_INVALID;
session->term_reason = NC_SESSION_TERM_DROPPED;
return -1;
@@ -148,7 +148,7 @@
break;
} else if (r == SSH_ERROR) {
ERR("Session %u: reading from the SSH channel failed (%s).", session->id,
- ssh_get_error(session->ti.libssh.session));
+ ssh_get_error(session->ti.libssh.session));
session->status = NC_STATUS_INVALID;
session->term_reason = NC_SESSION_TERM_OTHER;
return -1;
@@ -269,7 +269,7 @@
static ssize_t
nc_read_until(struct nc_session *session, const char *endtag, size_t limit, uint32_t inact_timeout,
- struct timespec *ts_act_timeout, char **result)
+ struct timespec *ts_act_timeout, char **result)
{
char *chunk = NULL;
size_t size, count = 0, r, len, i, matched = 0;
@@ -277,7 +277,7 @@
assert(session);
assert(endtag);
- if (limit && limit < BUFFERSIZE) {
+ if (limit && (limit < BUFFERSIZE)) {
size = limit;
} else {
size = BUFFERSIZE;
@@ -290,7 +290,7 @@
len = strlen(endtag);
while (1) {
- if (limit && count == limit) {
+ if (limit && (count == limit)) {
free(chunk);
WRN("Session %u: reading limit (%d) reached.", session->id, limit);
ERR("Session %u: invalid input data (missing \"%s\" sequence).", session->id, endtag);
@@ -486,7 +486,7 @@
ret = ssh_channel_poll_timeout(session->ti.libssh.channel, io_timeout, 0);
if (ret == SSH_ERROR) {
ERR("Session %u: SSH channel poll error (%s).", session->id,
- ssh_get_error(session->ti.libssh.session));
+ ssh_get_error(session->ti.libssh.session));
session->status = NC_STATUS_INVALID;
session->term_reason = NC_SESSION_TERM_OTHER;
return -1;
@@ -516,13 +516,14 @@
fds.fd = SSL_get_fd(session->ti.tls);
#endif
- /* fallthrough */
+ /* fallthrough */
case NC_TI_FD:
case NC_TI_UNIX:
- if (session->ti_type == NC_TI_FD)
+ if (session->ti_type == NC_TI_FD) {
fds.fd = session->ti.fd.in;
- else if (session->ti_type == NC_TI_UNIX)
+ } else if (session->ti_type == NC_TI_UNIX) {
fds.fd = session->ti.unixsock.sock;
+ }
fds.events = POLLIN;
fds.revents = 0;
@@ -634,7 +635,7 @@
fds.revents = 0;
errno = 0;
- while (((ret = poll(&fds, 1, 0)) == -1) && (errno == EINTR));
+ while (((ret = poll(&fds, 1, 0)) == -1) && (errno == EINTR)) {}
if (ret == -1) {
ERR("Session %u: poll failed (%s).", session->id, strerror(errno));
@@ -658,6 +659,7 @@
{
int c, fd, interrupted;
size_t written = 0;
+
#ifdef NC_ENABLED_TLS
unsigned long e;
#endif
@@ -683,9 +685,9 @@
case NC_TI_UNIX:
fd = session->ti_type == NC_TI_FD ? session->ti.fd.out : session->ti.unixsock.sock;
c = write(fd, (char *)(buf + written), count - written);
- if (c < 0 && errno == EAGAIN) {
+ if ((c < 0) && (errno == EAGAIN)) {
c = 0;
- } else if (c < 0 && errno == EINTR) {
+ } else if ((c < 0) && (errno == EINTR)) {
c = 0;
interrupted = 1;
} else if (c < 0) {
@@ -747,7 +749,7 @@
return -1;
}
- if (c == 0 && !interrupted) {
+ if ((c == 0) && !interrupted) {
/* we must wait */
usleep(NC_TIMEOUT_STEP);
}
@@ -843,7 +845,7 @@
ret += c;
}
- if (!xmlcontent && count > WRITE_BUFSIZE) {
+ if (!xmlcontent && (count > WRITE_BUFSIZE)) {
/* write directly */
c = nc_write_starttag_and_msg(warg->session, buf, count);
if (c == -1) {
@@ -951,7 +953,7 @@
op = va_arg(ap, struct lyd_node *);
attrs = va_arg(ap, const char *);
- count = asprintf(&buf, "<rpc xmlns=\"%s\" message-id=\"%"PRIu64"\"%s>",
+ count = asprintf(&buf, "<rpc xmlns=\"%s\" message-id=\"%" PRIu64 "\"%s>",
NC_NS_BASE, session->opts.client.msgid + 1, attrs ? attrs : "");
if (count == -1) {
ERRMEM;
@@ -1007,7 +1009,7 @@
}
break;
case NC_RPL_DATA:
- switch(((struct nc_server_reply_data *)reply)->wd) {
+ switch (((struct nc_server_reply_data *)reply)->wd) {
case NC_WD_UNKNOWN:
case NC_WD_EXPLICIT:
wd = LYD_PRINT_WD_EXPLICIT;
@@ -1083,7 +1085,7 @@
case NC_MSG_NOTIF:
notif = va_arg(ap, struct nc_server_notif *);
- nc_write_clb((void *)&arg, "<notification xmlns=\""NC_NS_NOTIF"\">", 21 + 47 + 2, 0);
+ nc_write_clb((void *)&arg, "<notification xmlns=\""NC_NS_NOTIF "\">", 21 + 47 + 2, 0);
nc_write_clb((void *)&arg, "<eventTime>", 11, 0);
nc_write_clb((void *)&arg, notif->eventtime, strlen(notif->eventtime), 0);
nc_write_clb((void *)&arg, "</eventTime>", 12, 0);
@@ -1100,7 +1102,7 @@
goto cleanup;
}
capabilities = va_arg(ap, const char **);
- sid = va_arg(ap, uint32_t*);
+ sid = va_arg(ap, uint32_t *);
count = asprintf(&buf, "<hello xmlns=\"%s\"><capabilities>", NC_NS_BASE);
if (count == -1) {
diff --git a/src/libnetconf.h b/src/libnetconf.h
index 1ea7475..3927ac6 100644
--- a/src/libnetconf.h
+++ b/src/libnetconf.h
@@ -17,10 +17,10 @@
#define NC_LIBNETCONF_H_
#include "config.h"
-#include "netconf.h"
#include "log_p.h"
-#include "session_p.h"
#include "messages_p.h"
+#include "netconf.h"
+#include "session_p.h"
/* Tests whether string is empty or non-empty. */
#define strisempty(str) ((str)[0] == '\0')
diff --git a/src/log.h b/src/log.h
index 7933e28..14e4f51 100644
--- a/src/log.h
+++ b/src/log.h
@@ -32,7 +32,7 @@
NC_VERB_WARNING = 1, /**< Print error and warning messages. */
NC_VERB_VERBOSE = 2, /**< Besides errors and warnings, print some other verbose messages. */
NC_VERB_DEBUG = 3, /**< Print almost all messages including some development debug messages. */
- NC_VERB_DEBUG_LOWLVL = 4, /**< Print all messages including low level debug messages. */
+ NC_VERB_DEBUG_LOWLVL = 4 /**< Print all messages including low level debug messages. */
} NC_VERB_LEVEL;
/**
diff --git a/src/log_p.h b/src/log_p.h
index d142131..124b9ed 100644
--- a/src/log_p.h
+++ b/src/log_p.h
@@ -38,11 +38,11 @@
/*
* Verbose printing macros
*/
-#define ERR(format,args...) prv_printf(NC_VERB_ERROR,format,##args)
-#define WRN(format,args...) if(verbose_level>=NC_VERB_WARNING){prv_printf(NC_VERB_WARNING,format,##args);}
-#define VRB(format,args...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(NC_VERB_VERBOSE,format,##args);}
-#define DBG(format,args...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(NC_VERB_DEBUG,format,##args);}
-#define DBL(format,args...) if(verbose_level>=NC_VERB_DEBUG_LOWLVL){prv_printf(NC_VERB_DEBUG_LOWLVL,format,##args);}
+#define ERR(format, args ...) prv_printf(NC_VERB_ERROR,format,##args)
+#define WRN(format, args ...) if(verbose_level>=NC_VERB_WARNING){prv_printf(NC_VERB_WARNING,format,##args);}
+#define VRB(format, args ...) if(verbose_level>=NC_VERB_VERBOSE){prv_printf(NC_VERB_VERBOSE,format,##args);}
+#define DBG(format, args ...) if(verbose_level>=NC_VERB_DEBUG){prv_printf(NC_VERB_DEBUG,format,##args);}
+#define DBL(format, args ...) if(verbose_level>=NC_VERB_DEBUG_LOWLVL){prv_printf(NC_VERB_DEBUG_LOWLVL,format,##args);}
#define ERRMEM ERR("%s: memory reallocation failed (%s:%d).", __func__, __FILE__, __LINE__)
#define ERRARG(arg) ERR("%s: invalid argument (%s).", __func__, arg)
diff --git a/src/messages_client.c b/src/messages_client.c
index 817a60f..27812d2 100644
--- a/src/messages_client.c
+++ b/src/messages_client.c
@@ -14,9 +14,9 @@
#include <assert.h>
#include <ctype.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
#include <libyang/libyang.h>
diff --git a/src/messages_client.h b/src/messages_client.h
index 6feecab..77ce4f5 100644
--- a/src/messages_client.h
+++ b/src/messages_client.h
@@ -74,7 +74,7 @@
/* ietf-yang-push */
NC_RPC_ESTABLISHPUSH, /**< \<establish-subscription\> RPC with augments. */
NC_RPC_MODIFYPUSH, /**< \<modify-subscription\> RPC with augments. */
- NC_RPC_RESYNCSUB, /**< \<resync-subscription\> RPC. */
+ NC_RPC_RESYNCSUB /**< \<resync-subscription\> RPC. */
} NC_RPC_TYPE;
/**
diff --git a/src/messages_p.h b/src/messages_p.h
index 2d9cd85..c029dfc 100644
--- a/src/messages_p.h
+++ b/src/messages_p.h
@@ -17,8 +17,8 @@
#include <libyang/libyang.h>
-#include "messages_server.h"
#include "messages_client.h"
+#include "messages_server.h"
extern const char *rpcedit_dfltop2str[];
extern const char *rpcedit_testopt2str[];
diff --git a/src/messages_server.c b/src/messages_server.c
index 8bcea89..7a39e69 100644
--- a/src/messages_server.c
+++ b/src/messages_server.c
@@ -13,10 +13,10 @@
*/
#include <ctype.h>
+#include <inttypes.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
-#include <inttypes.h>
#include <libyang/libyang.h>
diff --git a/src/messages_server.h b/src/messages_server.h
index dcd0670..642d47c 100644
--- a/src/messages_server.h
+++ b/src/messages_server.h
@@ -19,8 +19,8 @@
extern "C" {
#endif
-#include <stdint.h>
#include <libyang/libyang.h>
+#include <stdint.h>
#include "netconf.h"
#include "session.h"
diff --git a/src/session.c b/src/session.c
index e600f28..79d21af 100644
--- a/src/session.c
+++ b/src/session.c
@@ -14,23 +14,23 @@
#define _DEFAULT_SOURCE
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <libyang/libyang.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/types.h>
#include <time.h>
-#include <ctype.h>
-#include <libyang/libyang.h>
+#include <unistd.h>
#include "compat.h"
-#include "session.h"
#include "libnetconf.h"
+#include "session.h"
#include "session_server.h"
#ifdef NC_ENABLED_SSH
@@ -39,7 +39,7 @@
#endif /* NC_ENABLED_SSH */
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
# include <openssl/conf.h>
# include <openssl/err.h>
@@ -60,7 +60,7 @@
{
#ifdef CLOCK_MONOTONIC_RAW
return clock_gettime(CLOCK_MONOTONIC_RAW, ts);
-#elif defined(CLOCK_MONOTONIC)
+#elif defined (CLOCK_MONOTONIC)
return clock_gettime(CLOCK_MONOTONIC, ts);
#else
/* no monotonic clock available, return realtime */
@@ -95,7 +95,7 @@
nsec_diff += (((int64_t)ts2->tv_sec) - ((int64_t)ts1->tv_sec)) * 1000000000L;
nsec_diff += ((int64_t)ts2->tv_nsec) - ((int64_t)ts1->tv_nsec);
- return (nsec_diff ? nsec_diff / 1000000L : 0);
+ return nsec_diff ? nsec_diff / 1000000L : 0;
}
void
@@ -445,7 +445,7 @@
return -1;
}
- return (session->version == NC_VERSION_10 ? 0 : 1);
+ return session->version == NC_VERSION_10 ? 0 : 1;
}
API NC_TRANSPORT_IMPL
@@ -488,8 +488,9 @@
ERRARG("session");
return NULL;
}
- if (session->ti_type != NC_TI_UNIX)
+ if (session->ti_type != NC_TI_UNIX) {
return NULL;
+ }
return session->path;
}
@@ -543,7 +544,7 @@
{
if (session->ctx != op->schema->module->ctx) {
ERR("Session %u: RPC \"%s\" was created in different context than that of the session.",
- session->id, op->schema->name);
+ session->id, op->schema->name);
return NC_MSG_ERROR;
}
@@ -747,7 +748,7 @@
ssh_free(session->ti.libssh.session);
} else {
/* remove the session from the list */
- for (siter = session->ti.libssh.next; siter->ti.libssh.next != session; siter = siter->ti.libssh.next);
+ for (siter = session->ti.libssh.next; siter->ti.libssh.next != session; siter = siter->ti.libssh.next) {}
if (session->ti.libssh.next == siter) {
/* there will be only one session */
siter->ti.libssh.next = NULL;
@@ -852,7 +853,7 @@
len = strlen(capab);
}
for (i = 0; i < *count; i++) {
- if (!strncmp((*cpblts)[i], capab, len) && ((*cpblts)[i][len] == '\0' || (*cpblts)[i][len] == '?')) {
+ if (!strncmp((*cpblts)[i], capab, len) && (((*cpblts)[i][len] == '\0') || ((*cpblts)[i][len] == '?'))) {
/* already present, do not duplicate it */
return;
}
@@ -887,6 +888,7 @@
uint32_t i, u;
LY_ARRAY_COUNT_TYPE v;
char *yl_content_id;
+
#define NC_CPBLT_BUF_LEN 4096
char str[NC_CPBLT_BUF_LEN];
@@ -932,7 +934,7 @@
* https://tools.ietf.org/html/rfc6241#section-8.8.3
*/
// if (lys_feature_value(mod, "url") == LY_SUCCESS) {
- // add_cpblt(ctx, "urn:ietf:params:netconf:capability:url:1.0", &cpblts, &size, &count);
+ // add_cpblt(ctx, "urn:ietf:params:netconf:capability:url:1.0", &cpblts, &size, &count);
// }
if (lys_feature_value(mod, "xpath") == LY_SUCCESS) {
@@ -1139,9 +1141,9 @@
}
/* detect NETCONF version */
- if (ver < 0 && !strncmp(cpb_start, "urn:ietf:params:netconf:base:1.0", cpb_end - cpb_start)) {
+ if ((ver < 0) && !strncmp(cpb_start, "urn:ietf:params:netconf:base:1.0", cpb_end - cpb_start)) {
ver = 0;
- } else if (ver < 1 && !strncmp(cpb_start, "urn:ietf:params:netconf:base:1.1", cpb_end - cpb_start)) {
+ } else if ((ver < 1) && !strncmp(cpb_start, "urn:ietf:params:netconf:base:1.1", cpb_end - cpb_start)) {
ver = 1;
}
@@ -1238,7 +1240,7 @@
}
str = NULL;
id = strtoll(node->value, &str, 10);
- if (*str || id < 1 || id > UINT32_MAX) {
+ if (*str || (id < 1) || (id > UINT32_MAX)) {
ERR("Invalid value of <session-id> element in server <hello>.");
rc = NC_MSG_ERROR;
goto cleanup;
@@ -1436,11 +1438,12 @@
pthread_mutex_destroy(&l->lock);
free(l);
}
+
#endif
#endif /* NC_ENABLED_TLS */
-#if defined(NC_ENABLED_TLS) && !defined(NC_ENABLED_SSH)
+#if defined (NC_ENABLED_TLS) && !defined (NC_ENABLED_SSH)
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
static pthread_mutex_t *tls_locks;
@@ -1460,6 +1463,7 @@
{
CRYPTO_THREADID_set_numeric(tid, (unsigned long)pthread_self());
}
+
#endif
static void
@@ -1522,7 +1526,7 @@
#endif /* NC_ENABLED_TLS && !NC_ENABLED_SSH */
-#if defined(NC_ENABLED_SSH) && defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS)
static void
nc_ssh_tls_init(void)
@@ -1565,13 +1569,13 @@
#endif /* NC_ENABLED_SSH && NC_ENABLED_TLS */
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
API void
nc_thread_destroy(void)
{
/* caused data-races and seems not neccessary for avoiding valgrind reachable memory */
- //CRYPTO_cleanup_all_ex_data();
+ // CRYPTO_cleanup_all_ex_data();
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
CRYPTO_THREADID crypto_tid;
@@ -1586,11 +1590,11 @@
void
nc_init(void)
{
-#if defined(NC_ENABLED_SSH) && defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS)
nc_ssh_tls_init();
-#elif defined(NC_ENABLED_SSH)
+#elif defined (NC_ENABLED_SSH)
nc_ssh_init();
-#elif defined(NC_ENABLED_TLS)
+#elif defined (NC_ENABLED_TLS)
nc_tls_init();
#endif
}
@@ -1598,11 +1602,11 @@
void
nc_destroy(void)
{
-#if defined(NC_ENABLED_SSH) && defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS)
nc_ssh_tls_destroy();
-#elif defined(NC_ENABLED_SSH)
+#elif defined (NC_ENABLED_SSH)
nc_ssh_destroy();
-#elif defined(NC_ENABLED_TLS)
+#elif defined (NC_ENABLED_TLS)
nc_tls_destroy();
#endif
}
diff --git a/src/session.h b/src/session.h
index 2b4fa54..76c7cc7 100644
--- a/src/session.h
+++ b/src/session.h
@@ -91,7 +91,7 @@
* @brief Enumeration of Call Home client priority policy.
*/
typedef enum {
- NC_CH_FIRST_LISTED = 0, //default
+ NC_CH_FIRST_LISTED = 0, // default
NC_CH_LAST_CONNECTED,
NC_CH_RANDOM
} NC_CH_START_WITH;
@@ -223,7 +223,7 @@
*/
void nc_session_free(struct nc_session *session, void (*data_free)(void *));
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
/**
* @brief Free all the dynamically allocated thread-specific libssl/libcrypto
diff --git a/src/session_client.c b/src/session_client.c
index f3444ae..8107cc9 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -18,34 +18,34 @@
# include <sys/syscall.h>
#endif
+#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <poll.h>
#include <pthread.h>
+#include <pwd.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/select.h>
#include <sys/socket.h>
-#include <sys/un.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/select.h>
+#include <sys/un.h>
#include <unistd.h>
-#include <arpa/inet.h>
-#include <poll.h>
-#include <pwd.h>
#include <libyang/libyang.h>
#include "compat.h"
#include "libnetconf.h"
-#include "session_client.h"
#include "messages_client.h"
+#include "session_client.h"
-#include "../modules/ietf_netconf_monitoring@2010-10-04_yang.h"
#include "../modules/ietf_netconf@2013-09-29_yang.h"
+#include "../modules/ietf_netconf_monitoring@2010-10-04_yang.h"
static const char *ncds2str[] = {NULL, "config", "url", "running", "startup", "candidate"};
@@ -53,7 +53,7 @@
int sshauth_hostkey_check(const char *hostname, ssh_session session, void *priv);
char *sshauth_password(const char *username, const char *hostname, void *priv);
char *sshauth_interactive(const char *auth_name, const char *instruction, const char *prompt, int echo, void *priv);
-char *sshauth_privkey_passphrase(const char* privkey_path, void *priv);
+char *sshauth_privkey_passphrase(const char *privkey_path, void *priv);
#endif /* NC_ENABLED_SSH */
static pthread_once_t nc_client_context_once = PTHREAD_ONCE_INIT;
@@ -108,7 +108,7 @@
/* for the main thread the same is done in nc_client_destroy() */
free(c->opts.schema_searchpath);
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
int i;
for (i = 0; i < c->opts.ch_bind_count; ++i) {
close(c->opts.ch_binds[i].sock);
@@ -136,7 +136,7 @@
int r;
/* initiate */
- while ((r = pthread_key_create(&nc_client_context_key, nc_client_context_free)) == EAGAIN);
+ while ((r = pthread_key_create(&nc_client_context_key, nc_client_context_free)) == EAGAIN) {}
pthread_setspecific(nc_client_context_key, NULL);
}
@@ -311,7 +311,7 @@
static char *
retrieve_schema_data_localfile(const char *name, const char *rev, struct clb_data_s *clb_data,
- LYS_INFORMAT *format)
+ LYS_INFORMAT *format)
{
char *localfile = NULL;
FILE *f;
@@ -319,8 +319,8 @@
char *model_data = NULL;
if (lys_search_localfile(ly_ctx_get_searchdirs(clb_data->session->ctx),
- !(ly_ctx_get_options(clb_data->session->ctx) & LY_CTX_DISABLE_SEARCHDIR_CWD),
- name, rev, &localfile, format)) {
+ !(ly_ctx_get_options(clb_data->session->ctx) & LY_CTX_DISABLE_SEARCHDIR_CWD),
+ name, rev, &localfile, format)) {
return NULL;
}
if (localfile) {
@@ -328,7 +328,7 @@
f = fopen(localfile, "r");
if (!f) {
ERR("Session %u: unable to open \"%s\" file to get schema (%s).",
- clb_data->session->id, localfile, strerror(errno));
+ clb_data->session->id, localfile, strerror(errno));
free(localfile);
return NULL;
}
@@ -337,7 +337,7 @@
length = ftell(f);
if (length < 0) {
ERR("Session %u: unable to get size of schema file \"%s\".",
- clb_data->session->id, localfile);
+ clb_data->session->id, localfile);
free(localfile);
fclose(f);
return NULL;
@@ -349,7 +349,7 @@
ERRMEM;
} else if ((l = fread(model_data, 1, length, f)) != length) {
ERR("Session %u: reading schema from \"%s\" failed (%d bytes read, but %d expected).",
- clb_data->session->id, localfile, l, length);
+ clb_data->session->id, localfile, l, length);
free(model_data);
model_data = NULL;
} else {
@@ -365,7 +365,7 @@
static char *
retrieve_schema_data_getschema(const char *name, const char *rev, struct clb_data_s *clb_data,
- LYS_INFORMAT *format)
+ LYS_INFORMAT *format)
{
struct nc_rpc *rpc;
struct lyd_node *envp = NULL, *op = NULL;
@@ -395,7 +395,7 @@
if (msg == NC_MSG_WOULDBLOCK) {
ERR("Session %u: timeout for receiving reply to a <get-schema> expired.", clb_data->session->id);
goto cleanup;
- } else if (msg == NC_MSG_ERROR || !op) {
+ } else if ((msg == NC_MSG_ERROR) || !op) {
ERR("Session %u: failed to receive a reply to <get-schema>.", clb_data->session->id);
goto cleanup;
}
@@ -436,7 +436,7 @@
f = fopen(localfile, "w");
if (!f) {
WRN("Unable to store \"%s\" as a local copy of schema retrieved via <get-schema> (%s).",
- localfile, strerror(errno));
+ localfile, strerror(errno));
} else {
fputs(model_data, f);
fclose(f);
@@ -452,7 +452,8 @@
return model_data;
}
-static void free_with_user_data(void *data, void *user_data)
+static void
+free_with_user_data(void *data, void *user_data)
{
free(data);
(void)user_data;
@@ -476,7 +477,7 @@
if (strcmp(mod_name, clb_data->schemas[u].name)) {
continue;
}
- if (!match || strcmp(mod_rev, clb_data->schemas[u].revision) > 0) {
+ if (!match || (strcmp(mod_rev, clb_data->schemas[u].revision) > 0)) {
mod_rev = clb_data->schemas[u].revision;
}
match = u + 1;
@@ -485,7 +486,7 @@
/* valid situation if we are retrieving YANG 1.1 schema and have only capabilities for now
* (when loading ietf-datastore for ietf-yang-library) */
VRB("Session %u: unable to identify revision of the schema \"%s\" from the available server side information.",
- clb_data->session->id, mod_name);
+ clb_data->session->id, mod_name);
}
}
if (submod_name) {
@@ -495,7 +496,7 @@
} else if (match) {
if (!clb_data->schemas[match - 1].submodules) {
VRB("Session %u: Unable to identify revision of the requested submodule \"%s\", in schema \"%s\", from the available server side information.",
- clb_data->session->id, submod_name, mod_name);
+ clb_data->session->id, submod_name, mod_name);
} else {
for (v = 0; clb_data->schemas[match - 1].submodules[v].name; ++v) {
if (!strcmp(submod_name, clb_data->schemas[match - 1].submodules[v].name)) {
@@ -504,7 +505,7 @@
}
if (!rev) {
ERR("Session %u: requested submodule \"%s\" is not known for schema \"%s\" on server side.",
- clb_data->session->id, submod_name, mod_name);
+ clb_data->session->id, submod_name, mod_name);
return LY_ENOTFOUND;
}
}
@@ -554,7 +555,7 @@
*free_module_data = free_with_user_data;
*module_data = model_data;
- return (*module_data ? LY_SUCCESS : LY_ENOTFOUND);
+ return *module_data ? LY_SUCCESS : LY_ENOTFOUND;
}
static int
@@ -565,7 +566,8 @@
struct ly_err_item *eitem;
const char *module_data = NULL;
LYS_INFORMAT format;
- void (*free_module_data)(void*, void*) = NULL;
+
+ void (*free_module_data)(void *, void *) = NULL;
struct clb_data_s clb_data;
*mod = NULL;
@@ -659,7 +661,6 @@
free(list);
}
-
static int
build_schema_info_yl(struct nc_session *session, struct schema_info **result)
{
@@ -692,7 +693,7 @@
}
if (msg == NC_MSG_ERROR) {
WRN("Session %u: failed to send request for yang-library data.",
- session->id);
+ session->id);
goto cleanup;
}
@@ -779,7 +780,7 @@
v = 0;
LY_LIST_FOR(lyd_child(modules->dnodes[u]), iter) {
mod = modules->dnodes[u]->schema->module;
- if (mod == iter->schema->module && !strcmp(iter->schema->name, "submodule")) {
+ if ((mod == iter->schema->module) && !strcmp(iter->schema->name, "submodule")) {
LY_LIST_FOR(lyd_child(iter), child) {
if (mod != child->schema->module) {
continue;
@@ -816,7 +817,7 @@
uint32_t u, v, feature_count;
char *module_cpblt, *ptr, *ptr2;
- for (u = 0; cpblts[u]; ++u);
+ for (u = 0; cpblts[u]; ++u) {}
(*result) = calloc(u + 1, sizeof **result);
if (!(*result)) {
ERRMEM;
@@ -1168,7 +1169,7 @@
if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) < 0) {
ERR("cannot connect to sock server %s (%s)",
- address, strerror(errno));
+ address, strerror(errno));
goto fail;
}
@@ -1218,8 +1219,9 @@
fail:
nc_session_free(session, NULL);
- if (sock >= 0)
+ if (sock >= 0) {
close(sock);
+ }
return NULL;
}
@@ -1239,8 +1241,8 @@
uint16_t port;
char str[INET6_ADDRSTRLEN];
- if (sock_pending && *sock_pending != -1) {
- VRB("Trying to connect the pending socket %d.", *sock_pending );
+ if (sock_pending && (*sock_pending != -1)) {
+ VRB("Trying to connect the pending socket %d.", *sock_pending);
sock = *sock_pending;
} else {
assert(res);
@@ -1364,7 +1366,7 @@
for (res = res_list; res != NULL; res = res->ai_next) {
sock = _non_blocking_connect(timeout, sock_pending, res, ka);
if (sock == -1) {
- if (!sock_pending || *sock_pending == -1) {
+ if (!sock_pending || (*sock_pending == -1)) {
/* try the next resource */
continue;
} else {
@@ -1424,7 +1426,7 @@
return -1;
}
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
int
nc_client_ch_add_bind_listen(const char *address, uint16_t port, NC_TRANSPORT_IMPL ti)
@@ -1491,9 +1493,9 @@
client_opts.ch_bind_count = 0;
} else {
for (i = 0; i < client_opts.ch_bind_count; ++i) {
- if ((!address || !strcmp(client_opts.ch_binds[i].address, address))
- && (!port || (client_opts.ch_binds[i].port == port))
- && (!ti || (client_opts.ch_bind_ti[i] == ti))) {
+ if ((!address || !strcmp(client_opts.ch_binds[i].address, address)) &&
+ (!port || (client_opts.ch_binds[i].port == port)) &&
+ (!ti || (client_opts.ch_bind_ti[i] == ti))) {
close(client_opts.ch_binds[i].sock);
free((char *)client_opts.ch_binds[i].address);
@@ -1617,7 +1619,7 @@
nc_client_destroy(void)
{
nc_client_set_schema_searchpath(NULL);
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
nc_client_ch_del_bind(NULL, 0, 0);
#endif
#ifdef NC_ENABLED_SSH
@@ -2042,7 +2044,7 @@
} else if (!op) {
ERRARG("op");
return NC_MSG_ERROR;
- } else if (session->status != NC_STATUS_RUNNING || session->side != NC_CLIENT) {
+ } else if ((session->status != NC_STATUS_RUNNING) || (session->side != NC_CLIENT)) {
ERR("Session %u: invalid session to receive Notifications.", session->id);
return NC_MSG_ERROR;
}
@@ -2056,6 +2058,7 @@
{
struct nc_ntf_thread_arg *ntarg;
struct nc_session *session;
+
void (*notif_clb)(struct nc_session *session, const struct lyd_node *envp, const struct lyd_node *op);
struct lyd_node *envp, *op;
NC_MSG_TYPE msgtype;
@@ -2210,7 +2213,7 @@
} else if (!msgid) {
ERRARG("msgid");
return NC_MSG_ERROR;
- } else if (session->status != NC_STATUS_RUNNING || session->side != NC_CLIENT) {
+ } else if ((session->status != NC_STATUS_RUNNING) || (session->side != NC_CLIENT)) {
ERR("Session %u: invalid session to send RPCs.", session->id);
return NC_MSG_ERROR;
}
diff --git a/src/session_client.h b/src/session_client.h
index 0d9b994..342943a 100644
--- a/src/session_client.h
+++ b/src/session_client.h
@@ -33,9 +33,9 @@
#endif
-#include "session.h"
-#include "netconf.h"
#include "messages_client.h"
+#include "netconf.h"
+#include "session.h"
/**
* @addtogroup client
@@ -192,7 +192,7 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void *priv);
+ void *priv);
/**
* @brief Get currently set SSH authentication hostkey check (knownhosts) callback and its private data previously set
@@ -202,7 +202,7 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void **priv);
+ void **priv);
/**
* @brief Set SSH password authentication callback.
@@ -216,7 +216,7 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
- void *priv);
+ void *priv);
/**
* @brief Get currently set SSH password authentication callback and its private data previously set
@@ -226,7 +226,7 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
- void **priv);
+ void **priv);
/**
* @brief Set SSH interactive authentication callback.
@@ -241,8 +241,8 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
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);
+ const char *prompt, int echo, void *priv),
+ void *priv);
/**
* @brief Get currently set SSH interactive authentication callback and its private data previously set
@@ -252,8 +252,8 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
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);
+ const char *prompt, int echo, void *priv),
+ void **priv);
/**
* @brief Set SSH publickey authentication encrypted private key passphrase callback.
@@ -267,7 +267,7 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void *priv);
+ void *priv);
/**
* @brief Get currently set SSH publickey authentication encrypted private key passphrase callback and its private data
@@ -277,7 +277,7 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void **priv);
+ void **priv);
/**
* @brief Add an SSH public and private key pair to be used for client authentication.
diff --git a/src/session_client_ch.h b/src/session_client_ch.h
index 800841d..e3431c6 100644
--- a/src/session_client_ch.h
+++ b/src/session_client_ch.h
@@ -21,11 +21,11 @@
#include <libyang/libyang.h>
-#include "session.h"
-#include "netconf.h"
#include "messages_client.h"
+#include "netconf.h"
+#include "session.h"
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
/**
* @defgroup client_ch Client-side Call Home
@@ -72,7 +72,7 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_ch_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void *priv);
+ void *priv);
/**
* @brief Get currently set SSH Call Home authentication hostkey check (knownhosts) callback and its private data
@@ -82,7 +82,7 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_ch_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void **priv);
+ void **priv);
/**
* @brief Set SSH Call Home password authentication callback.
*
@@ -95,7 +95,7 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_ch_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
- void *priv);
+ void *priv);
/**
* @brief Get currently set SSH Call Home password authentication callback and its private data
@@ -105,7 +105,7 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_ch_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
- void **priv);
+ void **priv);
/**
* @brief Set SSH Call Home interactive authentication callback.
@@ -120,8 +120,8 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_ch_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction,
- const char *prompt, int echo, void *priv),
- void *priv);
+ const char *prompt, int echo, void *priv),
+ void *priv);
/**
* @brief Get currently set SSH Call Home interactive authentication callback and its private data
@@ -131,8 +131,8 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_ch_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction,
- const char *prompt, int echo, void *priv),
- void **priv);
+ const char *prompt, int echo, void *priv),
+ void **priv);
/**
* @brief Set SSH Call Home publickey authentication encrypted private key passphrase callback.
@@ -146,7 +146,7 @@
* @param[in] priv Optional private data to be passed to the callback function.
*/
void nc_client_ssh_ch_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void *priv);
+ void *priv);
/**
* @brief Get currently set SSH Call Home publickey authentication encrypted private key passphrase callback and its
@@ -156,7 +156,7 @@
* @param[out] priv Currently set (optional) private data to be passed to the callback function.
*/
void nc_client_ssh_ch_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void **priv);
+ void **priv);
/**
* @brief Add a new client bind and start listening on it for SSH Call Home connections.
diff --git a/src/session_client_ssh.c b/src/session_client_ssh.c
index 1821ee4..5c5b6fc 100644
--- a/src/session_client_ssh.c
+++ b/src/session_client_ssh.c
@@ -18,23 +18,23 @@
#define _GNU_SOURCE
#include <assert.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
#include <errno.h>
#include <fcntl.h>
-#include <termios.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pwd.h>
-#include <unistd.h>
#include <pthread.h>
+#include <pwd.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <termios.h>
#include <time.h>
+#include <unistd.h>
#ifdef ENABLE_DNSSEC
-# include <validator/validator.h>
# include <validator/resolver.h>
+# include <validator/validator.h>
# include <validator/validator-compat.h>
#endif
@@ -42,9 +42,9 @@
#include <libyang/libyang.h>
#include "compat.h"
+#include "libnetconf.h"
#include "session_client.h"
#include "session_client_ch.h"
-#include "libnetconf.h"
struct nc_client_context *nc_client_context_location(void);
int nc_session_new_ctx(struct nc_session *session, struct ly_ctx *ctx);
@@ -181,11 +181,12 @@
/* return 0 (DNSSEC + key valid), 1 (unsecure DNS + key valid), 2 (key not found or an error) */
/* type - 1 (RSA), 2 (DSA), 3 (ECDSA); alg - 1 (SHA1), 2 (SHA-256) */
static int
-sshauth_hostkey_hash_dnssec_check(const char *hostname, const unsigned char *sha1hash, int type, int alg) {
+sshauth_hostkey_hash_dnssec_check(const char *hostname, const unsigned char *sha1hash, int type, int alg)
+{
ns_msg handle;
ns_rr rr;
val_status_t val_status;
- const unsigned char* rdata;
+ const unsigned char *rdata;
unsigned char buf[4096];
int buf_len = 4096;
int ret = 0, i, j, len;
@@ -275,6 +276,7 @@
sshauth_hostkey_check(const char *hostname, ssh_session session, void *UNUSED(priv))
{
char *hexa = NULL;
+
#if (LIBSSH_VERSION_INT >= SSH_VERSION_INT(0, 9, 0))
int c, ret;
enum ssh_known_hosts_e state;
@@ -419,7 +421,7 @@
ERR("Reading from input failed (%s).", feof(in) ? "EOF" : strerror(errno));
goto error;
}
- while (((c = getc(in)) != EOF) && (c != '\n'));
+ while (((c = getc(in)) != EOF) && (c != '\n')) {}
fflush(in);
if (!strcmp("yes", answer)) {
@@ -587,7 +589,7 @@
}
char *
-sshauth_privkey_passphrase(const char* privkey_path, void *UNUSED(priv))
+sshauth_privkey_passphrase(const char *privkey_path, void *UNUSED(priv))
{
char *buf = NULL;
int c, buflen = 1024, len;
@@ -642,7 +644,7 @@
static void
_nc_client_ssh_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void *priv, struct nc_client_ssh_opts *opts)
+ void *priv, struct nc_client_ssh_opts *opts)
{
if (auth_hostkey_check) {
opts->auth_hostkey_check = auth_hostkey_check;
@@ -655,7 +657,7 @@
static void
_nc_client_ssh_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void **priv, struct nc_client_ssh_opts *opts)
+ void **priv, struct nc_client_ssh_opts *opts)
{
if (auth_hostkey_check) {
(*auth_hostkey_check) = opts->auth_hostkey_check == sshauth_hostkey_check ? NULL : opts->auth_hostkey_check;
@@ -665,38 +667,37 @@
}
}
-
API void
nc_client_ssh_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void *priv)
+ void *priv)
{
_nc_client_ssh_set_auth_hostkey_check_clb(auth_hostkey_check, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void *priv)
+ void *priv)
{
_nc_client_ssh_set_auth_hostkey_check_clb(auth_hostkey_check, priv, &ssh_ch_opts);
}
API void
nc_client_ssh_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void **priv)
+ void **priv)
{
_nc_client_ssh_get_auth_hostkey_check_clb(auth_hostkey_check, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv),
- void **priv)
+ void **priv)
{
_nc_client_ssh_get_auth_hostkey_check_clb(auth_hostkey_check, priv, &ssh_ch_opts);
}
static void
_nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
- void *priv, struct nc_client_ssh_opts *opts)
+ void *priv, struct nc_client_ssh_opts *opts)
{
if (auth_password) {
opts->auth_password = auth_password;
@@ -709,7 +710,7 @@
static void
_nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
- void **priv, struct nc_client_ssh_opts *opts)
+ void **priv, struct nc_client_ssh_opts *opts)
{
if (auth_password) {
(*auth_password) = opts->auth_password == sshauth_password ? NULL : opts->auth_password;
@@ -721,36 +722,36 @@
API void
nc_client_ssh_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
- void *priv)
+ void *priv)
{
_nc_client_ssh_set_auth_password_clb(auth_password, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv),
- void *priv)
+ void *priv)
{
_nc_client_ssh_set_auth_password_clb(auth_password, priv, &ssh_ch_opts);
}
API void
nc_client_ssh_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
- void **priv)
+ void **priv)
{
_nc_client_ssh_get_auth_password_clb(auth_password, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv),
- void **priv)
+ void **priv)
{
_nc_client_ssh_get_auth_password_clb(auth_password, priv, &ssh_ch_opts);
}
static 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, struct nc_client_ssh_opts *opts)
+ const char *prompt, int echo, void *priv),
+ void *priv, struct nc_client_ssh_opts *opts)
{
if (auth_interactive) {
opts->auth_interactive = auth_interactive;
@@ -763,8 +764,8 @@
static 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, struct nc_client_ssh_opts *opts)
+ const char *prompt, int echo, void *priv),
+ void **priv, struct nc_client_ssh_opts *opts)
{
if (auth_interactive) {
(*auth_interactive) = opts->auth_interactive == sshauth_interactive ? NULL : opts->auth_interactive;
@@ -776,39 +777,39 @@
API 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)
+ const char *prompt, int echo, void *priv),
+ void *priv)
{
_nc_client_ssh_set_auth_interactive_clb(auth_interactive, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction,
- const char *prompt, int echo, void *priv),
- void *priv)
+ const char *prompt, int echo, void *priv),
+ void *priv)
{
_nc_client_ssh_set_auth_interactive_clb(auth_interactive, priv, &ssh_ch_opts);
}
API 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)
+ const char *prompt, int echo, void *priv),
+ void **priv)
{
_nc_client_ssh_get_auth_interactive_clb(auth_interactive, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction,
- const char *prompt, int echo, void *priv),
- void **priv)
+ const char *prompt, int echo, void *priv),
+ void **priv)
{
_nc_client_ssh_get_auth_interactive_clb(auth_interactive, priv, &ssh_ch_opts);
}
static void
_nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void *priv, struct nc_client_ssh_opts *opts)
+ void *priv, struct nc_client_ssh_opts *opts)
{
if (auth_privkey_passphrase) {
opts->auth_privkey_passphrase = auth_privkey_passphrase;
@@ -821,7 +822,7 @@
static void
_nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void **priv, struct nc_client_ssh_opts *opts)
+ void **priv, struct nc_client_ssh_opts *opts)
{
if (auth_privkey_passphrase) {
(*auth_privkey_passphrase) = opts->auth_privkey_passphrase == sshauth_privkey_passphrase ? NULL : opts->auth_privkey_passphrase;
@@ -833,28 +834,28 @@
API void
nc_client_ssh_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void *priv)
+ void *priv)
{
_nc_client_ssh_set_auth_privkey_passphrase_clb(auth_privkey_passphrase, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void *priv)
+ void *priv)
{
_nc_client_ssh_set_auth_privkey_passphrase_clb(auth_privkey_passphrase, priv, &ssh_ch_opts);
}
API void
nc_client_ssh_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void **priv)
+ void **priv)
{
_nc_client_ssh_get_auth_privkey_passphrase_clb(auth_privkey_passphrase, priv, &ssh_opts);
}
API void
nc_client_ssh_ch_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv),
- void **priv)
+ void **priv)
{
_nc_client_ssh_get_auth_privkey_passphrase_clb(auth_privkey_passphrase, priv, &ssh_ch_opts);
}
@@ -878,11 +879,11 @@
if (!strcmp(opts->keys[i].pubkey_path, pub_key) || !strcmp(opts->keys[i].privkey_path, priv_key)) {
if (strcmp(opts->keys[i].pubkey_path, pub_key)) {
WRN("Private key \"%s\" found with another public key \"%s\".",
- priv_key, opts->keys[i].pubkey_path);
+ priv_key, opts->keys[i].pubkey_path);
continue;
} else if (strcmp(opts->keys[i].privkey_path, priv_key)) {
WRN("Public key \"%s\" found with another private key \"%s\".",
- pub_key, opts->keys[i].privkey_path);
+ pub_key, opts->keys[i].privkey_path);
continue;
}
@@ -1165,7 +1166,7 @@
int j, ret_auth, userauthlist, ret, attempt = 0;
NC_SSH_AUTH_TYPE auth;
int16_t pref;
- const char* prompt;
+ const char *prompt;
char *s, *answer, echo;
ssh_key pubkey, privkey;
ssh_session ssh_sess;
@@ -1299,8 +1300,8 @@
nc_gettimespec_mono(&ts_timeout);
nc_addtimespec(&ts_timeout, timeout);
}
- while (((ret_auth = ssh_userauth_kbdint(ssh_sess, NULL, NULL)) == SSH_AUTH_INFO)
- || (ret_auth == SSH_AUTH_AGAIN)) {
+ while (((ret_auth = ssh_userauth_kbdint(ssh_sess, NULL, NULL)) == SSH_AUTH_INFO) ||
+ (ret_auth == SSH_AUTH_AGAIN)) {
if (ret_auth == SSH_AUTH_AGAIN) {
usleep(NC_TIMEOUT_STEP);
if (timeout > -1) {
@@ -1323,8 +1324,8 @@
echo = 0;
answer = opts->auth_interactive(ssh_userauth_kbdint_getname(ssh_sess),
- ssh_userauth_kbdint_getinstruction(ssh_sess),
- prompt, echo, opts->auth_interactive_priv);
+ ssh_userauth_kbdint_getinstruction(ssh_sess),
+ prompt, echo, opts->auth_interactive_priv);
if (ssh_userauth_kbdint_setanswer(ssh_sess, j, answer) < 0) {
free(answer);
ret_auth = SSH_AUTH_ERROR;
@@ -1355,8 +1356,8 @@
for (j = 0; j < opts->key_count; j++) {
VRB("Trying to authenticate using %spair \"%s\" \"%s\".",
- opts->keys[j].privkey_crypt ? "password-protected " : "", opts->keys[j].privkey_path,
- opts->keys[j].pubkey_path);
+ opts->keys[j].privkey_crypt ? "password-protected " : "", opts->keys[j].privkey_path,
+ opts->keys[j].pubkey_path);
ret = ssh_pki_import_pubkey_file(opts->keys[j].pubkey_path, &pubkey);
if (ret == SSH_EOF) {
@@ -1738,8 +1739,8 @@
/* temporarily, for session connection */
session->host = host;
session->username = username;
- if ((connect_ssh_session(session, &ssh_opts, NC_TRANSPORT_TIMEOUT) != 1)
- || (open_netconf_channel(session, NC_TRANSPORT_TIMEOUT) != 1)) {
+ if ((connect_ssh_session(session, &ssh_opts, NC_TRANSPORT_TIMEOUT) != 1) ||
+ (open_netconf_channel(session, NC_TRANSPORT_TIMEOUT) != 1)) {
goto fail;
}
diff --git a/src/session_client_tls.c b/src/session_client_tls.c
index 4777a1e..cdc3919 100644
--- a/src/session_client_tls.c
+++ b/src/session_client_tls.c
@@ -21,20 +21,20 @@
#include <unistd.h>
#include <libyang/libyang.h>
-#include <openssl/ossl_typ.h>
#include <openssl/err.h>
+#include <openssl/ossl_typ.h>
#include <openssl/x509.h>
+#include "libnetconf.h"
#include "session_client.h"
#include "session_client_ch.h"
-#include "libnetconf.h"
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
#endif
struct nc_client_context *nc_client_context_location(void);
-int nc_session_new_ctx( struct nc_session *session, struct ly_ctx *ctx);
+int nc_session_new_ctx(struct nc_session *session, struct ly_ctx *ctx);
#define client_opts nc_client_context_location()->opts
#define tls_opts nc_client_context_location()->tls_opts
@@ -81,7 +81,7 @@
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
X509_STORE_CTX_free(store_ctx);
crl = X509_OBJECT_get0_X509_CRL(obj);
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
next_update = X509_CRL_get0_nextUpdate(crl);
/* verify the signature on this CRL */
@@ -120,7 +120,7 @@
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
X509_STORE_CTX_free(store_ctx);
crl = X509_OBJECT_get0_X509_CRL(obj);
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
/* check if the current certificate is revoked by this CRL */
n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
for (i = 0; i < n; i++) {
@@ -176,7 +176,7 @@
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
X509_STORE_CTX_cleanup(&store_ctx);
crl = obj.data.crl;
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
next_update = X509_CRL_get_nextUpdate(crl);
/* verify the signature on this CRL */
@@ -214,7 +214,7 @@
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
X509_STORE_CTX_cleanup(&store_ctx);
crl = obj.data.crl;
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
/* check if the current certificate is revoked by this CRL */
n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
for (i = 0; i < n; i++) {
diff --git a/src/session_p.h b/src/session_p.h
index 212b0fe..6993313 100644
--- a/src/session_p.h
+++ b/src/session_p.h
@@ -16,21 +16,21 @@
#ifndef NC_SESSION_PRIVATE_H_
#define NC_SESSION_PRIVATE_H_
-#include <stdint.h>
#include <pthread.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <libyang/libyang.h>
#include "libnetconf.h"
+#include "messages_client.h"
#include "netconf.h"
#include "session.h"
-#include "messages_client.h"
#ifdef NC_ENABLED_SSH
-# include <libssh/libssh.h>
# include <libssh/callbacks.h>
+# include <libssh/libssh.h>
# include <libssh/server.h>
/* seconds */
@@ -200,7 +200,7 @@
#ifdef NC_ENABLED_TLS
int (*user_verify_clb)(const struct nc_session *session);
- int (*server_cert_clb)(const char *name, void *user_data, char **cert_path, char **cert_data,char **privkey_path,
+ int (*server_cert_clb)(const char *name, void *user_data, char **cert_path, char **cert_data, char **privkey_path,
char **privkey_data, NC_SSH_KEY_TYPE *privkey_type);
void *server_cert_data;
void (*server_cert_data_free)(void *data);
@@ -761,7 +761,7 @@
* @return -1 on error.
* @return -2 on malformed message error.
*/
-int nc_read_msg_poll_io(struct nc_session* session, int io_timeout, struct ly_in **msg);
+int nc_read_msg_poll_io(struct nc_session *session, int io_timeout, struct ly_in **msg);
/**
* @brief Read a message from the wire.
@@ -777,7 +777,7 @@
* @return -1 on error.
* @return -2 on malformed message error.
*/
-int nc_read_msg_io(struct nc_session* session, int io_timeout, struct ly_in **msg, int passing_io_lock);
+int nc_read_msg_io(struct nc_session *session, int io_timeout, struct ly_in **msg, int passing_io_lock);
/**
* @brief Write message into wire.
diff --git a/src/session_server.c b/src/session_server.c
index cb63e71..f0e9da4 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -14,23 +14,23 @@
#define _QNX_SOURCE /* getpeereid */
#define _GNU_SOURCE /* signals, threads, SO_PEERCRED */
-#include <stdint.h>
-#include <stdlib.h>
+#include <arpa/inet.h>
#include <errno.h>
-#include <string.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
+#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <fcntl.h>
+#include <poll.h>
#include <pthread.h>
-#include <time.h>
-#include <signal.h>
#include <pwd.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <time.h>
+#include <unistd.h>
#include "compat.h"
#include "libnetconf.h"
@@ -202,7 +202,6 @@
struct sockaddr_in *saddr4;
struct sockaddr_in6 *saddr6;
-
if (!strchr(address, ':')) {
is_ipv4 = 1;
} else {
@@ -308,7 +307,7 @@
}
}
- if (opts->uid != (uid_t)-1 || opts->gid != (gid_t)-1) {
+ if ((opts->uid != (uid_t)-1) || (opts->gid != (gid_t)-1)) {
if (chown(sun.sun_path, opts->uid, opts->gid) < 0) {
ERR("Failed to set unix socket uid/gid (%s).", strerror(errno));
goto fail;
@@ -410,7 +409,7 @@
static int
sock_host_inet6(const struct sockaddr_in6 *addr, char **host, uint16_t *port)
{
- *host = malloc(INET6_ADDRSTRLEN);
+ *host = malloc(INET6_ADDRSTRLEN);
if (!(*host)) {
ERRMEM;
return -1;
@@ -563,7 +562,7 @@
identifier = lyd_get_value(child);
} else if (!strcmp(child->schema->name, "version")) {
revision = lyd_get_value(child);
- if (revision && revision[0] == '\0') {
+ if (revision && (revision[0] == '\0')) {
revision = NULL;
}
} else if (!strcmp(child->schema->name, "format")) {
@@ -686,7 +685,7 @@
errno = 0;
if (pthread_rwlockattr_init(&attr) == 0) {
-#if defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
+#if defined (HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
if (pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) == 0) {
if (pthread_rwlock_init(&server_opts.endpt_lock, &attr) != 0) {
ERR("%s: failed to init rwlock(%s).", __FUNCTION__, strerror(errno));
@@ -722,7 +721,7 @@
server_opts.passwd_auth_data = NULL;
server_opts.passwd_auth_data_free = NULL;
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
nc_server_del_endpt(NULL, 0);
nc_server_ch_del_client(NULL);
#endif
@@ -1202,7 +1201,7 @@
/* UNLOCK */
ret2 = nc_ps_unlock(ps, q_id, __func__);
- return (ret || ret2 ? -1 : 0);
+ return ret || ret2 ? -1 : 0;
}
API struct nc_session *
@@ -1287,7 +1286,8 @@
ret = NC_PSPOLL_REPLY_ERROR;
reply = nc_server_reply_err(nc_err(server_opts.ctx, NC_ERR_MALFORMED_MSG));
goto send_reply;
- } if (r == -1) {
+ }
+ if (r == -1) {
return NC_PSPOLL_ERROR;
} else if (!r) {
return NC_PSPOLL_TIMEOUT;
@@ -1413,7 +1413,7 @@
/* no callback, reply with a not-implemented error */
reply = nc_server_reply_err(nc_err(server_opts.ctx, NC_ERR_OP_NOT_SUPPORTED, NC_ERR_TYPE_PROT));
} else {
- reply = global_rpc_clb(rpc->rpc, session);
+ reply = global_rpc_clb(rpc->rpc, session);
}
} else {
clb = (nc_rpc_clb)rpc_act->priv;
@@ -1455,13 +1455,14 @@
{
struct pollfd pfd;
int r, ret = 0;
+
#ifdef NC_ENABLED_SSH
struct nc_session *new;
#endif
/* check timeout first */
- if (!(session->flags & NC_SESSION_CALLHOME) && !session->opts.server.ntf_status && server_opts.idle_timeout
- && (now_mono >= session->opts.server.last_rpc + server_opts.idle_timeout)) {
+ if (!(session->flags & NC_SESSION_CALLHOME) && !session->opts.server.ntf_status && server_opts.idle_timeout &&
+ (now_mono >= session->opts.server.last_rpc + server_opts.idle_timeout)) {
sprintf(msg, "session idle timeout elapsed");
session->status = NC_STATUS_INVALID;
session->term_reason = NC_SESSION_TERM_TIMEOUT;
@@ -1496,8 +1497,8 @@
session->flags &= ~NC_SESSION_SSH_NEW_MSG;
if (session->ti.libssh.next) {
for (new = session->ti.libssh.next; new != session; new = new->ti.libssh.next) {
- if ((new->status == NC_STATUS_STARTING) && new->ti.libssh.channel
- && (new->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) {
+ if ((new->status == NC_STATUS_STARTING) && new->ti.libssh.channel &&
+ (new->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) {
/* new NETCONF SSH channel */
ret = NC_PSPOLL_SSH_CHANNEL;
break;
@@ -1858,7 +1859,7 @@
static int
nc_accept_unix(struct nc_session *session, int sock)
{
-#if defined(SO_PEERCRED) || defined(HAVE_GETPEEREID)
+#if defined (SO_PEERCRED) || defined (HAVE_GETPEEREID)
const struct passwd *pw;
char *username;
session->ti_type = NC_TI_UNIX;
@@ -2184,18 +2185,19 @@
address = bind->address;
}
- if (!set_addr && endpt->ti == NC_TI_UNIX) {
+ if (!set_addr && (endpt->ti == NC_TI_UNIX)) {
ret = -1;
goto cleanup;
}
/* we have all the information we need to create a listening socket */
- if (address && (port || endpt->ti == NC_TI_UNIX)) {
+ if (address && (port || (endpt->ti == NC_TI_UNIX))) {
/* create new socket, close the old one */
- if (endpt->ti == NC_TI_UNIX)
+ if (endpt->ti == NC_TI_UNIX) {
sock = nc_sock_listen_unix(address, endpt->opts.unixsock);
- else
+ } else {
sock = nc_sock_listen_inet(address, port, &endpt->ka);
+ }
if (sock == -1) {
ret = -1;
goto cleanup;
@@ -2251,7 +2253,7 @@
return nc_server_endpt_set_address_port(endpt_name, address, 0);
}
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
API int
nc_server_endpt_set_port(const char *endpt_name, uint16_t port)
@@ -2278,8 +2280,9 @@
/* ENDPT LOCK */
endpt = nc_server_endpt_lock_get(endpt_name, 0, &i);
- if (!endpt)
+ if (!endpt) {
return -1;
+ }
if (endpt->ti != NC_TI_UNIX) {
ret = -1;
@@ -2490,7 +2493,7 @@
return msgtype;
}
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
/* client is expected to be locked */
static int
diff --git a/src/session_server.h b/src/session_server.h
index 60beb28..a28fb21 100644
--- a/src/session_server.h
+++ b/src/session_server.h
@@ -19,21 +19,21 @@
extern "C" {
#endif
-#include <stdint.h>
#include <libyang/libyang.h>
+#include <stdint.h>
#ifdef NC_ENABLED_TLS
# include <openssl/x509.h>
#endif
#ifdef NC_ENABLED_SSH
-# include <libssh/libssh.h>
# include <libssh/callbacks.h>
+# include <libssh/libssh.h>
# include <libssh/server.h>
#endif
-#include "session.h"
#include "netconf.h"
+#include "session.h"
/**
* @defgroup server_session Server Session
@@ -408,7 +408,7 @@
*/
int nc_server_endpt_set_address(const char *endpt_name, const char *address);
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
/**
* @brief Change endpoint listening port.
@@ -546,7 +546,7 @@
* @return 0 on success, -1 on not finding any match.
*/
int nc_server_ssh_del_authkey(const char *pubkey_path, const char *pubkey_base64, NC_SSH_KEY_TYPE type,
- const char *username);
+ const char *username);
/**
* @brief Set the callback for SSH password authentication. If none is set, local system users are used.
@@ -578,7 +578,7 @@
* @param[in] user_data Optional arbitrary user data that will be passed to \p passwd_auth_clb.
* @param[in] free_user_data Optional callback that will be called during cleanup to free any \p user_data.
*/
- void nc_server_ssh_set_pubkey_auth_clb(int (*pubkey_auth_clb)(const struct nc_session *session, ssh_key key,
+void nc_server_ssh_set_pubkey_auth_clb(int (*pubkey_auth_clb)(const struct nc_session *session, ssh_key key,
void *user_data), void *user_data, void (*free_user_data)(void *user_data));
/**
@@ -817,7 +817,7 @@
* @return 0 on success, -1 on error.
*/
int nc_server_tls_endpt_add_ctn(const char *endpt_name, uint32_t id, const char *fingerprint,
- NC_TLS_CTN_MAPTYPE map_type, const char *name);
+ NC_TLS_CTN_MAPTYPE map_type, const char *name);
/**
* @brief Remove a cert-to-name entry.
@@ -830,7 +830,7 @@
* @return 0 on success, -1 on not finding any match.
*/
int nc_server_tls_endpt_del_ctn(const char *endpt_name, int64_t id, const char *fingerprint,
- NC_TLS_CTN_MAPTYPE map_type, const char *name);
+ NC_TLS_CTN_MAPTYPE map_type, const char *name);
/**
* @brief Get a cert-to-name entry.
@@ -847,7 +847,7 @@
* @return 0 on success, -1 on not finding any match.
*/
int nc_server_tls_endpt_get_ctn(const char *endpt_name, uint32_t *id, char **fingerprint, NC_TLS_CTN_MAPTYPE *map_type,
- char **name);
+ char **name);
/**
* @brief Get client certificate.
diff --git a/src/session_server_ch.h b/src/session_server_ch.h
index 2096b98..8628252 100644
--- a/src/session_server_ch.h
+++ b/src/session_server_ch.h
@@ -19,13 +19,13 @@
extern "C" {
#endif
-#include <stdint.h>
#include <libyang/libyang.h>
+#include <stdint.h>
-#include "session.h"
#include "netconf.h"
+#include "session.h"
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
/**
* @defgroup server_ch Server-side Call Home
diff --git a/src/session_server_ssh.c b/src/session_server_ssh.c
index 0809d58..3a49c57 100644
--- a/src/session_server_ssh.c
+++ b/src/session_server_ssh.c
@@ -23,14 +23,14 @@
#include <crypt.h>
#endif
+#include <errno.h>
+#include <fcntl.h>
+#include <pwd.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <pwd.h>
-#include <errno.h>
+#include <sys/types.h>
#include <time.h>
-#include <fcntl.h>
#include <unistd.h>
#include "compat.h"
@@ -38,7 +38,7 @@
#include "session_server.h"
#include "session_server_ch.h"
-#if !defined(HAVE_CRYPT_R)
+#if !defined (HAVE_CRYPT_R)
pthread_mutex_t crypt_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
@@ -157,7 +157,7 @@
API void
nc_server_ssh_set_passwd_auth_clb(int (*passwd_auth_clb)(const struct nc_session *session, const char *password, void *user_data),
- void *user_data, void (*free_user_data)(void *user_data))
+ void *user_data, void (*free_user_data)(void *user_data))
{
server_opts.passwd_auth_clb = passwd_auth_clb;
server_opts.passwd_auth_data = user_data;
@@ -166,7 +166,7 @@
API void
nc_server_ssh_set_interactive_auth_clb(int (*interactive_auth_clb)(const struct nc_session *session, ssh_message msg, void *user_data),
- void *user_data, void (*free_user_data)(void *user_data))
+ void *user_data, void (*free_user_data)(void *user_data))
{
server_opts.interactive_auth_clb = interactive_auth_clb;
server_opts.interactive_auth_data = user_data;
@@ -175,7 +175,7 @@
API void
nc_server_ssh_set_pubkey_auth_clb(int (*pubkey_auth_clb)(const struct nc_session *session, ssh_key key, void *user_data),
- void *user_data, void (*free_user_data)(void *user_data))
+ void *user_data, void (*free_user_data)(void *user_data))
{
server_opts.pubkey_auth_clb = pubkey_auth_clb;
server_opts.pubkey_auth_data = user_data;
@@ -622,7 +622,7 @@
API int
nc_server_ssh_del_authkey(const char *pubkey_path, const char *pubkey_base64, NC_SSH_KEY_TYPE type,
- const char *username)
+ const char *username)
{
uint32_t i;
int ret = -1;
@@ -643,10 +643,10 @@
server_opts.authkey_count = 0;
} else {
for (i = 0; i < server_opts.authkey_count; ++i) {
- if ((!pubkey_path || !strcmp(server_opts.authkeys[i].path, pubkey_path))
- && (!pubkey_base64 || !strcmp(server_opts.authkeys[i].base64, pubkey_base64))
- && (!type || (server_opts.authkeys[i].type == type))
- && (!username || !strcmp(server_opts.authkeys[i].username, username))) {
+ if ((!pubkey_path || !strcmp(server_opts.authkeys[i].path, pubkey_path)) &&
+ (!pubkey_base64 || !strcmp(server_opts.authkeys[i].base64, pubkey_base64)) &&
+ (!type || (server_opts.authkeys[i].type == type)) &&
+ (!username || !strcmp(server_opts.authkeys[i].username, username))) {
lydict_remove(server_opts.ctx, server_opts.authkeys[i].path);
lydict_remove(server_opts.ctx, server_opts.authkeys[i].base64);
lydict_remove(server_opts.ctx, server_opts.authkeys[i].username);
@@ -654,7 +654,7 @@
--server_opts.authkey_count;
if (i < server_opts.authkey_count) {
memcpy(&server_opts.authkeys[i], &server_opts.authkeys[server_opts.authkey_count],
- sizeof *server_opts.authkeys);
+ sizeof *server_opts.authkeys);
} else if (!server_opts.authkey_count) {
free(server_opts.authkeys);
server_opts.authkeys = NULL;
@@ -735,7 +735,8 @@
auth_password_compare_pwd(const char *pass_hash, const char *pass_clear)
{
char *new_pass_hash;
-#if defined(HAVE_CRYPT_R)
+
+#if defined (HAVE_CRYPT_R)
struct crypt_data cdata;
#endif
@@ -750,7 +751,7 @@
}
}
-#if defined(HAVE_CRYPT_R)
+#if defined (HAVE_CRYPT_R)
cdata.initialized = 0;
new_pass_hash = crypt_r(pass_clear, pass_hash, &cdata);
#else
@@ -948,7 +949,7 @@
}
session->ti.libssh.channel = chan;
- /* additional channel request */
+ /* additional channel request */
} else {
chan = ssh_message_channel_request_open_reply_accept(msg);
if (!chan) {
@@ -1065,7 +1066,7 @@
str_subtype = "channel-x11";
break;
case SSH_CHANNEL_UNKNOWN:
- /* fallthrough */
+ /* fallthrough */
default:
str_subtype = "unknown";
break;
@@ -1097,7 +1098,7 @@
str_subtype = "x11";
break;
case SSH_CHANNEL_REQUEST_UNKNOWN:
- /* fallthrough */
+ /* fallthrough */
default:
str_subtype = "unknown";
break;
@@ -1119,7 +1120,7 @@
str_subtype = "cancel-tcpip-forward";
break;
case SSH_GLOBAL_REQUEST_UNKNOWN:
- /* fallthrough */
+ /* fallthrough */
default:
str_subtype = "unknown";
break;
@@ -1137,7 +1138,7 @@
/* "valid" situation if, for example, receiving some auth or channel request timeouted,
* but we got it now, during session free */
VRB("SSH message arrived on a %s session, the request will be denied.",
- (session && session->status == NC_STATUS_CLOSING ? "closing" : "invalid"));
+ (session && session->status == NC_STATUS_CLOSING ? "closing" : "invalid"));
ssh_message_reply_default(msg);
return 0;
}
@@ -1224,7 +1225,7 @@
ret = ssh_execute_message_callbacks(session->ti.libssh.session);
if (ret != SSH_OK) {
ERR("Failed to receive SSH messages on a session (%s).",
- ssh_get_error(session->ti.libssh.session));
+ ssh_get_error(session->ti.libssh.session));
return -1;
}
@@ -1235,7 +1236,7 @@
ret = ssh_execute_message_callbacks(session->ti.libssh.session);
if (ret != SSH_OK) {
ERR("Failed to receive SSH messages on a session (%s).",
- ssh_get_error(session->ti.libssh.session));
+ ssh_get_error(session->ti.libssh.session));
return -1;
}
@@ -1260,7 +1261,7 @@
ret = ssh_execute_message_callbacks(session->ti.libssh.session);
if (ret != SSH_OK) {
ERR("Failed to receive SSH messages on a session (%s).",
- ssh_get_error(session->ti.libssh.session));
+ ssh_get_error(session->ti.libssh.session));
return -1;
}
@@ -1424,7 +1425,7 @@
if (ssh_execute_message_callbacks(session->ti.libssh.session) != SSH_OK) {
ERR("Failed to receive SSH messages on a session (%s).",
- ssh_get_error(session->ti.libssh.session));
+ ssh_get_error(session->ti.libssh.session));
return -1;
}
@@ -1482,13 +1483,13 @@
return NC_MSG_ERROR;
}
- if ((orig_session->status == NC_STATUS_RUNNING) && (orig_session->ti_type == NC_TI_LIBSSH)
- && orig_session->ti.libssh.next) {
+ if ((orig_session->status == NC_STATUS_RUNNING) && (orig_session->ti_type == NC_TI_LIBSSH) &&
+ orig_session->ti.libssh.next) {
for (new_session = orig_session->ti.libssh.next;
new_session != orig_session;
new_session = new_session->ti.libssh.next) {
- if ((new_session->status == NC_STATUS_STARTING) && new_session->ti.libssh.channel
- && (new_session->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) {
+ if ((new_session->status == NC_STATUS_STARTING) && new_session->ti.libssh.channel &&
+ (new_session->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) {
/* we found our session */
break;
}
@@ -1546,14 +1547,14 @@
for (i = 0; i < ps->session_count; ++i) {
cur_session = ps->sessions[i]->session;
- if ((cur_session->status == NC_STATUS_RUNNING) && (cur_session->ti_type == NC_TI_LIBSSH)
- && cur_session->ti.libssh.next) {
+ if ((cur_session->status == NC_STATUS_RUNNING) && (cur_session->ti_type == NC_TI_LIBSSH) &&
+ cur_session->ti.libssh.next) {
/* an SSH session with more channels */
for (new_session = cur_session->ti.libssh.next;
new_session != cur_session;
new_session = new_session->ti.libssh.next) {
- if ((new_session->status == NC_STATUS_STARTING) && new_session->ti.libssh.channel
- && (new_session->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) {
+ if ((new_session->status == NC_STATUS_STARTING) && new_session->ti.libssh.channel &&
+ (new_session->flags & NC_SESSION_SSH_SUBSYS_NETCONF)) {
/* we found our session */
break;
}
diff --git a/src/session_server_tls.c b/src/session_server_tls.c
index 1e17ec1..95d0ae2 100644
--- a/src/session_server_tls.c
+++ b/src/session_server_tls.c
@@ -14,20 +14,20 @@
#define _GNU_SOURCE
-#include <string.h>
#include <poll.h>
+#include <string.h>
#include <unistd.h>
-#include <openssl/ssl.h>
-#include <openssl/evp.h>
#include <openssl/err.h>
-#include <openssl/x509v3.h>
+#include <openssl/evp.h>
+#include <openssl/ssl.h>
#include <openssl/x509.h>
+#include <openssl/x509v3.h>
#include "compat.h"
+#include "libnetconf.h"
#include "session_server.h"
#include "session_server_ch.h"
-#include "libnetconf.h"
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define X509_STORE_CTX_get_by_subject X509_STORE_get_by_subject
@@ -151,7 +151,7 @@
}
if (asprintf(&buf, "%s%s%s%s%s%s%s", "-----BEGIN ", key_str, " PRIVATE KEY-----\n", in, "\n-----END ",
- key_str, " PRIVATE KEY-----") == -1) {
+ key_str, " PRIVATE KEY-----") == -1) {
return NULL;
}
bio = BIO_new_mem_buf(buf, strlen(buf));
@@ -191,7 +191,7 @@
static int
nc_tls_ctn_get_username_from_cert(X509 *client_cert, NC_TLS_CTN_MAPTYPE map_type, char **username)
{
- STACK_OF(GENERAL_NAME) *san_names;
+ STACK_OF(GENERAL_NAME) * san_names;
GENERAL_NAME *san_name;
ASN1_OCTET_STRING *ip;
int i, san_count;
@@ -228,8 +228,8 @@
san_name = sk_GENERAL_NAME_value(san_names, i);
/* rfc822Name (email) */
- if ((map_type == NC_TLS_CTN_SAN_ANY || map_type == NC_TLS_CTN_SAN_RFC822_NAME) &&
- san_name->type == GEN_EMAIL) {
+ if (((map_type == NC_TLS_CTN_SAN_ANY) || (map_type == NC_TLS_CTN_SAN_RFC822_NAME)) &&
+ (san_name->type == GEN_EMAIL)) {
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
*username = strdup((char *)ASN1_STRING_data(san_name->d.rfc822Name));
#else
@@ -243,8 +243,8 @@
}
/* dNSName */
- if ((map_type == NC_TLS_CTN_SAN_ANY || map_type == NC_TLS_CTN_SAN_DNS_NAME) &&
- san_name->type == GEN_DNS) {
+ if (((map_type == NC_TLS_CTN_SAN_ANY) || (map_type == NC_TLS_CTN_SAN_DNS_NAME)) &&
+ (san_name->type == GEN_DNS)) {
#if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
*username = strdup((char *)ASN1_STRING_data(san_name->d.dNSName));
#else
@@ -258,8 +258,8 @@
}
/* iPAddress */
- if ((map_type == NC_TLS_CTN_SAN_ANY || map_type == NC_TLS_CTN_SAN_IP_ADDRESS) &&
- san_name->type == GEN_IPADD) {
+ if (((map_type == NC_TLS_CTN_SAN_ANY) || (map_type == NC_TLS_CTN_SAN_IP_ADDRESS)) &&
+ (san_name->type == GEN_IPADD)) {
ip = san_name->d.iPAddress;
if (ip->length == 4) {
if (asprintf(username, "%d.%d.%d.%d", ip->data[0], ip->data[1], ip->data[2], ip->data[3]) == -1) {
@@ -358,7 +358,7 @@
break;
}
- /* SHA-1 */
+ /* SHA-1 */
} else if (!strncmp(ctn->fingerprint, "02", 2)) {
if (!digest_sha1) {
if (X509_digest(cert, EVP_sha1(), buf, &buf_len) != 1) {
@@ -379,7 +379,7 @@
break;
}
- /* SHA-224 */
+ /* SHA-224 */
} else if (!strncmp(ctn->fingerprint, "03", 2)) {
if (!digest_sha224) {
if (X509_digest(cert, EVP_sha224(), buf, &buf_len) != 1) {
@@ -400,7 +400,7 @@
break;
}
- /* SHA-256 */
+ /* SHA-256 */
} else if (!strncmp(ctn->fingerprint, "04", 2)) {
if (!digest_sha256) {
if (X509_digest(cert, EVP_sha256(), buf, &buf_len) != 1) {
@@ -421,7 +421,7 @@
break;
}
- /* SHA-384 */
+ /* SHA-384 */
} else if (!strncmp(ctn->fingerprint, "05", 2)) {
if (!digest_sha384) {
if (X509_digest(cert, EVP_sha384(), buf, &buf_len) != 1) {
@@ -442,7 +442,7 @@
break;
}
- /* SHA-512 */
+ /* SHA-512 */
} else if (!strncmp(ctn->fingerprint, "06", 2)) {
if (!digest_sha512) {
if (X509_digest(cert, EVP_sha512(), buf, &buf_len) != 1) {
@@ -463,7 +463,7 @@
break;
}
- /* unknown */
+ /* unknown */
} else {
WRN("Unknown fingerprint algorithm used (%s), skipping.", ctn->fingerprint);
}
@@ -496,9 +496,10 @@
X509 *cert;
X509_CRL *crl;
X509_REVOKED *revoked;
- STACK_OF(X509) *cert_stack;
+
+ STACK_OF(X509) * cert_stack;
EVP_PKEY *pubkey;
- struct nc_session* session;
+ struct nc_session *session;
struct nc_server_tls_opts *opts;
const ASN1_INTEGER *serial;
int i, n, rc, depth;
@@ -534,7 +535,7 @@
/* we are just overriding the failed standard certificate verification (preverify_ok == 0),
* this callback will be called again with the same current certificate and preverify_ok == 1 */
VRB("Cert verify: fail (%s), but the client certificate is trusted, continuing.",
- X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509_ctx)));
+ X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509_ctx)));
X509_STORE_CTX_set_error(x509_ctx, X509_V_OK);
sk_X509_pop_free(cert_stack, X509_free);
return 1;
@@ -572,7 +573,7 @@
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, subject, obj);
X509_STORE_CTX_free(store_ctx);
crl = X509_OBJECT_get0_X509_CRL(obj);
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
cp = X509_NAME_oneline(subject, NULL, 0);
VRB("Cert verify CRL: issuer: %s.", cp);
OPENSSL_free(cp);
@@ -625,7 +626,7 @@
rc = X509_STORE_CTX_get_by_subject(store_ctx, X509_LU_CRL, issuer, obj);
X509_STORE_CTX_free(store_ctx);
crl = X509_OBJECT_get0_X509_CRL(obj);
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
/* check if the current certificate is revoked by this CRL */
n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
for (i = 0; i < n; i++) {
@@ -708,9 +709,10 @@
X509 *cert;
X509_CRL *crl;
X509_REVOKED *revoked;
- STACK_OF(X509) *cert_stack;
+
+ STACK_OF(X509) * cert_stack;
EVP_PKEY *pubkey;
- struct nc_session* session;
+ struct nc_session *session;
struct nc_server_tls_opts *opts;
long serial;
int i, n, rc, depth;
@@ -748,7 +750,7 @@
/* we are just overriding the failed standard certificate verification (preverify_ok == 0),
* this callback will be called again with the same current certificate and preverify_ok == 1 */
VRB("Cert verify: fail (%s), but the client certificate is trusted, continuing.",
- X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509_ctx)));
+ X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509_ctx)));
X509_STORE_CTX_set_error(x509_ctx, X509_V_OK);
sk_X509_pop_free(cert_stack, X509_free);
return 1;
@@ -785,7 +787,7 @@
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj);
X509_STORE_CTX_cleanup(&store_ctx);
crl = obj.data.crl;
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
cp = X509_NAME_oneline(subject, NULL, 0);
VRB("Cert verify CRL: issuer: %s.", cp);
OPENSSL_free(cp);
@@ -837,7 +839,7 @@
rc = X509_STORE_CTX_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj);
X509_STORE_CTX_cleanup(&store_ctx);
crl = obj.data.crl;
- if (rc > 0 && crl) {
+ if ((rc > 0) && crl) {
/* check if the current certificate is revoked by this CRL */
n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
for (i = 0; i < n; i++) {
@@ -1386,7 +1388,7 @@
new->next = opts->ctn;
opts->ctn = new;
} else {
- for (ctn = opts->ctn; ctn->next && ctn->next->id <= id; ctn = ctn->next);
+ for (ctn = opts->ctn; ctn->next && ctn->next->id <= id; ctn = ctn->next) {}
if (ctn->id == id) {
/* it exists already */
new = ctn;
@@ -1488,10 +1490,10 @@
prev = NULL;
ctn = opts->ctn;
while (ctn) {
- if (((id < 0) || (ctn->id == id))
- && (!fingerprint || !strcmp(ctn->fingerprint, fingerprint))
- && (!map_type || (ctn->map_type == map_type))
- && (!name || (ctn->name && !strcmp(ctn->name, name)))) {
+ if (((id < 0) || (ctn->id == id)) &&
+ (!fingerprint || !strcmp(ctn->fingerprint, fingerprint)) &&
+ (!map_type || (ctn->map_type == map_type)) &&
+ (!name || (ctn->name && !strcmp(ctn->name, name)))) {
lydict_remove(server_opts.ctx, ctn->fingerprint);
lydict_remove(server_opts.ctx, ctn->name);
@@ -1564,7 +1566,7 @@
static int
nc_server_tls_get_ctn(uint32_t *id, char **fingerprint, NC_TLS_CTN_MAPTYPE *map_type, char **name,
- struct nc_server_tls_opts *opts)
+ struct nc_server_tls_opts *opts)
{
struct nc_ctn *ctn;
int ret = -1;
@@ -1684,7 +1686,7 @@
pthread_key_create(&verify_key, NULL);
}
-static X509*
+static X509 *
tls_load_cert(const char *cert_path, const char *cert_data)
{
X509 *cert;
@@ -1698,10 +1700,10 @@
if (!cert) {
if (cert_path) {
ERR("Loading a trusted certificate (path \"%s\") failed (%s).", cert_path,
- ERR_reason_error_string(ERR_get_error()));
+ ERR_reason_error_string(ERR_get_error()));
} else {
ERR("Loading a trusted certificate (data \"%s\") failed (%s).", cert_data,
- ERR_reason_error_string(ERR_get_error()));
+ ERR_reason_error_string(ERR_get_error()));
}
}
return cert;
@@ -1720,14 +1722,14 @@
}
if (server_opts.server_cert_chain_clb(cert_name, server_opts.server_cert_chain_data, &cert_paths,
- &cert_path_count, &cert_data, &cert_data_count)) {
+ &cert_path_count, &cert_data, &cert_data_count)) {
ERR("Server certificate chain callback failed.");
return -1;
}
for (i = 0; i < cert_path_count; ++i) {
cert = tls_load_cert(cert_paths[i], NULL);
- if (!cert || SSL_CTX_add_extra_chain_cert(tls_ctx, cert) != 1) {
+ if (!cert || (SSL_CTX_add_extra_chain_cert(tls_ctx, cert) != 1)) {
ERR("Loading the server certificate chain failed (%s).", ERR_reason_error_string(ERR_get_error()));
ret = -1;
goto cleanup;
@@ -1736,7 +1738,7 @@
for (i = 0; i < cert_data_count; ++i) {
cert = tls_load_cert(NULL, cert_data[i]);
- if (!cert || SSL_CTX_add_extra_chain_cert(tls_ctx, cert) != 1) {
+ if (!cert || (SSL_CTX_add_extra_chain_cert(tls_ctx, cert) != 1)) {
ERR("Loading the server certificate chain failed (%s).", ERR_reason_error_string(ERR_get_error()));
ret = -1;
goto cleanup;
@@ -1774,7 +1776,7 @@
}
if (server_opts.server_cert_clb(cert_name, server_opts.server_cert_data, &cert_path, &cert_data, &privkey_path,
- &privkey_data, &privkey_type)) {
+ &privkey_data, &privkey_type)) {
ERR("Server certificate callback failed.");
return -1;
}
@@ -1827,6 +1829,7 @@
tls_store_add_trusted_cert(X509_STORE *cert_store, const char *cert_path, const char *cert_data)
{
X509 *cert = tls_load_cert(cert_path, cert_data);
+
if (!cert) {
return;
}
@@ -1857,7 +1860,7 @@
cert_paths = cert_data = NULL;
cert_path_count = cert_data_count = 0;
if (server_opts.trusted_cert_list_clb(trusted_cert_lists[i], server_opts.trusted_cert_list_data,
- &cert_paths, &cert_path_count, &cert_data, &cert_data_count)) {
+ &cert_paths, &cert_path_count, &cert_data, &cert_data_count)) {
ERR("Trusted certificate list callback for \"%s\" failed.", trusted_cert_lists[i]);
return -1;
}
diff --git a/tests/client/test_client.c b/tests/client/test_client.c
index 1be8fa5..dcfd8c7 100644
--- a/tests/client/test_client.c
+++ b/tests/client/test_client.c
@@ -1,14 +1,14 @@
+#include <errno.h>
+#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <setjmp.h>
-#include <sys/types.h>
#include <sys/socket.h>
-#include <errno.h>
+#include <sys/types.h>
#include <cmocka.h>
#include <libyang/libyang.h>
-#include <session_client.h>
#include <log.h>
+#include <session_client.h>
#include "tests/config.h"
static int
diff --git a/tests/client/test_client_messages.c b/tests/client/test_client_messages.c
index d2ac4f4..51a244f 100644
--- a/tests/client/test_client_messages.c
+++ b/tests/client/test_client_messages.c
@@ -1,17 +1,17 @@
+#include <errno.h>
+#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <setjmp.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
#include <cmocka.h>
-#include <libyang/libyang.h>
-#include <session_client.h>
-#include <log.h>
#include <config.h>
+#include <libyang/libyang.h>
+#include <log.h>
#include <messages_p.h>
+#include <session_client.h>
#include "tests/config.h"
static int
@@ -50,6 +50,7 @@
/* create generic rpc with NC_PARAMTYPE_FREE */
char *str = strdup("str");
+
rpc = nc_rpc_act_generic_xml(str, NC_PARAMTYPE_FREE);
assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_ACT_GENERIC);
generic_rpc = (struct nc_rpc_act_generic *)rpc;
@@ -75,6 +76,7 @@
struct nc_rpc *rpc = NULL;
struct nc_rpc_act_generic *generic_rpc = NULL;
struct lyd_node node;
+
node.next = NULL;
node.prev = &node;
@@ -115,6 +117,7 @@
/* create getconfig rpc with NC_PARAMTYPE_FREE */
char *filter = strdup("string");
+
rpc = nc_rpc_getconfig(NC_DATASTORE_CONFIG, filter, NC_WD_EXPLICIT, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_getconfig(rpc, NC_DATASTORE_CONFIG, filter, NC_WD_EXPLICIT);
@@ -130,7 +133,7 @@
/* function to check if values of edit rpc are set correctly */
void
check_edit(struct nc_rpc *rpc, NC_DATASTORE target, NC_RPC_EDIT_DFLTOP default_op, NC_RPC_EDIT_TESTOPT test_opt,
- NC_RPC_EDIT_ERROPT error_opt, const char *edit_content)
+ NC_RPC_EDIT_ERROPT error_opt, const char *edit_content)
{
assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_EDIT);
struct nc_rpc_edit *edit_rpc = (struct nc_rpc_edit *)rpc;
@@ -143,7 +146,6 @@
assert_string_equal(edit_rpc->edit_cont, edit_content);
}
-
static void
test_nc_rpc_edit(void **state)
{
@@ -152,34 +154,35 @@
/* create edit rpc with NC_PARAMTYPE_CONST */
rpc = nc_rpc_edit(NC_DATASTORE_RUNNING, NC_RPC_EDIT_DFLTOP_REPLACE, NC_RPC_EDIT_TESTOPT_TESTSET,
- NC_RPC_EDIT_ERROPT_STOP, "url", NC_PARAMTYPE_CONST);
+ NC_RPC_EDIT_ERROPT_STOP, "url", NC_PARAMTYPE_CONST);
assert_non_null(rpc);
check_edit(rpc, NC_DATASTORE_RUNNING, NC_RPC_EDIT_DFLTOP_REPLACE,
- NC_RPC_EDIT_TESTOPT_TESTSET, NC_RPC_EDIT_ERROPT_STOP, "url");
+ NC_RPC_EDIT_TESTOPT_TESTSET, NC_RPC_EDIT_ERROPT_STOP, "url");
nc_rpc_free(rpc);
/* create edit rpc with NC_PARAMTYPE_FREE */
char *str = strdup("string");
+
rpc = nc_rpc_edit(NC_DATASTORE_CANDIDATE, NC_RPC_EDIT_DFLTOP_MERGE, NC_RPC_EDIT_TESTOPT_SET,
- NC_RPC_EDIT_ERROPT_ROLLBACK, str, NC_PARAMTYPE_FREE);
+ NC_RPC_EDIT_ERROPT_ROLLBACK, str, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_edit(rpc, NC_DATASTORE_CANDIDATE, NC_RPC_EDIT_DFLTOP_MERGE,
- NC_RPC_EDIT_TESTOPT_SET, NC_RPC_EDIT_ERROPT_ROLLBACK, str);
+ NC_RPC_EDIT_TESTOPT_SET, NC_RPC_EDIT_ERROPT_ROLLBACK, str);
nc_rpc_free(rpc);
/* create edit rpc with NC_PARAMTYPE_DUP_AND_FREE */
rpc = nc_rpc_edit(NC_DATASTORE_CONFIG, NC_RPC_EDIT_DFLTOP_NONE, NC_RPC_EDIT_TESTOPT_TEST,
- NC_RPC_EDIT_ERROPT_CONTINUE, "url1", NC_PARAMTYPE_DUP_AND_FREE);
+ NC_RPC_EDIT_ERROPT_CONTINUE, "url1", NC_PARAMTYPE_DUP_AND_FREE);
assert_non_null(rpc);
check_edit(rpc, NC_DATASTORE_CONFIG, NC_RPC_EDIT_DFLTOP_NONE,
- NC_RPC_EDIT_TESTOPT_TEST, NC_RPC_EDIT_ERROPT_CONTINUE, "url1");
+ NC_RPC_EDIT_TESTOPT_TEST, NC_RPC_EDIT_ERROPT_CONTINUE, "url1");
nc_rpc_free(rpc);
}
/* function to check if values of copy rpc are set correctly */
void
check_copy(struct nc_rpc *rpc, NC_DATASTORE target, const char *url_trg, NC_DATASTORE source,
- const char *url_or_config_src, NC_WD_MODE wd_mode)
+ const char *url_or_config_src, NC_WD_MODE wd_mode)
{
assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_COPY);
struct nc_rpc_copy *copy_rpc = (struct nc_rpc_copy *)rpc;
@@ -200,7 +203,7 @@
/* create copy rpc with NC_PARAMTYPE_CONST */
rpc = nc_rpc_copy(NC_DATASTORE_RUNNING, "target-url", NC_DATASTORE_RUNNING, "src-url",
- NC_WD_ALL, NC_PARAMTYPE_CONST);
+ NC_WD_ALL, NC_PARAMTYPE_CONST);
assert_non_null(rpc);
check_copy(rpc, NC_DATASTORE_RUNNING, "target-url", NC_DATASTORE_RUNNING, "src-url", NC_WD_ALL);
nc_rpc_free(rpc);
@@ -208,15 +211,16 @@
/* create copy rpc with NC_PARAMTYPE_FREE */
char *target = strdup("target");
char *src = strdup("src");
+
rpc = nc_rpc_copy(NC_DATASTORE_STARTUP, target, NC_DATASTORE_RUNNING, src,
- NC_WD_ALL_TAG, NC_PARAMTYPE_FREE);
+ NC_WD_ALL_TAG, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_copy(rpc, NC_DATASTORE_STARTUP, target, NC_DATASTORE_RUNNING, src, NC_WD_ALL_TAG);
nc_rpc_free(rpc);
/* create copy rpc with NC_PARAMTYPE_DUP_AND_FREE */
rpc = nc_rpc_copy(NC_DATASTORE_STARTUP, "url", NC_DATASTORE_CANDIDATE, "url",
- NC_WD_TRIM, NC_PARAMTYPE_DUP_AND_FREE);
+ NC_WD_TRIM, NC_PARAMTYPE_DUP_AND_FREE);
assert_non_null(rpc);
check_copy(rpc, NC_DATASTORE_STARTUP, "url", NC_DATASTORE_CANDIDATE, "url", NC_WD_TRIM);
nc_rpc_free(rpc);
@@ -248,6 +252,7 @@
/* create delete rpc with NC_PARAMTYPE_FREE */
char *url = strdup("url");
+
rpc = nc_rpc_delete(NC_DATASTORE_CANDIDATE, url, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_delete(rpc, NC_DATASTORE_CANDIDATE, url);
@@ -321,6 +326,7 @@
/* create get rpc with NC_PARAMTYPE_FREE */
char *str = strdup("string");
+
rpc = nc_rpc_get(str, NC_WD_EXPLICIT, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_get_rpc(rpc, str, NC_WD_EXPLICIT);
@@ -380,6 +386,7 @@
/* create commit rpc with NC_PARAMTYPE_FREE*/
char *str1 = strdup("str1");
char *str2 = strdup("str2");
+
rpc = nc_rpc_commit(2, 5, str1, str2, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_commit_rpc(rpc, 2, 5, str1, str2);
@@ -430,6 +437,7 @@
/* create cancel rpc with NC_PARAMTYPE_FREE*/
char *str = strdup("string");
+
rpc = nc_rpc_cancel(str, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_cancel_rpc(rpc, str);
@@ -468,6 +476,7 @@
/* create validate rpc with NC_PARAMTYPE_FREE */
char *str = strdup("string");
+
rpc = nc_rpc_validate(NC_DATASTORE_CANDIDATE, str, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_validate_rpc(rpc, NC_DATASTORE_CANDIDATE, str);
@@ -509,6 +518,7 @@
char *str1 = strdup("str1");
char *str2 = strdup("str2");
char *str3 = strdup("str3");
+
rpc = nc_rpc_getschema(str1, str2, str3, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_getschema_rpc(rpc, str1, str2, str3);
@@ -524,7 +534,7 @@
/* function to check if values of subscribe rpc are set correctly */
void
check_subscribe_rpc(struct nc_rpc *rpc, const char *stream_name, const char *filter,
- const char *start_time, const char *stop_time)
+ const char *start_time, const char *stop_time)
{
assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_SUBSCRIBE);
struct nc_rpc_subscribe *subscribe_rpc = (struct nc_rpc_subscribe *)rpc;
@@ -553,6 +563,7 @@
char *str2 = strdup("str2");
char *str3 = strdup("str3");
char *str4 = strdup("str4");
+
rpc = nc_rpc_subscribe(str1, str2, str3, str4, NC_PARAMTYPE_FREE);
assert_non_null(rpc);
check_subscribe_rpc(rpc, str1, str2, str3, str4);
@@ -568,22 +579,22 @@
/* function to check if values of getdata rpc are set correctly */
void
check_getdata(struct nc_rpc *rpc, char *datastore, const char *filter, const char *config_filter,
- char **origin_filter, int origin_filter_count, int negated_origin_filter, uint16_t max_depth,
- int with_origin, NC_WD_MODE wd_mode)
+ char **origin_filter, int origin_filter_count, int negated_origin_filter, uint16_t max_depth,
+ int with_origin, NC_WD_MODE wd_mode)
{
- assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_GETDATA);
- struct nc_rpc_getdata *rpc_getdata = (struct nc_rpc_getdata*)rpc;
+ assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_GETDATA);
+ struct nc_rpc_getdata *rpc_getdata = (struct nc_rpc_getdata *)rpc;
- assert_int_equal(rpc_getdata->type, NC_RPC_GETDATA);
- assert_string_equal(rpc_getdata->datastore, datastore);
- assert_string_equal(rpc_getdata->filter, filter);
- assert_string_equal(rpc_getdata->config_filter, config_filter);
- assert_string_equal(*rpc_getdata->origin_filter, *origin_filter);
- assert_int_equal(rpc_getdata->origin_filter_count, origin_filter_count);
- assert_int_equal(rpc_getdata->negated_origin_filter, negated_origin_filter);
- assert_int_equal(rpc_getdata->max_depth, max_depth);
- assert_int_equal(rpc_getdata->with_origin, with_origin);
- assert_int_equal(rpc_getdata->wd_mode, wd_mode);
+ assert_int_equal(rpc_getdata->type, NC_RPC_GETDATA);
+ assert_string_equal(rpc_getdata->datastore, datastore);
+ assert_string_equal(rpc_getdata->filter, filter);
+ assert_string_equal(rpc_getdata->config_filter, config_filter);
+ assert_string_equal(*rpc_getdata->origin_filter, *origin_filter);
+ assert_int_equal(rpc_getdata->origin_filter_count, origin_filter_count);
+ assert_int_equal(rpc_getdata->negated_origin_filter, negated_origin_filter);
+ assert_int_equal(rpc_getdata->max_depth, max_depth);
+ assert_int_equal(rpc_getdata->with_origin, with_origin);
+ assert_int_equal(rpc_getdata->wd_mode, wd_mode);
}
static void
@@ -594,6 +605,7 @@
/* create getdata rpc with NC_PARAMTYPE_CONST */
char *origin_filters = "origin_filter";
+
rpc = nc_rpc_getdata("candidate", "filter", "true", &origin_filters, 1, 1, 3, 1, NC_WD_UNKNOWN, NC_PARAMTYPE_CONST);
assert_non_null(rpc);
check_getdata(rpc, "candidate", "filter", "true", &origin_filters, 1, 1, 3, 1, NC_WD_UNKNOWN);
@@ -610,8 +622,8 @@
origin_filter = calloc(origin_filter_count, sizeof *origin_filter);
assert_non_null(origin_filter);
for (int i = 0; i < origin_filter_count; i++) {
- snprintf(buf, sizeof(buf) - 1, "origin_filter%d", i + 1);
- origin_filter[i] = strdup(buf);
+ snprintf(buf, sizeof(buf) - 1, "origin_filter%d", i + 1);
+ origin_filter[i] = strdup(buf);
}
rpc = nc_rpc_getdata(datastore, filter, config_filter, origin_filter, origin_filter_count, 2, 3, 1, NC_WD_EXPLICIT, NC_PARAMTYPE_FREE);
@@ -621,6 +633,7 @@
/* create getdata rpc with NC_PARAMTYPE_DUP_AND_FREE */
char *origin_filter1 = "origin_filter1";
+
rpc = nc_rpc_getdata("startup", "filter1", "false", &origin_filter1, 1, 0, 3, 1, NC_WD_ALL, NC_PARAMTYPE_DUP_AND_FREE);
assert_non_null(rpc);
check_getdata(rpc, "startup", "filter1", "false", &origin_filter1, 1, 0, 3, 1, NC_WD_ALL);
@@ -631,13 +644,13 @@
void
check_editdata(struct nc_rpc *rpc, char *datastore, NC_RPC_EDIT_DFLTOP default_op, const char *edit_content)
{
- assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_EDITDATA);
- struct nc_rpc_editdata *rpc_editdata = (struct nc_rpc_editdata*)rpc;
+ assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_EDITDATA);
+ struct nc_rpc_editdata *rpc_editdata = (struct nc_rpc_editdata *)rpc;
- assert_int_equal(rpc_editdata->type, NC_RPC_EDITDATA);
- assert_string_equal(rpc_editdata->datastore, datastore);
- assert_int_equal(rpc_editdata->default_op, default_op);
- assert_string_equal(rpc_editdata->edit_cont, edit_content);
+ assert_int_equal(rpc_editdata->type, NC_RPC_EDITDATA);
+ assert_string_equal(rpc_editdata->datastore, datastore);
+ assert_int_equal(rpc_editdata->default_op, default_op);
+ assert_string_equal(rpc_editdata->edit_cont, edit_content);
}
static void
diff --git a/tests/client/test_client_ssh.c b/tests/client/test_client_ssh.c
index 5fcb12f..06f935b 100644
--- a/tests/client/test_client_ssh.c
+++ b/tests/client/test_client_ssh.c
@@ -1,21 +1,21 @@
+#include <errno.h>
+#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <setjmp.h>
-#include <sys/types.h>
#include <sys/socket.h>
-#include <errno.h>
+#include <sys/types.h>
#include <cmocka.h>
+#include <config.h>
#include <libyang/libyang.h>
+#include <log.h>
#include <session_client.h>
#include <session_client_ch.h>
#include <session_p.h>
-#include <log.h>
-#include <config.h>
#include "tests/config.h"
-#include <libssh/libssh.h>
#include <libssh/callbacks.h>
+#include <libssh/libssh.h>
#include <libssh/server.h>
static int
@@ -150,7 +150,6 @@
check_expected(password);
check_expected(username);
-
return (int)mock();
}
@@ -368,6 +367,7 @@
(void)state;
char *(*ret_f)(const char *privkey_path, void *priv);
char *priv_data_ret;
+
/* set first callback */
nc_client_ssh_set_auth_privkey_passphrase_clb(test_passphrase_clb1, "DATA");
nc_client_ssh_get_auth_privkey_passphrase_clb(&ret_f, (void **)&priv_data_ret);
@@ -387,12 +387,13 @@
(void)state;
int ret;
const char *pubkey1, *pubkey2;
+
/* at the beginning keypair count should be 0 */
ret = nc_client_ssh_get_keypair_count();
assert_int_equal(ret, 0);
/* add first key pair */
- ret = nc_client_ssh_add_keypair(TESTS_DIR"/data/key_dsa.pub", TESTS_DIR"/data/key_dsa");
+ ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_dsa.pub", TESTS_DIR "/data/key_dsa");
assert_int_equal(ret, 0);
ret = nc_client_ssh_get_keypair_count();
assert_int_equal(ret, 1);
@@ -480,6 +481,7 @@
(void)state;
int ret;
const char *username_ret;
+
username_ret = nc_client_ssh_get_username();
/* username is set to "username" in setup_f */
assert_string_equal(username_ret, "username");
@@ -588,7 +590,7 @@
nc_client_ssh_set_auth_pref(NC_SSH_AUTH_INTERACTIVE, -1);
/* add keypair for authentication */
- ret = nc_client_ssh_add_keypair(TESTS_DIR"/data/key_dsa.pub", TESTS_DIR"/data/key_dsa");
+ ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_dsa.pub", TESTS_DIR "/data/key_dsa");
assert_int_equal(ret, 0);
/* fake succesfull connection */
diff --git a/tests/client/test_client_tls.c b/tests/client/test_client_tls.c
index 4a92281..0f2b2e7 100644
--- a/tests/client/test_client_tls.c
+++ b/tests/client/test_client_tls.c
@@ -1,15 +1,15 @@
+#include <errno.h>
+#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
-#include <setjmp.h>
-#include <sys/types.h>
#include <sys/socket.h>
-#include <errno.h>
+#include <sys/types.h>
#include <cmocka.h>
-#include <libyang/libyang.h>
-#include <session_client.h>
-#include <log.h>
#include <config.h>
+#include <libyang/libyang.h>
+#include <log.h>
+#include <session_client.h>
#include "tests/config.h"
static int
@@ -120,9 +120,9 @@
int ret;
struct nc_session *session;
- ret = nc_client_tls_set_cert_key_paths(TESTS_DIR"/data/client.crt", TESTS_DIR"/data/client.key");
+ ret = nc_client_tls_set_cert_key_paths(TESTS_DIR "/data/client.crt", TESTS_DIR "/data/client.key");
assert_int_equal(ret, 0);
- ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR"/data");
+ ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR "/data");
assert_int_equal(ret, 0);
will_return(__wrap_connect, 0);
@@ -171,9 +171,9 @@
int ret;
struct nc_session *session;
- ret = nc_client_tls_set_cert_key_paths(TESTS_DIR"/data/client.crt", TESTS_DIR"/data/client.key");
+ ret = nc_client_tls_set_cert_key_paths(TESTS_DIR "/data/client.crt", TESTS_DIR "/data/client.key");
assert_int_equal(ret, 0);
- ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR"/data");
+ ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR "/data");
assert_int_equal(ret, 0);
will_return(__wrap_connect, 0);
@@ -197,4 +197,4 @@
};
return cmocka_run_group_tests(tests, NULL, NULL);
-}
\ No newline at end of file
+}
diff --git a/tests/test_client_thread.c b/tests/test_client_thread.c
index de0c193..7df7819 100644
--- a/tests/test_client_thread.c
+++ b/tests/test_client_thread.c
@@ -13,12 +13,12 @@
*/
#include <pthread.h>
-#include <unistd.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
#include <libyang/libyang.h>
diff --git a/tests/test_fd_comm.c b/tests/test_fd_comm.c
index 66ab168..53cbbeb 100644
--- a/tests/test_fd_comm.c
+++ b/tests/test_fd_comm.c
@@ -20,19 +20,19 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
+#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/socket.h>
+#include <unistd.h>
#include <cmocka.h>
#include <libyang/libyang.h>
-#include <session_client.h>
-#include <session_server.h>
-#include <session_p.h>
#include <messages_p.h>
+#include <session_client.h>
+#include <session_p.h>
+#include <session_server.h>
#include "tests/config.h"
struct nc_session *server_session;
@@ -374,6 +374,7 @@
struct nc_server_notif *notif;
struct timespec ts;
char *buf;
+
(void)arg;
/* wait for the RPC callback to be called */
@@ -494,7 +495,7 @@
const char *nc_features[] = {"candidate", NULL};
/* create ctx */
- ly_ctx_new(TESTS_DIR"/data/modules", 0, &ctx);
+ ly_ctx_new(TESTS_DIR "/data/modules", 0, &ctx);
assert_non_null(ctx);
/* load modules */
diff --git a/tests/test_init_destroy_client.c b/tests/test_init_destroy_client.c
index 57f54d4..6b354a8 100644
--- a/tests/test_init_destroy_client.c
+++ b/tests/test_init_destroy_client.c
@@ -20,17 +20,17 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
+#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/socket.h>
+#include <unistd.h>
#include <cmocka.h>
#include <libyang/libyang.h>
-#include "tests/config.h"
#include <session_client.h>
+#include "tests/config.h"
static int
setup_client(void **state)
@@ -67,4 +67,3 @@
return cmocka_run_group_tests(init_destroy, NULL, NULL);
}
-
diff --git a/tests/test_init_destroy_server.c b/tests/test_init_destroy_server.c
index 2bb3975..6e58da4 100644
--- a/tests/test_init_destroy_server.c
+++ b/tests/test_init_destroy_server.c
@@ -20,17 +20,17 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
+#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/socket.h>
+#include <unistd.h>
#include <cmocka.h>
#include <libyang/libyang.h>
-#include "tests/config.h"
#include <session_server.h>
+#include "tests/config.h"
struct ly_ctx *ctx;
@@ -73,4 +73,3 @@
return cmocka_run_group_tests(init_destroy, NULL, NULL);
}
-
diff --git a/tests/test_io.c b/tests/test_io.c
index 467f12f..a3d4bdf 100644
--- a/tests/test_io.c
+++ b/tests/test_io.c
@@ -19,17 +19,17 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <unistd.h>
#include <cmocka.h>
#include <libyang/libyang.h>
#include <messages_p.h>
-#include <session_p.h>
#include <session_client.h>
+#include <session_p.h>
#include "tests/config.h"
struct wr {
@@ -46,10 +46,10 @@
w = malloc(sizeof *w);
w->session = calloc(1, sizeof *w->session);
- ly_ctx_new(TESTS_DIR"/data/modules", 0, &w->session->ctx);
+ ly_ctx_new(TESTS_DIR "/data/modules", 0, &w->session->ctx);
/* ietf-netconf */
- fd = open(TESTS_DIR"/data/modules/ietf-netconf.yin", O_RDONLY);
+ fd = open(TESTS_DIR "/data/modules/ietf-netconf.yin", O_RDONLY);
if (fd == -1) {
free(w);
return -1;
@@ -106,7 +106,7 @@
do {
type = nc_send_rpc(w->session, w->rpc, 1000, &msgid);
- } while(type == NC_MSG_WOULDBLOCK);
+ } while (type == NC_MSG_WOULDBLOCK);
assert_int_equal(type, NC_MSG_RPC);
@@ -147,7 +147,7 @@
do {
type = nc_send_rpc(w->session, w->rpc, 1000, &msgid);
- } while(type == NC_MSG_WOULDBLOCK);
+ } while (type == NC_MSG_WOULDBLOCK);
assert_int_equal(type, NC_MSG_ERROR);
}
@@ -172,13 +172,15 @@
return test_write_rpc_bad(state);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest io[] = {
cmocka_unit_test_setup_teardown(test_write_rpc_10, setup_write, teardown_write),
cmocka_unit_test_setup_teardown(test_write_rpc_10_bad, setup_write, teardown_write),
cmocka_unit_test_setup_teardown(test_write_rpc_11, setup_write, teardown_write),
- cmocka_unit_test_setup_teardown(test_write_rpc_11_bad, setup_write, teardown_write)};
+ cmocka_unit_test_setup_teardown(test_write_rpc_11_bad, setup_write, teardown_write)
+ };
return cmocka_run_group_tests(io, NULL, NULL);
}
diff --git a/tests/test_server_thread.c b/tests/test_server_thread.c
index a1faeb6..15e5d4c 100644
--- a/tests/test_server_thread.c
+++ b/tests/test_server_thread.c
@@ -13,18 +13,18 @@
*/
#include <pthread.h>
-#include <unistd.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
#include <libyang/libyang.h>
+#include <log.h>
#include <session_client.h>
#include <session_server.h>
-#include <log.h>
#include "tests/config.h"
/* millisec */
@@ -39,7 +39,7 @@
#if _POSIX_BARRIERS >= 200112L
pthread_barrier_t barrier;
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
static void *
server_thread(void *arg)
@@ -55,7 +55,7 @@
pthread_barrier_wait(&barrier);
-#if defined(NC_ENABLED_SSH) && defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS)
msgtype = nc_accept(NC_ACCEPT_TIMEOUT, &session);
nc_assert(msgtype == NC_MSG_HELLO);
@@ -85,13 +85,13 @@
static int
clb_hostkeys(const char *name, void *UNUSED(user_data), char **privkey_path, char **UNUSED(privkey_data),
- NC_SSH_KEY_TYPE *UNUSED(privkey_type))
+ NC_SSH_KEY_TYPE *UNUSED(privkey_type))
{
if (!strcmp(name, "key_rsa")) {
- *privkey_path = strdup(TESTS_DIR"/data/key_rsa");
+ *privkey_path = strdup(TESTS_DIR "/data/key_rsa");
return 0;
} else if (!strcmp(name, "key_dsa")) {
- *privkey_path = strdup(TESTS_DIR"/data/key_dsa");
+ *privkey_path = strdup(TESTS_DIR "/data/key_dsa");
return 0;
}
@@ -189,7 +189,7 @@
pthread_barrier_wait(&barrier);
- ret = nc_server_ssh_add_authkey_path(TESTS_DIR"/data/key_rsa.pub", "test3");
+ ret = nc_server_ssh_add_authkey_path(TESTS_DIR "/data/key_rsa.pub", "test3");
nc_assert(!ret);
return NULL;
@@ -203,7 +203,7 @@
pthread_barrier_wait(&barrier);
- ret = nc_server_ssh_del_authkey(TESTS_DIR"/data/key_dsa.pub", NULL, 0, "test2");
+ ret = nc_server_ssh_del_authkey(TESTS_DIR "/data/key_dsa.pub", NULL, 0, "test2");
nc_assert(!ret);
return NULL;
@@ -238,7 +238,7 @@
ret = nc_client_ssh_set_username("test");
nc_assert(!ret);
- ret = nc_client_ssh_add_keypair(TESTS_DIR"/data/key_ecdsa.pub", TESTS_DIR"/data/key_ecdsa");
+ ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_ecdsa.pub", TESTS_DIR "/data/key_ecdsa");
nc_assert(!ret);
nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PUBLICKEY, 1);
@@ -266,82 +266,82 @@
{
if (!strcmp(name, "server_cert1")) {
*cert_data = strdup("MIIEQDCCAygCCQCV65JgDvfWkTANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJD\n"
- "WjETMBEGA1UECAwKU29tZS1TdGF0ZTENMAsGA1UEBwwEQnJubzEPMA0GA1UECgwG\n"
- "Q0VTTkVUMQwwCgYDVQQLDANUTUMxETAPBgNVBAMMCHNlcnZlcmNhMB4XDTE4MTEw\n"
- "NTA3MzExMFoXDTI4MTEwMjA3MzExMFowYTELMAkGA1UEBhMCQ1oxEzARBgNVBAgM\n"
- "ClNvbWUtU3RhdGUxDTALBgNVBAcMBEJybm8xDzANBgNVBAoMBkNFU05FVDEMMAoG\n"
- "A1UECwwDVE1DMQ8wDQYDVQQDDAZzZXJ2ZXIwggIiMA0GCSqGSIb3DQEBAQUAA4IC\n"
- "DwAwggIKAoICAQDqiO2N8Oa/JA/V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o7fgQn2RyX0k+zXE8/7zqjqvji9zyemdNu\n"
+ "8we4uJICSntyvJwkbj/hrufTKEnBrwXpzfVn1EsH+6w32ZPBGLUhT75txJ8r56SR\n"
+ "q7l1XPU9vxovmT+lSMFF/Y0j1MbHWnds5H1shoFPNtYTvWBL/gfPHjIc+H23zsiu\n"
+ "3XlZAoIBAC2xB/Pnpoi9vOUMiqFH36AXtYa1DURy+AqCFlYlClMvb7YgvQ1w1eJv\n"
+ "nwrHSLk7HdKhnwGsLPduuRRH8q0n/osnoOutSQroE0n41UyIv2ZNccRwNmSzQcai\n"
+ "rBu2dSz02hlsh2otNl5IuGpOqXyPjXBpW4qGD6n2tH7THALnLC0BHtTSQVQsJsRM\n"
+ "3gX39LoiWvLDp2qJvplm6rTpi8Rgap6rZSqHe1yNKIxxD2vlr/WY9SMgLXYASO4S\n"
+ "SBz9wfGOmQIPk6KXNJkdV4kC7nNjIi75iwLLCgjHgUiHTrDq5sWekpeNnUoWsinb\n"
+ "Tsdsjnv3zHG9GyiClyLGxMbs4M5eyYECggEBAKuC8ZMpdIrjk6tERYB6g0LnQ7mW\n"
+ "8XYbDFAmLYMLs9yfG2jcjVbsW9Kugsr+3poUUv/q+hNO3jfY4HazhZDa0MalgNPo\n"
+ "Swr/VNRnkck40x2ovFb989J7yl++zTrnIrax9XRH1V0cNu+Kj7OMwZ2RRfbNv5JB\n"
+ "dOZPvkfqyIKFmbQgYbtD66rHuzNOfJpzqr/WVLO57/zzW8245NKG2B6B0oXkei/K\n"
+ "qDY0DAbHR3i3EOj1NPtVI1FC/xX8R9BREaid458bqoHJKuInrGcBjaUI9Cvymv8T\n"
+ "bstUgD6NPbJR4Sm6vrLeUqzjWZP3t1+Z6DjXmnpR2vvhMU/FWb//21p/88o=");
*privkey_type = NC_SSH_KEY_RSA;
return 0;
} else if (!strcmp(name, "main_cert")) {
- *cert_path = strdup(TESTS_DIR"/data/server.crt");
- *privkey_path = strdup(TESTS_DIR"/data/server.key");
+ *cert_path = strdup(TESTS_DIR "/data/server.crt");
+ *privkey_path = strdup(TESTS_DIR "/data/server.key");
return 0;
}
@@ -355,30 +355,30 @@
if (!strcmp(name, "trusted_cert_list1")) {
*cert_data = malloc(sizeof **cert_data);
(*cert_data)[0] = strdup("MIIDnDCCAoSgAwIBAgIJAIjf7UNx4uabMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV\n"
- "BAYTAkNaMRMwEQYDVQQIDApTb21lLVN0YXRlMQ0wCwYDVQQHDARCcm5vMQ8wDQYD\n"
- "VQQKDAZDRVNORVQxDDAKBgNVBAsMA1RNQzERMA8GA1UEAwwIc2VydmVyY2EwHhcN\n"
- "MTgxMTA1MDcyNjM5WhcNMjgxMTAyMDcyNjM5WjBjMQswCQYDVQQGEwJDWjETMBEG\n"
- "A1UECAwKU29tZS1TdGF0ZTENMAsGA1UEBwwEQnJubzEPMA0GA1UECgwGQ0VTTkVU\n"
- "MQwwCgYDVQQLDANUTUMxETAPBgNVBAMMCHNlcnZlcmNhMIIBIjANBgkqhkiG9w0B\n"
- "AQEFAAOCAQ8AMIIBCgKCAQEAyMrKraqraFGklO2itRIEWxfuzWo1IwxZ22aJmeXD\n"
- "Leomt6893NXelMLaC3swQ+hu49JjiIY81DXvbVgmIgLm7cAz5tHTHuJbfdI4Q6gy\n"
- "ic4aOpy2s3s1/vYz+1TvEUFCiPXEsJrH72he/z9nBxL8vY6Eg8U8EG8NvKp9zyCK\n"
- "A7vmNSgQOtuyF18fesYHAnvQjNXO5q6diPXdHOr2bjTRUvARGbWlv4Rvf81RwUkR\n"
- "sWoF/0pglV/TxnW2MoHnn3apxb/kmH92CQ+GWKxq5SkhvbkYePlA87kgKnDtXl4w\n"
- "EXIhYwM51kafRhhlAKN+qYeV9teBqGpjsZRYesrh3mXHlQIDAQABo1MwUTAdBgNV\n"
- "HQ4EFgQU60nJ4q3ItcfaOOBjJSqadAPiMg8wHwYDVR0jBBgwFoAU60nJ4q3Itcfa\n"
- "OOBjJSqadAPiMg8wD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+ "sWoF/0pglV/TxnW2MoHnn3apxb/kmH92CQ+GWKxq5SkhvbkYePlA87kgKnDtXl4w\n"
+ "EXIhYwM51kafRhhlAKN+qYeV9teBqGpjsZRYesrh3mXHlQIDAQABo1MwUTAdBgNV\n"
+ "HQ4EFgQU60nJ4q3ItcfaOOBjJSqadAPiMg8wHwYDVR0jBBgwFoAU60nJ4q3Itcfa\n"
+ "OOBjJSqadAPiMg8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEA\n"
+ "xIqIQ5SCXnKslZfrXiAEbB5dglxVOSa8me5a/70uHK/27JZ6veeIgRqZ4VgPHnBC\n"
+ "a3m6EHr+mnTjjqSUcGIUiKV3g2Dumw8paqZC+Qv+Ib/NKquS1lO2Ry1wHBtXzn5K\n"
+ "KHHyM1bWMDaDszirw2+pp22VdRrPZNA9NWXheEDYOLyQekyL2CfidhxhaXvUZyWg\n"
+ "alLyF2XRZ5/jAT+NjfWw39EmWPUGk13Jm83OaFc1VdrXNCiD0sGCQ+BTCllDinQv\n"
+ "R08yzd4fzA3YXthvX1dBu1SvqQAGOS7gssRCyv9uWI6MXta25X91eY1ZMz1euJ04\n"
+ "mB8EdyYiZc0kzrb9dv5d0g==");
*cert_data_count = 1;
return 0;
} else if (!strcmp(name, "client_cert_list")) {
*cert_paths = malloc(sizeof **cert_paths);
- (*cert_paths)[0] = strdup(TESTS_DIR"/data/client.crt");
+ (*cert_paths)[0] = strdup(TESTS_DIR "/data/client.crt");
*cert_path_count = 1;
return 0;
}
@@ -452,7 +452,7 @@
pthread_barrier_wait(&barrier);
- ret = nc_server_tls_endpt_set_trusted_ca_paths("quaternary", TESTS_DIR"/data/serverca.pem", "data");
+ ret = nc_server_tls_endpt_set_trusted_ca_paths("quaternary", TESTS_DIR "/data/serverca.pem", "data");
nc_assert(!ret);
nc_thread_destroy();
@@ -507,7 +507,7 @@
pthread_barrier_wait(&barrier);
ret = nc_server_tls_endpt_add_ctn("main_tls", 2, "02:F0:F1:F2:F3:F4:F5:F6:F7:F8:F9:10:11:12:EE:FF:A0:A1:A2:A3",
- NC_TLS_CTN_SAN_IP_ADDRESS, NULL);
+ NC_TLS_CTN_SAN_IP_ADDRESS, NULL);
nc_assert(!ret);
return NULL;
@@ -540,16 +540,16 @@
nc_assert(ret == 9);
nc_assert(!strncmp(buf, "tls_ready", 9));
- ret = nc_client_tls_set_cert_key_paths(TESTS_DIR"/data/client.crt", TESTS_DIR"/data/client.key");
+ ret = nc_client_tls_set_cert_key_paths(TESTS_DIR "/data/client.crt", TESTS_DIR "/data/client.key");
nc_assert(!ret);
- ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR"/data");
+ ret = nc_client_tls_set_trusted_ca_paths(NULL, TESTS_DIR "/data");
nc_assert(!ret);
session = nc_connect_tls("127.0.0.1", 6501, NULL);
nc_assert(session);
/* verify some capabilities */
- nc_assert( nc_session_cpblt(session, "urn:jmu:params:xml:ns:yang:module-a?module=module-a&deviations=module-a-dv,module-a-dv2") );
+ nc_assert(nc_session_cpblt(session, "urn:jmu:params:xml:ns:yang:module-a?module=module-a&deviations=module-a-dv,module-a-dv2"));
nc_session_free(session, NULL);
@@ -562,7 +562,7 @@
#endif /* NC_ENABLED_TLS */
static void *(*thread_funcs[])(void *) = {
-#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS)
server_thread,
#endif
#ifdef NC_ENABLED_SSH
@@ -591,7 +591,7 @@
const int thread_count = sizeof thread_funcs / sizeof *thread_funcs;
-#if defined(NC_ENABLED_SSH) && defined(NC_ENABLED_TLS)
+#if defined (NC_ENABLED_SSH) && defined (NC_ENABLED_TLS)
const int client_count = 2;
pid_t pids[2];
int pipes[4];
@@ -612,7 +612,7 @@
if (!(pids[clients] = fork())) {
nc_client_init();
- ret = nc_client_set_schema_searchpath(TESTS_DIR"/data/modules");
+ ret = nc_client_set_schema_searchpath(TESTS_DIR "/data/modules");
nc_assert(!ret);
/* close write */
@@ -634,7 +634,7 @@
if (!(pids[clients] = fork())) {
nc_client_init();
- ret = nc_client_set_schema_searchpath(TESTS_DIR"/data/modules");
+ ret = nc_client_set_schema_searchpath(TESTS_DIR "/data/modules");
nc_assert(!ret);
/* close write */
@@ -650,6 +650,7 @@
++clients;
#endif
}
+
#endif
int
@@ -664,7 +665,7 @@
client_fork();
- ly_ctx_new(TESTS_DIR"/data/modules", 0, &ctx);
+ ly_ctx_new(TESTS_DIR "/data/modules", 0, &ctx);
nc_assert(ctx);
ly_ctx_load_module(ctx, "ietf-netconf", NULL, NULL);
@@ -688,7 +689,7 @@
nc_assert(!ret);
ret = nc_server_endpt_set_port("main_ssh", 6001);
nc_assert(!ret);
- ret = nc_server_ssh_add_authkey_path(TESTS_DIR"/data/key_ecdsa.pub", "test");
+ ret = nc_server_ssh_add_authkey_path(TESTS_DIR "/data/key_ecdsa.pub", "test");
nc_assert(!ret);
ret = nc_server_ssh_endpt_add_hostkey("main_ssh", "key_rsa", -1);
nc_assert(!ret);
@@ -699,7 +700,7 @@
++clients;
/* for ssh_endpt_del_authkey */
- ret = nc_server_ssh_add_authkey_path(TESTS_DIR"/data/key_dsa.pub", "test2");
+ ret = nc_server_ssh_add_authkey_path(TESTS_DIR "/data/key_dsa.pub", "test2");
nc_assert(!ret);
ret = nc_server_add_endpt("secondary", NC_TI_LIBSSH);