From 8c12e7d8a3d0294b604271095a5fca71ad5e0d12 Mon Sep 17 00:00:00 2001 From: Julian Kranz Date: Sat, 28 Jan 2012 13:59:24 +0100 Subject: [PATCH] --- --- src/client.c | 4 ++++ src/common.c | 4 ++-- src/common.h | 3 ++- src/iodined.c | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/client.c b/src/client.c index b67a668..444b4ba 100644 --- a/src/client.c +++ b/src/client.c @@ -396,6 +396,10 @@ send_query(int fd, char *hostname) fprintf(stderr, " Sendquery: id %5d name[0] '%c'\n", q.id, hostname[0]); #endif + static char a = 0; + printf("send_query() -> sendto: %d\n", a); + a++; + if(_v6_connect) sendto(fd, packet, len, 0, (struct sockaddr*)&nameserv6, sizeof(nameserv6)); else diff --git a/src/common.c b/src/common.c index c9c9737..7dbcf1b 100644 --- a/src/common.c +++ b/src/common.c @@ -184,13 +184,13 @@ open_dns_ipv6(int localport, struct in6_addr listen_ip6) #ifndef WINDOWS32 /* To get destination address from each UDP datagram, see iodined.c:read_dns() */ - setsockopt(fd, IPPROTO_IP, DSTADDR_SOCKOPT, (const void*) &flag, sizeof(flag)); + setsockopt(fd, IPPROTO_IPV6, DSTADDR_SOCKOPT, (const void*) &flag, sizeof(flag)); #endif #ifdef IP_OPT_DONT_FRAG /* Set dont-fragment ip header flag */ flag = DONT_FRAG_VALUE; - setsockopt(fd, IPPROTO_IP, IP_OPT_DONT_FRAG, (const void*) &flag, sizeof(flag)); + setsockopt(fd, IPPROTO_IPV6, IP_OPT_DONT_FRAG, (const void*) &flag, sizeof(flag)); #endif if(bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) diff --git a/src/common.h b/src/common.h index 71b4948..dd95e80 100644 --- a/src/common.h +++ b/src/common.h @@ -59,7 +59,8 @@ extern const unsigned char raw_header[RAW_HDR_LEN]; # define dstaddr(x) ((struct in_addr *) CMSG_DATA(x)) #elif defined IP_PKTINFO # define DSTADDR_SOCKOPT IP_PKTINFO -# define dstaddr(x) (&(((struct in_pktinfo *)(CMSG_DATA(x)))->ipi_addr)) +# define dstaddr(x) (&(((struct in_pktinfo *)(CMSG_DATA(x)))->ipi_addr)) +# define dstaddr6(x) (&(((struct in6_pktinfo *)(CMSG_DATA(x)))->ipi6_addr)) #endif #if defined IP_MTU_DISCOVER diff --git a/src/iodined.c b/src/iodined.c index 8759213..b6a81f1 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -2124,7 +2124,11 @@ read_dns(int fd, int tun_fd, struct query *q) /* FIXME: tun_fd is because of raw if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == DSTADDR_SOCKOPT) { - memcpy(&q->destination.v6, dstaddr(cmsg), sizeof(struct in6_addr)); + memcpy(&q->destination.v6, cmsg->__cmsg_data, sizeof(struct in6_addr)); + + printf("Vaavvaaaa\n"); + ipv6_print(&q->destination.v6, 00); + break;// printf("write_dns()\n"); // ipv6_print(&q->from.v6, 44); }