fix #4546
[oweals/gnunet.git] / src / nat / nat_stun.c
index e97b0016b097f1b938bb2f0a6d66e509b17ed73e..4aa9094ea37d1733aea4a01c588f391687c70f02 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009, 2015 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009, 2015 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
@@ -322,8 +322,8 @@ stun_get_mapped (struct StunState *st,
  * If a callback is specified, invoke it with the attribute.
  *
  * @param data the packet
- * @param len the length of the packet
- * @param arg sockaddr_in where we will set our discovered packet
+ * @param len the length of the packet in @a data
+ * @param[out] arg sockaddr_in where we will set our discovered address
  *
  * @return, #GNUNET_OK on OK, #GNUNET_NO if the packet is invalid (not a stun packet)
  */
@@ -361,7 +361,7 @@ GNUNET_NAT_stun_handle_packet (const void *data,
 
   message_magic_cookie = ntohl(hdr->magic);
   /* Compare if the cookie match */
-  if(STUN_MAGIC_COOKIE != message_magic_cookie)
+  if (STUN_MAGIC_COOKIE != message_magic_cookie)
   {
     LOG (GNUNET_ERROR_TYPE_INFO,
          "Invalid magic cookie \n");
@@ -382,7 +382,7 @@ GNUNET_NAT_stun_handle_packet (const void *data,
     return GNUNET_NO;
   }
   len = advertised_message_size;
-  memset (&st,0, sizeof(st));
+  memset (&st, 0, sizeof(st));
 
   while (len > 0)
   {
@@ -408,7 +408,10 @@ GNUNET_NAT_stun_handle_packet (const void *data,
            (int)len);
       break;
     }
-    stun_get_mapped (&st, attr, arg, hdr->magic);
+    stun_get_mapped (&st,
+                     attr,
+                     arg,
+                     hdr->magic);
     /* Clear attribute id: in case previous entry was a string,
      * this will act as the terminator for the string.
      */
@@ -508,6 +511,7 @@ stun_dns_callback (void *cls,
   /* sending STUN request done, let's wait for replies... */
   rh->cb (rh->cb_cls,
           GNUNET_NAT_ERROR_SUCCESS);
+  GNUNET_NAT_stun_make_request_cancel (rh);
 }