[dns-operations] dnscap V1.0-RC1

Paul Vixie paul at vix.com
Thu May 24 17:18:07 UTC 2007


> FC5 has no FD_COPY...

meanwhile, gates and ballmer are laughing their asses off watching us
try to share code in an organic environment where anybody can innovate
a system's API (and usually does.)

> ...this patch worked ok, borrowing FD_COPY from os x:

since we don't care whether FD_COPY is present, and we can't depend on
it being present, and since the previous "structure assignment" wasn't
portable to mac/os, i replaced the FD_COPY with a memcpy().

and while we're on the subject of systems who can't do structure assignments,
Andris Kalnozols sent a report about hpux on itanium today.  i've replaced
his trouble spots with memcpy()'s since unaligned longwords just won't move.

the following has been checked in and is available in anoncvs as V1.0-RC4:

Index: dnscap.c
===================================================================
RCS file: /proj/cvsroot/dnscap/dnscap.c,v
retrieving revision 1.17
diff -u -r1.17 dnscap.c
--- dnscap.c    24 May 2007 14:25:41 -0000      1.17
+++ dnscap.c    24 May 2007 17:14:39 -0000
@@ -587,6 +587,7 @@
 endpoint_arg(endpoint_list *list, const char *arg) {
        struct addrinfo *ai;
        iaddr ia;
+       void *p;

        if (inet_pton(AF_INET6, arg, &ia.u.a6) > 0) {
                ia.af = AF_INET6;
@@ -603,13 +604,15 @@
                        switch (a->ai_family) {
                        case PF_INET:
                                ia.af = AF_INET;
-                               ia.u.a4 = ((struct sockaddr_in *)a->ai_addr)
+                               p = &((struct sockaddr_in *)a->ai_addr)
                                        ->sin_addr;
+                               memcpy(&ia.u.a4, p, sizeof ia.u.a4);
                                break;
                        case PF_INET6:
                                ia.af = AF_INET6;
-                               ia.u.a6 = ((struct sockaddr_in6 *)a->ai_addr)
+                               p = &((struct sockaddr_in6 *)a->ai_addr)
                                        ->sin6_addr;
+                               memcpy(&ia.u.a6, p, sizeof ia.u.a6);
                                break;
                        default:
                                continue;
@@ -828,7 +831,7 @@
        int n;

        do {
-               FD_COPY(&mypcap_fdset, &readfds);
+               memcpy(&readfds, &mypcap_fdset, sizeof(fd_set));
                n = select(pcap_maxfd+1, &readfds, NULL, NULL, NULL);
        } while (n < 0 && errno == EINTR && !main_exit);
        if (n < 0) {



More information about the dns-operations mailing list