gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r31357 - gnunet/src/transport
Date: Fri, 13 Dec 2013 14:06:08 +0100

Author: grothoff
Date: 2013-12-13 14:06:08 +0100 (Fri, 13 Dec 2013)
New Revision: 31357

Modified:
   gnunet/src/transport/plugin_transport_tcp.c
Log:
use enum GNUNET_ATS_Network_Type instead of uint32_t where appropriate

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2013-12-13 13:00:14 UTC (rev 
31356)
+++ gnunet/src/transport/plugin_transport_tcp.c 2013-12-13 13:06:08 UTC (rev 
31357)
@@ -330,7 +330,7 @@
   /**
    * ATS network type in NBO
    */
-  uint32_t ats_address_network_type;
+  enum GNUNET_ATS_Network_Type ats_address_network_type;
 };
 
 
@@ -806,7 +806,8 @@
  * @return new session object
  */
 static struct Session *
-create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity 
*target,
+create_session (struct Plugin *plugin,
+                const struct GNUNET_PeerIdentity *target,
                 struct GNUNET_SERVER_Client *client, int is_nat)
 {
   struct Session *session;
@@ -821,14 +822,14 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Creating new session for peer `%4s'\n",
        GNUNET_i2s (target));
-  session = GNUNET_malloc (sizeof (struct Session));
+  session = GNUNET_new (struct Session);
   session->last_activity = GNUNET_TIME_absolute_get ();
   session->plugin = plugin;
   session->is_nat = is_nat;
   session->client = client;
   session->target = *target;
   session->expecting_welcome = GNUNET_YES;
-  session->ats_address_network_type = htonl (GNUNET_ATS_NET_UNSPECIFIED);
+  session->ats_address_network_type = GNUNET_ATS_NET_UNSPECIFIED;
   pm = GNUNET_malloc (sizeof (struct PendingMessage) +
                       sizeof (struct WelcomeMessage));
   pm->msg = (const char *) &pm[1];
@@ -1443,7 +1444,7 @@
     return NULL;
   }
 
-  ats = plugin->env->get_address_type (plugin->env->cls, sb ,sbs);
+  ats = plugin->env->get_address_type (plugin->env->cls, sb, sbs);
 
   if ((is_natd == GNUNET_YES) && (addrlen == sizeof (struct IPv6TcpAddress)))
   {
@@ -1473,10 +1474,15 @@
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Found valid IPv4 NAT address (creating session)!\n") ;
-    session = create_session (plugin, &address->peer, NULL, GNUNET_YES);
+    session = create_session (plugin,
+                              &address->peer,
+                              NULL,
+                              GNUNET_YES);
     session->addrlen = 0;
     session->addr = NULL;
-    session->ats_address_network_type = ats.value;
+    session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl 
(ats.value)
+;
+    GNUNET_break (session->ats_address_network_type != 
GNUNET_ATS_NET_UNSPECIFIED);
     session->nat_connection_timeout = GNUNET_SCHEDULER_add_delayed 
(NAT_TIMEOUT,
                                                                    
&nat_connect_timeout,
                                                                    session);
@@ -1528,8 +1534,8 @@
   session->addr = GNUNET_malloc (addrlen);
   memcpy (session->addr, address->address, addrlen);
   session->addrlen = addrlen;
-  session->ats_address_network_type = ats.value;
-
+  session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl 
(ats.value);
+  GNUNET_break (session->ats_address_network_type != 
GNUNET_ATS_NET_UNSPECIFIED);
   GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
                                     &session->target,
                                     session, 
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -2118,7 +2124,7 @@
       if (alen == sizeof (struct sockaddr_in))
       {
         s4 = vaddr;
-        t4 = GNUNET_malloc (sizeof (struct IPv4TcpAddress));
+        t4 = GNUNET_new (struct IPv4TcpAddress);
         t4->options = htonl (0);
         t4->t4_port = s4->sin_port;
         t4->ipv4_addr = s4->sin_addr.s_addr;
@@ -2128,7 +2134,7 @@
       else if (alen == sizeof (struct sockaddr_in6))
       {
         s6 = vaddr;
-        t6 = GNUNET_malloc (sizeof (struct IPv6TcpAddress));
+        t6 = GNUNET_new (struct IPv6TcpAddress);
         t6->options = htonl (0);
         t6->t6_port = s6->sin6_port;
         memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr));
@@ -2137,11 +2143,11 @@
       }
 
       ats = plugin->env->get_address_type (plugin->env->cls, vaddr ,alen);
-      session->ats_address_network_type = ats.value;
+      session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl 
(ats.value);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-     "Creating new session %p for peer `%s'\n",
-     session,
-     GNUNET_a2s (vaddr, alen));
+           "Creating new session %p for peer `%s'\n",
+           session,
+           GNUNET_a2s (vaddr, alen));
       GNUNET_free (vaddr);
       GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
                                       &session->target,
@@ -2277,8 +2283,8 @@
   struct GNUNET_ATS_Information distance;
 
   distance.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-  distance.value = session->ats_address_network_type;
-  GNUNET_break (ntohl(session->ats_address_network_type) != 
GNUNET_ATS_NET_UNSPECIFIED);
+  distance.value = htonl ((uint32_t) session->ats_address_network_type);
+  GNUNET_break (session->ats_address_network_type != 
GNUNET_ATS_NET_UNSPECIFIED);
 
   GNUNET_assert (GNUNET_CONTAINER_multipeermap_contains_value 
(plugin->sessionmap,
                                                               &session->target,
@@ -2535,7 +2541,7 @@
                 struct Session *session)
 {
   GNUNET_assert (NULL != session);
-  return ntohl (session->ats_address_network_type);
+  return session->ats_address_network_type;
 }
 
 




reply via email to

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