diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2015-04-26 11:23:26 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2015-04-26 11:23:26 +0000 |
commit | d3348d437fb0408bc24892ebd0b035686c294705 (patch) | |
tree | 01c1d94467622a175fad10cd34a2f6f05d32c1b7 /pythonmod/pythonmod_utils.c | |
parent | 54dd3272da3f4a5fda7dd6ac359b7cf68e21a796 (diff) |
Diffstat (limited to 'pythonmod/pythonmod_utils.c')
-rw-r--r-- | pythonmod/pythonmod_utils.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pythonmod/pythonmod_utils.c b/pythonmod/pythonmod_utils.c index 1091dcf107277..05914b88a8fba 100644 --- a/pythonmod/pythonmod_utils.c +++ b/pythonmod/pythonmod_utils.c @@ -48,6 +48,7 @@ #include "util/data/msgreply.h" #include "util/storage/slabhash.h" #include "util/regional.h" +#include "iterator/iter_delegpt.h" #include "ldns/sbuffer.h" #undef _POSIX_C_SOURCE @@ -176,3 +177,17 @@ void reply_addr2str(struct comm_reply* reply, char* dest, int maxlen) return; dest[maxlen-1] = 0; } + +/* Convert target->addr to string */ +void delegpt_addr_addr2str(struct delegpt_addr* target, char *dest, int maxlen) +{ + int af = (int)((struct sockaddr_in*) &(target->addr))->sin_family; + void* sinaddr = &((struct sockaddr_in*) &(target->addr))->sin_addr; + + if(af == AF_INET6) + sinaddr = &((struct sockaddr_in6*)&(target->addr))->sin6_addr; + dest[0] = 0; + if (inet_ntop(af, sinaddr, dest, (socklen_t)maxlen) == 0) + return; + dest[maxlen-1] = 0; +} |