gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17966 - gnunet/src/transport
Date: Thu, 3 Nov 2011 16:00:26 +0100

Author: grothoff
Date: 2011-11-03 16:00:26 +0100 (Thu, 03 Nov 2011)
New Revision: 17966

Modified:
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_clients.h
   gnunet/src/transport/transport.h
   gnunet/src/transport/transport_api.c
Log:
fix 1821: only send payload to transport clients that care

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2011-11-03 
14:55:09 UTC (rev 17965)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2011-11-03 
15:00:26 UTC (rev 17966)
@@ -108,6 +108,11 @@
    * Length of the list of messages pending for this client.
    */
   unsigned int message_count;
+
+  /**
+   * Is this client interested in payload messages?
+   */
+  int send_payload;
 };
 
 
@@ -370,6 +375,7 @@
 {
   const struct StartMessage *start;
   struct TransportClient *tc;
+  uint32_t options;
 
   tc = lookup_client (client);
 
@@ -394,10 +400,11 @@
     return;
   }
   start = (const struct StartMessage *) message;
-  if ((GNUNET_NO != ntohl (start->do_check)) &&
+  options = ntohl (start->options);
+  if ((0 != (1 & options) ) &&
       (0 !=
        memcmp (&start->self, &GST_my_identity,
-               sizeof (struct GNUNET_PeerIdentity))))
+              sizeof (struct GNUNET_PeerIdentity))))
   {
     /* client thinks this is a different peer, reject */
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -408,7 +415,7 @@
     return;
   }
   tc = setup_client (client);
-
+  tc->send_payload = (0 != (2 & options));
   unicast (tc, GST_hello_get (), GNUNET_NO);
   GST_neighbours_iterate (&notify_client_about_neighbour, tc);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -892,7 +899,7 @@
  * Broadcast the given message to all of our clients.
  *
  * @param msg message to broadcast
- * @param may_drop GNUNET_YES if the message can be dropped
+ * @param may_drop GNUNET_YES if the message can be dropped / is payload
  */
 void
 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
@@ -900,7 +907,12 @@
   struct TransportClient *tc;
 
   for (tc = clients_head; tc != NULL; tc = tc->next)
+  {
+    if ( (GNUNET_YES == may_drop) &&
+        (GNUNET_YES != tc->send_payload) )
+      continue; /* skip, this client does not care about payload */
     unicast (tc, msg, may_drop);
+  }
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_clients.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.h     2011-11-03 
14:55:09 UTC (rev 17965)
+++ gnunet/src/transport/gnunet-service-transport_clients.h     2011-11-03 
15:00:26 UTC (rev 17966)
@@ -50,7 +50,7 @@
  * Broadcast the given message to all of our clients.
  *
  * @param msg message to broadcast
- * @param may_drop GNUNET_YES if the message can be dropped
+ * @param may_drop GNUNET_YES if the message can be dropped / is payload
  */
 void
 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop);

Modified: gnunet/src/transport/transport.h
===================================================================
--- gnunet/src/transport/transport.h    2011-11-03 14:55:09 UTC (rev 17965)
+++ gnunet/src/transport/transport.h    2011-11-03 15:00:26 UTC (rev 17966)
@@ -75,9 +75,11 @@
   struct GNUNET_MessageHeader header;
 
   /**
-   * Should the 'self' field be checked?
+   * 0: no options
+   * 1: The 'self' field should be checked
+   * 2: this client is interested in payload traffic
    */
-  uint32_t do_check;
+  uint32_t options;
 
   /**
    * Identity we think we have.  If it does not match, the

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2011-11-03 14:55:09 UTC (rev 
17965)
+++ gnunet/src/transport/transport_api.c        2011-11-03 15:00:26 UTC (rev 
17966)
@@ -861,6 +861,7 @@
 {
   struct GNUNET_TRANSPORT_Handle *h = cls;
   struct StartMessage s;
+  uint32_t options;
 
   if (buf == NULL)
   {
@@ -877,7 +878,12 @@
   GNUNET_assert (size >= sizeof (struct StartMessage));
   s.header.size = htons (sizeof (struct StartMessage));
   s.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_START);
-  s.do_check = htonl (h->check_self);
+  options = 0;
+  if (h->check_self)
+    options |= 1;
+  if (h->rec != NULL)
+    options |= 2;
+  s.options = htonl (options);
   s.self = h->self;
   memcpy (buf, &s, sizeof (struct StartMessage));
   GNUNET_CLIENT_receive (h->client, &demultiplexer, h,




reply via email to

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