From 5afd08c1faa47523e9d8f52a452e119630636009 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Tue, 21 Sep 2010 13:49:10 +0000 Subject: [PATCH] Receive DNS-Responses and print them --- src/vpn/gnunet-service-dns.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index cd521921e..b05bfd17f 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -79,6 +79,22 @@ void receive_query(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_SERVER_receive_done(client, GNUNET_OK); } +static void read_response (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + unsigned char buf[65536]; + struct dns_pkt* dns = (struct dns_pkt*)buf; + + if (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) + return; + + int r; + r = GNUNET_NETWORK_socket_recv(mycls.dnsout, buf, 65536); + + pkt_printf_dns(dns); + + GNUNET_SCHEDULER_add_read_net(mycls.sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls.dnsout, &read_response, NULL); +} + + /** * Task run during shutdown. * @@ -134,6 +150,8 @@ run (void *cls, hijack(htons(addr.sin_port)); + GNUNET_SCHEDULER_add_read_net(sched, GNUNET_TIME_UNIT_FOREVER_REL, mycls.dnsout, &read_response, NULL); + GNUNET_SERVER_add_handlers (server, handlers); GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_FOREVER_REL, -- 2.25.1