diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-29 22:26:21 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-29 22:26:21 +0100 |
commit | e871f8368c8a1f0867f68f656875e4c37c26f298 (patch) | |
tree | c2aa6a2b40213d695e8f047a51695563f44d74b8 /src/ats | |
parent | f8bccfbb602bdbed4bcc00fd3c6c3a00add82416 (diff) | |
download | gnunet-e871f8368c8a1f0867f68f656875e4c37c26f298.tar.gz gnunet-e871f8368c8a1f0867f68f656875e4c37c26f298.zip |
finish (?) libgnunetatstransport for now
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/ats_api2_transport.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/ats/ats_api2_transport.c b/src/ats/ats_api2_transport.c index 6add4baf5..5ad9fb40e 100644 --- a/src/ats/ats_api2_transport.c +++ b/src/ats/ats_api2_transport.c | |||
@@ -131,6 +131,29 @@ struct GNUNET_ATS_TransportHandle | |||
131 | }; | 131 | }; |
132 | 132 | ||
133 | 133 | ||
134 | |||
135 | /** | ||
136 | * Convert ATS properties from host to network byte order. | ||
137 | * | ||
138 | * @param nbo[OUT] value written | ||
139 | * @param hbo value read | ||
140 | */ | ||
141 | static void | ||
142 | properties_hton (struct PropertiesNBO *nbo, | ||
143 | const struct GNUNET_ATS_Properties *hbo) | ||
144 | { | ||
145 | nbo->delay = GNUNET_TIME_relative_hton (hbo->delay); | ||
146 | nbo->goodput_out = htonl (hbo->goodput_out); | ||
147 | nbo->goodput_in = htonl (hbo->goodput_in); | ||
148 | nbo->utilization_out = htonl (hbo->utilization_out); | ||
149 | nbo->utilization_in = htonl (hbo->utilization_in); | ||
150 | nbo->distance = htonl (hbo->distance); | ||
151 | nbo->mtu = htonl (hbo->mtu); | ||
152 | nbo->nt = htonl ((uint32_t) hbo->nt); | ||
153 | nbo->cc = htonl ((uint32_t) hbo->cc); | ||
154 | } | ||
155 | |||
156 | |||
134 | /** | 157 | /** |
135 | * Re-establish the connection to the ATS service. | 158 | * Re-establish the connection to the ATS service. |
136 | * | 159 | * |
@@ -250,10 +273,10 @@ match_session_cb (void *cls, | |||
250 | 273 | ||
251 | (void) pid; | 274 | (void) pid; |
252 | if (fc->session_id == sr->slot) | 275 | if (fc->session_id == sr->slot) |
253 | { | 276 | { |
254 | fc->sr = sr; | 277 | fc->sr = sr; |
255 | return GNUNET_NO; | 278 | return GNUNET_NO; |
256 | } | 279 | } |
257 | return GNUNET_YES; | 280 | return GNUNET_YES; |
258 | } | 281 | } |
259 | 282 | ||
@@ -366,8 +389,8 @@ send_add_session_message (const struct GNUNET_ATS_SessionRecord *ar) | |||
366 | : GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD); | 389 | : GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD); |
367 | m->peer = ar->pid; | 390 | m->peer = ar->pid; |
368 | m->session_id = htonl (ar->slot); | 391 | m->session_id = htonl (ar->slot); |
369 | // FIXME: convert endianess here! | 392 | properties_hton (&m->properties, |
370 | // m->properties = ar->properties; | 393 | &ar->properties); |
371 | GNUNET_memcpy (&m[1], | 394 | GNUNET_memcpy (&m[1], |
372 | ar->address, | 395 | ar->address, |
373 | alen); | 396 | alen); |
@@ -580,7 +603,7 @@ GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath, | |||
580 | alen = strlen (address) + 1; | 603 | alen = strlen (address) + 1; |
581 | ar = GNUNET_malloc (sizeof (struct GNUNET_ATS_SessionRecord) + alen); | 604 | ar = GNUNET_malloc (sizeof (struct GNUNET_ATS_SessionRecord) + alen); |
582 | ar->ath = ath; | 605 | ar->ath = ath; |
583 | ar->slot = 42; // FIXME: make up unique number! | 606 | ar->slot = s; |
584 | ar->session = session; | 607 | ar->session = session; |
585 | ar->address = (const char *) &ar[1]; | 608 | ar->address = (const char *) &ar[1]; |
586 | ar->pid = *pid; | 609 | ar->pid = *pid; |
@@ -627,8 +650,8 @@ GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar, | |||
627 | GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE); | 650 | GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE); |
628 | m->session_id = htonl (ar->slot); | 651 | m->session_id = htonl (ar->slot); |
629 | m->peer = ar->pid; | 652 | m->peer = ar->pid; |
630 | // FIXME: convert endianess here! | 653 | properties_hton (&m->properties, |
631 | // m->properties = ar->properties; | 654 | &ar->properties); |
632 | GNUNET_MQ_send (ath->mq, | 655 | GNUNET_MQ_send (ath->mq, |
633 | ev); | 656 | ev); |
634 | } | 657 | } |