aboutsummaryrefslogtreecommitdiff
path: root/external/unbound/pythonmod/pythonmod_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'external/unbound/pythonmod/pythonmod_utils.c')
-rw-r--r--external/unbound/pythonmod/pythonmod_utils.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/external/unbound/pythonmod/pythonmod_utils.c b/external/unbound/pythonmod/pythonmod_utils.c
index 1091dcf10..5120074e8 100644
--- a/external/unbound/pythonmod/pythonmod_utils.c
+++ b/external/unbound/pythonmod/pythonmod_utils.c
@@ -48,7 +48,8 @@
#include "util/data/msgreply.h"
#include "util/storage/slabhash.h"
#include "util/regional.h"
-#include "ldns/sbuffer.h"
+#include "iterator/iter_delegpt.h"
+#include "sldns/sbuffer.h"
#undef _POSIX_C_SOURCE
#undef _XOPEN_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;
+}