summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorvenaas <venaas>2008-09-17 12:02:22 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-09-17 12:02:22 +0000
commit403fafa13e85fa0e647b81313341cdb7d7aed68e (patch)
treeace8e26f2d6a4a81065a22c96176a71295d97ee1 /util.c
parent1e46e5030af79fae82a15a4d25f5e09d5a092719 (diff)
better logging, fixed bug with crash when removing client
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@387 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'util.c')
-rw-r--r--util.c41
1 files changed, 3 insertions, 38 deletions
diff --git a/util.c b/util.c
index 9a54b57..3ba212c 100644
--- a/util.c
+++ b/util.c
@@ -15,40 +15,7 @@
#include <unistd.h>
#include <stdarg.h>
#include "debug.h"
-
-#if 0
-#include <errno.h>
-void errx(char *format, ...) {
- extern int errno;
-
- va_list ap;
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
- if (errno) {
- fprintf(stderr, ": ");
- perror(NULL);
- fprintf(stderr, "errno=%d\n", errno);
- } else
- fprintf(stderr, "\n");
- exit(1);
-}
-
-void err(char *format, ...) {
- extern int errno;
-
- va_list ap;
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
- if (errno) {
- fprintf(stderr, ": ");
- perror(NULL);
- fprintf(stderr, "errno=%d\n", errno);
- } else
- fprintf(stderr, "\n");
-}
-#endif
+#include "util.h"
char *stringcopy(const char *s, int len) {
char *r;
@@ -131,7 +98,7 @@ struct sockaddr *addr_copy(struct sockaddr *in) {
return out;
}
-char *addr2string(struct sockaddr *addr, socklen_t len) {
+char *addr2string(struct sockaddr *addr) {
struct sockaddr_in6 *sa6;
struct sockaddr_in sa4;
static char addr_buf[2][INET6_ADDRSTRLEN];
@@ -147,9 +114,7 @@ char *addr2string(struct sockaddr *addr, socklen_t len) {
addr = (struct sockaddr *)&sa4;
}
}
- len = addr->sa_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
-
- if (getnameinfo(addr, len, addr_buf[i], sizeof(addr_buf[i]),
+ if (getnameinfo(addr, SOCKADDRP_SIZE(addr), addr_buf[i], sizeof(addr_buf[i]),
NULL, 0, NI_NUMERICHOST)) {
debug(DBG_WARN, "getnameinfo failed");
return "getnameinfo_failed";