From 89232bcaa6c154535499d8c5f10b215edabf5289 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Thu, 12 Jul 2007 15:18:34 +0000 Subject: [PATCH] some cleanup --- src/iodined.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/iodined.c b/src/iodined.c index 5a125e4..2241927 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -163,29 +163,26 @@ tunnel_dns(int tun_fd, int dns_fd) /* Version greeting, compare and send ack/nak */ if (read > 4) { /* Received V + 32bits version */ - version = (((unpacked[0] & 0xff) << 24) | ((unpacked[1] & 0xff) << 16) | ((unpacked[2] & 0xff) << 8) | ((unpacked[3] & 0xff))); + } - if (version == VERSION) { - userid = find_available_user(); - if (userid >= 0) { - users[userid].seed = rand(); - /* Store remote IP number */ - tempin = (struct sockaddr_in *) &(dummy.q.from); - memcpy(&(users[userid].host), &(tempin->sin_addr), sizeof(struct in_addr)); - memcpy(&(users[userid].q), &(dummy.q), sizeof(struct query)); - users[userid].encoder = get_base32_encoder(); - send_version_response(dns_fd, VERSION_ACK, users[userid].seed, &users[userid]); - users[userid].q.id = 0; - } else { - /* No space for another user */ - send_version_response(dns_fd, VERSION_FULL, USERS, &dummy); - } + if (version == VERSION) { + userid = find_available_user(); + if (userid >= 0) { + users[userid].seed = rand(); + /* Store remote IP number */ + tempin = (struct sockaddr_in *) &(dummy.q.from); + memcpy(&(users[userid].host), &(tempin->sin_addr), sizeof(struct in_addr)); + memcpy(&(users[userid].q), &(dummy.q), sizeof(struct query)); + users[userid].encoder = get_base32_encoder(); + send_version_response(dns_fd, VERSION_ACK, users[userid].seed, &users[userid]); + users[userid].q.id = 0; } else { - send_version_response(dns_fd, VERSION_NACK, VERSION, &dummy); + /* No space for another user */ + send_version_response(dns_fd, VERSION_FULL, USERS, &dummy); } } else { send_version_response(dns_fd, VERSION_NACK, VERSION, &dummy);