Give ip and mtu to client

This commit is contained in:
Bjorn Andersson 2006-06-11 17:23:26 +00:00
parent 03509b9e78
commit 6864263aac
3 changed files with 27 additions and 17 deletions

24
dns.c
View File

@ -55,6 +55,15 @@ short delayed_q_id;
struct sockaddr_in delayed_q_from; struct sockaddr_in delayed_q_from;
int delayed_q_fromlen; int delayed_q_fromlen;
struct packet
{
int len;
int offset;
char data[64*1024];
};
struct packet packetbuf;
int int
open_dns(const char *host, const char *domain) open_dns(const char *host, const char *domain)
{ {
@ -503,13 +512,6 @@ dnsd_forceack(int fd)
delayed_q_id = 0; delayed_q_id = 0;
} }
struct packet
{
int len;
int offset;
char data[64*1024];
};
static int static int
decodepacket(const char *name, struct packet *packet) decodepacket(const char *name, struct packet *packet)
{ {
@ -517,6 +519,7 @@ decodepacket(const char *name, struct packet *packet)
int len; int len;
int last; int last;
int ping; int ping;
int hello;
char *dp; char *dp;
char *domain; char *domain;
const char *np; const char *np;
@ -524,10 +527,11 @@ decodepacket(const char *name, struct packet *packet)
len = 0; len = 0;
last = (name[0] == '1'); last = (name[0] == '1');
ping = (name[0] == 'p' || name[0] == 'P'); ping = (name[0] == 'p' || name[0] == 'P');
hello = (name[0] == 'h' || name[0] == 'H');
domain = strstr(name, topdomain); domain = strstr(name, topdomain);
if (!ping && domain) { if (!ping && !hello && domain) {
np = name + 1; np = name + 1;
dp = packet->data + packet->offset; dp = packet->data + packet->offset;
@ -550,6 +554,8 @@ decodepacket(const char *name, struct packet *packet)
if(last) { if(last) {
len = packet->len; len = packet->len;
packet->len = packet->offset = 0; packet->len = packet->offset = 0;
} else if (hello) {
len = GOTHELLO;
} else { } else {
len = 0; len = 0;
} }
@ -563,8 +569,6 @@ close_dnsd(int fd)
close(fd); close(fd);
} }
struct packet packetbuf;
int int
dnsd_read(int fd, char *buf, int buflen) dnsd_read(int fd, char *buf, int buflen)
{ {

2
dns.h
View File

@ -17,6 +17,8 @@
#ifndef _DNS_H_ #ifndef _DNS_H_
#define _DNS_H_ #define _DNS_H_
#define GOTHELLO -5
int open_dns(const char *, const char *); int open_dns(const char *, const char *);
void close_dns(int); void close_dns(int);

View File

@ -90,8 +90,13 @@ tunnel(int tun_fd, int dns_fd)
} }
if(FD_ISSET(dns_fd, &fds)) { if(FD_ISSET(dns_fd, &fds)) {
read = dnsd_read(dns_fd, in, sizeof(in)); read = dnsd_read(dns_fd, in, sizeof(in));
if (read <= 0) if (read <= 0) {
if (read == GOTHELLO) {
read = snprintf(in, sizeof(in), "%s-%d", "172.30.5.2", 1023);
dnsd_queuepacket(in, read);
}
continue; continue;
}
outlen = sizeof(out); outlen = sizeof(out);
uncompress(out, &outlen, in, read); uncompress(out, &outlen, in, read);
@ -208,7 +213,6 @@ main(int argc, char **argv)
if ((dnsd_fd = open_dnsd(argv[1])) == -1) if ((dnsd_fd = open_dnsd(argv[1])) == -1)
goto cleanup2; goto cleanup2;
if (newroot) { if (newroot) {
if (chroot(newroot) != 0 || chdir("/") != 0) if (chroot(newroot) != 0 || chdir("/") != 0)
err(1, "%s", newroot); err(1, "%s", newroot);