Receive DNS-Responses and print them
authorPhilipp Tölke <toelke@in.tum.de>
Tue, 21 Sep 2010 13:49:10 +0000 (13:49 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Tue, 21 Sep 2010 13:49:10 +0000 (13:49 +0000)
src/vpn/gnunet-service-dns.c

index cd521921e629b6e2083e2ada2aecb5e827ed82c3..b05bfd17f8628843299ca6f660317995ebba4903 100644 (file)
@@ -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,