summaryrefslogtreecommitdiff
path: root/pythonmod/pythonmod_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'pythonmod/pythonmod_utils.c')
-rw-r--r--pythonmod/pythonmod_utils.c15
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;
+}