From 08643a664192acb1207719cec7dd278c9c4c6a21 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Tue, 6 Jun 2006 00:17:28 +0000 Subject: [PATCH] we got pong --- dns.c | 17 +++++------------ dnsd.c | 3 +-- dnstun.c | 9 +++++---- dnstund.c | 4 +--- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/dns.c b/dns.c index 687f3ce..30a87a8 100644 --- a/dns.c +++ b/dns.c @@ -317,6 +317,8 @@ dns_read(int fd, char *buf, int buflen) if(header->qr) { /* qr=1 => response */ ancount = ntohs(header->ancount); + rlen = 0; + for(i=0;i 6) { - char *r; - short priority; - short weight; - - r = rdata; - - READSHORT(priority, r); - READSHORT(weight, r); - READSHORT(port, r); - READNAME(packet, host, r); + if(type == T_NULL) { + memcpy(buf, rdata, rlen); } } if (dns_sending() && chunkid == ntohs(header->id)) { @@ -354,7 +347,7 @@ dns_read(int fd, char *buf, int buflen) } // TODO is any data attached? find out and copy into buf and return length - return 0; + return rlen; } } diff --git a/dnsd.c b/dnsd.c index 1152846..63fa389 100644 --- a/dnsd.c +++ b/dnsd.c @@ -180,10 +180,9 @@ static void dnsd_respond(int fd, short id, struct sockaddr_in from) { int len; - int size; - HEADER *header; char *p; char buf[1024]; + HEADER *header; memset(buf, 0, sizeof(buf)); diff --git a/dnstun.c b/dnstun.c index ea310a9..4b73c5a 100644 --- a/dnstun.c +++ b/dnstun.c @@ -24,12 +24,11 @@ #include #include #include +#include #include "tun.h" #include "dns.h" -#define MAX(a,b) ((a)>(b)?(a):(b)) - #define FRAMESIZE (64*1024) int running = 1; @@ -75,6 +74,7 @@ tunnel(int tun_fd, int dns_fd) if(FD_ISSET(tun_fd, &fds)) { read = read_tun(tun_fd, frame, FRAMESIZE); if (read > 0) { + printf("%04x\n", frame->proto); printf("Got data on tun! %d bytes\n", read); dns_handle_tun(dns_fd, frame->data, read - 4); } @@ -84,8 +84,9 @@ tunnel(int tun_fd, int dns_fd) if (read > 0) { printf("Got data on dns! %d bytes\n", read); - frame->flags = htons(0x0000); - frame->proto = htons(0x0800); + //frame->flags = htons(0x0000); + //frame->proto = htons(0x0200); + write_tun(tun_fd, frame, read + 4); } } diff --git a/dnstund.c b/dnstund.c index a8217ce..f04f71f 100644 --- a/dnstund.c +++ b/dnstund.c @@ -24,16 +24,14 @@ #include #include #include +#include #include "tun.h" #include "dns.h" #include "dnsd.h" -#define MAX(a,b) ((a)>(b)?(a):(b)) - int running = 1; - static void sigint(int sig) { running = 0;