Handle packet fragmentation in tunnel instead

This commit is contained in:
Bjorn Andersson 2006-06-11 18:43:37 +00:00
parent f76b8e410b
commit 5c01e8d8e3

View File

@ -56,6 +56,7 @@ tunnel(int tun_fd, int dns_fd)
{
int i;
int read;
int code;
fd_set fds;
struct timeval tv;
char in[64*1024];
@ -105,15 +106,21 @@ tunnel(int tun_fd, int dns_fd)
if(in[0] == 'H' || in[0] == 'h') {
read = snprintf(out, sizeof(out), "%s-%d", "172.30.5.2", 1023);
dnsd_queuepacket(out, read);
} else if(in[0] == '0') {
memcpy(packetbuf.data + packetbuf.offset, in, read);
packetbuf.len += read;
packetbuf.offset += read;
} else if(in[0] == '1') {
memcpy(packetbuf.data + packetbuf.offset, in, read);
packetbuf.len += read;
packetbuf.offset += read;
} else if((in[0] >= '0' && in[0] <= '9')
|| (in[0] >= 'a' && in[0] <= 'f')
|| (in[0] >= 'A' && in[0] <= 'F')) {
if ((in[0] >= '0' && in[0] <= '9'))
code = in[0] - '0';
if ((in[0] >= 'a' && in[0] <= 'f'))
code = in[0] - 'a' + 10;
if ((in[0] >= 'A' && in[0] <= 'F'))
code = in[0] - 'A' + 10;
memcpy(packetbuf.data + packetbuf.offset, in + 1, read - 1);
packetbuf.len += read - 1;
packetbuf.offset += read - 1;
if (code & 1) {
outlen = sizeof(out);
uncompress(out, &outlen, packetbuf.data, packetbuf.len);
@ -124,6 +131,7 @@ tunnel(int tun_fd, int dns_fd)
}
}
}
}
return 0;
}
@ -175,6 +183,9 @@ main(int argc, char **argv)
foreground = 0;
mtu = 1024;
packetbuf.len = 0;
packetbuf.offset = 0;
while ((choice = getopt(argc, argv, "vfhu:t:m:")) != -1) {
switch(choice) {
case 'v':