Commit bbf66738 authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

use isc_sockaddr_format() instead of a static function doing

the same thing
parent 527ea00c
......@@ -160,24 +160,6 @@ static isc_boolean_t exit_check(ns_client_t *client);
static void ns_client_endrequest(ns_client_t *client);
static void ns_client_checkactive(ns_client_t *client);
/*
* Format a human-readable representation of the socket address '*sa'
* into the character array 'array', which is of size 'size'.
* The resulting string is guaranteed to be null-terminated.
*/
static void
sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size)
{
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
strncpy(array, "<unknown address>", size);
array[size-1] = '\0';
}
}
/*
* Enter the inactive state.
*
......@@ -1619,7 +1601,8 @@ ns_client_logv(ns_client_t *client, isc_logcategory_t *category,
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
if (client->peeraddr_valid) {
sockaddr_format(&client->peeraddr, peerbuf, sizeof peerbuf);
isc_sockaddr_format(&client->peeraddr,
peerbuf, sizeof peerbuf);
isc_log_write(ns_g_lctx, category, module, level,
"client %s: %s", peerbuf, msgbuf);
} else {
......
......@@ -53,23 +53,6 @@ struct ns_interfacemgr {
static void
purge_old_interfaces(ns_interfacemgr_t *mgr);
/*
* Format a human-readable representation of the socket address '*sa'
* into the character array 'array', which is of size 'size'.
* The resulting string is guaranteed to be null-terminated.
*/
static void
sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size) {
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
strncpy(array, "<unknown address>", size);
array[size-1] = '\0';
}
}
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_socketmgr_t *socketmgr,
......@@ -472,7 +455,7 @@ purge_old_interfaces(ns_interfacemgr_t *mgr) {
if (ifp->generation != mgr->generation) {
char sabuf[256];
ISC_LIST_UNLINK(ifp->mgr->interfaces, ifp, link);
sockaddr_format(&ifp->addr, sabuf, sizeof(sabuf));
isc_sockaddr_format(&ifp->addr, sabuf, sizeof(sabuf));
isc_log_write(IFMGR_COMMON_LOGARGS,
ISC_LOG_INFO,
"no longer listening on %s", sabuf);
......@@ -580,8 +563,8 @@ do_ipv4(ns_interfacemgr_t *mgr) {
ifp->generation = mgr->generation;
} else {
char sabuf[256];
sockaddr_format(&listen_sockaddr,
sabuf, sizeof(sabuf));
isc_sockaddr_format(&listen_sockaddr,
sabuf, sizeof(sabuf));
isc_log_write(IFMGR_COMMON_LOGARGS,
ISC_LOG_INFO,
"listening on IPv4 interface "
......
......@@ -149,25 +149,6 @@ static dns_dispentry_t *linear_next(dns_dispatch_t *disp,
DNS_LOGCATEGORY_DISPATCH, DNS_LOGMODULE_DISPATCH, \
ISC_LOG_DEBUG(x)
/*
* Format a human-readable representation of the socket address '*sa'
* into the character array 'array', which is of size 'size'.
* The resulting string is guaranteed to be null-terminated.
*/
static void
sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size) {
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
snprintf(array, size, "<unknown address, family %u>",
sa->type.sa.sa_family);
array[size - 1] = '\0';
}
}
static void
dispatch_log(dns_dispatch_t *disp,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
......@@ -198,7 +179,7 @@ request_log(dns_dispatch_t *disp, dns_dispentry_t *resp,
va_end(ap);
if (VALID_RESPONSE(resp)) {
sockaddr_format(&resp->host, peerbuf, sizeof peerbuf);
isc_sockaddr_format(&resp->host, peerbuf, sizeof peerbuf);
isc_log_write(dns_lctx, category, module, level,
"dispatch %p request %p %s: %s", disp, resp,
peerbuf, msgbuf);
......@@ -1784,7 +1765,7 @@ dns_dispatchmgr_dump(dns_dispatchmgr_t *mgr) {
disp = ISC_LIST_HEAD(mgr->list);
while (disp != NULL) {
sockaddr_format(&disp->local, foo, sizeof foo);
isc_sockaddr_format(&disp->local, foo, sizeof foo);
printf("dispatch %p, addr %s\n", disp, foo);
disp = ISC_LIST_NEXT(disp, link);
}
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: zone.c,v 1.113 2000/05/14 20:01:25 gson Exp $ */
/* $Id: zone.c,v 1.114 2000/05/14 20:52:34 gson Exp $ */
#include <config.h>
......@@ -3202,27 +3202,6 @@ queue_xfrin(dns_zone_t *zone) {
}
}
/*
* Format a human-readable representation of the socket address '*sa'
* into the character array 'array', which is of size 'size'.
* The resulting string is guaranteed to be null-terminated.
*/
static void
sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size)
{
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
snprintf(array, size,
"<unknown address, family %u>",
sa->type.sa.sa_family);
array[size - 1] = '\0';
}
}
/*
* This event callback is called when a zone has received
* any necessary zone transfer quota. This is the time
......@@ -3249,7 +3228,7 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) {
goto cleanup;
}
sockaddr_format(&zone->masteraddr, mastertext, sizeof(mastertext));
isc_sockaddr_format(&zone->masteraddr, mastertext, sizeof(mastertext));
isc_netaddr_fromsockaddr(&masterip, &zone->masteraddr);
(void)dns_peerlist_peerbyaddr(zone->view->peers,
......
......@@ -219,27 +219,6 @@ static void build_msghdr_recv(isc_socket_t *, isc_socketevent_t *,
#define SOCK_DEAD(s) ((s)->references == 0)
/*
* Format a human-readable representation of the socket address '*sa'
* into the character array 'array', which is of size 'size'.
* The resulting string is guaranteed to be null-terminated.
*/
static void
sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size)
{
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
snprintf(array, size,
"<unknown address, family %u>",
sa->type.sa.sa_family);
array[size - 1] = '\0';
}
}
static void
manager_log(isc_socketmgr_t *sockmgr,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
......@@ -273,7 +252,7 @@ socket_log(isc_socket_t *sock, isc_sockaddr_t *address,
isc_log_write(isc_lctx, category, module, level,
"socket %p: %s", sock, msgbuf);
} else {
sockaddr_format(address, peerbuf, sizeof peerbuf);
isc_sockaddr_format(address, peerbuf, sizeof peerbuf);
isc_log_write(isc_lctx, category, module, level,
"socket %p %s: %s", sock, peerbuf, msgbuf);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment