gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34964 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r34964 - gnunet/src/ats
Date: Thu, 22 Jan 2015 22:43:13 +0100

Author: grothoff
Date: 2015-01-22 22:43:13 +0100 (Thu, 22 Jan 2015)
New Revision: 34964

Modified:
   gnunet/src/ats/ats.h
   gnunet/src/ats/ats_api_scheduling.c
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_scheduling.c
   gnunet/src/ats/gnunet-service-ats_scheduling.h
Log:
also simplify message format for AddressSuggestionMessage

Modified: gnunet/src/ats/ats.h
===================================================================
--- gnunet/src/ats/ats.h        2015-01-22 21:34:47 UTC (rev 34963)
+++ gnunet/src/ats/ats.h        2015-01-22 21:43:13 UTC (rev 34964)
@@ -219,32 +219,41 @@
 };
 
 
+/**
+ * ATS Service suggests to the transport service to use the address
+ * identified by the given @e session_id for the given @e peer with
+ * the given @e bandwidth_in and @e bandwidth_out limits from now on.
+ */
 struct AddressSuggestionMessage
 {
+  /**
+   * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
+   */
   struct GNUNET_MessageHeader header;
 
-  uint32_t ats_count GNUNET_PACKED;
+  /**
+   * Internal number this client uses to refer to the address this
+   * suggestion is about.
+   */
+  uint32_t session_id GNUNET_PACKED;
 
+  /**
+   * Which peer is this about? (Technically redundant, as the
+   * @e session_id should be sufficient, but may enable client
+   * to find the session faster and/or check consistency).
+   */
   struct GNUNET_PeerIdentity peer;
 
-  uint16_t address_length GNUNET_PACKED;
-
-  uint16_t plugin_name_length GNUNET_PACKED;
-
-  uint32_t session_id GNUNET_PACKED;
-
-  uint32_t address_local_info GNUNET_PACKED;
-
+  /**
+   * How much bandwidth we are allowed for sending.
+   */
   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
 
+  /**
+   * How much bandwidth we are allowed for receiving.
+   */
   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
 
-  /* followed by:
-   * - struct GNUNET_ATS_Information [ats_count];
-   * - char address[address_length]
-   * - char plugin_name[plugin_name_length] (including '\0'-termination).
-   */
-
 };
 
 

Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2015-01-22 21:34:47 UTC (rev 34963)
+++ gnunet/src/ats/ats_api_scheduling.c 2015-01-22 21:43:13 UTC (rev 34964)
@@ -448,44 +448,11 @@
 {
   struct GNUNET_ATS_SchedulingHandle *sh = cls;
   const struct AddressSuggestionMessage *m;
-  const struct GNUNET_ATS_Information *atsi;
-  const char *plugin_address;
-  const char *plugin_name;
-  uint16_t plugin_address_length;
-  uint16_t plugin_name_length;
-  uint32_t ats_count;
-  struct GNUNET_HELLO_Address address;
-  struct Session *s;
   struct GNUNET_ATS_AddressRecord *ar;
+  uint32_t session_id;
 
-  if (ntohs (msg->size) <= sizeof (struct AddressSuggestionMessage))
-  {
-    GNUNET_break (0);
-    force_reconnect (sh);
-    return;
-  }
-  /* FIXME: we have all the address details, no need for ATS
-     to send those back to us any longer! */
   m = (const struct AddressSuggestionMessage *) msg;
-  ats_count = ntohl (m->ats_count);
-  plugin_address_length = ntohs (m->address_length);
-  atsi = (const struct GNUNET_ATS_Information *) &m[1];
-  plugin_address = (const char *) &atsi[ats_count];
-  plugin_name = &plugin_address[plugin_address_length];
-  plugin_name_length = ntohs (m->plugin_name_length);
-  if ((plugin_address_length + plugin_name_length +
-       ats_count * sizeof (struct GNUNET_ATS_Information) +
-       sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) ||
-      (ats_count >
-       GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
-      || (plugin_name[plugin_name_length - 1] != '\0'))
-  {
-    GNUNET_break (0);
-    force_reconnect (sh);
-    return;
-  }
-  uint32_t session_id = ntohl (m->session_id);
-
+  session_id = ntohl (m->session_id);
   if (0 == session_id)
   {
     GNUNET_break (0);
@@ -499,7 +466,6 @@
     force_reconnect (sh);
     return;
   }
-  s = ar->session;
   if (NULL == sh->suggest_cb)
     return;
   if ( (GNUNET_YES == ar->in_destroy) &&
@@ -509,27 +475,17 @@
     /* ignore suggestion, as this address is dying */
     return;
   }
-  address.peer = m->peer;
-  address.address = plugin_address;
-  address.address_length = plugin_address_length;
-  address.transport_name = plugin_name;
-  address.local_info = ntohl(m->address_local_info);
-
-  if ((s == NULL) && (0 == address.address_length))
+  if ( (NULL == ar->session) &&
+       (GNUNET_HELLO_address_check_option (ar->address,
+                                           GNUNET_HELLO_ADDRESS_INFO_INBOUND)) 
)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "ATS returned invalid address for peer `%s' transport `%s' 
address length %i, session_id %i\n",
-                GNUNET_i2s (&address.peer),
-                address.transport_name,
-                plugin_address_length,
-                session_id);
-    GNUNET_break_op (0);
+    GNUNET_break (0);
     return;
   }
   sh->suggest_cb (sh->suggest_cb_cls,
                   &m->peer,
-                  &address,
-                  s,
+                  ar->address,
+                  ar->session,
                   m->bandwidth_out,
                   m->bandwidth_in);
 }
