gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24179 - gnunet/src/transport
Date: Thu, 4 Oct 2012 14:47:33 +0200

Author: wachs
Date: 2012-10-04 14:47:33 +0200 (Thu, 04 Oct 2012)
New Revision: 24179

Modified:
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_clients.h
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/plugin_transport_http_server.c
Log:
fix type issue

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2012-10-04 
12:28:03 UTC (rev 24178)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2012-10-04 
12:47:33 UTC (rev 24179)
@@ -974,6 +974,18 @@
   }
 }
 
+/**
+ * Tell clients how many bytes were used on the wire
+ * Can differ from payload bytes depending on plugin
+ *
+ * @param n peer
+ * @param send_phys bytes sent on the wire
+ */
+void
+GST_clients_communicate_bytes_used (const struct GNUNET_PeerIdentity *n, 
ssize_t send_phys)
+{
+  //FIXME: To be implemented
+}
 
 /**
  * Broadcast the given message to all of our clients.

Modified: gnunet/src/transport/gnunet-service-transport_clients.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.h     2012-10-04 
12:28:03 UTC (rev 24178)
+++ gnunet/src/transport/gnunet-service-transport_clients.h     2012-10-04 
12:47:33 UTC (rev 24179)
@@ -39,7 +39,17 @@
 void
 GST_clients_start (struct GNUNET_SERVER_Handle *server);
 
+/**
+ * Tell clients how many bytes were used on the wire
+ * Can differ from payload bytes depending on plugin
+ *
+ * @param n peer
+ * @param send_phys bytes sent on the wire
+ */
+void
+GST_clients_communicate_bytes_used (const struct GNUNET_PeerIdentity *n, 
ssize_t send_phys);
 
+
 /**
  * Stop processing clients.
  */

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2012-10-04 
12:28:03 UTC (rev 24178)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2012-10-04 
12:47:33 UTC (rev 24179)
@@ -924,7 +924,6 @@
   GNUNET_free (n);
 }
 
-
 /**
  * Transmit a message using the current session of the given
  * neighbour.
@@ -946,17 +945,20 @@
                   void *cont_cls)
 {
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
+  ssize_t send_phys;
 
   GNUNET_assert (n->primary_address.session != NULL);
   if ( ( (NULL == (papi = GST_plugins_find 
(n->primary_address.address->transport_name))) ||
-        (-1 == papi->send (papi->cls,
+        (-1 ==  (send_phys = papi->send (papi->cls,
                            n->primary_address.session,
                            msgbuf, msgbuf_size,
                            priority,
                            timeout,
-                           cont, cont_cls))) &&
+                           cont, cont_cls)))) &&
        (NULL != cont) )
     cont (cont_cls, &n->id, GNUNET_SYSERR);
+  if (-1 != send_phys)
+    GST_clients_communicate_bytes_used (&n->id, send_phys);
   GNUNET_break (NULL != papi);
 }
 
@@ -1520,6 +1522,7 @@
 {
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
   struct SessionConnectMessage connect_msg;
+  ssize_t send_phys;
   
   if (NULL == (papi = GST_plugins_find (na->address->transport_name)))  
   {
@@ -1538,12 +1541,14 @@
   connect_msg.header.type = htons 
(GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT);
   connect_msg.reserved = htonl (0);
   connect_msg.timestamp = GNUNET_TIME_absolute_hton (na->connect_timestamp);
-  (void) papi->send (papi->cls,
+  send_phys = papi->send (papi->cls,
                     na->session,
                     (const char *) &connect_msg, sizeof (struct 
SessionConnectMessage),
                     UINT_MAX,
                     GNUNET_TIME_UNIT_FOREVER_REL,
                     NULL, NULL);
+  if (-1 != send_phys)
+    GST_clients_communicate_bytes_used (&na->address->peer, send_phys);
 }
 
 
@@ -1561,6 +1566,7 @@
 {
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
   struct SessionConnectMessage connect_msg;
+  ssize_t send_phys;
   
   if (NULL == (papi = GST_plugins_find (address->transport_name)))  
   {
@@ -1578,12 +1584,14 @@
   connect_msg.header.type = htons 
(GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK);
   connect_msg.reserved = htonl (0);
   connect_msg.timestamp = GNUNET_TIME_absolute_hton (timestamp);
-  (void) papi->send (papi->cls,
+  send_phys = papi->send (papi->cls,
                     session,
                     (const char *) &connect_msg, sizeof (struct 
SessionConnectMessage),
                     UINT_MAX,
                     GNUNET_TIME_UNIT_FOREVER_REL,
                     NULL, NULL);
+  if (-1 != send_phys)
+    GST_clients_communicate_bytes_used (&address->peer, send_phys);
 }
 
 

Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-10-04 12:28:03 UTC 
(rev 24178)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-10-04 12:47:33 UTC 
(rev 24179)
@@ -876,6 +876,7 @@
   char * separator = NULL;
   char hash[plugin->peer_id_length+1];
   int hash_length;
+  unsigned long int ctag;
 
   /* URL parsing
    * URL is valid if it is in the form [prefix with (multiple) 
'/'][peerid[103];tag]*/
@@ -903,19 +904,26 @@
     if (debug) GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  (*tag) = strtoul (tag_start, &tag_end, 10);
-  if ((*tag) == 0)
+  ctag = strtoul (tag_start, &tag_end, 10);
+  if (ctag == 0)
   {
     /* tag == 0 , invalid */
     if (debug) GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  if (((*tag) == ULONG_MAX) && (ERANGE == errno))
+  if ((ctag == ULONG_MAX) && (ERANGE == errno))
   {
     /* out of range: > ULONG_MAX */
     if (debug) GNUNET_break (0);
     return GNUNET_SYSERR;
   }
+  if (ctag > UINT32_MAX)
+  {
+    /* out of range: > UINT32_MAX */
+    if (debug) GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+  (*tag) = (uint32_t) ctag;
   if (NULL == tag_end)
   {
       /* no char after tag */




reply via email to

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