aboutsummaryrefslogtreecommitdiff
path: root/src/core/gnunet-service-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/gnunet-service-core.c')
-rw-r--r--src/core/gnunet-service-core.c527
1 files changed, 233 insertions, 294 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index e26bb4d5c..740707ce1 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -107,7 +107,6 @@ struct GSC_Client
107 * specifically cares about. Size of the @e types array. 107 * specifically cares about. Size of the @e types array.
108 */ 108 */
109 unsigned int tcnt; 109 unsigned int tcnt;
110
111}; 110};
112 111
113 112
@@ -150,12 +149,10 @@ static struct GSC_Client *client_tail;
150 * @return #GNUNET_YES if @a c is interested, #GNUNET_NO if not. 149 * @return #GNUNET_YES if @a c is interested, #GNUNET_NO if not.
151 */ 150 */
152static int 151static int
153type_match (uint16_t type, 152type_match (uint16_t type, struct GSC_Client *c)
154 struct GSC_Client *c)
155{ 153{
156 if ( (0 == c->tcnt) && 154 if ((0 == c->tcnt) && (0 != c->options))
157 (0 != c->options) ) 155 return GNUNET_YES; /* peer without handlers and inbound/outbond
158 return GNUNET_YES; /* peer without handlers and inbound/outbond
159 callbacks matches ALL */ 156 callbacks matches ALL */
160 if (NULL == c->types) 157 if (NULL == c->types)
161 return GNUNET_NO; 158 return GNUNET_NO;
@@ -174,8 +171,7 @@ type_match (uint16_t type,
174 * @return #GNUNET_OK if @a im is well-formed 171 * @return #GNUNET_OK if @a im is well-formed
175 */ 172 */
176static int 173static int
177check_client_init (void *cls, 174check_client_init (void *cls, const struct InitMessage *im)
178 const struct InitMessage *im)
179{ 175{
180 return GNUNET_OK; 176 return GNUNET_OK;
181} 177}
@@ -188,8 +184,7 @@ check_client_init (void *cls,
188 * @param im the `struct InitMessage` 184 * @param im the `struct InitMessage`
189 */ 185 */
190static void 186static void
191handle_client_init (void *cls, 187handle_client_init (void *cls, const struct InitMessage *im)
192 const struct InitMessage *im)
193{ 188{
194 struct GSC_Client *c = cls; 189 struct GSC_Client *c = cls;
195 struct GNUNET_MQ_Envelope *env; 190 struct GNUNET_MQ_Envelope *env;
@@ -206,24 +201,23 @@ handle_client_init (void *cls,
206 all_client_options |= c->options; 201 all_client_options |= c->options;
207 c->types = GNUNET_malloc (msize); 202 c->types = GNUNET_malloc (msize);
208 GNUNET_assert (GNUNET_YES == 203 GNUNET_assert (GNUNET_YES ==
209 GNUNET_CONTAINER_multipeermap_put (c->connectmap, 204 GNUNET_CONTAINER_multipeermap_put (
210 &GSC_my_identity, 205 c->connectmap,
211 NULL, 206 &GSC_my_identity,
212 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 207 NULL,
208 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
213 for (unsigned int i = 0; i < c->tcnt; i++) 209 for (unsigned int i = 0; i < c->tcnt; i++)
214 c->types[i] = ntohs (types[i]); 210 c->types[i] = ntohs (types[i]);
215 GSC_TYPEMAP_add (c->types, 211 GSC_TYPEMAP_add (c->types, c->tcnt);
216 c->tcnt); 212 GNUNET_log (
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 213 GNUNET_ERROR_TYPE_DEBUG,
218 "Client connecting to core service is interested in %u message types\n", 214 "Client connecting to core service is interested in %u message types\n",
219 (unsigned int) c->tcnt); 215 (unsigned int) c->tcnt);
220 /* send init reply message */ 216 /* send init reply message */
221 env = GNUNET_MQ_msg (irm, 217 env = GNUNET_MQ_msg (irm, GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY);
222 GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY);
223 irm->reserved = htonl (0); 218 irm->reserved = htonl (0);
224 irm->my_identity = GSC_my_identity; 219 irm->my_identity = GSC_my_identity;
225 GNUNET_MQ_send (c->mq, 220 GNUNET_MQ_send (c->mq, env);
226 env);
227 GSC_SESSIONS_notify_client_about_sessions (c); 221 GSC_SESSIONS_notify_client_about_sessions (c);
228 GNUNET_SERVICE_client_continue (c->client); 222 GNUNET_SERVICE_client_continue (c->client);
229} 223}
@@ -245,11 +239,11 @@ void
245GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car, 239GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car,
246 int drop_client) 240 int drop_client)
247{ 241{
248 GNUNET_assert (GNUNET_YES == 242 GNUNET_assert (
249 GNUNET_CONTAINER_multipeermap_remove (car-> 243 GNUNET_YES ==
250 client_handle->requests, 244 GNUNET_CONTAINER_multipeermap_remove (car->client_handle->requests,
251 &car->target, 245 &car->target,
252 car)); 246 car));
253 if (GNUNET_YES == drop_client) 247 if (GNUNET_YES == drop_client)
254 GNUNET_SERVICE_client_drop (car->client_handle->client); 248 GNUNET_SERVICE_client_drop (car->client_handle->client);
255 GNUNET_free (car); 249 GNUNET_free (car);
@@ -274,38 +268,31 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
274 268
275 c = car->client_handle; 269 c = car->client_handle;
276 if (GNUNET_YES != 270 if (GNUNET_YES !=
277 GNUNET_CONTAINER_multipeermap_contains (c->connectmap, 271 GNUNET_CONTAINER_multipeermap_contains (c->connectmap, &car->target))
278 &car->target))
279 { 272 {
280 /* connection has gone down since, drop request */ 273 /* connection has gone down since, drop request */
281 GNUNET_assert (0 != 274 GNUNET_assert (0 != memcmp (&car->target,
282 memcmp (&car->target, 275 &GSC_my_identity,
283 &GSC_my_identity, 276 sizeof (struct GNUNET_PeerIdentity)));
284 sizeof (struct GNUNET_PeerIdentity)));
285 GSC_SESSIONS_dequeue_request (car); 277 GSC_SESSIONS_dequeue_request (car);
286 GSC_CLIENTS_reject_request (car, 278 GSC_CLIENTS_reject_request (car, GNUNET_NO);
287 GNUNET_NO);
288 return; 279 return;
289 } 280 }
290 delay = GNUNET_TIME_absolute_get_duration (car->received_time); 281 delay = GNUNET_TIME_absolute_get_duration (car->received_time);
291 left = GNUNET_TIME_absolute_get_duration (car->deadline); 282 left = GNUNET_TIME_absolute_get_duration (car->deadline);
292 if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) 283 if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
293 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 284 GNUNET_log (
294 "Client waited %s for permission to transmit to `%s'%s (priority %u)\n", 285 GNUNET_ERROR_TYPE_WARNING,
295 GNUNET_STRINGS_relative_time_to_string (delay, 286 "Client waited %s for permission to transmit to `%s'%s (priority %u)\n",
296 GNUNET_YES), 287 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
297 GNUNET_i2s (&car->target), 288 GNUNET_i2s (&car->target),
298 (0 == left.rel_value_us) 289 (0 == left.rel_value_us) ? " (past deadline)" : "",
299 ? " (past deadline)" 290 car->priority);
300 : "", 291 env = GNUNET_MQ_msg (smr, GNUNET_MESSAGE_TYPE_CORE_SEND_READY);
301 car->priority);
302 env = GNUNET_MQ_msg (smr,
303 GNUNET_MESSAGE_TYPE_CORE_SEND_READY);
304 smr->size = htons (car->msize); 292 smr->size = htons (car->msize);
305 smr->smr_id = car->smr_id; 293 smr->smr_id = car->smr_id;
306 smr->peer = car->target; 294 smr->peer = car->target;
307 GNUNET_MQ_send (c->mq, 295 GNUNET_MQ_send (c->mq, env);
308 env);
309} 296}
310 297
311 298
@@ -316,51 +303,47 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
316 * @param req the `struct SendMessageRequest` 303 * @param req the `struct SendMessageRequest`
317 */ 304 */
318static void 305static void
319handle_client_send_request (void *cls, 306handle_client_send_request (void *cls, const struct SendMessageRequest *req)
320 const struct SendMessageRequest *req)
321{ 307{
322 struct GSC_Client *c = cls; 308 struct GSC_Client *c = cls;
323 struct GSC_ClientActiveRequest *car; 309 struct GSC_ClientActiveRequest *car;
324 int is_loopback; 310 int is_loopback;
325 311
326 if (NULL == c->requests) 312 if (NULL == c->requests)
327 c->requests = GNUNET_CONTAINER_multipeermap_create (16, 313 c->requests = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO);
328 GNUNET_NO);
329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
330 "Client asked for transmission to `%s'\n", 315 "Client asked for transmission to `%s'\n",
331 GNUNET_i2s (&req->peer)); 316 GNUNET_i2s (&req->peer));
332 is_loopback = 317 is_loopback = (0 == memcmp (&req->peer,
333 (0 == 318 &GSC_my_identity,
334 memcmp (&req->peer, 319 sizeof (struct GNUNET_PeerIdentity)));
335 &GSC_my_identity,
336 sizeof (struct GNUNET_PeerIdentity)));
337 if ((! is_loopback) && 320 if ((! is_loopback) &&
338 (GNUNET_YES != 321 (GNUNET_YES !=
339 GNUNET_CONTAINER_multipeermap_contains (c->connectmap, 322 GNUNET_CONTAINER_multipeermap_contains (c->connectmap, &req->peer)))
340 &req->peer)))
341 { 323 {
342 /* neighbour must have disconnected since request was issued, 324 /* neighbour must have disconnected since request was issued,
343 * ignore (client will realize it once it processes the 325 * ignore (client will realize it once it processes the
344 * disconnect notification) */ 326 * disconnect notification) */
345 GNUNET_STATISTICS_update (GSC_stats, 327 GNUNET_STATISTICS_update (GSC_stats,
346 gettext_noop 328 gettext_noop (
347 ("# send requests dropped (disconnected)"), 1, 329 "# send requests dropped (disconnected)"),
330 1,
348 GNUNET_NO); 331 GNUNET_NO);
349 GNUNET_SERVICE_client_continue (c->client); 332 GNUNET_SERVICE_client_continue (c->client);
350 return; 333 return;
351 } 334 }
352 335
353 car = GNUNET_CONTAINER_multipeermap_get (c->requests, 336 car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer);
354 &req->peer);
355 if (NULL == car) 337 if (NULL == car)
356 { 338 {
357 /* create new entry */ 339 /* create new entry */
358 car = GNUNET_new (struct GSC_ClientActiveRequest); 340 car = GNUNET_new (struct GSC_ClientActiveRequest);
359 GNUNET_assert (GNUNET_OK == 341 GNUNET_assert (GNUNET_OK ==
360 GNUNET_CONTAINER_multipeermap_put (c->requests, 342 GNUNET_CONTAINER_multipeermap_put (
361 &req->peer, 343 c->requests,
362 car, 344 &req->peer,
363 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 345 car,
346 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
364 car->client_handle = c; 347 car->client_handle = c;
365 } 348 }
366 else 349 else
@@ -368,8 +351,9 @@ handle_client_send_request (void *cls,
368 /* dequeue and recycle memory from pending request, there can only 351 /* dequeue and recycle memory from pending request, there can only
369 be at most one per client and peer */ 352 be at most one per client and peer */
370 GNUNET_STATISTICS_update (GSC_stats, 353 GNUNET_STATISTICS_update (GSC_stats,
371 gettext_noop ("# dequeuing CAR (duplicate request)"), 354 gettext_noop (
372 1, 355 "# dequeuing CAR (duplicate request)"),
356 1,
373 GNUNET_NO); 357 GNUNET_NO);
374 GSC_SESSIONS_dequeue_request (car); 358 GSC_SESSIONS_dequeue_request (car);
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -379,7 +363,7 @@ handle_client_send_request (void *cls,
379 car->target = req->peer; 363 car->target = req->peer;
380 car->received_time = GNUNET_TIME_absolute_get (); 364 car->received_time = GNUNET_TIME_absolute_get ();
381 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline); 365 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline);
382 car->priority = (enum GNUNET_CORE_Priority) ntohl (req->priority); 366 car->priority = (enum GNUNET_MQ_PriorityPreferences) ntohl (req->priority);
383 car->msize = ntohs (req->size); 367 car->msize = ntohs (req->size);
384 car->smr_id = req->smr_id; 368 car->smr_id = req->smr_id;
385 car->was_solicited = GNUNET_NO; 369 car->was_solicited = GNUNET_NO;
@@ -408,13 +392,7 @@ struct TokenizerContext
408 /** 392 /**
409 * How important is this message. 393 * How important is this message.
410 */ 394 */
411 enum GNUNET_CORE_Priority priority; 395 enum GNUNET_MQ_PriorityPreferences priority;
412
413 /**
414 * Is corking allowed (set only once we have the real message).
415 */
416 int cork;
417
418}; 396};
419 397
420 398
@@ -431,65 +409,57 @@ struct TokenizerContext
431 * #GNUNET_SYSERR to stop further processing with error 409 * #GNUNET_SYSERR to stop further processing with error
432 */ 410 */
433static int 411static int
434tokenized_cb (void *cls, 412tokenized_cb (void *cls, const struct GNUNET_MessageHeader *message)
435 const struct GNUNET_MessageHeader *message)
436{ 413{
437 struct TokenizerContext *tc = cls; 414 struct TokenizerContext *tc = cls;
438 struct GSC_ClientActiveRequest *car = tc->car; 415 struct GSC_ClientActiveRequest *car = tc->car;
439 char buf[92]; 416 char buf[92];
440 417
441 GNUNET_snprintf (buf, 418 GNUNET_snprintf (buf,
442 sizeof (buf), 419 sizeof (buf),
443 gettext_noop ("# bytes of messages of type %u received"), 420 gettext_noop ("# bytes of messages of type %u received"),
444 (unsigned int) ntohs (message->type)); 421 (unsigned int) ntohs (message->type));
445 GNUNET_STATISTICS_update (GSC_stats, 422 GNUNET_STATISTICS_update (GSC_stats, buf, ntohs (message->size), GNUNET_NO);
446 buf, 423 if (0 == memcmp (&car->target,
447 ntohs (message->size), 424 &GSC_my_identity,
448 GNUNET_NO); 425 sizeof (struct GNUNET_PeerIdentity)))
449 if (0 ==
450 memcmp (&car->target,
451 &GSC_my_identity,
452 sizeof (struct GNUNET_PeerIdentity)))
453 { 426 {
454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
455 "Delivering message of type %u to myself\n", 428 "Delivering message of type %u to myself\n",
456 ntohs (message->type)); 429 ntohs (message->type));
457 GSC_CLIENTS_deliver_message (&GSC_my_identity, 430 GSC_CLIENTS_deliver_message (&GSC_my_identity,
458 message, 431 message,
459 ntohs (message->size), 432 ntohs (message->size),
460 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); 433 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
461 GSC_CLIENTS_deliver_message (&GSC_my_identity, 434 GSC_CLIENTS_deliver_message (&GSC_my_identity,
462 message, 435 message,
463 sizeof (struct GNUNET_MessageHeader), 436 sizeof (struct GNUNET_MessageHeader),
464 GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND); 437 GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
465 GSC_CLIENTS_deliver_message (&GSC_my_identity, 438 GSC_CLIENTS_deliver_message (&GSC_my_identity,
466 message, 439 message,
467 ntohs (message->size), 440 ntohs (message->size),
468 GNUNET_CORE_OPTION_SEND_FULL_INBOUND); 441 GNUNET_CORE_OPTION_SEND_FULL_INBOUND);
469 GSC_CLIENTS_deliver_message (&GSC_my_identity, 442 GSC_CLIENTS_deliver_message (&GSC_my_identity,
470 message, 443 message,
471 sizeof (struct GNUNET_MessageHeader), 444 sizeof (struct GNUNET_MessageHeader),
472 GNUNET_CORE_OPTION_SEND_HDR_INBOUND); 445 GNUNET_CORE_OPTION_SEND_HDR_INBOUND);
473 } 446 }
474 else 447 else
475 { 448 {
476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
477 "Delivering message of type %u and size %u to %s\n", 450 "Delivering message of type %u and size %u to %s\n",
478 ntohs (message->type), 451 ntohs (message->type),
479 ntohs (message->size), 452 ntohs (message->size),
480 GNUNET_i2s (&car->target)); 453 GNUNET_i2s (&car->target));
481 GSC_CLIENTS_deliver_message (&car->target, 454 GSC_CLIENTS_deliver_message (&car->target,
482 message, 455 message,
483 ntohs (message->size), 456 ntohs (message->size),
484 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); 457 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
485 GSC_CLIENTS_deliver_message (&car->target, 458 GSC_CLIENTS_deliver_message (&car->target,
486 message, 459 message,
487 sizeof (struct GNUNET_MessageHeader), 460 sizeof (struct GNUNET_MessageHeader),
488 GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND); 461 GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
489 GSC_SESSIONS_transmit (car, 462 GSC_SESSIONS_transmit (car, message, tc->priority);
490 message,
491 tc->cork,
492 tc->priority);
493 } 463 }
494 return GNUNET_OK; 464 return GNUNET_OK;
495} 465}
@@ -503,8 +473,7 @@ tokenized_cb (void *cls,
503 * @return #GNUNET_OK if @a sm is well-formed 473 * @return #GNUNET_OK if @a sm is well-formed
504 */ 474 */
505static int 475static int
506check_client_send (void *cls, 476check_client_send (void *cls, const struct SendMessage *sm)
507 const struct SendMessage *sm)
508{ 477{
509 return GNUNET_OK; 478 return GNUNET_OK;
510} 479}
@@ -517,8 +486,7 @@ check_client_send (void *cls,
517 * @param sm the `struct SendMessage` 486 * @param sm the `struct SendMessage`
518 */ 487 */
519static void 488static void
520handle_client_send (void *cls, 489handle_client_send (void *cls, const struct SendMessage *sm)
521 const struct SendMessage *sm)
522{ 490{
523 struct GSC_Client *c = cls; 491 struct GSC_Client *c = cls;
524 struct TokenizerContext tc; 492 struct TokenizerContext tc;
@@ -527,9 +495,7 @@ handle_client_send (void *cls,
527 struct GNUNET_MessageStreamTokenizer *mst; 495 struct GNUNET_MessageStreamTokenizer *mst;
528 496
529 msize = ntohs (sm->header.size) - sizeof (struct SendMessage); 497 msize = ntohs (sm->header.size) - sizeof (struct SendMessage);
530 GNUNET_break (0 == ntohl (sm->reserved)); 498 tc.car = GNUNET_CONTAINER_multipeermap_get (c->requests, &sm->peer);
531 tc.car = GNUNET_CONTAINER_multipeermap_get (c->requests,
532 &sm->peer);
533 if (NULL == tc.car) 499 if (NULL == tc.car)
534 { 500 {
535 /* Must have been that we first approved the request, then got disconnected 501 /* Must have been that we first approved the request, then got disconnected
@@ -538,43 +504,37 @@ handle_client_send (void *cls,
538 * might also now be *again* connected. So this can happen (but should be 504 * might also now be *again* connected. So this can happen (but should be
539 * rare). If it does happen, the message is discarded. */ 505 * rare). If it does happen, the message is discarded. */
540 GNUNET_STATISTICS_update (GSC_stats, 506 GNUNET_STATISTICS_update (GSC_stats,
541 gettext_noop ("# messages discarded (session disconnected)"), 507 gettext_noop (
508 "# messages discarded (session disconnected)"),
542 1, 509 1,
543 GNUNET_NO); 510 GNUNET_NO);
544 GNUNET_SERVICE_client_continue (c->client); 511 GNUNET_SERVICE_client_continue (c->client);
545 return; 512 return;
546 } 513 }
547 delay = GNUNET_TIME_absolute_get_duration (tc.car->received_time); 514 delay = GNUNET_TIME_absolute_get_duration (tc.car->received_time);
548 tc.cork = ntohl (sm->cork); 515 tc.priority = (enum GNUNET_MQ_PriorityPreferences) ntohl (sm->priority);
549 tc.priority = (enum GNUNET_CORE_Priority) ntohl (sm->priority);
550 if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) 516 if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
551 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 517 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
552 "Client waited %s for transmission of %u bytes to `%s'%s\n", 518 "Client waited %s for transmission of %u bytes to `%s'\n",
553 GNUNET_STRINGS_relative_time_to_string (delay, 519 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
554 GNUNET_YES),
555 msize, 520 msize,
556 GNUNET_i2s (&sm->peer), 521 GNUNET_i2s (&sm->peer));
557 tc.cork ? " (cork)" : " (uncorked)");
558 else 522 else
559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
560 "Client waited %s for transmission of %u bytes to `%s'%s\n", 524 "Client waited %s for transmission of %u bytes to `%s'\n",
561 GNUNET_STRINGS_relative_time_to_string (delay, 525 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
562 GNUNET_YES),
563 msize, 526 msize,
564 GNUNET_i2s (&sm->peer), 527 GNUNET_i2s (&sm->peer));
565 tc.cork ? " (cork)" : " (uncorked)");
566 528
567 GNUNET_assert (GNUNET_YES == 529 GNUNET_assert (
568 GNUNET_CONTAINER_multipeermap_remove (c->requests, 530 GNUNET_YES ==
569 &sm->peer, 531 GNUNET_CONTAINER_multipeermap_remove (c->requests, &sm->peer, tc.car));
570 tc.car)); 532 mst = GNUNET_MST_create (&tokenized_cb, &tc);
571 mst = GNUNET_MST_create (&tokenized_cb,
572 &tc);
573 GNUNET_MST_from_buffer (mst, 533 GNUNET_MST_from_buffer (mst,
574 (const char *) &sm[1], 534 (const char *) &sm[1],
575 msize, 535 msize,
576 GNUNET_YES, 536 GNUNET_YES,
577 GNUNET_NO); 537 GNUNET_NO);
578 GNUNET_MST_destroy (mst); 538 GNUNET_MST_destroy (mst);
579 GSC_SESSIONS_dequeue_request (tc.car); 539 GSC_SESSIONS_dequeue_request (tc.car);
580 GNUNET_free (tc.car); 540 GNUNET_free (tc.car);
@@ -592,16 +552,16 @@ handle_client_send (void *cls,
592 */ 552 */
593static int 553static int
594destroy_active_client_request (void *cls, 554destroy_active_client_request (void *cls,
595 const struct GNUNET_PeerIdentity *key, 555 const struct GNUNET_PeerIdentity *key,
596 void *value) 556 void *value)
597{ 557{
598 struct GSC_ClientActiveRequest *car = value; 558 struct GSC_ClientActiveRequest *car = value;
599 559
600 GNUNET_assert (GNUNET_YES == 560 GNUNET_assert (
601 GNUNET_CONTAINER_multipeermap_remove (car-> 561 GNUNET_YES ==
602 client_handle->requests, 562 GNUNET_CONTAINER_multipeermap_remove (car->client_handle->requests,
603 &car->target, 563 &car->target,
604 car)); 564 car));
605 GSC_SESSIONS_dequeue_request (car); 565 GSC_SESSIONS_dequeue_request (car);
606 GNUNET_free (car); 566 GNUNET_free (car);
607 return GNUNET_YES; 567 return GNUNET_YES;
@@ -618,19 +578,16 @@ destroy_active_client_request (void *cls,
618 */ 578 */
619static void * 579static void *
620client_connect_cb (void *cls, 580client_connect_cb (void *cls,
621 struct GNUNET_SERVICE_Client *client, 581 struct GNUNET_SERVICE_Client *client,
622 struct GNUNET_MQ_Handle *mq) 582 struct GNUNET_MQ_Handle *mq)
623{ 583{
624 struct GSC_Client *c; 584 struct GSC_Client *c;
625 585
626 c = GNUNET_new (struct GSC_Client); 586 c = GNUNET_new (struct GSC_Client);
627 c->client = client; 587 c->client = client;
628 c->mq = mq; 588 c->mq = mq;
629 c->connectmap = GNUNET_CONTAINER_multipeermap_create (16, 589 c->connectmap = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO);
630 GNUNET_NO); 590 GNUNET_CONTAINER_DLL_insert (client_head, client_tail, c);
631 GNUNET_CONTAINER_DLL_insert (client_head,
632 client_tail,
633 c);
634 return c; 591 return c;
635} 592}
636 593
@@ -644,17 +601,15 @@ client_connect_cb (void *cls,
644 */ 601 */
645static void 602static void
646client_disconnect_cb (void *cls, 603client_disconnect_cb (void *cls,
647 struct GNUNET_SERVICE_Client *client, 604 struct GNUNET_SERVICE_Client *client,
648 void *app_ctx) 605 void *app_ctx)
649{ 606{
650 struct GSC_Client *c = app_ctx; 607 struct GSC_Client *c = app_ctx;
651 608
652 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
653 "Client %p has disconnected from core service.\n", 610 "Client %p has disconnected from core service.\n",
654 client); 611 client);
655 GNUNET_CONTAINER_DLL_remove (client_head, 612 GNUNET_CONTAINER_DLL_remove (client_head, client_tail, c);
656 client_tail,
657 c);
658 if (NULL != c->requests) 613 if (NULL != c->requests)
659 { 614 {
660 GNUNET_CONTAINER_multipeermap_iterate (c->requests, 615 GNUNET_CONTAINER_multipeermap_iterate (c->requests,
@@ -666,15 +621,14 @@ client_disconnect_cb (void *cls,
666 c->connectmap = NULL; 621 c->connectmap = NULL;
667 if (NULL != c->types) 622 if (NULL != c->types)
668 { 623 {
669 GSC_TYPEMAP_remove (c->types, 624 GSC_TYPEMAP_remove (c->types, c->tcnt);
670 c->tcnt);
671 GNUNET_free (c->types); 625 GNUNET_free (c->types);
672 } 626 }
673 GNUNET_free (c); 627 GNUNET_free (c);
674 628
675 /* recalculate 'all_client_options' */ 629 /* recalculate 'all_client_options' */
676 all_client_options = 0; 630 all_client_options = 0;
677 for (c = client_head; NULL != c ; c = c->next) 631 for (c = client_head; NULL != c; c = c->next)
678 all_client_options |= c->options; 632 all_client_options |= c->options;
679} 633}
680 634
@@ -690,10 +644,11 @@ client_disconnect_cb (void *cls,
690 * @param tmap_new updated type map for the neighbour, NULL for disconnect 644 * @param tmap_new updated type map for the neighbour, NULL for disconnect
691 */ 645 */
692void 646void
693GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client, 647GSC_CLIENTS_notify_client_about_neighbour (
694 const struct GNUNET_PeerIdentity *neighbour, 648 struct GSC_Client *client,
695 const struct GSC_TypeMap *tmap_old, 649 const struct GNUNET_PeerIdentity *neighbour,
696 const struct GSC_TypeMap *tmap_new) 650 const struct GSC_TypeMap *tmap_old,
651 const struct GSC_TypeMap *tmap_new)
697{ 652{
698 struct GNUNET_MQ_Envelope *env; 653 struct GNUNET_MQ_Envelope *env;
699 int old_match; 654 int old_match;
@@ -701,12 +656,8 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
701 656
702 if (GNUNET_YES != client->got_init) 657 if (GNUNET_YES != client->got_init)
703 return; 658 return;
704 old_match = GSC_TYPEMAP_test_match (tmap_old, 659 old_match = GSC_TYPEMAP_test_match (tmap_old, client->types, client->tcnt);
705 client->types, 660 new_match = GSC_TYPEMAP_test_match (tmap_new, client->types, client->tcnt);
706 client->tcnt);
707 new_match = GSC_TYPEMAP_test_match (tmap_new,
708 client->types,
709 client->tcnt);
710 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 661 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
711 "Notifying client about neighbour %s (%d/%d)\n", 662 "Notifying client about neighbour %s (%d/%d)\n",
712 GNUNET_i2s (neighbour), 663 GNUNET_i2s (neighbour),
@@ -714,55 +665,52 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
714 new_match); 665 new_match);
715 if (old_match == new_match) 666 if (old_match == new_match)
716 { 667 {
717 GNUNET_assert (old_match == 668 GNUNET_assert (
718 GNUNET_CONTAINER_multipeermap_contains (client->connectmap, 669 old_match ==
719 neighbour)); 670 GNUNET_CONTAINER_multipeermap_contains (client->connectmap, neighbour));
720 return; /* no change */ 671 return; /* no change */
721 } 672 }
722 if (GNUNET_NO == old_match) 673 if (GNUNET_NO == old_match)
723 { 674 {
724 struct ConnectNotifyMessage *cnm; 675 struct ConnectNotifyMessage *cnm;
725 676
726 /* send connect */ 677 /* send connect */
727 GNUNET_assert (GNUNET_NO == 678 GNUNET_assert (
728 GNUNET_CONTAINER_multipeermap_contains (client->connectmap, 679 GNUNET_NO ==
729 neighbour)); 680 GNUNET_CONTAINER_multipeermap_contains (client->connectmap, neighbour));
730 GNUNET_assert (GNUNET_YES == 681 GNUNET_assert (GNUNET_YES ==
731 GNUNET_CONTAINER_multipeermap_put (client->connectmap, 682 GNUNET_CONTAINER_multipeermap_put (
732 neighbour, 683 client->connectmap,
733 NULL, 684 neighbour,
734 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 685 NULL,
735 env = GNUNET_MQ_msg (cnm, 686 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
736 GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); 687 env = GNUNET_MQ_msg (cnm, GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
737 cnm->reserved = htonl (0); 688 cnm->reserved = htonl (0);
738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
739 "Sending NOTIFY_CONNECT message about peer %s to client.\n", 690 "Sending NOTIFY_CONNECT message about peer %s to client.\n",
740 GNUNET_i2s (neighbour)); 691 GNUNET_i2s (neighbour));
741 cnm->peer = *neighbour; 692 cnm->peer = *neighbour;
742 GNUNET_MQ_send (client->mq, 693 GNUNET_MQ_send (client->mq, env);
743 env);
744 } 694 }
745 else 695 else
746 { 696 {
747 struct DisconnectNotifyMessage *dcm; 697 struct DisconnectNotifyMessage *dcm;
748 698
749 /* send disconnect */ 699 /* send disconnect */
750 GNUNET_assert (GNUNET_YES == 700 GNUNET_assert (
751 GNUNET_CONTAINER_multipeermap_contains (client->connectmap, 701 GNUNET_YES ==
752 neighbour)); 702 GNUNET_CONTAINER_multipeermap_contains (client->connectmap, neighbour));
753 GNUNET_assert (GNUNET_YES == 703 GNUNET_assert (GNUNET_YES ==
754 GNUNET_CONTAINER_multipeermap_remove (client->connectmap, 704 GNUNET_CONTAINER_multipeermap_remove (client->connectmap,
755 neighbour, 705 neighbour,
756 NULL)); 706 NULL));
757 env = GNUNET_MQ_msg (dcm, 707 env = GNUNET_MQ_msg (dcm, GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
758 GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
759 dcm->reserved = htonl (0); 708 dcm->reserved = htonl (0);
760 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
761 "Sending NOTIFY_DISCONNECT message about peer %s to client.\n", 710 "Sending NOTIFY_DISCONNECT message about peer %s to client.\n",
762 GNUNET_i2s (neighbour)); 711 GNUNET_i2s (neighbour));
763 dcm->peer = *neighbour; 712 dcm->peer = *neighbour;
764 GNUNET_MQ_send (client->mq, 713 GNUNET_MQ_send (client->mq, env);
765 env);
766 } 714 }
767} 715}
768 716
@@ -777,17 +725,18 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
777 * @param tmap_new updated type map for the neighbour, NULL for disconnect 725 * @param tmap_new updated type map for the neighbour, NULL for disconnect
778 */ 726 */
779void 727void
780GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour, 728GSC_CLIENTS_notify_clients_about_neighbour (
781 const struct GSC_TypeMap *tmap_old, 729 const struct GNUNET_PeerIdentity *neighbour,
782 const struct GSC_TypeMap *tmap_new) 730 const struct GSC_TypeMap *tmap_old,
731 const struct GSC_TypeMap *tmap_new)
783{ 732{
784 struct GSC_Client *c; 733 struct GSC_Client *c;
785 734
786 for (c = client_head; NULL != c; c = c->next) 735 for (c = client_head; NULL != c; c = c->next)
787 GSC_CLIENTS_notify_client_about_neighbour (c, 736 GSC_CLIENTS_notify_client_about_neighbour (c,
788 neighbour, 737 neighbour,
789 tmap_old, 738 tmap_old,
790 tmap_new); 739 tmap_new);
791} 740}
792 741
793 742
@@ -815,15 +764,14 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
815 GNUNET_break (0); 764 GNUNET_break (0);
816 return; 765 return;
817 } 766 }
818 if (! ( (0 != (all_client_options & options)) || 767 if (! ((0 != (all_client_options & options)) ||
819 (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) )) 768 (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND))))
820 return; /* no client cares about this message notification */ 769 return; /* no client cares about this message notification */
821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 770 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
822 "Core service passes message from `%s' of type %u to client.\n", 771 "Core service passes message from `%s' of type %u to client.\n",
823 GNUNET_i2s (sender), 772 GNUNET_i2s (sender),
824 (unsigned int) ntohs (msg->type)); 773 (unsigned int) ntohs (msg->type));
825 GSC_SESSIONS_add_to_typemap (sender, 774 GSC_SESSIONS_add_to_typemap (sender, ntohs (msg->type));
826 ntohs (msg->type));
827 775
828 for (struct GSC_Client *c = client_head; NULL != c; c = c->next) 776 for (struct GSC_Client *c = client_head; NULL != c; c = c->next)
829 { 777 {
@@ -833,18 +781,17 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
833 unsigned int qlen; 781 unsigned int qlen;
834 int tm; 782 int tm;
835 783
836 tm = type_match (ntohs (msg->type), 784 tm = type_match (ntohs (msg->type), c);
837 c); 785 if (! ((0 != (c->options & options)) ||
838 if (! ( (0 != (c->options & options)) || 786 ((0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) &&
839 ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) && 787 (GNUNET_YES == tm))))
840 (GNUNET_YES == tm) ) ) ) 788 continue; /* neither options nor type match permit the message */
841 continue; /* neither options nor type match permit the message */ 789 if ((0 != (options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND)) &&
842 if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND)) && 790 ((0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) ||
843 ( (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || 791 (GNUNET_YES == tm)))
844 (GNUNET_YES == tm) ) )
845 continue; 792 continue;
846 if ( (0 != (options & GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND)) && 793 if ((0 != (options & GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND)) &&
847 (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND)) ) 794 (0 != (c->options & GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND)))
848 continue; 795 continue;
849 796
850 /* Drop messages if: 797 /* Drop messages if:
@@ -862,54 +809,50 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
862 (ACK, queries) which may be cummulative or highly redundant, 809 (ACK, queries) which may be cummulative or highly redundant,
863 and cheap to drop than data traffic. */ 810 and cheap to drop than data traffic. */
864 qlen = GNUNET_MQ_get_length (c->mq); 811 qlen = GNUNET_MQ_get_length (c->mq);
865 if ( (qlen >= HARD_MAX_QUEUE) || 812 if ((qlen >= HARD_MAX_QUEUE) ||
866 ( (qlen > SOFT_MAX_QUEUE) && 813 ((qlen > SOFT_MAX_QUEUE) &&
867 ( (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 814 ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
868 ntohs (msg->size)) ) < 815 ntohs (msg->size))) <
869 (qlen - SOFT_MAX_QUEUE) * 0x8000 / 816 (qlen - SOFT_MAX_QUEUE) * 0x8000 /
870 (HARD_MAX_QUEUE - SOFT_MAX_QUEUE) ) ) ) 817 (HARD_MAX_QUEUE - SOFT_MAX_QUEUE))))
871 { 818 {
872 char buf[1024]; 819 char buf[1024];
873 820
874 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, 821 GNUNET_log (
875 "Dropping decrypted message of type %u as client is too busy (queue full)\n", 822 GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
876 (unsigned int) ntohs (msg->type)); 823 "Dropping decrypted message of type %u as client is too busy (queue full)\n",
824 (unsigned int) ntohs (msg->type));
877 GNUNET_snprintf (buf, 825 GNUNET_snprintf (buf,
878 sizeof (buf), 826 sizeof (buf),
879 gettext_noop ("# messages of type %u discarded (client busy)"), 827 gettext_noop (
828 "# messages of type %u discarded (client busy)"),
880 (unsigned int) ntohs (msg->type)); 829 (unsigned int) ntohs (msg->type));
881 GNUNET_STATISTICS_update (GSC_stats, 830 GNUNET_STATISTICS_update (GSC_stats, buf, 1, GNUNET_NO);
882 buf,
883 1,
884 GNUNET_NO);
885 continue; 831 continue;
886 } 832 }
887 833
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 834 GNUNET_log (
889 "Sending %u message with %u bytes to client interested in messages of type %u.\n", 835 GNUNET_ERROR_TYPE_DEBUG,
890 options, 836 "Sending %u message with %u bytes to client interested in messages of type %u.\n",
891 ntohs (msg->size), 837 options,
892 (unsigned int) ntohs (msg->type)); 838 ntohs (msg->size),
839 (unsigned int) ntohs (msg->type));
893 840
894 if (0 != (options & (GNUNET_CORE_OPTION_SEND_FULL_INBOUND | GNUNET_CORE_OPTION_SEND_HDR_INBOUND))) 841 if (0 != (options & (GNUNET_CORE_OPTION_SEND_FULL_INBOUND |
842 GNUNET_CORE_OPTION_SEND_HDR_INBOUND)))
895 mtype = GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND; 843 mtype = GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND;
896 else 844 else
897 mtype = GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND; 845 mtype = GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND;
898 env = GNUNET_MQ_msg_extra (ntm, 846 env = GNUNET_MQ_msg_extra (ntm, msize, mtype);
899 msize,
900 mtype);
901 ntm->peer = *sender; 847 ntm->peer = *sender;
902 GNUNET_memcpy (&ntm[1], 848 GNUNET_memcpy (&ntm[1], msg, msize);
903 msg, 849
904 msize); 850 GNUNET_assert (
905 851 (0 == (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) ||
906 GNUNET_assert ( (0 == (c->options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) || 852 (GNUNET_YES != tm) ||
907 (GNUNET_YES != tm) || 853 (GNUNET_YES ==
908 (GNUNET_YES == 854 GNUNET_CONTAINER_multipeermap_contains (c->connectmap, sender)));
909 GNUNET_CONTAINER_multipeermap_contains (c->connectmap, 855 GNUNET_MQ_send (c->mq, env);
910 sender)) );
911 GNUNET_MQ_send (c->mq,
912 env);
913 } 856 }
914} 857}
915 858
@@ -925,8 +868,7 @@ shutdown_task (void *cls)
925{ 868{
926 struct GSC_Client *c; 869 struct GSC_Client *c;
927 870
928 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service shutting down.\n");
929 "Core service shutting down.\n");
930 while (NULL != (c = client_head)) 872 while (NULL != (c = client_head))
931 GNUNET_SERVICE_client_drop (c->client); 873 GNUNET_SERVICE_client_drop (c->client);
932 GSC_SESSIONS_done (); 874 GSC_SESSIONS_done ();
@@ -934,8 +876,7 @@ shutdown_task (void *cls)
934 GSC_TYPEMAP_done (); 876 GSC_TYPEMAP_done ();
935 if (NULL != GSC_stats) 877 if (NULL != GSC_stats)
936 { 878 {
937 GNUNET_STATISTICS_destroy (GSC_stats, 879 GNUNET_STATISTICS_destroy (GSC_stats, GNUNET_NO);
938 GNUNET_NO);
939 GSC_stats = NULL; 880 GSC_stats = NULL;
940 } 881 }
941 GSC_cfg = NULL; 882 GSC_cfg = NULL;
@@ -953,7 +894,7 @@ shutdown_task (void *cls)
953 */ 894 */
954static void 895static void
955handle_client_monitor_peers (void *cls, 896handle_client_monitor_peers (void *cls,
956 const struct GNUNET_MessageHeader *message) 897 const struct GNUNET_MessageHeader *message)
957{ 898{
958 struct GSC_Client *c = cls; 899 struct GSC_Client *c = cls;
959 900
@@ -978,21 +919,19 @@ run (void *cls,
978 char *keyfile; 919 char *keyfile;
979 920
980 GSC_cfg = c; 921 GSC_cfg = c;
981 if (GNUNET_OK != 922 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GSC_cfg,
982 GNUNET_CONFIGURATION_get_value_filename (GSC_cfg, 923 "PEER",
983 "PEER", 924 "PRIVATE_KEY",
984 "PRIVATE_KEY", 925 &keyfile))
985 &keyfile))
986 { 926 {
987 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 927 GNUNET_log (
988 _("Core service is lacking HOSTKEY configuration setting. Exiting.\n")); 928 GNUNET_ERROR_TYPE_ERROR,
929 _ ("Core service is lacking HOSTKEY configuration setting. Exiting.\n"));
989 GNUNET_SCHEDULER_shutdown (); 930 GNUNET_SCHEDULER_shutdown ();
990 return; 931 return;
991 } 932 }
992 GSC_stats = GNUNET_STATISTICS_create ("core", 933 GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg);
993 GSC_cfg); 934 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
994 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
995 NULL);
996 GNUNET_SERVICE_suspend (service); 935 GNUNET_SERVICE_suspend (service);
997 GSC_TYPEMAP_init (); 936 GSC_TYPEMAP_init ();
998 pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); 937 pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile);
@@ -1006,7 +945,7 @@ run (void *cls,
1006 GSC_SESSIONS_init (); 945 GSC_SESSIONS_init ();
1007 GNUNET_SERVICE_resume (service); 946 GNUNET_SERVICE_resume (service);
1008 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 947 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1009 _("Core service of `%s' ready.\n"), 948 _ ("Core service of `%s' ready.\n"),
1010 GNUNET_i2s (&GSC_my_identity)); 949 GNUNET_i2s (&GSC_my_identity));
1011} 950}
1012 951
@@ -1014,30 +953,30 @@ run (void *cls,
1014/** 953/**
1015 * Define "main" method using service macro. 954 * Define "main" method using service macro.
1016 */ 955 */
1017GNUNET_SERVICE_MAIN 956GNUNET_SERVICE_MAIN (
1018("core", 957 "core",
1019 GNUNET_SERVICE_OPTION_NONE, 958 GNUNET_SERVICE_OPTION_NONE,
1020 &run, 959 &run,
1021 &client_connect_cb, 960 &client_connect_cb,
1022 &client_disconnect_cb, 961 &client_disconnect_cb,
1023 NULL, 962 NULL,
1024 GNUNET_MQ_hd_var_size (client_init, 963 GNUNET_MQ_hd_var_size (client_init,
1025 GNUNET_MESSAGE_TYPE_CORE_INIT, 964 GNUNET_MESSAGE_TYPE_CORE_INIT,
1026 struct InitMessage, 965 struct InitMessage,
1027 NULL), 966 NULL),
1028 GNUNET_MQ_hd_fixed_size (client_monitor_peers, 967 GNUNET_MQ_hd_fixed_size (client_monitor_peers,
1029 GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS, 968 GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS,
1030 struct GNUNET_MessageHeader, 969 struct GNUNET_MessageHeader,
1031 NULL), 970 NULL),
1032 GNUNET_MQ_hd_fixed_size (client_send_request, 971 GNUNET_MQ_hd_fixed_size (client_send_request,
1033 GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, 972 GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST,
1034 struct SendMessageRequest, 973 struct SendMessageRequest,
1035 NULL), 974 NULL),
1036 GNUNET_MQ_hd_var_size (client_send, 975 GNUNET_MQ_hd_var_size (client_send,
1037 GNUNET_MESSAGE_TYPE_CORE_SEND, 976 GNUNET_MESSAGE_TYPE_CORE_SEND,
1038 struct SendMessage, 977 struct SendMessage,
1039 NULL), 978 NULL),
1040 GNUNET_MQ_handler_end ()); 979 GNUNET_MQ_handler_end ());
1041 980
1042 981
1043/* end of gnunet-service-core.c */ 982/* end of gnunet-service-core.c */