@@ -625,7 +581,7 @@
         sizeof (struct SessionReleaseMessage) },
       { &process_ats_address_suggestion_message,
         GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION,
-        0 },
+        sizeof (struct AddressSuggestionMessage) },
       { NULL, 0, 0 } };
   struct GNUNET_MQ_Envelope *ev;
   struct ClientStartMessage *init;

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2015-01-22 21:34:47 UTC 
(rev 34963)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2015-01-22 21:43:13 UTC 
(rev 34964)
@@ -1244,10 +1244,10 @@
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Suggesting address %p for peer `%s'\n",
       aa, GNUNET_i2s (peer));
 
-  GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr,
-      aa->addr_len, aa->local_address_info, aa->session_id, aa->atsi,
-      aa->atsi_count, GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out),
-      GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in));
+  GAS_scheduling_transmit_address_suggestion (peer,
+                                              aa->session_id,
+                                              GNUNET_BANDWIDTH_value_init 
(aa->assigned_bw_out),
+                                              GNUNET_BANDWIDTH_value_init 
(aa->assigned_bw_in));
 
   aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval,
       ATS_BLOCKING_DELTA);
@@ -1767,13 +1767,11 @@
                "Telling transport to disconnect peer `%s'\n",
                 GNUNET_i2s (&address->peer));
 
-    /* *Notify scheduling clients about suggestion */
-    GAS_scheduling_transmit_address_suggestion (&address->peer, 
address->plugin,
-        address->addr, address->addr_len, address->local_address_info,
-        address->session_id, address->atsi, address->atsi_count,
-        GNUNET_BANDWIDTH_value_init (0),
-        GNUNET_BANDWIDTH_value_init (0));
-
+    /* Notify scheduling clients about suggestion */
+    GAS_scheduling_transmit_address_suggestion (&address->peer,
+                                                address->session_id,
+                                                GNUNET_BANDWIDTH_value_init 
(0),
+                                                GNUNET_BANDWIDTH_value_init 
(0));
     return;
   }
 
@@ -1791,11 +1789,10 @@
       address->assigned_bw_out);
 
   /* *Notify scheduling clients about suggestion */
-  GAS_scheduling_transmit_address_suggestion (&address->peer, address->plugin,
-      address->addr, address->addr_len, address->local_address_info,
-      address->session_id, address->atsi, address->atsi_count,
-      GNUNET_BANDWIDTH_value_init (address->assigned_bw_out),
-      GNUNET_BANDWIDTH_value_init (address->assigned_bw_in));
+  GAS_scheduling_transmit_address_suggestion (&address->peer,
+                                              address->session_id,
+                                              GNUNET_BANDWIDTH_value_init 
(address->assigned_bw_out),
+                                              GNUNET_BANDWIDTH_value_init 
(address->assigned_bw_in));
 
   address->last_notified_bw_out = address->assigned_bw_out;
   address->last_notified_bw_in = address->assigned_bw_in;

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-01-22 21:34:47 UTC 
(rev 34963)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-01-22 21:43:13 UTC 
(rev 34964)
@@ -89,70 +89,37 @@
  * clients.
  *
  * @param peer peer for which this is an address suggestion
- * @param plugin_name 0-termintated string specifying the transport plugin
- * @param plugin_addr binary address for the plugin to use
- * @param plugin_addr_len number of bytes in @a plugin_addr
- * @param local_address_info the local address for the address
  * @param session_id session ID to use for the given client
