diff options
Diffstat (limited to 'src/core/gnunet-service-core_clients.c')
-rw-r--r-- | src/core/gnunet-service-core_clients.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index 7514da8a2..bcbb56ef3 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c | |||
@@ -73,12 +73,12 @@ struct GSC_Client | |||
73 | * Map of peer identities to active transmission requests of this | 73 | * Map of peer identities to active transmission requests of this |
74 | * client to the peer (of type 'struct GSC_ClientActiveRequest'). | 74 | * client to the peer (of type 'struct GSC_ClientActiveRequest'). |
75 | */ | 75 | */ |
76 | struct GNUNET_CONTAINER_MultiHashMap *requests; | 76 | struct GNUNET_CONTAINER_MultiPeerMap *requests; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Map containing all peers that this client knows we're connected to. | 79 | * Map containing all peers that this client knows we're connected to. |
80 | */ | 80 | */ |
81 | struct GNUNET_CONTAINER_MultiHashMap *connectmap; | 81 | struct GNUNET_CONTAINER_MultiPeerMap *connectmap; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Options for messages this client cares about, | 84 | * Options for messages this client cares about, |
@@ -247,8 +247,8 @@ send_to_all_clients (const struct GNUNET_PeerIdentity *partner, | |||
247 | GNUNET_assert ( (0 == (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || | 247 | GNUNET_assert ( (0 == (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || |
248 | (GNUNET_YES != tm) || | 248 | (GNUNET_YES != tm) || |
249 | (GNUNET_YES == | 249 | (GNUNET_YES == |
250 | GNUNET_CONTAINER_multihashmap_contains (c->connectmap, | 250 | GNUNET_CONTAINER_multipeermap_contains (c->connectmap, |
251 | &partner->hashPubKey)) ); | 251 | partner)) ); |
252 | send_to_client (c, msg, can_drop); | 252 | send_to_client (c, msg, can_drop); |
253 | } | 253 | } |
254 | } | 254 | } |
@@ -298,10 +298,10 @@ handle_client_init (void *cls, struct GNUNET_SERVER_Client *client, | |||
298 | c->options = ntohl (im->options); | 298 | c->options = ntohl (im->options); |
299 | all_client_options |= c->options; | 299 | all_client_options |= c->options; |
300 | c->types = (const uint16_t *) &c[1]; | 300 | c->types = (const uint16_t *) &c[1]; |
301 | c->connectmap = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); | 301 | c->connectmap = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO); |
302 | GNUNET_assert (GNUNET_YES == | 302 | GNUNET_assert (GNUNET_YES == |
303 | GNUNET_CONTAINER_multihashmap_put (c->connectmap, | 303 | GNUNET_CONTAINER_multipeermap_put (c->connectmap, |
304 | &GSC_my_identity.hashPubKey, | 304 | &GSC_my_identity, |
305 | NULL, | 305 | NULL, |
306 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 306 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
307 | wtypes = (uint16_t *) & c[1]; | 307 | wtypes = (uint16_t *) & c[1]; |
@@ -349,7 +349,7 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | if (c->requests == NULL) | 351 | if (c->requests == NULL) |
352 | c->requests = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); | 352 | c->requests = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO); |
353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
354 | "Client asked for transmission to `%s'\n", | 354 | "Client asked for transmission to `%s'\n", |
355 | GNUNET_i2s (&req->peer)); | 355 | GNUNET_i2s (&req->peer)); |
@@ -359,8 +359,8 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
359 | sizeof (struct GNUNET_PeerIdentity))); | 359 | sizeof (struct GNUNET_PeerIdentity))); |
360 | if ((!is_loopback) && | 360 | if ((!is_loopback) && |
361 | (GNUNET_YES != | 361 | (GNUNET_YES != |
362 | GNUNET_CONTAINER_multihashmap_contains (c->connectmap, | 362 | GNUNET_CONTAINER_multipeermap_contains (c->connectmap, |
363 | &req->peer.hashPubKey))) | 363 | &req->peer))) |
364 | { | 364 | { |
365 | /* neighbour must have disconnected since request was issued, | 365 | /* neighbour must have disconnected since request was issued, |
366 | * ignore (client will realize it once it processes the | 366 | * ignore (client will realize it once it processes the |
@@ -373,14 +373,14 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | car = GNUNET_CONTAINER_multihashmap_get (c->requests, &req->peer.hashPubKey); | 376 | car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer); |
377 | if (car == NULL) | 377 | if (car == NULL) |
378 | { | 378 | { |
379 | /* create new entry */ | 379 | /* create new entry */ |
380 | car = GNUNET_malloc (sizeof (struct GSC_ClientActiveRequest)); | 380 | car = GNUNET_malloc (sizeof (struct GSC_ClientActiveRequest)); |
381 | GNUNET_assert (GNUNET_OK == | 381 | GNUNET_assert (GNUNET_OK == |
382 | GNUNET_CONTAINER_multihashmap_put (c->requests, | 382 | GNUNET_CONTAINER_multipeermap_put (c->requests, |
383 | &req->peer.hashPubKey, | 383 | &req->peer, |
384 | car, | 384 | car, |
385 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 385 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
386 | car->client_handle = c; | 386 | car->client_handle = c; |
@@ -462,7 +462,7 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client, | |||
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | tc.car = | 464 | tc.car = |
465 | GNUNET_CONTAINER_multihashmap_get (c->requests, &sm->peer.hashPubKey); | 465 | GNUNET_CONTAINER_multipeermap_get (c->requests, &sm->peer); |
466 | if (NULL == tc.car) | 466 | if (NULL == tc.car) |
467 | { | 467 | { |
468 | /* Must have been that we first approved the request, then got disconnected | 468 | /* Must have been that we first approved the request, then got disconnected |
@@ -478,8 +478,8 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client, | |||
478 | return; | 478 | return; |
479 | } | 479 | } |
480 | GNUNET_assert (GNUNET_YES == | 480 | GNUNET_assert (GNUNET_YES == |
481 | GNUNET_CONTAINER_multihashmap_remove (c->requests, | 481 | GNUNET_CONTAINER_multipeermap_remove (c->requests, |
482 | &sm->peer.hashPubKey, | 482 | &sm->peer, |
483 | tc.car)); | 483 | tc.car)); |
484 | tc.cork = ntohl (sm->cork); | 484 | tc.cork = ntohl (sm->cork); |
485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -561,18 +561,19 @@ client_tokenizer_callback (void *cls, void *client, | |||
561 | * @param cls NULL | 561 | * @param cls NULL |
562 | * @param key identity of peer for which this is an active request | 562 | * @param key identity of peer for which this is an active request |
563 | * @param value the 'struct GSC_ClientActiveRequest' to free | 563 | * @param value the 'struct GSC_ClientActiveRequest' to free |
564 | * @return GNUNET_YES (continue iteration) | 564 | * @return #GNUNET_YES (continue iteration) |
565 | */ | 565 | */ |
566 | static int | 566 | static int |
567 | destroy_active_client_request (void *cls, const struct GNUNET_HashCode * key, | 567 | destroy_active_client_request (void *cls, |
568 | const struct GNUNET_PeerIdentity *key, | ||
568 | void *value) | 569 | void *value) |
569 | { | 570 | { |
570 | struct GSC_ClientActiveRequest *car = value; | 571 | struct GSC_ClientActiveRequest *car = value; |
571 | 572 | ||
572 | GNUNET_assert (GNUNET_YES == | 573 | GNUNET_assert (GNUNET_YES == |
573 | GNUNET_CONTAINER_multihashmap_remove (car-> | 574 | GNUNET_CONTAINER_multipeermap_remove (car-> |
574 | client_handle->requests, | 575 | client_handle->requests, |
575 | &car->target.hashPubKey, | 576 | &car->target, |
576 | car)); | 577 | car)); |
577 | GSC_SESSIONS_dequeue_request (car); | 578 | GSC_SESSIONS_dequeue_request (car); |
578 | GNUNET_free (car); | 579 | GNUNET_free (car); |
@@ -601,12 +602,12 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
601 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, c); | 602 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, c); |
602 | if (c->requests != NULL) | 603 | if (c->requests != NULL) |
603 | { | 604 | { |
604 | GNUNET_CONTAINER_multihashmap_iterate (c->requests, | 605 | GNUNET_CONTAINER_multipeermap_iterate (c->requests, |
605 | &destroy_active_client_request, | 606 | &destroy_active_client_request, |
606 | NULL); | 607 | NULL); |
607 | GNUNET_CONTAINER_multihashmap_destroy (c->requests); | 608 | GNUNET_CONTAINER_multipeermap_destroy (c->requests); |
608 | } | 609 | } |
609 | GNUNET_CONTAINER_multihashmap_destroy (c->connectmap); | 610 | GNUNET_CONTAINER_multipeermap_destroy (c->connectmap); |
610 | c->connectmap = NULL; | 611 | c->connectmap = NULL; |
611 | GSC_TYPEMAP_remove (c->types, c->tcnt); | 612 | GSC_TYPEMAP_remove (c->types, c->tcnt); |
612 | GNUNET_free (c); | 613 | GNUNET_free (c); |
@@ -633,8 +634,8 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car) | |||
633 | 634 | ||
634 | c = car->client_handle; | 635 | c = car->client_handle; |
635 | if (GNUNET_YES != | 636 | if (GNUNET_YES != |
636 | GNUNET_CONTAINER_multihashmap_contains (c->connectmap, | 637 | GNUNET_CONTAINER_multipeermap_contains (c->connectmap, |
637 | &car->target.hashPubKey)) | 638 | &car->target)) |
638 | { | 639 | { |
639 | /* connection has gone down since, drop request */ | 640 | /* connection has gone down since, drop request */ |
640 | GNUNET_assert (0 != | 641 | GNUNET_assert (0 != |
@@ -665,9 +666,9 @@ void | |||
665 | GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car) | 666 | GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car) |
666 | { | 667 | { |
667 | GNUNET_assert (GNUNET_YES == | 668 | GNUNET_assert (GNUNET_YES == |
668 | GNUNET_CONTAINER_multihashmap_remove (car-> | 669 | GNUNET_CONTAINER_multipeermap_remove (car-> |
669 | client_handle->requests, | 670 | client_handle->requests, |
670 | &car->target.hashPubKey, | 671 | &car->target, |
671 | car)); | 672 | car)); |
672 | GNUNET_free (car); | 673 | GNUNET_free (car); |
673 | } | 674 | } |
@@ -702,19 +703,19 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client, | |||
702 | if (old_match == new_match) | 703 | if (old_match == new_match) |
703 | { | 704 | { |
704 | GNUNET_assert (old_match == | 705 | GNUNET_assert (old_match == |
705 | GNUNET_CONTAINER_multihashmap_contains (client->connectmap, | 706 | GNUNET_CONTAINER_multipeermap_contains (client->connectmap, |
706 | &neighbour->hashPubKey)); | 707 | neighbour)); |
707 | return; /* no change */ | 708 | return; /* no change */ |
708 | } | 709 | } |
709 | if (old_match == GNUNET_NO) | 710 | if (old_match == GNUNET_NO) |
710 | { | 711 | { |
711 | /* send connect */ | 712 | /* send connect */ |
712 | GNUNET_assert (GNUNET_NO == | 713 | GNUNET_assert (GNUNET_NO == |
713 | GNUNET_CONTAINER_multihashmap_contains (client->connectmap, | 714 | GNUNET_CONTAINER_multipeermap_contains (client->connectmap, |
714 | &neighbour->hashPubKey)); | 715 | neighbour)); |
715 | GNUNET_assert (GNUNET_YES == | 716 | GNUNET_assert (GNUNET_YES == |
716 | GNUNET_CONTAINER_multihashmap_put (client->connectmap, | 717 | GNUNET_CONTAINER_multipeermap_put (client->connectmap, |
717 | &neighbour->hashPubKey, | 718 | neighbour, |
718 | NULL, | 719 | NULL, |
719 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 720 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
720 | size = sizeof (struct ConnectNotifyMessage); | 721 | size = sizeof (struct ConnectNotifyMessage); |
@@ -731,11 +732,11 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client, | |||
731 | { | 732 | { |
732 | /* send disconnect */ | 733 | /* send disconnect */ |
733 | GNUNET_assert (GNUNET_YES == | 734 | GNUNET_assert (GNUNET_YES == |
734 | GNUNET_CONTAINER_multihashmap_contains (client->connectmap, | 735 | GNUNET_CONTAINER_multipeermap_contains (client->connectmap, |
735 | &neighbour->hashPubKey)); | 736 | neighbour)); |
736 | GNUNET_assert (GNUNET_YES == | 737 | GNUNET_assert (GNUNET_YES == |
737 | GNUNET_CONTAINER_multihashmap_remove (client->connectmap, | 738 | GNUNET_CONTAINER_multipeermap_remove (client->connectmap, |
738 | &neighbour->hashPubKey, | 739 | neighbour, |
739 | NULL)); | 740 | NULL)); |
740 | dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage)); | 741 | dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage)); |
741 | dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT); | 742 | dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT); |