From 9355cd782906123c8a56ca92f0559cf2f2884282 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 5 Feb 2007 19:44:46 +0000 Subject: [PATCH] #10 fixed basic ack. pings bigger than 110 still lost --- src/dns.c | 2 +- src/iodine.c | 11 ++++++----- tests/encoding.c | 20 +++++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/dns.c b/src/dns.c index e41465d..9a800a8 100644 --- a/src/dns.c +++ b/src/dns.c @@ -150,7 +150,7 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz } if (q != NULL) - q->id = header->id; + q->id = id; readname(packet, packetlen, &data, name, sizeof(name)); readshort(packet, &data, &type); diff --git a/src/iodine.c b/src/iodine.c index 58ac6ff..e449871 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -73,7 +73,7 @@ send_packet(int fd, char cmd, const char *data, const size_t datalen) char buf[4096]; size_t len; - q.id = rand_seed; + q.id = ++chunkid; q.type = T_NULL; buf[0] = cmd; @@ -229,7 +229,7 @@ send_chunk(int fd) char *p; int len; - q.id = rand_seed; + q.id = ++chunkid; q.type = T_NULL; p = activepacket; @@ -239,7 +239,7 @@ send_chunk(int fd) lastlen = dns_build_hostname(buf + 1, sizeof(buf) - 1, p, avail, topdomain); if (lastlen == avail) buf[0] = '1'; - else + else buf[0] = '0'; len = dns_encode(packet, sizeof(packet), &q, QR_QUERY, buf, strlen(buf)); @@ -340,10 +340,10 @@ handshake(int dns_fd) if (read >= 8) { memcpy(&seed, in + 4, 4); seed = ntohl(seed); - printf("version ok, both running 0x%08x\n", VERSION); + printf("Version ok, both running 0x%08x\n", VERSION); break; } else { - printf("version ok but did not receive proper login challenge\n"); + printf("Version ok but did not receive proper login challenge\n"); } } else { memcpy(&version, in + 4, 4); @@ -475,6 +475,7 @@ main(int argc, char **argv) username = NULL; memset(password, 0, 33); foreground = 0; + chunkid = 0; newroot = NULL; device = NULL; diff --git a/tests/encoding.c b/tests/encoding.c index e1a30b0..4bf33e3 100644 --- a/tests/encoding.c +++ b/tests/encoding.c @@ -25,23 +25,21 @@ START_TEST(test_encoding_base32) { char temp[256]; - char *start = "HELLOTEST"; - char *out = "1HELLOTEST"; - char *end; + char end[256]; + char *start = "1HELLOTEST"; char *tempend; - int codedlength; + int len; memset(temp, 0, sizeof(temp)); - end = malloc(16); - memset(end, 0, 16); + memset(end, 0, sizeof(end)); - codedlength = encode_data(start, 9, 256, temp); + encode_data(start, 9, 256, temp); tempend = temp + strlen(temp); - decode_data(end, 16, temp, tempend); + printf("%d '%s'\n", strlen(temp), temp); + len = decode_data(end, sizeof(end), temp, tempend); - fail_unless(strcmp(out, end) == 0, NULL); - - free(end); + printf("%d %d '%s'\n", len, strlen(end), end); + fail_unless(strcmp(start, end) == 0, NULL); } END_TEST