gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13827 - gnunet/src/transport
Date: Tue, 30 Nov 2010 11:16:43 +0100

Author: wachs
Date: 2010-11-30 11:16:43 +0100 (Tue, 30 Nov 2010)
New Revision: 13827

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/transport_api.c
Log:
Transmitting ATS information to transport api


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-11-29 23:25:09 UTC 
(rev 13826)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-11-30 10:16:43 UTC 
(rev 13827)
@@ -3383,10 +3383,12 @@
  *
  * @param message the payload
  * @param n peer who claimed to be the sender
+ * @param ats ATS information
+ * @param ats_count numbers of elements following the ats struct (excluding 
the 0-terminator)
  */
 static void
 handle_payload_message (const struct GNUNET_MessageHeader *message,
-                       struct NeighbourList *n)
+                       struct NeighbourList *n, struct 
GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
 {
   struct InboundMessage *im;
   struct TransportClient *cpos;
@@ -3441,14 +3443,23 @@
                            gettext_noop ("# payload received from other 
peers"),
                            msize,
                            GNUNET_NO);
+
   /* transmit message to all clients */
-  im = GNUNET_malloc (sizeof (struct InboundMessage) + msize);
-  im->header.size = htons (sizeof (struct InboundMessage) + msize);
+  im = GNUNET_malloc (sizeof (struct InboundMessage) + ats_count * 
sizeof(struct GNUNET_TRANSPORT_ATS_Information) + msize);
+  im->header.size = htons (sizeof (struct InboundMessage) +  ats_count * 
sizeof(struct GNUNET_TRANSPORT_ATS_Information) + msize);
   im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
   im->latency = GNUNET_TIME_relative_hton (n->latency);
   im->peer = n->id;
   im->distance = ntohl(n->distance);
-  memcpy (&im[1], message, msize);
+  im->ats_count = htonl(ats_count);
+  /* insert ATS elements */
+  memcpy (&(im->ats), ats, ats_count * sizeof(struct 
GNUNET_TRANSPORT_ATS_Information));
+  /* insert ATS terminator */
+  (&im->ats)[ats_count].type  = htonl(0);
+  (&im->ats)[ats_count].value = htonl(0);
+  /* insert msg after terminator */
+  memcpy (&(&im->ats)[ats_count+1], message, msize);
+
   cpos = clients;
   while (cpos != NULL)
     {
@@ -3669,7 +3680,8 @@
          if (NULL != (prem = n->pre_connect_message_buffer))
            {
              n->pre_connect_message_buffer = NULL;
-             handle_payload_message (prem, n);
+             /* FIXME: */
+             handle_payload_message (prem, n, NULL, 0);
              GNUNET_free (prem);
            }
        }
@@ -4759,7 +4771,7 @@
          handle_pong (plugin, message, peer, sender_address, 
sender_address_len);
          break;
        default:
-         handle_payload_message (message, n);
+         handle_payload_message (message, n, NULL, 0);
          break;
        }
     }

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2010-11-29 23:25:09 UTC (rev 
13826)
+++ gnunet/src/transport/transport_api.c        2010-11-30 10:16:43 UTC (rev 
13827)
@@ -1661,8 +1661,9 @@
         }
       im = (const struct InboundMessage *) msg;
       GNUNET_break (0 == ntohl (im->reserved));
-      imm = (const struct GNUNET_MessageHeader *) &im[1];
-      if (ntohs (imm->size) + sizeof (struct InboundMessage) != size)
+      GNUNET_assert(sizeof (struct InboundMessage) + ntohl(im->ats_count) * 
sizeof(struct GNUNET_TRANSPORT_ATS_Information) + sizeof (struct 
GNUNET_MessageHeader) <= size);
+      imm = (const struct GNUNET_MessageHeader *) 
&((&im->ats)[ntohl(im->ats_count)+1]);
+      if (ntohs (imm->size) + sizeof (struct InboundMessage) + 
ntohl(im->ats_count) * sizeof(struct GNUNET_TRANSPORT_ATS_Information) != size)
         {
           GNUNET_break (0);
           break;




reply via email to

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