server sends data in response

This commit is contained in:
Bjorn Andersson 2006-06-05 23:49:18 +00:00
parent 5e7385a0ea
commit 36b134361b
3 changed files with 10 additions and 10 deletions

2
dns.c
View file

@ -185,7 +185,7 @@ dns_ping(int dns_fd)
printf("No reply on chunk, resending\n");
dns_send_chunk(dns_fd);
} else {
dns_write(dns_fd, dns_fd, "", 1);
dns_write(dns_fd, dns_fd, "", 0);
}
}

9
dnsd.c
View file

@ -198,22 +198,27 @@ dnsd_respond(int fd, short id, struct sockaddr_in from)
header->rd = 0;
header->ra = 0;
if(outbuflen > 0)
header->ancount = htons(1);
else
header->ancount = htons(0);
p = buf + sizeof(HEADER);
p += host2dns("fluff", p, 5);
PUTSHORT(T_PTR, p);
PUTSHORT(T_NULL, p);
PUTSHORT(C_IN, p);
PUTLONG(htons(3600), p);
size = host2dns("mupp", p+2, 4);
size = host2dns(outbuf, p+2, outbuflen);
PUTSHORT(size, p);
p += size;
len = p - buf;
printf("%d\n", len);
sendto(fd, buf, len, 0, (struct sockaddr*)&from, sizeof(from));
outbuflen = 0;
}
int

View file

@ -70,16 +70,11 @@ tunnel(int tun_fd, int dns_fd)
}
if(i == 0) {
//dns_ping(dns_fd);
dns_ping(dns_fd);
} else {
if(FD_ISSET(tun_fd, &fds)) {
read = read_tun(tun_fd, frame, FRAMESIZE);
if (read > 0) {
int fd;
fd = open("moo", O_WRONLY | O_CREAT, S_IRGRP);
write(fd, frame->data, read - 4);
close(fd);
printf("Got data on tun! %d bytes\n", read);
dns_handle_tun(dns_fd, frame->data, read - 4);
}