- * @param atsi performance data for the address
- * @param atsi_count number of performance records in @a atsi
  * @param bandwidth_out assigned outbound bandwidth
  * @param bandwidth_in assigned inbound bandwidth
  */
 void
 GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity 
*peer,
-                                            const char *plugin_name,
-                                            const void *plugin_addr,
-                                            size_t plugin_addr_len,
-                                            uint32_t local_address_info,
                                             uint32_t session_id,
-                                            const struct 
GNUNET_ATS_Information *atsi,
-                                            uint32_t atsi_count,
                                             struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
                                             struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in)
 {
-  struct AddressSuggestionMessage *msg;
-  size_t plugin_name_length = strlen (plugin_name) + 1;
-  size_t msize =
-      sizeof (struct AddressSuggestionMessage) +
-      atsi_count * sizeof (struct GNUNET_ATS_Information) + plugin_addr_len +
-      plugin_name_length;
-  char buf[msize] GNUNET_ALIGN;
-  struct GNUNET_ATS_Information *atsp;
-  char *addrp;
+  struct AddressSuggestionMessage msg;
 
-  if (my_client == NULL)
+  if (NULL == my_client)
     return;
-  GNUNET_STATISTICS_update (GSA_stats, "# address suggestions made", 1,
+  GNUNET_STATISTICS_update (GSA_stats,
+                            "# address suggestions made", 1,
                             GNUNET_NO);
-  GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
-  GNUNET_assert (atsi_count <
-                 GNUNET_SERVER_MAX_MESSAGE_SIZE /
-                 sizeof (struct GNUNET_ATS_Information));
-  msg = (struct AddressSuggestionMessage *) buf;
-  msg->header.size = htons (msize);
-  msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
-  msg->ats_count = htonl (atsi_count);
-  msg->peer = *peer;
-  msg->address_length = htons (plugin_addr_len);
-  msg->plugin_name_length = htons (plugin_name_length);
-  msg->address_local_info = htonl (local_address_info);
-  msg->session_id = htonl (session_id);
-  msg->bandwidth_out = bandwidth_out;
-  msg->bandwidth_in = bandwidth_in;
-  atsp = (struct GNUNET_ATS_Information *) &msg[1];
-  memcpy (atsp, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
-  addrp = (char *) &atsp[atsi_count];
-  memcpy (addrp, plugin_addr, plugin_addr_len);
-  strcpy (&addrp[plugin_addr_len], plugin_name);
-
+  msg.header.size = htons (sizeof (struct AddressSuggestionMessage));
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
+  msg.peer = *peer;
+  msg.session_id = htonl (session_id);
+  msg.bandwidth_out = bandwidth_out;
+  msg.bandwidth_in = bandwidth_in;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "ATS sends quota for peer `%s': (in/out) %u/%u\n",
               GNUNET_i2s (peer),
               (unsigned int) ntohl (bandwidth_in.value__),
               (unsigned int) ntohl (bandwidth_out.value__));
-
-  GNUNET_SERVER_notification_context_unicast (nc, my_client, &msg->header,
+  GNUNET_SERVER_notification_context_unicast (nc,
+                                              my_client,
+                                              &msg.header,
                                               GNUNET_YES);
 }
 

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.h      2015-01-22 21:34:47 UTC 
(rev 34963)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.h      2015-01-22 21:43:13 UTC 
(rev 34964)
@@ -68,25 +68,13 @@
  * clients.
  *
  * @param peer peer for which this is an address suggestion
- * @param plugin_name 0-termintated string specifying the transport plugin
- * @param plugin_addr binary address for the plugin to use
- * @param plugin_addr_len number of bytes in @a plugin_addr
  * @param session_id session ID to use
- * @param local_address_info the local address for the address
- * @param atsi performance data for the address
- * @param atsi_count number of performance records in @a atsi
  * @param bandwidth_out assigned outbound bandwidth
  * @param bandwidth_in assigned inbound bandwidth
  */
 void
 GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity 
*peer,
-                                            const char *plugin_name,
-                                            const void *plugin_addr,
-                                            size_t plugin_addr_len,
-                                            uint32_t local_address_info,
                                             uint32_t session_id,
-                                            const struct 
GNUNET_ATS_Information *atsi,
-                                            uint32_t atsi_count,
                                             struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
                                             struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in);
 




reply via email to

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