version 1.1.1.1, 2013/07/21 23:43:41
|
version 1.1.1.2, 2016/11/01 09:33:48
|
Line 22
|
Line 22
|
Released under GPL, as above. |
Released under GPL, as above. |
*/ |
*/ |
|
|
#include <config.h> | #include "config.h" |
| |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/time.h> |
#include <sys/time.h> |
#include <sys/select.h> |
#include <sys/select.h> |
Line 56
|
Line 57
|
|
|
#ifdef ENABLE_IPV6 |
#ifdef ENABLE_IPV6 |
#ifdef __GLIBC__ |
#ifdef __GLIBC__ |
#define NSCOUNT6 myres._u._ext.nscount6 |
|
#define NSSOCKADDR6(i) (myres._u._ext.nsaddrs[i]) |
#define NSSOCKADDR6(i) (myres._u._ext.nsaddrs[i]) |
#else |
#else |
#define NSCOUNT6 myres.nscount |
|
#define NSSOCKADDR6(i) (&(myres._u._ext.ext->nsaddrs[i].sin6)) |
#define NSSOCKADDR6(i) (&(myres._u._ext.ext->nsaddrs[i].sin6)) |
#endif |
#endif |
#endif |
#endif |
Line 529 void dns_open(void)
|
Line 528 void dns_open(void)
|
#ifdef ENABLE_IPV6 |
#ifdef ENABLE_IPV6 |
resfd6 = socket(AF_INET6, SOCK_DGRAM, 0); |
resfd6 = socket(AF_INET6, SOCK_DGRAM, 0); |
if (resfd6 == -1) { |
if (resfd6 == -1) { |
|
// consider making removing this warning. For now leave it in to see |
|
// new code activated. -- REW |
fprintf(stderr, |
fprintf(stderr, |
"Unable to allocate IPv6 socket for nameserver communication: %s\n", |
"Unable to allocate IPv6 socket for nameserver communication: %s\n", |
strerror(errno)); |
strerror(errno)); |
exit(-1); | // exit(-1); |
} |
} |
#endif |
#endif |
option = 1; |
option = 1; |
Line 543 void dns_open(void)
|
Line 544 void dns_open(void)
|
exit(-1); |
exit(-1); |
} |
} |
#ifdef ENABLE_IPV6 |
#ifdef ENABLE_IPV6 |
if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) { | if (resfd6 > 0) { |
fprintf(stderr, | if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) { |
"Unable to setsockopt() on IPv6 nameserver communication socket: %s\n", | fprintf(stderr, |
strerror(errno)); | "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n", |
exit(-1); | strerror(errno)); |
| exit(-1); |
| } |
} |
} |
#endif |
#endif |
longipstr( "127.0.0.1", &localhost, AF_INET ); |
longipstr( "127.0.0.1", &localhost, AF_INET ); |
Line 932 void dorequest(char *s,int type,word id)
|
Line 935 void dorequest(char *s,int type,word id)
|
} |
} |
hp = (packetheader *)buf; |
hp = (packetheader *)buf; |
hp->id = id; /* htons() deliberately left out (redundant) */ |
hp->id = id; /* htons() deliberately left out (redundant) */ |
#ifdef ENABLE_IPV6 |
|
for (i = 0;i < NSCOUNT6;i++) { |
|
if (!NSSOCKADDR6(i)) |
|
continue; |
|
if (NSSOCKADDR6(i)->sin6_family == AF_INET6) |
|
(void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i), |
|
sizeof(struct sockaddr_in6)); |
|
} |
|
#endif |
|
for (i = 0;i < myres.nscount;i++) |
for (i = 0;i < myres.nscount;i++) |
if (myres.nsaddr_list[i].sin_family == AF_INET) |
if (myres.nsaddr_list[i].sin_family == AF_INET) |
(void)sendto(resfd,buf,r,0,(struct sockaddr *)&myres.nsaddr_list[i], |
(void)sendto(resfd,buf,r,0,(struct sockaddr *)&myres.nsaddr_list[i], |
sizeof(struct sockaddr)); |
sizeof(struct sockaddr)); |
|
#ifdef ENABLE_IPV6 |
|
else if (resfd6 > 0) { |
|
if (!NSSOCKADDR6(i)) |
|
continue; |
|
if (NSSOCKADDR6(i)->sin6_family == AF_INET6) |
|
(void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i), |
|
sizeof(struct sockaddr_in6)); |
|
} |
|
#endif |
} |
} |
|
|
void resendrequest(struct resolve *rp,int type) |
void resendrequest(struct resolve *rp,int type) |
Line 1327 void dns_ack6(void)
|
Line 1330 void dns_ack6(void)
|
int r,i; |
int r,i; |
static char addrstr[INET6_ADDRSTRLEN]; |
static char addrstr[INET6_ADDRSTRLEN]; |
|
|
|
// Probably not necessary. -- REW |
|
if (resfd6 < 0) return; |
|
|
r = recvfrom(resfd6,(byte *)resrecvbuf,MaxPacketsize,0, |
r = recvfrom(resfd6,(byte *)resrecvbuf,MaxPacketsize,0, |
from, &fromlen); |
from, &fromlen); |
if (r > 0) { |
if (r > 0) { |
/* Check to see if this server is actually one we sent to */ |
/* Check to see if this server is actually one we sent to */ |
if ( addrcmp( (void *) &(from6->sin6_addr), (void *) &localhost6, |
if ( addrcmp( (void *) &(from6->sin6_addr), (void *) &localhost6, |
(int) AF_INET6 ) == 0 ) { |
(int) AF_INET6 ) == 0 ) { |
for (i = 0;i < NSCOUNT6;i++) { | for (i = 0;i < myres.nscount;i++) { |
if (!NSSOCKADDR6(i)) |
if (!NSSOCKADDR6(i)) |
continue; |
continue; |
|
|
Line 1344 void dns_ack6(void)
|
Line 1350 void dns_ack6(void)
|
break; |
break; |
} |
} |
} else |
} else |
for (i = 0;i < NSCOUNT6;i++) { | for (i = 0;i < myres.nscount;i++) { |
if (!NSSOCKADDR6(i)) |
if (!NSSOCKADDR6(i)) |
continue; |
continue; |
if ( addrcmp( (void *) &(NSSOCKADDR6(i)->sin6_addr), |
if ( addrcmp( (void *) &(NSSOCKADDR6(i)->sin6_addr), |
(void *) &(from6->sin6_addr), AF_INET6 ) == 0 ) |
(void *) &(from6->sin6_addr), AF_INET6 ) == 0 ) |
break; |
break; |
} |
} |
if (i == NSCOUNT6) { | if (i == myres.nscount) { |
snprintf(tempstring, sizeof(tempstring), |
snprintf(tempstring, sizeof(tempstring), |
"Resolver error: Received reply from unknown source: %s", |
"Resolver error: Received reply from unknown source: %s", |
inet_ntop( AF_INET6, &(from6->sin6_addr), addrstr, |
inet_ntop( AF_INET6, &(from6->sin6_addr), addrstr, |