aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-07 09:42:36 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-07 09:42:36 +0000
commit145db4f07472ffd03b8872928c165a4a7ef46352 (patch)
tree8bf1eee2d2dfb2537b34b39f2d3cc81fb6be1ddd /src
parentdb1ababc2af1771a10c79c65a729852700ac7699 (diff)
downloadgnunet-145db4f07472ffd03b8872928c165a4a7ef46352.tar.gz
gnunet-145db4f07472ffd03b8872928c165a4a7ef46352.zip
fixes
Diffstat (limited to 'src')
-rw-r--r--src/core/gnunet-service-core-new.c38
-rw-r--r--src/core/gnunet-service-core.h5
-rw-r--r--src/core/gnunet-service-core_clients.c107
-rw-r--r--src/core/gnunet-service-core_clients.h3
-rw-r--r--src/core/gnunet-service-core_kx.c51
-rw-r--r--src/core/gnunet-service-core_kx.h2
-rw-r--r--src/core/gnunet-service-core_sessions.h11
-rw-r--r--src/core/gnunet-service-core_typemap.c2
-rw-r--r--src/core/gnunet-service-core_typemap.h15
9 files changed, 137 insertions, 97 deletions
diff --git a/src/core/gnunet-service-core-new.c b/src/core/gnunet-service-core-new.c
index afdc22d9d..94783ecee 100644
--- a/src/core/gnunet-service-core-new.c
+++ b/src/core/gnunet-service-core-new.c
@@ -41,7 +41,12 @@
41#include "gnunet_signatures.h" 41#include "gnunet_signatures.h"
42#include "gnunet_statistics_service.h" 42#include "gnunet_statistics_service.h"
43#include "gnunet_transport_service.h" 43#include "gnunet_transport_service.h"
44#include "core.h" 44#include "gnunet-service-core.h"
45#include "gnunet-service-core_clients.h"
46#include "gnunet-service-core_kx.h"
47#include "gnunet-service-core_neighbours.h"
48#include "gnunet-service-core_sessions.h"
49#include "gnunet-service-core_typemap.h"
45 50
46 51
47#define DEBUG_HANDSHAKE GNUNET_EXTRA_LOGGING 52#define DEBUG_HANDSHAKE GNUNET_EXTRA_LOGGING
@@ -168,11 +173,6 @@ const struct GNUNET_CONFIGURATION_Handle *GSC_cfg;
168 */ 173 */
169struct GNUNET_STATISTICS_Handle *GSC_stats; 174struct GNUNET_STATISTICS_Handle *GSC_stats;
170 175
171/**
172 * Our message stream tokenizer (for encrypted payload).
173 */
174struct GNUNET_SERVER_MessageStreamTokenizer *GSC_mst;
175
176 176
177/** 177/**
178 * Last task run during shutdown. Disconnects us from 178 * Last task run during shutdown. Disconnects us from
@@ -186,12 +186,10 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
186 "Core service shutting down.\n"); 186 "Core service shutting down.\n");
187#endif 187#endif
188 GSC_CLIENTS_done (); 188 GSC_CLIENTS_done ();
189 189 GSC_SESSIONS_done ();
190 if (GSC_mst != NULL) 190 GSC_NEIGHBOURS_done ();
191 { 191 GSC_KX_done ();
192 GNUNET_SERVER_mst_destroy (GSC_mst); 192 GSC_TYPEMAP_done ();
193 GSC_mst = NULL;
194 }
195 if (GSC_stats != NULL) 193 if (GSC_stats != NULL)
196 { 194 {
197 GNUNET_STATISTICS_destroy (GSC_stats, GNUNET_NO); 195 GNUNET_STATISTICS_destroy (GSC_stats, GNUNET_NO);
@@ -213,14 +211,20 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
213 const struct GNUNET_CONFIGURATION_Handle *c) 211 const struct GNUNET_CONFIGURATION_Handle *c)
214{ 212{
215 GSC_cfg = c; 213 GSC_cfg = c;
216 GSC_mst = GNUNET_SERVER_mst_create (&deliver_message, NULL); 214 GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg);
217 GSC_stats = GNUNET_STATISTICS_create ("core", cfg);
218
219 GSC_CLIENTS_init (server);
220 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, 215 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task,
221 NULL); 216 NULL);
217 GSC_TYPEMAP_init ();
218 if ( (GNUNET_OK != GSC_KX_init ()) ||
219 (GNUNET_OK != GSC_NEIGHBOURS_init ()) )
220 {
221 GNUNET_SCHEDULER_shutdown ();
222 return;
223 }
224 GSC_SESSIONS_init ();
225 GSC_CLIENTS_init (server);
222 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"), 226 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"),
223 GNUNET_i2s (&my_identity)); 227 GNUNET_i2s (&GSC_my_identity));
224} 228}
225 229
226 230
diff --git a/src/core/gnunet-service-core.h b/src/core/gnunet-service-core.h
index 2b0a0c557..5153640ea 100644
--- a/src/core/gnunet-service-core.h
+++ b/src/core/gnunet-service-core.h
@@ -102,10 +102,5 @@ extern struct GNUNET_STATISTICS_Handle *GSC_stats;
102 */ 102 */
103extern struct GNUNET_PeerIdentity GSC_my_identity; 103extern struct GNUNET_PeerIdentity GSC_my_identity;
104 104
105/**
106 * Our message stream tokenizer (for encrypted payload).
107 */
108extern struct GNUNET_SERVER_MessageStreamTokenizer *GSC_mst;
109
110 105
111#endif 106#endif
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c
index 333bd5ad8..7b884f44f 100644
--- a/src/core/gnunet-service-core_clients.c
+++ b/src/core/gnunet-service-core_clients.c
@@ -25,11 +25,20 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_statistics_service.h"
28#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
29#include "gnunet_service_core.h" 30#include "gnunet-service-core.h"
30#include "gnunet_service_core_clients.h" 31#include "gnunet-service-core_clients.h"
31#include "gnunet_service_core_sessions.h" 32#include "gnunet-service-core_sessions.h"
32#include "gnunet_service_core_typemap.h" 33#include "gnunet-service-core_typemap.h"
34#include "core.h"
35
36/**
37 * How many messages do we queue up at most for optional
38 * notifications to a client? (this can cause notifications
39 * about outgoing messages to be dropped).
40 */
41#define MAX_NOTIFY_QUEUE 1024
33 42
34 43
35/** 44/**
@@ -207,12 +216,10 @@ send_to_all_clients (const struct GNUNET_MessageHeader *msg,
207 216
208 for (c = client_head; c != NULL; c = c->next) 217 for (c = client_head; c != NULL; c = c->next)
209 { 218 {
210 if ( (0 != (c->options & options)) && 219 if (! ( (0 != (c->options & options)) ||
211 (GNUNET_YES == type_match (type, c)) ) 220 ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) &&
212 continue; /* both match, wait for only type match */ 221 (GNUNET_YES == type_match (type, c)) ) ) )
213 if ( (0 == (c->options & options)) && 222 continue; /* skip */
214 (GNUNET_YES != type_match (type, c)) )
215 continue; /* neither match, skip entirely */
216#if DEBUG_CORE_CLIENT > 1 223#if DEBUG_CORE_CLIENT > 1
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 224 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
218 "Sending message of type %u to client.\n", 225 "Sending message of type %u to client.\n",
@@ -326,11 +333,9 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
326 &req->peer.hashPubKey, 333 &req->peer.hashPubKey,
327 car, 334 car,
328 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 335 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
329 car->client = c; 336 car->client_handle = c;
330 } 337 }
331 car->target = req->peer; 338 car->target = req->peer;
332 GNUNET_SERVER_client_keep (client);
333 car->client_handle = client;
334 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline); 339 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline);
335 car->priority = ntohl (req->priority); 340 car->priority = ntohl (req->priority);
336 car->msize = ntohs (req->size); 341 car->msize = ntohs (req->size);
@@ -393,11 +398,11 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
393 car)); 398 car));
394 GNUNET_SERVER_mst_receive (client_mst, 399 GNUNET_SERVER_mst_receive (client_mst,
395 car, 400 car,
396 &sm[1], msize, 401 (const char*) &sm[1], msize,
397 GNUNET_YES, 402 GNUNET_YES,
398 GNUNET_NO); 403 GNUNET_NO);
399 if (0 != 404 if (0 !=
400 memcmp (&car->peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity))) 405 memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
401 GSC_SESSIONS_dequeue_request (car); 406 GSC_SESSIONS_dequeue_request (car);
402 GNUNET_free (car); 407 GNUNET_free (car);
403 GNUNET_SERVER_receive_done (client, GNUNET_OK); 408 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -421,10 +426,21 @@ client_tokenizer_callback (void *cls, void *client,
421 struct GSC_ClientActiveRequest *car = client; 426 struct GSC_ClientActiveRequest *car = client;
422 427
423 if (0 == 428 if (0 ==
424 memcmp (&car->peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity))) 429 memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
425 GDS_CLIENTS_deliver_message (&GSC_my_identity, &payload->header); 430 {
431 GSC_CLIENTS_deliver_message (&GSC_my_identity,
432 NULL, 0,
433 message,
434 ntohs (message->size),
435 GNUNET_CORE_OPTION_SEND_FULL_INBOUND | GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
436 GSC_CLIENTS_deliver_message (&GSC_my_identity,
437 NULL, 0,
438 message,
439 sizeof (struct GNUNET_MessageHeader),
440 GNUNET_CORE_OPTION_SEND_HDR_INBOUND | GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
441 }
426 else 442 else
427 GSC_SESSIONS_transmit (car, &payload->header); 443 GSC_SESSIONS_transmit (car, message);
428} 444}
429 445
430 446
@@ -443,9 +459,9 @@ destroy_active_client_request (void *cls, const GNUNET_HashCode * key,
443 struct GSC_ClientActiveRequest *car = value; 459 struct GSC_ClientActiveRequest *car = value;
444 460
445 GNUNET_assert (GNUNET_YES == 461 GNUNET_assert (GNUNET_YES ==
446 GNUNET_CONTAINER_multihashmap_remove (car->client->requests, 462 GNUNET_CONTAINER_multihashmap_remove (car->client_handle->requests,
447 &car->peer, 463 &car->target.hashPubKey,
448 car); 464 car));
449 GSC_SESSIONS_dequeue_request (car); 465 GSC_SESSIONS_dequeue_request (car);
450 GNUNET_free (car); 466 GNUNET_free (car);
451 return GNUNET_YES; 467 return GNUNET_YES;
@@ -501,12 +517,12 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
501 struct GSC_Client *c; 517 struct GSC_Client *c;
502 struct SendMessageReady smr; 518 struct SendMessageReady smr;
503 519
504 c = car->client; 520 c = car->client_handle;
505 smr.header.size = htons (sizeof (struct SendMessageReady)); 521 smr.header.size = htons (sizeof (struct SendMessageReady));
506 smr.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_READY); 522 smr.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_READY);
507 smr.size = htons (car->msize); 523 smr.size = htons (car->msize);
508 smr.smr_id = car->smr_id; 524 smr.smr_id = car->smr_id;
509 smr.peer = n->peer; 525 smr.peer = car->target;
510 send_to_client (c, &smr.header, GNUNET_NO); 526 send_to_client (c, &smr.header, GNUNET_NO);
511} 527}
512 528
@@ -523,7 +539,7 @@ void
523GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car) 539GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car)
524{ 540{
525 GNUNET_assert (GNUNET_YES == 541 GNUNET_assert (GNUNET_YES ==
526 destroy_active_client_request (NULL, &car->peer.hashPubKey, car)); 542 destroy_active_client_request (NULL, &car->target.hashPubKey, car));
527} 543}
528 544
529 545
@@ -564,31 +580,29 @@ GDS_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
564 /* send connect */ 580 /* send connect */
565 size = 581 size =
566 sizeof (struct ConnectNotifyMessage) + 582 sizeof (struct ConnectNotifyMessage) +
567 (n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); 583 (atsi_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
568 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 584 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
569 { 585 {
570 GNUNET_break (0); 586 GNUNET_break (0);
571 /* recovery strategy: throw away performance data */ 587 /* recovery strategy: throw away performance data */
572 GNUNET_array_grow (n->ats, n->ats_count, 0); 588 atsi_count = 0;
573 size = 589 size = sizeof (struct ConnectNotifyMessage);
574 sizeof (struct ConnectNotifyMessage) +
575 (n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
576 } 590 }
577 cnm = (struct ConnectNotifyMessage *) buf; 591 cnm = (struct ConnectNotifyMessage *) buf;
578 cnm->header.size = htons (size); 592 cnm->header.size = htons (size);
579 cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); 593 cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
580 cnm->ats_count = htonl (atsi); 594 cnm->ats_count = htonl (atsi_count);
581 a = &cnm->atsi; 595 a = &cnm->ats;
582 memcpy (a, atsi, 596 memcpy (a, atsi,
583 sizeof (struct GNUNET_TRANSPORT_ATS_Information) * atsi_count); 597 sizeof (struct GNUNET_TRANSPORT_ATS_Information) * atsi_count);
584 a[ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); 598 a[atsi_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
585 a[ats_count].value = htonl (0); 599 a[atsi_count].value = htonl (0);
586#if DEBUG_CORE_CLIENT 600#if DEBUG_CORE_CLIENT
587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
588 "Sending `%s' message to client.\n", 602 "Sending `%s' message to client.\n",
589 "NOTIFY_CONNECT"); 603 "NOTIFY_CONNECT");
590#endif 604#endif
591 cnm->peer = n->peer; 605 cnm->peer = *neighbour;
592 send_to_client (client, &cnm->header, GNUNET_NO); 606 send_to_client (client, &cnm->header, GNUNET_NO);
593 } 607 }
594 else 608 else
@@ -597,8 +611,8 @@ GDS_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
597 dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage)); 611 dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage));
598 dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT); 612 dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
599 dcm.reserved = htonl (0); 613 dcm.reserved = htonl (0);
600 dcm.peer = *peer; 614 dcm.peer = *neighbour;
601 send_to_client (client, &cnm.header, GNUNET_NO); 615 send_to_client (client, &dcm.header, GNUNET_NO);
602 } 616 }
603} 617}
604 618
@@ -652,29 +666,24 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
652 int options) 666 int options)
653{ 667{
654 size_t size = msize + sizeof (struct NotifyTrafficMessage) + 668 size_t size = msize + sizeof (struct NotifyTrafficMessage) +
655 (sender->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); 669 atsi_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
656 char buf[size]; 670 char buf[size];
657 struct NotifyTrafficMessage *ntm; 671 struct NotifyTrafficMessage *ntm;
658 struct GNUNET_TRANSPORT_ATS_Information *a; 672 struct GNUNET_TRANSPORT_ATS_Information *a;
659 int dropped;
660 673
661 if (0 == options) 674 if (0 == options)
662 { 675 {
663 GNUNET_snprintf (buf, sizeof (buf), 676 GNUNET_snprintf (buf, sizeof (buf),
664 gettext_noop ("# bytes of messages of type %u received"), 677 gettext_noop ("# bytes of messages of type %u received"),
665 (unsigned int) ntohs (msg->type)); 678 (unsigned int) ntohs (msg->type));
666 GNUNET_STATISTICS_update (stats, buf, msize, GNUNET_NO); 679 GNUNET_STATISTICS_update (GSC_stats, buf, msize, GNUNET_NO);
667 } 680 }
668 GNUNET_assert (GNUNET_YES == sender->is_connected);
669 GNUNET_break (sender->status == PEER_STATE_KEY_CONFIRMED);
670 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 681 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
671 { 682 {
672 GNUNET_break (0); 683 GNUNET_break (0);
673 /* recovery strategy: throw performance data away... */ 684 /* recovery strategy: throw performance data away... */
674 GNUNET_array_grow (sender->ats, sender->ats_count, 0); 685 atsi_count = 0;
675 size = 686 size = msize + sizeof (struct NotifyTrafficMessage);
676 msize + sizeof (struct NotifyTrafficMessage) +
677 (sender->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
678 } 687 }
679#if DEBUG_CORE 688#if DEBUG_CORE
680 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -686,13 +695,13 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
686 ntm->header.size = htons (size); 695 ntm->header.size = htons (size);
687 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND); 696 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND);
688 ntm->ats_count = htonl (atsi_count); 697 ntm->ats_count = htonl (atsi_count);
689 ntm->peer = sender->peer; 698 ntm->peer = *sender;
690 a = &ntm->ats; 699 a = &ntm->ats;
691 memcpy (a, atsi, 700 memcpy (a, atsi,
692 sizeof (struct GNUNET_TRANSPORT_ATS_Information) * sender->atsi_count); 701 sizeof (struct GNUNET_TRANSPORT_ATS_Information) * atsi_count);
693 a[atsi_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); 702 a[atsi_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
694 a[atsi_count].value = htonl (0); 703 a[atsi_count].value = htonl (0);
695 memcpy (&ats[atsi_count + 1], msg, msize); 704 memcpy (&a[atsi_count + 1], msg, msize);
696 send_to_all_clients (&ntm->header, GNUNET_YES, 705 send_to_all_clients (&ntm->header, GNUNET_YES,
697 options, ntohs (msg->type)); 706 options, ntohs (msg->type));
698} 707}
@@ -748,7 +757,7 @@ GSC_CLIENTS_done ()
748 handle_client_disconnect (NULL, c->client_handle); 757 handle_client_disconnect (NULL, c->client_handle);
749 GNUNET_SERVER_notification_context_destroy (notifier); 758 GNUNET_SERVER_notification_context_destroy (notifier);
750 notifier = NULL; 759 notifier = NULL;
751 GNUNET_SERVER_MST_destroy (client_mst); 760 GNUNET_SERVER_mst_destroy (client_mst);
752 client_mst = NULL; 761 client_mst = NULL;
753} 762}
754 763
diff --git a/src/core/gnunet-service-core_clients.h b/src/core/gnunet-service-core_clients.h
index a137c6e81..7e316d90f 100644
--- a/src/core/gnunet-service-core_clients.h
+++ b/src/core/gnunet-service-core_clients.h
@@ -27,7 +27,8 @@
27#define GNUNET_SERVICE_CORE_CLIENTS_H 27#define GNUNET_SERVICE_CORE_CLIENTS_H
28 28
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_service_core.h" 30#include "gnunet-service-core.h"
31#include "gnunet-service-core_typemap.h"
31 32
32 33
33/** 34/**
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 8f6d19652..8c02eb2ea 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -1202,6 +1202,29 @@ update_timeout (struct GSC_KeyExchangeInfo *kx)
1202 1202
1203 1203
1204/** 1204/**
1205 * Closure for 'deliver_message'
1206 */
1207struct DeliverMessageContext
1208{
1209
1210 /**
1211 * Performance information for the connection.
1212 */
1213 const struct GNUNET_TRANSPORT_ATS_Information *atsi;
1214
1215 /**
1216 * Sender of the message.
1217 */
1218 const struct GNUNET_PeerIdentity *peer;
1219
1220 /**
1221 * Number of entries in 'atsi' array.
1222 */
1223 uint32_t atsi_count;
1224}
1225
1226
1227/**
1205 * We received an encrypted message. Decrypt, validate and 1228 * We received an encrypted message. Decrypt, validate and
1206 * pass on to the appropriate clients. 1229 * pass on to the appropriate clients.
1207 * 1230 *
@@ -1217,14 +1240,15 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *n,
1217 uint32_t atsi_count) 1240 uint32_t atsi_count)
1218{ 1241{
1219 const struct EncryptedMessage *m; 1242 const struct EncryptedMessage *m;
1220 char buf[size];
1221 struct EncryptedMessage *pt; /* plaintext */ 1243 struct EncryptedMessage *pt; /* plaintext */
1222 GNUNET_HashCode ph; 1244 GNUNET_HashCode ph;
1223 uint32_t snum; 1245 uint32_t snum;
1224 struct GNUNET_TIME_Absolute t; 1246 struct GNUNET_TIME_Absolute t;
1225 struct GNUNET_CRYPTO_AesInitializationVector iv; 1247 struct GNUNET_CRYPTO_AesInitializationVector iv;
1226 struct GNUNET_CRYPTO_AuthKey auth_key; 1248 struct GNUNET_CRYPTO_AuthKey auth_key;
1249 struct DeliverMessageContext dmc;
1227 uint16_t size = ntohs (msg->size); 1250 uint16_t size = ntohs (msg->size);
1251 char buf[size];
1228 1252
1229 if (size < 1253 if (size <
1230 sizeof (struct EncryptedMessage) + sizeof (struct GNUNET_MessageHeader)) 1254 sizeof (struct EncryptedMessage) + sizeof (struct GNUNET_MessageHeader))
@@ -1330,23 +1354,25 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *n,
1330 /* process decrypted message(s) */ 1354 /* process decrypted message(s) */
1331 update_timeout (kx); 1355 update_timeout (kx);
1332 GSC_SESSIONS_update (&kx->peer, 1356 GSC_SESSIONS_update (&kx->peer,
1333 pt->inbound_bw_limit, 1357 pt->inbound_bw_limit);
1334 atsi, atsi_count); // FIXME: does 'SESSIONS' need atsi!?
1335 GNUNET_STATISTICS_update (stats, 1358 GNUNET_STATISTICS_update (stats,
1336 gettext_noop ("# bytes of payload decrypted"), 1359 gettext_noop ("# bytes of payload decrypted"),
1337 size - sizeof (struct EncryptedMessage), GNUNET_NO); 1360 size - sizeof (struct EncryptedMessage), GNUNET_NO);
1361 dmc.atsi = atsi;
1362 dmc.atsi_count = atsi_count;
1363 dmc.peer = &kx->peer;
1338 if (GNUNET_OK != 1364 if (GNUNET_OK !=
1339 GNUNET_SERVER_mst_receive (mst, kx, &buf[sizeof (struct EncryptedMessage)], 1365 GNUNET_SERVER_mst_receive (mst, &dmc, &buf[sizeof (struct EncryptedMessage)],
1340 size - sizeof (struct EncryptedMessage), 1366 size - sizeof (struct EncryptedMessage),
1341 GNUNET_YES, GNUNET_NO)) 1367 GNUNET_YES, GNUNET_NO))
1342 GNUNET_break_op (0); 1368 GNUNET_break_op (0);
1343} 1369}
1344 1370
1345 1371
1346
1347
1348/** 1372/**
1349 * Deliver P2P message to interested clients. 1373 * Deliver P2P message to interested clients.
1374 * Invokes send twice, once for clients that want the full message, and once
1375 * for clients that only want the header
1350 * 1376 *
1351 * @param cls always NULL 1377 * @param cls always NULL
1352 * @param client who sent us the message (struct GSC_KeyExchangeInfo) 1378 * @param client who sent us the message (struct GSC_KeyExchangeInfo)
@@ -1355,22 +1381,21 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *n,
1355static void 1381static void
1356deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m) 1382deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m)
1357{ 1383{
1358 struct GSC_KeyExchangeInfo *kx = client; 1384 struct DeliverMessageContext *dmc = client;
1359 1385
1360 // FIXME (need to check stuff, need ATSI, etc.) 1386 GSC_CLIENTS_deliver_message (dmc->peer,
1361 // FIXME: does clients work properly if never called with option 'NOTHING'!? 1387 dmc->atsi, dmc->atsi_count,
1362 GSC_CLIENTS_deliver_message (&kx->peer,
1363 NULL, 0, // kx->atsi...
1364 m, 1388 m,
1365 ntohs (m->size), 1389 ntohs (m->size),
1366 GNUNET_CORE_OPTION_SEND_FULL_INBOUND); 1390 GNUNET_CORE_OPTION_SEND_FULL_INBOUND);
1367 GSC_CLIENTS_deliver_message (&kx->peer, 1391 GSC_CLIENTS_deliver_message (dmc->peer,
1368 NULL, 0, // kx->atsi... 1392 dmc->atsi, dmc->atsi_count,
1369 m, 1393 m,
1370 sizeof (struct GNUNET_MessageHeader), 1394 sizeof (struct GNUNET_MessageHeader),
1371 GNUNET_CORE_OPTION_SEND_HDR_INBOUND); 1395 GNUNET_CORE_OPTION_SEND_HDR_INBOUND);
1372} 1396}
1373 1397
1398
1374/** 1399/**
1375 * Initialize KX subsystem. 1400 * Initialize KX subsystem.
1376 * 1401 *
diff --git a/src/core/gnunet-service-core_kx.h b/src/core/gnunet-service-core_kx.h
index 5517001da..a7f4b9058 100644
--- a/src/core/gnunet-service-core_kx.h
+++ b/src/core/gnunet-service-core_kx.h
@@ -44,7 +44,7 @@ struct GSC_KeyExchangeInfo;
44 */ 44 */
45void 45void
46GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx, 46GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
47 const struct GNUNET_MessageHandler *msg); 47 const struct GNUNET_MessageHeader *msg);
48 48
49 49
50/** 50/**
diff --git a/src/core/gnunet-service-core_sessions.h b/src/core/gnunet-service-core_sessions.h
index fa85bc05a..46f8d1f5c 100644
--- a/src/core/gnunet-service-core_sessions.h
+++ b/src/core/gnunet-service-core_sessions.h
@@ -26,8 +26,8 @@
26#ifndef GNUNET_SERVICE_CORE_SESSIONS_H 26#ifndef GNUNET_SERVICE_CORE_SESSIONS_H
27#define GNUNET_SERVICE_CORE_SESSIONS_H 27#define GNUNET_SERVICE_CORE_SESSIONS_H
28 28
29#include "gnunet_service_core_kx.h" 29#include "gnunet-service-core.h"
30#include "gnunet_service_core_sessions.h" 30#include "gnunet-service-core_kx.h"
31 31
32 32
33/** 33/**
@@ -162,15 +162,10 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
162 * 162 *
163 * @param peer peer who's session should be updated 163 * @param peer peer who's session should be updated
164 * @param bw_out new outbound bandwidth limit for the peer 164 * @param bw_out new outbound bandwidth limit for the peer
165 * @param atsi performance information
166 * @param atsi_count number of performance records supplied
167 */ 165 */
168void 166void
169GSC_SESSIONS_update (const struct GNUNET_PeerIdentity *peer, 167GSC_SESSIONS_update (const struct GNUNET_PeerIdentity *peer,
170 struct GNUNET_BANDWIDTH_Value32NBO bw_out, 168 struct GNUNET_BANDWIDTH_Value32NBO bw_out);
171 const struct GNUNET_TRANSPORT_ATS_Information *atsi,
172 uint32_t atsi_count);
173
174 169
175 170
176/** 171/**
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c
index 5feb65a53..079611de6 100644
--- a/src/core/gnunet-service-core_typemap.c
+++ b/src/core/gnunet-service-core_typemap.c
@@ -142,7 +142,7 @@ GSC_TYPEMAP_remove (const uint16_t *types,
142 * @return GNUNET_YES if a type is in the map, GNUNET_NO if not 142 * @return GNUNET_YES if a type is in the map, GNUNET_NO if not
143 */ 143 */
144int 144int
145GSC_TYPEMAP_test_match (struct GSC_TypeMap *tmap, 145GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
146 const uint16_t *types, 146 const uint16_t *types,
147 unsigned int tcnt) 147 unsigned int tcnt)
148{ 148{
diff --git a/src/core/gnunet-service-core_typemap.h b/src/core/gnunet-service-core_typemap.h
index fe3b885b3..d43c64536 100644
--- a/src/core/gnunet-service-core_typemap.h
+++ b/src/core/gnunet-service-core_typemap.h
@@ -28,7 +28,11 @@
28 28
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
31#include "gnunet_service_core.h" 31
32/**
33 * Map specifying which message types a peer supports.
34 */
35struct GSC_TypeMap;
32 36
33 37
34/** 38/**
@@ -57,10 +61,17 @@ GSC_TYPEMAP_remove (const uint16_t *types,
57 * @return GNUNET_YES if a type is in the map, GNUNET_NO if not 61 * @return GNUNET_YES if a type is in the map, GNUNET_NO if not
58 */ 62 */
59int 63int
60GSC_TYPEMAP_test_match (struct GSC_TypeMap *tmap, 64GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
61 const uint16_t *types, 65 const uint16_t *types,
62 unsigned int tcnt); 66 unsigned int tcnt);
63 67
64 68
69void
70GSC_TYPEMAP_init ();
71
72
73void
74GSC_TYPEMAP_done ();
75
65#endif 76#endif
66/* end of gnunet-service-core_typemap.h */ 77/* end of gnunet-service-core_typemap.h */