]> asedeno.scripts.mit.edu Git - 1ts-debian.git/commitdiff
use {ares_,}getnameinfo to lookup addresses
authorkcr <kcr@cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f>
Fri, 20 Mar 2009 05:40:01 +0000 (05:40 +0000)
committerkcr <kcr@cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f>
Fri, 20 Mar 2009 05:40:01 +0000 (05:40 +0000)
git-svn-id: svn://svn.1ts.org/debian/branches/zephyr-reloaded@441 cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f

zephyr/zwgc/main.c

index 771d155bf6f34db85b83e61935ea31848be4d025..e66e2095fd3428e623da8d5a52cf8f41fb5727c2 100644 (file)
@@ -21,6 +21,7 @@ static const char rcsid_main_c[] = "$Id$";
 #endif
 
 #include <netdb.h>
+#include <arpa/nameser.h>
 #include <sys/socket.h>
 #include <sys/resource.h>
 #include <zephyr/mit-copyright.h>
@@ -53,7 +54,7 @@ static void setup_signals(int);
 static void detach(void);
 static void signal_exit(int);
 #ifdef HAVE_ARES
-static void notice_callback(void *, int, int, struct hostent *);
+static void notice_callback(void *, int, int, char *, char *);
 #endif
 #ifdef CMU_ZWGCPLUS
 void reprocess_notice(ZNotice_t *notice, char *hostname);
@@ -399,23 +400,22 @@ create_punt_reply(int_dictionary_binding *punt)
 void
 notice_handler(ZNotice_t *notice)
 {
-    struct hostent *fromhost = NULL;
+    char node[MAXDNAME];
 
 #if defined(CMU_ZWGCPLUS)
     list_add_notice(notice);
 #endif
 
-    if (notice->z_sender_addr.s_addr) {
 #ifdef HAVE_ARES
-       ares_gethostbyaddr(achannel, &(notice->z_sender_addr),
-                          sizeof(notice->z_sender_addr), AF_INET,
-                          notice_callback, notice);
-       return;
+    ares_getnameinfo(achannel, (const struct sockaddr *)&(notice->z_sender_sockaddr),
+                    sizeof(notice->z_sender_sockaddr), ARES_NI_LOOKUPHOST,
+                    notice_callback, notice);
+    
 #else
-       fromhost = gethostbyaddr((char *) &(notice->z_sender_addr),
-                                sizeof(struct in_addr), AF_INET);
-#endif
-    }
+    ret = getnameinfo((const struct sockaddr *)&(notice->z_sender_sockaddr),
+                     sizeof(notice->z_sender_sockaddr),
+                     node, sizeof(node), NULL, 0, 0);
+    
     process_notice(notice, fromhost ? fromhost->h_name : NULL);
 #ifdef CMU_ZWGCPLUS
     /* Let list_del_notice clean up for us. */
@@ -423,22 +423,31 @@ notice_handler(ZNotice_t *notice)
     ZFreeNotice(notice);
     free(notice);
 #endif
+#endif
 }
 
 #ifdef HAVE_ARES
+/*
 static void
 notice_callback(void *arg,
                int status,
                int timeouts,
                struct hostent *fromhost)
+*/
+static void
+notice_callback(void *arg,
+               int status,
+               int timeouts,
+               char *node,
+               char *service)
 {
     ZNotice_t *notice = (ZNotice_t *) arg;
 
 #ifdef CMU_ZWGCPLUS
-    plus_set_hname(notice, fromhost ? fromhost->h_name : NULL);
+    plus_set_hname(notice, node);
 #endif
 
-    process_notice(notice, fromhost ? fromhost->h_name : NULL);
+    process_notice(notice, node);
 #ifdef CMU_ZWGCPLUS
     list_del_notice(notice);
 #else