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

2
dns.h
View file

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

View file

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