REST: nothing triggers rest
[oweals/gnunet.git] / src / ats / ats_api2_transport.c
index 6add4baf50fb235e4c033bd75d8926a7219ffaf5..e73b2daa87d7b08bb3f1e7961bba76bb53e5bc76 100644 (file)
@@ -14,6 +14,8 @@
 
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 /**
  * @file ats/ats_api2_transport.c
@@ -131,6 +133,29 @@ struct GNUNET_ATS_TransportHandle
 };
 
 
+
+/**
+ * Convert ATS properties from host to network byte order.
+ *
+ * @param nbo[OUT] value written
+ * @param hbo value read
+ */
+static void
+properties_hton (struct PropertiesNBO *nbo,
+                 const struct GNUNET_ATS_Properties *hbo)
+{
+  nbo->delay = GNUNET_TIME_relative_hton (hbo->delay);
+  nbo->goodput_out = htonl (hbo->goodput_out);
+  nbo->goodput_in = htonl (hbo->goodput_in);
+  nbo->utilization_out = htonl (hbo->utilization_out);
+  nbo->utilization_in = htonl (hbo->utilization_in);
+  nbo->distance = htonl (hbo->distance);
+  nbo->mtu = htonl (hbo->mtu);
+  nbo->nt = htonl ((uint32_t) hbo->nt);
+  nbo->cc = htonl ((uint32_t) hbo->cc);
+}
+
+
 /**
  * Re-establish the connection to the ATS service.
  *
@@ -250,10 +275,10 @@ match_session_cb (void *cls,
 
   (void) pid;
   if (fc->session_id == sr->slot)
-    {
-      fc->sr = sr;
-      return GNUNET_NO;
-    }
+  {
+    fc->sr = sr;
+    return GNUNET_NO;
+  }
   return GNUNET_YES;
 }
 
@@ -366,8 +391,8 @@ send_add_session_message (const struct GNUNET_ATS_SessionRecord *ar)
                             : GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD);
   m->peer = ar->pid;
   m->session_id = htonl (ar->slot);
-  // FIXME: convert endianess here!
-  // m->properties = ar->properties;
+  properties_hton (&m->properties,
+                   &ar->properties);
   GNUNET_memcpy (&m[1],
                  ar->address,
                  alen);
@@ -580,7 +605,7 @@ GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath,
   alen = strlen (address) + 1;
   ar = GNUNET_malloc (sizeof (struct GNUNET_ATS_SessionRecord) + alen);
   ar->ath = ath;
-  ar->slot = 42; // FIXME: make up unique number!
+  ar->slot = s;
   ar->session = session;
   ar->address = (const char *) &ar[1];
   ar->pid = *pid;
@@ -627,8 +652,8 @@ GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar,
                       GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE);
   m->session_id = htonl (ar->slot);
   m->peer = ar->pid;
-  // FIXME: convert endianess here!
-  // m->properties = ar->properties;
+  properties_hton (&m->properties,
+                   &ar->properties);
   GNUNET_MQ_send (ath->mq,
                   ev);
 }