fix codesonar finding: add CLOSE(fd)
[oweals/gnunet.git] / src / gns / gnunet-dns2gns.c
index 47cc6dde0b9be9643b403f11b0ea05618689c172..e6e53d40524b4ce8810336af39e238ba421164d3 100644 (file)
@@ -2,20 +2,18 @@
      This file is part of GNUnet.
      Copyright (C) 2012-2013 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 /**
  * @file gnunet-dns2gns.c
@@ -247,19 +245,16 @@ do_timeout (void *cls)
  * Iterator called on obtained result for a DNS lookup
  *
  * @param cls closure
- * @param rs the request socket
  * @param dns the DNS udp payload
  * @param r size of the DNS payload
  */
 static void
 dns_result_processor (void *cls,
-                     struct GNUNET_DNSSTUB_RequestSocket *rs,
                      const struct GNUNET_TUN_DnsHeader *dns,
                      size_t r)
 {
   struct Request *request = cls;
 
-  (void) rs;
   if (NULL == dns)
   {
     /* DNSSTUB gave up, so we trigger timeout early */
@@ -307,11 +302,11 @@ result_processor (void *cls,
     request->original_request_id = request->packet->id;
     GNUNET_DNSPARSER_free_packet (request->packet);
     request->packet = NULL;
-    request->dns_lookup = GNUNET_DNSSTUB_resolve2 (dns_stub,
-                                                  request->udp_msg,
-                                                  request->udp_msg_size,
-                                                  &dns_result_processor,
-                                                  request);
+    request->dns_lookup = GNUNET_DNSSTUB_resolve (dns_stub,
+                                                  request->udp_msg,
+                                                  request->udp_msg_size,
+                                                  &dns_result_processor,
+                                                  request);
     return;
   }
   packet = request->packet;
@@ -594,8 +589,12 @@ run (void *cls,
                                 NULL);
   if (NULL == (gns = GNUNET_GNS_connect (cfg)))
     return;
-  if (NULL == (dns_stub = GNUNET_DNSSTUB_start (dns_ip)))
+  GNUNET_assert (NULL != (dns_stub = GNUNET_DNSSTUB_start (128)));
+  if (GNUNET_OK !=
+      GNUNET_DNSSTUB_add_dns_ip (dns_stub,
+                                 dns_ip))
   {
+    GNUNET_DNSSTUB_stop (dns_stub);
     GNUNET_GNS_disconnect (gns);
     gns = NULL;
     return;