gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10436 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r10436 - gnunet/src/transport
Date: Wed, 24 Feb 2010 12:54:38 +0100

Author: nevans
Date: 2010-02-24 12:54:38 +0100 (Wed, 24 Feb 2010)
New Revision: 10436

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_udp.c
   gnunet/src/transport/plugin_transport_udp_nat.c
Log:
coverity, doxygen cleanup stuff

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-02-24 10:09:42 UTC 
(rev 10435)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-02-24 11:54:38 UTC 
(rev 10436)
@@ -1844,7 +1844,7 @@
  * @param cls closure
  * @param message the pong message
  * @param peer who responded to our challenge
- * @param sender_addr string describing our sender address (as observed
+ * @param sender_address string describing our sender address (as observed
  *         by the other peer in binary format)
  * @param sender_address_len number of bytes in 'sender_address'
  */

Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2010-02-24 10:09:42 UTC (rev 
10435)
+++ gnunet/src/transport/plugin_transport_udp.c 2010-02-24 11:54:38 UTC (rev 
10436)
@@ -557,7 +557,8 @@
  * connect to it but simply to see if the binary format is technically
  * legal for establishing a connection.
  *
- * @param addr pointer to the address, may be modified (slightly)
+ * @param cls handle to Plugin
+ * @param addr address to check
  * @param addrlen length of addr
  * @return GNUNET_OK if this is a plausible address for this peer
  *         and transport, GNUNET_SYSERR if not

Modified: gnunet/src/transport/plugin_transport_udp_nat.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp_nat.c     2010-02-24 10:09:42 UTC 
(rev 10435)
+++ gnunet/src/transport/plugin_transport_udp_nat.c     2010-02-24 11:54:38 UTC 
(rev 10436)
@@ -418,20 +418,27 @@
 
 
 /**
- * Disconnect from a remote node.
+ * Disconnect from a remote node.  Clean up session if we have one for this 
peer
  *
- * @param tsession the session that is closed
+ * @param cls closure for this call (should be handle to Plugin)
+ * @param target the peeridentity of the peer to disconnect
  * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 void
 udp_nat_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
 {
+  /** TODO: Implement! */
   return;
 }
 
 /**
  * Shutdown the server process (stop receiving inbound traffic). Maybe
  * restarted later!
+ *
+ * @param cls Handle to the plugin for this transport
+ *
+ * @return returns the number of sockets successfully closed,
+ *         should equal the number of sockets successfully opened
  */
 static int
 udp_nat_transport_server_stop (void *cls)
@@ -441,6 +448,7 @@
   int ok;
   int i;
 
+  ret = 0;
   if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
     {
       GNUNET_SCHEDULER_cancel (plugin->env->sched, plugin->select_task);
@@ -495,7 +503,7 @@
  * @param send_handle which handle to send message on
  * @param target who should receive this message (ignored by UDP)
  * @param msgbuf one or more GNUNET_MessageHeader(s) strung together
- * @param msgbufsize the size of the msgbuf to send
+ * @param msgbuf_size the size of the msgbuf to send
  * @param priority how important is the message (ignored by UDP)
  * @param timeout when should we time out (give up) if we can not transmit?
  * @param addr the addr to send the message to, needs to be a sockaddr for us
@@ -618,7 +626,7 @@
  * @param cls closure
  * @param target who should receive this message (ignored by UDP)
  * @param msgbuf one or more GNUNET_MessageHeader(s) strung together
- * @param msgbufsize the size of the msgbuf to send
+ * @param msgbuf_size the size of the msgbuf to send
  * @param priority how important is the message (ignored by UDP)
  * @param timeout when should we time out (give up) if we can not transmit?
  * @param addr the addr to send the message to, needs to be a sockaddr for us
@@ -631,7 +639,8 @@
  *        peer disconnected...)
  * @param cont_cls closure for cont
  *
- * @return the number of bytes written
+ * @return the number of bytes written (may return 0 and the message can
+ *         still be transmitted later!)
  */
 static ssize_t
 udp_nat_plugin_send (void *cls,
@@ -658,11 +667,6 @@
       other_peer_natd = GNUNET_YES;
     }
 
-  /**
-   * FIXME: find which sock in udp_nat_socks to actually send the message on,
-   * also this means creating some sort of structure to remember target to
-   * udp sock (or address, or index of udp sock array...)
-   */
   sent = 0;
 
   if (other_peer_natd == GNUNET_YES)
@@ -759,7 +763,7 @@
       v4 = (struct sockaddr_in *) addr;
       if (plugin->behind_nat == GNUNET_YES)
         {
-          inet_pton(AF_INET, plugin->external_address, &v4->sin_addr);
+          GNUNET_assert(inet_pton(AF_INET, plugin->external_address, 
&v4->sin_addr) == GNUNET_OK);
           v4->sin_port = htons (0); /* Indicates to receiver we are behind NAT 
*/
         }
       else
@@ -1007,10 +1011,14 @@
  * Demultiplexer for UDP NAT messages
  *
  * @param plugin the main plugin for this transport
- *
+ * @param sender from which peer the message was received
+ * @param currhdr pointer to the header of the message
+ * @param sender_addr the address from which the message was received
+ * @param fromlen the length of the address
+ * @param sockinfo which socket did we receive the message on
  */
 static void
