session MAINTENANCE log messages unified and corrected
diff --git a/src/session_server.c b/src/session_server.c
index 51b9a99..5744a41 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -70,12 +70,12 @@
sock = socket((is_ipv4 ? AF_INET : AF_INET6), SOCK_STREAM, 0);
if (sock == -1) {
- ERR("%s: could not create socket (%s).", __func__, strerror(errno));
+ ERR("Failed to create socket (%s).", strerror(errno));
goto fail;
}
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&optVal, optLen)) {
- ERR("%s: could not set socket SO_REUSEADDR option (%s).", __func__, strerror(errno));
+ ERR("Could not set socket SO_REUSEADDR socket option (%s).", strerror(errno));
goto fail;
}
@@ -87,12 +87,12 @@
saddr4->sin_port = htons(port);
if (inet_pton(AF_INET, address, &saddr4->sin_addr) != 1) {
- ERR("%s: failed to convert IPv4 address \"%s\".", __func__, address);
+ ERR("Failed to convert IPv4 address \"%s\".", address);
goto fail;
}
if (bind(sock, (struct sockaddr *)saddr4, sizeof(struct sockaddr_in)) == -1) {
- ERR("%s: could not bind \"%s\" port %d (%s).", __func__, address, port, strerror(errno));
+ ERR("Could not bind \"%s\" port %d (%s).", address, port, strerror(errno));
goto fail;
}
@@ -103,18 +103,18 @@
saddr6->sin6_port = htons(port);
if (inet_pton(AF_INET6, address, &saddr6->sin6_addr) != 1) {
- ERR("%s: failed to convert IPv6 address \"%s\".", __func__, address);
+ ERR("Failed to convert IPv6 address \"%s\".", address);
goto fail;
}
if (bind(sock, (struct sockaddr *)saddr6, sizeof(struct sockaddr_in6)) == -1) {
- ERR("%s: could not bind \"%s\" port %d (%s).", __func__, address, port, strerror(errno));
+ ERR("Could not bind \"%s\" port %d (%s).", address, port, strerror(errno));
goto fail;
}
}
if (listen(sock, NC_REVERSE_QUEUE) == -1) {
- ERR("%s: unable to start listening on \"%s\" port %d (%s).", __func__, address, port, strerror(errno));
+ ERR("Unable to start listening on \"%s\" port %d (%s).", address, port, strerror(errno));
goto fail;
}
@@ -152,7 +152,7 @@
free(pfd);
return 0;
} else if (ret == -1) {
- ERR("%s: poll failed (%s).", __func__, strerror(errno));
+ ERR("Poll failed (%s).", strerror(errno));
free(pfd);
return -1;
}
@@ -166,13 +166,13 @@
free(pfd);
if (sock == -1) {
- ERR("%s: fatal error (%s:%d).", __func__, __FILE__, __LINE__);
+ ERRINT;
return -1;
}
ret = accept(sock, (struct sockaddr *)&saddr, &saddr_len);
if (ret == -1) {
- ERR("%s: accept failed (%s).", __func__, strerror(errno));
+ ERR("Accept failed (%s).", strerror(errno));
return -1;
}
@@ -185,7 +185,7 @@
if (saddr.ss_family == AF_INET) {
*host = malloc(15);
if (!inet_ntop(AF_INET, &((struct sockaddr_in *)&saddr)->sin_addr.s_addr, *host, 15)) {
- ERR("%s: inet_ntop failed (%s).", __func__, strerror(errno));
+ ERR("inet_ntop failed (%s).", strerror(errno));
free(*host);
*host = NULL;
}
@@ -196,7 +196,7 @@
} else if (saddr.ss_family == AF_INET6) {
*host = malloc(40);
if (!inet_ntop(AF_INET6, ((struct sockaddr_in6 *)&saddr)->sin6_addr.s6_addr, *host, 40)) {
- ERR("%s: inet_ntop failed (%s).", __func__, strerror(errno));
+ ERR("inet_ntop failed (%s).", strerror(errno));
free(*host);
*host = NULL;
}
@@ -205,7 +205,7 @@
*port = ntohs(((struct sockaddr_in6 *)&saddr)->sin6_port);
}
} else {
- ERR("%s: source host of an unknown protocol family.", __func__);
+ ERR("Source host of an unknown protocol family.");
}
}
@@ -487,7 +487,7 @@
ERRARG;
return NC_MSG_ERROR;
} else if ((session->status != NC_STATUS_RUNNING) || (session->side != NC_SERVER)) {
- ERR("%s: invalid session to receive RPCs.", __func__);
+ ERR("Session %u: invalid session to receive RPCs.", session->id);
return NC_MSG_ERROR;
}
@@ -500,13 +500,13 @@
(*rpc)->root = xml;
break;
case NC_MSG_HELLO:
- ERR("%s: session %u: received another <hello> message.", __func__, session->id);
+ ERR("Session %u: received another <hello> message.", session->id);
goto error;
case NC_MSG_REPLY:
- ERR("%s: session %u: received <rpc-reply> from NETCONF client.", __func__, session->id);
+ ERR("Session %u: received <rpc-reply> from NETCONF client.", session->id);
goto error;
case NC_MSG_NOTIF:
- ERR("%s: session %u: received <notification> from NETCONF client.", __func__, session->id);
+ ERR("Session %u: received <notification> from NETCONF client.", session->id);
goto error;
default:
/* NC_MSG_ERROR - pass it out;
@@ -552,7 +552,7 @@
}
if (ret == -1) {
- ERR("%s: failed to write reply.", __func__);
+ ERR("Session %u: failed to write reply.", session->id);
nc_server_reply_free(reply);
return NC_MSG_ERROR;
}
@@ -578,7 +578,7 @@
for (i = 0; i < ps->session_count; ++i) {
if (ps->sessions[i].session->status != NC_STATUS_RUNNING) {
- ERR("%s: session %u: session not running.", __func__, ps->sessions[i].session->id);
+ ERR("Session %u: session not running.", ps->sessions[i].session->id);
return -1;
}
}
@@ -628,14 +628,14 @@
/* check other sessions */
continue;
} else if (ret == SSH_ERROR) {
- ERR("%s: session %u: SSH channel error (%s).", __func__, ps->sessions[i].session->id,
+ ERR("Session %u: SSH channel error (%s).", ps->sessions[i].session->id,
ssh_get_error(ps->sessions[i].session->ti.libssh.session));
ps->sessions[i].session->status = NC_STATUS_INVALID;
ps->sessions[i].session->term_reason = NC_SESSION_TERM_OTHER;
return 2;
} else if (ret == SSH_EOF) {
- ERR("%s: session %u: communication channel unexpectedly closed (libssh).",
- __func__, ps->sessions[i].session->id);
+ ERR("Session %u: communication channel unexpectedly closed (libssh).",
+ ps->sessions[i].session->id);
ps->sessions[i].session->status = NC_STATUS_INVALID;
ps->sessions[i].session->term_reason = NC_SESSION_TERM_DROPPED;
return 2;