From: Philipp Tölke Date: Tue, 21 Sep 2010 13:49:10 +0000 (+0000) Subject: Receive DNS-Responses and print them X-Git-Tag: initial-import-from-subversion-38251~20275 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5afd08c1faa47523e9d8f52a452e119630636009;p=oweals%2Fgnunet.git Receive DNS-Responses and print them --- 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,