-udp_nat_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity 
*sender, const struct GNUNET_MessageHeader *currhdr, struct sockaddr_storage 
*sender_addr, socklen_t fromlen,   struct UDP_Sock_Info *sockinfo)
+udp_nat_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity 
*sender, const struct GNUNET_MessageHeader *currhdr, struct sockaddr_storage 
*sender_addr, socklen_t fromlen, struct UDP_Sock_Info *sockinfo)
 {
   struct UDP_NAT_ProbeMessageReply *outgoing_probe_reply;
   struct UDP_NAT_ProbeMessageConfirmation *outgoing_probe_confirmation;
@@ -1053,7 +1061,7 @@
       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "udp-nat",
                       _("Sent PROBE REPLY to port %d on outgoing port %d\n"), 
ntohs(((struct sockaddr_in *)sender_addr)->sin_port), sockinfo->port);
 #endif
-
+      GNUNET_free(outgoing_probe_reply);
       break;
     case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_NAT_PROBE_REPLY:
       /* Check for existing probe, check ports returned, send confirmation if 
all is well */
@@ -1084,6 +1092,7 @@
                   outgoing_probe->task = GNUNET_SCHEDULER_NO_TASK;
                   /* Schedule task to timeout and remove probe if confirmation 
not received */
                 }
+              GNUNET_free(outgoing_probe_confirmation);
             }
           else
             {
@@ -1273,11 +1282,10 @@
           offset += ntohs(currhdr->size);
           count++;
         }
+      GNUNET_free_non_null (buf);
+      GNUNET_free_non_null (sender);
     }
 
-  GNUNET_free_non_null (sender);
-  GNUNET_free_non_null (buf);
-
   plugin->select_task =
     GNUNET_SCHEDULER_add_select (plugin->env->sched,
                                  GNUNET_SCHEDULER_PRIORITY_DEFAULT,
@@ -1383,29 +1391,26 @@
                 serverAddrv4.sin_port = htons 
(GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* 
Find a non-root port */
               addrlen = sizeof (serverAddrv4);
               serverAddr = (struct sockaddr *) &serverAddrv4;
-            }
-        }
-
-      if (udp_nat_socks[i]->desc != NULL)
-        {
 #if DEBUG_UDP_NAT
-          GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
-                           "udp_nat",
-                           "Binding to port %d\n", 
ntohs(serverAddrv4.sin_port));
+              GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                               "udp_nat",
+                               "Binding to port %d\n", 
ntohs(serverAddrv4.sin_port));
 #endif
-          while (GNUNET_NETWORK_socket_bind (udp_nat_socks[i]->desc, 
serverAddr, addrlen) !=
-                         GNUNET_OK)
-            {
-              serverAddrv4.sin_port = htons 
(GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* 
Find a good, non-root port */
+              while (GNUNET_NETWORK_socket_bind (udp_nat_socks[i]->desc, 
serverAddr, addrlen) !=
+                             GNUNET_OK)
+                {
+                  serverAddrv4.sin_port = htons 
(GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* 
Find a good, non-root port */
 #if DEBUG_UDP_NAT
               GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                               "udp_nat",
                               "Binding failed, trying new port %d\n", 
ntohs(serverAddrv4.sin_port));
 #endif
+                }
+              udp_nat_socks[i]->port = ntohs(serverAddrv4.sin_port);
+              sockets_created++;
             }
-          udp_nat_socks[i]->port = ntohs(serverAddrv4.sin_port);
-          sockets_created++;
         }
+
     }
 
   plugin->rs = GNUNET_NETWORK_fdset_create ();
@@ -1461,13 +1466,12 @@
  * connect to it but simply to see if the binary format is technically
  * legal for establishing a connection.
  *
+ * @param cls closure, should be our handle to the Plugin
  * @param addr pointer to the address, may be modified (slightly)
  * @param addrlen length of addr
  * @return GNUNET_OK if this is a plausible address for this peer
  *         and transport, GNUNET_SYSERR if not
  *
- * TODO: perhaps make everything work with sockaddr_storage, it may
- *       be a cleaner way to handle addresses in UDP
  */
 static int
 udp_nat_check_address (void *cls, void *addr, size_t addrlen)
@@ -1494,11 +1498,13 @@
       v4 = (struct sockaddr_in *) buf;
       v4->sin_port = htons (check_port (plugin, ntohs (v4->sin_port)));
     }
+#if IPV6
   else
     {
       v6 = (struct sockaddr_in6 *) buf;
       v6->sin6_port = htons (check_port (plugin, ntohs (v6->sin6_port)));
     }
+#endif
 #if DEBUG_UDP_NAT
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                    "udp_nat",
@@ -1647,6 +1653,7 @@
                        ("Require EXTERNAL_ADDRESS for service `%s' in 
configuration!\n"),
                        "transport-udp");
       GNUNET_SERVICE_stop (service);
+      return NULL;
     }
 
   if (GNUNET_OK !=
@@ -1661,6 +1668,8 @@
                        ("Require INTERNAL_ADDRESS for service `%s' in 
configuration!\n"),
                        "transport-udp");
       GNUNET_SERVICE_stop (service);
+      GNUNET_free_non_null(external_address);
+      return NULL;
     }
 
   if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (env->cfg,





reply via email to

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