Added CMC to I and S packet types

This commit is contained in:
Erik Ekman 2009-06-12 05:44:34 +00:00
parent 225d48dbc3
commit 53dfac0b3c
3 changed files with 15 additions and 3 deletions

View File

@ -54,10 +54,12 @@ Client sends:
5 bits coded as Base32 char, meaning userid
5 bits coded as Base32 char, with value 5 or 6, representing number of raw
bits per encoded byte
CMC
Server sends:
Name of codec if accepted. After this all upstream data packets must
be encoded with the new codec.
BADCODEC if not accepted. Client must then revert to Base32
BADLEN if length of query is too short
Probe downstream fragment size:
Client sends:

View File

@ -476,9 +476,14 @@ send_version(int fd, uint32_t version)
static void
send_ip_request(int fd, int userid)
{
char buf[512] = "I_.";
char buf[512] = "I____.";
buf[1] = b32_5to8(userid);
buf[2] = b32_5to8((rand_seed >> 10) & 0x1f);
buf[3] = b32_5to8((rand_seed >> 5) & 0x1f);
buf[4] = b32_5to8((rand_seed ) & 0x1f);
rand_seed++;
strncat(buf, topdomain, 512 - strlen(buf));
send_query(fd, buf);
}
@ -498,10 +503,15 @@ send_case_check(int fd)
static void
send_codec_switch(int fd, int userid, int bits)
{
char buf[512] = "S__.";
char buf[512] = "S_____.";
buf[1] = b32_5to8(userid);
buf[2] = b32_5to8(bits);
buf[3] = b32_5to8((rand_seed >> 10) & 0x1f);
buf[4] = b32_5to8((rand_seed >> 5) & 0x1f);
buf[5] = b32_5to8((rand_seed ) & 0x1f);
rand_seed++;
strncat(buf, topdomain, 512 - strlen(buf));
send_query(fd, buf);
}

View File

@ -425,7 +425,7 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len)
} else if(in[0] == 'S' || in[0] == 's') {
int codec;
struct encoder *enc;
if (domain_len != 4) { /* len = 4, example: "S15." */
if (domain_len < 3) { /* len at least 3, example: "S15" */
write_dns(dns_fd, q, "BADLEN", 6);
return;
}