aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-22 21:59:27 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-22 21:59:27 +0000
commitf44c0036572d5557d2496748a4190a61e40e61ff (patch)
treebceb908e8542883ed246f96b4c619c0c49a06782 /src/fs
parent9d87d51965287d83ee332b8c50baff95bd62649a (diff)
downloadgnunet-f44c0036572d5557d2496748a4190a61e40e61ff.tar.gz
gnunet-f44c0036572d5557d2496748a4190a61e40e61ff.zip
replacing 0-terminated atsi-array with array+length in core API (and the core-connect IPC)
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-service-fs.c14
-rw-r--r--src/fs/gnunet-service-fs_cp.c43
-rw-r--r--src/fs/gnunet-service-fs_cp.h8
3 files changed, 38 insertions, 27 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 6ea47c2e2..c5933d989 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -220,13 +220,15 @@ GSF_test_get_load_too_high_ (uint32_t priority)
220 * for loopback messages where we are both sender and receiver) 220 * for loopback messages where we are both sender and receiver)
221 * @param message the actual message 221 * @param message the actual message
222 * @param atsi performance information 222 * @param atsi performance information
223 * @param atsi_count number of records in 'atsi'
223 * @return GNUNET_OK to keep the connection open, 224 * @return GNUNET_OK to keep the connection open,
224 * GNUNET_SYSERR to close it (signal serious error) 225 * GNUNET_SYSERR to close it (signal serious error)
225 */ 226 */
226static int 227static int
227handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other, 228handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other,
228 const struct GNUNET_MessageHeader *message, 229 const struct GNUNET_MessageHeader *message,
229 const struct GNUNET_ATS_Information *atsi) 230 const struct GNUNET_ATS_Information *atsi,
231 unsigned int atsi_count)
230{ 232{
231 struct GSF_ConnectedPeer *cp; 233 struct GSF_ConnectedPeer *cp;
232 234
@@ -299,13 +301,15 @@ consider_forwarding (void *cls, struct GSF_PendingRequest *pr,
299 * for loopback messages where we are both sender and receiver) 301 * for loopback messages where we are both sender and receiver)
300 * @param message the actual message 302 * @param message the actual message
301 * @param atsi performance information 303 * @param atsi performance information
304 * @param atsi_count number of records in 'atsi'
302 * @return GNUNET_OK to keep the connection open, 305 * @return GNUNET_OK to keep the connection open,
303 * GNUNET_SYSERR to close it (signal serious error) 306 * GNUNET_SYSERR to close it (signal serious error)
304 */ 307 */
305static int 308static int
306handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other, 309handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other,
307 const struct GNUNET_MessageHeader *message, 310 const struct GNUNET_MessageHeader *message,
308 const struct GNUNET_ATS_Information *atsi) 311 const struct GNUNET_ATS_Information *atsi,
312 unsigned int atsi_count)
309{ 313{
310 struct GSF_PendingRequest *pr; 314 struct GSF_PendingRequest *pr;
311 315
@@ -456,16 +460,18 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key,
456 * @param cls closure, not used 460 * @param cls closure, not used
457 * @param peer peer identity this notification is about 461 * @param peer peer identity this notification is about
458 * @param atsi performance information 462 * @param atsi performance information
463 * @param atsi_count number of records in 'atsi'
459 */ 464 */
460static void 465static void
461peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, 466peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
462 const struct GNUNET_ATS_Information *atsi) 467 const struct GNUNET_ATS_Information *atsi,
468 unsigned int atsi_count)
463{ 469{
464 struct GSF_ConnectedPeer *cp; 470 struct GSF_ConnectedPeer *cp;
465 471
466 if (0 == memcmp (&my_id, peer, sizeof (struct GNUNET_PeerIdentity))) 472 if (0 == memcmp (&my_id, peer, sizeof (struct GNUNET_PeerIdentity)))
467 return; 473 return;
468 cp = GSF_peer_connect_handler_ (peer, atsi); 474 cp = GSF_peer_connect_handler_ (peer, atsi, atsi_count);
469 if (NULL == cp) 475 if (NULL == cp)
470 return; 476 return;
471 GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, cp); 477 GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, cp);
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index b9302e645..fc9c44785 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -328,25 +328,20 @@ get_trust_filename (const struct GNUNET_PeerIdentity *id)
328 * Find latency information in 'atsi'. 328 * Find latency information in 'atsi'.
329 * 329 *
330 * @param atsi performance data 330 * @param atsi performance data
331 * @param atsi_count number of records in 'atsi'
331 * @return connection latency 332 * @return connection latency
332 */ 333 */
333static struct GNUNET_TIME_Relative 334static struct GNUNET_TIME_Relative
334get_latency (const struct GNUNET_ATS_Information *atsi) 335get_latency (const struct GNUNET_ATS_Information *atsi,
336 unsigned int atsi_count)
335{ 337{
336 if (atsi == NULL) 338 unsigned int i;
337 return GNUNET_TIME_UNIT_SECONDS; 339
338 while ((ntohl (atsi->type) != GNUNET_ATS_ARRAY_TERMINATOR) && 340 for (i=0;i<atsi_count;i++)
339 (ntohl (atsi->type) != GNUNET_ATS_QUALITY_NET_DELAY)) 341 if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DELAY)
340 atsi++; 342 return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
341 if (ntohl (atsi->type) == GNUNET_ATS_ARRAY_TERMINATOR) 343 ntohl (atsi->value));
342 { 344 return GNUNET_TIME_UNIT_SECONDS;
343 /* We sometime have no latency data, i.e. if the address came from
344 peerinfo and we never had a chance to play transport-level
345 PING/PONG yet. Assume 1s in that case. */
346 return GNUNET_TIME_UNIT_SECONDS;
347 }
348 return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
349 ntohl (atsi->value));
350} 345}
351 346
352 347
@@ -355,14 +350,16 @@ get_latency (const struct GNUNET_ATS_Information *atsi)
355 * 350 *
356 * @param cp peer record to update 351 * @param cp peer record to update
357 * @param atsi transport performance data 352 * @param atsi transport performance data
353 * @param atsi_count number of records in 'atsi'
358 */ 354 */
359static void 355static void
360update_atsi (struct GSF_ConnectedPeer *cp, 356update_atsi (struct GSF_ConnectedPeer *cp,
361 const struct GNUNET_ATS_Information *atsi) 357 const struct GNUNET_ATS_Information *atsi,
358 unsigned int atsi_count)
362{ 359{
363 struct GNUNET_TIME_Relative latency; 360 struct GNUNET_TIME_Relative latency;
364 361
365 latency = get_latency (atsi); 362 latency = get_latency (atsi, atsi_count);
366 GNUNET_LOAD_value_set_decline (cp->ppd.transmission_delay, latency); 363 GNUNET_LOAD_value_set_decline (cp->ppd.transmission_delay, latency);
367 /* LATER: merge atsi into cp's performance data (if we ever care...) */ 364 /* LATER: merge atsi into cp's performance data (if we ever care...) */
368} 365}
@@ -584,11 +581,13 @@ ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
584 * 581 *
585 * @param peer identity of peer that connected 582 * @param peer identity of peer that connected
586 * @param atsi performance data for the connection 583 * @param atsi performance data for the connection
584 * @param atsi_count number of records in 'atsi'
587 * @return handle to connected peer entry 585 * @return handle to connected peer entry
588 */ 586 */
589struct GSF_ConnectedPeer * 587struct GSF_ConnectedPeer *
590GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, 588GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
591 const struct GNUNET_ATS_Information *atsi) 589 const struct GNUNET_ATS_Information *atsi,
590 unsigned int atsi_count)
592{ 591{
593 struct GSF_ConnectedPeer *cp; 592 struct GSF_ConnectedPeer *cp;
594 char *fn; 593 char *fn;
@@ -619,7 +618,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
619 ("# peers connected"), 618 ("# peers connected"),
620 GNUNET_CONTAINER_multihashmap_size (cp_map), 619 GNUNET_CONTAINER_multihashmap_size (cp_map),
621 GNUNET_NO); 620 GNUNET_NO);
622 update_atsi (cp, atsi); 621 update_atsi (cp, atsi, atsi_count);
623 GSF_push_start_ (cp); 622 GSF_push_start_ (cp);
624 return cp; 623 return cp;
625} 624}
@@ -674,6 +673,7 @@ GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer)
674 * for loopback messages where we are both sender and receiver) 673 * for loopback messages where we are both sender and receiver)
675 * @param message the actual message 674 * @param message the actual message
676 * @param atsi performance information 675 * @param atsi performance information
676 * @param atsi_count number of records in 'atsi'
677 * @return GNUNET_OK to keep the connection open, 677 * @return GNUNET_OK to keep the connection open,
678 * GNUNET_SYSERR to close it (signal serious error) 678 * GNUNET_SYSERR to close it (signal serious error)
679 */ 679 */
@@ -682,7 +682,8 @@ GSF_handle_p2p_migration_stop_ (void *cls,
682 const struct GNUNET_PeerIdentity *other, 682 const struct GNUNET_PeerIdentity *other,
683 const struct GNUNET_MessageHeader *message, 683 const struct GNUNET_MessageHeader *message,
684 const struct GNUNET_ATS_Information 684 const struct GNUNET_ATS_Information
685 *atsi) 685 *atsi,
686 unsigned int atsi_count)
686{ 687{
687 struct GSF_ConnectedPeer *cp; 688 struct GSF_ConnectedPeer *cp;
688 const struct MigrationStopMessage *msm; 689 const struct MigrationStopMessage *msm;
@@ -710,7 +711,7 @@ GSF_handle_p2p_migration_stop_ (void *cls,
710 cp->mig_revive_task = 711 cp->mig_revive_task =
711 GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); 712 GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp);
712 } 713 }
713 update_atsi (cp, atsi); 714 update_atsi (cp, atsi, atsi_count);
714 return GNUNET_OK; 715 return GNUNET_OK;
715} 716}
716 717
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h
index c725dee75..8923513c7 100644
--- a/src/fs/gnunet-service-fs_cp.h
+++ b/src/fs/gnunet-service-fs_cp.h
@@ -168,11 +168,13 @@ struct GSF_PeerTransmitHandle;
168 * 168 *
169 * @param peer identity of peer that connected 169 * @param peer identity of peer that connected
170 * @param atsi performance data for the connection 170 * @param atsi performance data for the connection
171 * @param atsi_count number of records in 'atsi'
171 * @return handle to connected peer entry 172 * @return handle to connected peer entry
172 */ 173 */
173struct GSF_ConnectedPeer * 174struct GSF_ConnectedPeer *
174GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, 175GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
175 const struct GNUNET_ATS_Information *atsi); 176 const struct GNUNET_ATS_Information *atsi,
177 unsigned int atsi_count);
176 178
177 179
178/** 180/**
@@ -260,6 +262,7 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp,
260 * for loopback messages where we are both sender and receiver) 262 * for loopback messages where we are both sender and receiver)
261 * @param message the actual message 263 * @param message the actual message
262 * @param atsi performance information 264 * @param atsi performance information
265 * @param atsi_count number of records in 'atsi'
263 * @return GNUNET_OK to keep the connection open, 266 * @return GNUNET_OK to keep the connection open,
264 * GNUNET_SYSERR to close it (signal serious error) 267 * GNUNET_SYSERR to close it (signal serious error)
265 */ 268 */
@@ -268,7 +271,8 @@ GSF_handle_p2p_migration_stop_ (void *cls,
268 const struct GNUNET_PeerIdentity *other, 271 const struct GNUNET_PeerIdentity *other,
269 const struct GNUNET_MessageHeader *message, 272 const struct GNUNET_MessageHeader *message,
270 const struct GNUNET_ATS_Information 273 const struct GNUNET_ATS_Information
271 *atsi); 274 *atsi,
275 unsigned int atsi_count);
272 276
273 277
274/** 278/**