gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36245 - in gnunet/src: include nat


From: gnunet
Subject: [GNUnet-SVN] r36245 - in gnunet/src: include nat
Date: Mon, 17 Aug 2015 03:59:44 +0200

Author: bratao
Date: 2015-08-17 03:59:44 +0200 (Mon, 17 Aug 2015)
New Revision: 36245

Modified:
   gnunet/src/include/gnunet_nat_lib.h
   gnunet/src/nat/nat.c
   gnunet/src/nat/nat_stun.c
Log:
Fix #3918

Modified: gnunet/src/include/gnunet_nat_lib.h
===================================================================
--- gnunet/src/include/gnunet_nat_lib.h 2015-08-14 15:12:59 UTC (rev 36244)
+++ gnunet/src/include/gnunet_nat_lib.h 2015-08-17 01:59:44 UTC (rev 36245)
@@ -220,7 +220,7 @@
                      GNUNET_NAT_AddressCallback address_callback,
                      GNUNET_NAT_ReversalCallback reversal_callback,
                      void *callback_cls,
-                     struct GNUNET_NETWORK_Handle* sock );
+                     struct GNUNET_NETWORK_Handle* sock);
 
 
 /**
@@ -492,7 +492,8 @@
  * @return GNUNET_NAT_STUN_Handle on success, NULL on error.
  */
 struct GNUNET_NAT_STUN_Handle *
-GNUNET_NAT_stun_make_request(char * server, int port,
+GNUNET_NAT_stun_make_request(char * server,
+                             int port,
                              struct GNUNET_NETWORK_Handle * sock, 
GNUNET_NAT_stun_RequestCallback cb,
                              void *cb_cls);
 
@@ -511,7 +512,9 @@
  * @return, 0 on IGNORE, -1 if the packet is invalid ( not a stun packet)
  */
 int
-GNUNET_NAT_stun_handle_packet(const uint8_t *data, size_t len,struct 
sockaddr_in *arg);
+GNUNET_NAT_stun_handle_packet(const void *data,
+                              size_t len,
+                              struct sockaddr_in *arg);
 
 /**
  * CHECK if is a valid STUN packet sending to GNUNET_NAT_stun_handle_packet
@@ -524,7 +527,9 @@
  * @return, 0 on IGNORE, -1 if the packet is invalid ( not a stun packet)
  */
 int
-GNUNET_NAT_try_decode_stun_packet(void *cls, const uint8_t *data, size_t len);
+GNUNET_NAT_try_decode_stun_packet(void *cls,
+                                  const void *data,
+                                  size_t len);
 
 
 

Modified: gnunet/src/nat/nat.c
===================================================================
--- gnunet/src/nat/nat.c        2015-08-14 15:12:59 UTC (rev 36244)
+++ gnunet/src/nat/nat.c        2015-08-17 01:59:44 UTC (rev 36245)
@@ -1115,9 +1115,16 @@
 
   struct GNUNET_NAT_Handle *h = cls;
 
+  if(NULL == cls)
+    return;
+
   h->waiting_stun = GNUNET_NO;
-  LOG (GNUNET_ERROR_TYPE_WARNING,
+
+  if(result != GNUNET_OK)
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
        "Error processing a STUN request");
+  }
 
 };
 
@@ -1131,7 +1138,7 @@
  * @return GNUNET_NO if it can't decode, GNUNET_YES if is a packet
  */
 int
-GNUNET_NAT_try_decode_stun_packet(void *cls, const uint8_t *data, size_t len)
+GNUNET_NAT_try_decode_stun_packet(void *cls, const void *data, size_t len)
 {
   struct GNUNET_NAT_Handle *h = cls;
   struct sockaddr_in answer;

Modified: gnunet/src/nat/nat_stun.c
===================================================================
--- gnunet/src/nat/nat_stun.c   2015-08-14 15:12:59 UTC (rev 36244)
+++ gnunet/src/nat/nat_stun.c   2015-08-17 01:59:44 UTC (rev 36245)
@@ -334,7 +334,7 @@
  * @return, GNUNET_OK on OK, GNUNET_NO if the packet is invalid ( not a stun 
packet)
  */
 int
-GNUNET_NAT_stun_handle_packet(const uint8_t *data, size_t len,struct 
sockaddr_in *arg)
+GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in 
*arg)
 {
     struct stun_header *hdr = (struct stun_header *)data;
     struct stun_attr *attr;
@@ -463,8 +463,9 @@
 
         if( GNUNET_NO == request->dns_success){
             LOG (GNUNET_ERROR_TYPE_INFO, "Empty request\n");
+            request->cb(request->cb_cls, 
GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
             clean(request);
-            request->cb(request->cb_cls, 
GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
+
         }
         return;
     }
@@ -474,8 +475,9 @@
 
         if( GNUNET_NO == request->dns_success){
             LOG (GNUNET_ERROR_TYPE_INFO, "Error resolving host %s\n", 
request->stun_server);
+            request->cb(request->cb_cls, 
GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
             clean(request);
-            request->cb(request->cb_cls, 
GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
+
         }
 
         return;
@@ -503,8 +505,8 @@
                                             (const struct sockaddr *) &server, 
sizeof (server)))
     {
         GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "Fail to sendto");
+        request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
         clean(request);
-        request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
         return;
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]