From 25e51c666a0618f49d41215e85da107f2eac1845 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Wed, 11 Jul 2007 23:10:08 +0000 Subject: [PATCH] use common send_query function --- src/iodine.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/iodine.c b/src/iodine.c index 739a9aa..7e21e41 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -75,24 +75,31 @@ sighandler(int sig) } static void -send_packet(int fd, char cmd, const char *data, const size_t datalen) +send_query(int fd, char *hostname) { char packet[4096]; struct query q; - char buf[4096]; size_t len; q.id = ++chunkid; q.type = T_NULL; - buf[0] = cmd; - - len = build_hostname(buf + 1, sizeof(buf) - 1, data, datalen, topdomain, b32); - len = dns_encode(packet, sizeof(packet), &q, QR_QUERY, buf, strlen(buf)); + len = dns_encode(packet, sizeof(packet), &q, QR_QUERY, hostname, strlen(hostname)); sendto(fd, packet, len, 0, (struct sockaddr*)&peer, sizeof(peer)); } +static void +send_packet(int fd, char cmd, const char *data, const size_t datalen) +{ + char buf[4096]; + + buf[0] = cmd; + + build_hostname(buf + 1, sizeof(buf) - 1, data, datalen, topdomain, b32); + send_query(fd, buf); +} + static int build_hostname(char *buf, size_t buflen, const char *data, const size_t datalen, @@ -265,16 +272,10 @@ static void send_chunk(int fd) { char hex[] = "0123456789ABCDEF"; - char data[4096]; - struct query q; char buf[4096]; int avail; int code; char *p; - int len; - - q.id = ++chunkid; - q.type = T_NULL; p = packet.data; p += packet.offset; @@ -289,9 +290,8 @@ send_chunk(int fd) code |= (userid << 1); buf[0] = hex[code]; - len = dns_encode(data, sizeof(data), &q, QR_QUERY, buf, strlen(buf)); - sendto(fd, data, len, 0, (struct sockaddr*)&peer, sizeof(peer)); + send_query(fd, buf); } void