diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-22 21:43:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-22 21:43:13 +0000 |
commit | 03c7d2c186ae7371ce5be6fddd376faf90c44e53 (patch) | |
tree | 1a961bd69ed3f758a218df2d5166ffea7a000870 /src/ats/ats_api_scheduling.c | |
parent | 8c0022803d0a2f74b8f8e3fbbbb9afddf2b621bc (diff) | |
download | gnunet-03c7d2c186ae7371ce5be6fddd376faf90c44e53.tar.gz gnunet-03c7d2c186ae7371ce5be6fddd376faf90c44e53.zip |
also simplify message format for AddressSuggestionMessage
Diffstat (limited to 'src/ats/ats_api_scheduling.c')
-rw-r--r-- | src/ats/ats_api_scheduling.c | 62 |
1 files changed, 9 insertions, 53 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 797ef2d59..52cc40bb2 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -448,44 +448,11 @@ process_ats_address_suggestion_message (void *cls, | |||
448 | { | 448 | { |
449 | struct GNUNET_ATS_SchedulingHandle *sh = cls; | 449 | struct GNUNET_ATS_SchedulingHandle *sh = cls; |
450 | const struct AddressSuggestionMessage *m; | 450 | const struct AddressSuggestionMessage *m; |
451 | const struct GNUNET_ATS_Information *atsi; | ||
452 | const char *plugin_address; | ||
453 | const char *plugin_name; | ||
454 | uint16_t plugin_address_length; | ||
455 | uint16_t plugin_name_length; | ||
456 | uint32_t ats_count; | ||
457 | struct GNUNET_HELLO_Address address; | ||
458 | struct Session *s; | ||
459 | struct GNUNET_ATS_AddressRecord *ar; | 451 | struct GNUNET_ATS_AddressRecord *ar; |
452 | uint32_t session_id; | ||
460 | 453 | ||
461 | if (ntohs (msg->size) <= sizeof (struct AddressSuggestionMessage)) | ||
462 | { | ||
463 | GNUNET_break (0); | ||
464 | force_reconnect (sh); | ||
465 | return; | ||
466 | } | ||
467 | /* FIXME: we have all the address details, no need for ATS | ||
468 | to send those back to us any longer! */ | ||
469 | m = (const struct AddressSuggestionMessage *) msg; | 454 | m = (const struct AddressSuggestionMessage *) msg; |
470 | ats_count = ntohl (m->ats_count); | 455 | session_id = ntohl (m->session_id); |
471 | plugin_address_length = ntohs (m->address_length); | ||
472 | atsi = (const struct GNUNET_ATS_Information *) &m[1]; | ||
473 | plugin_address = (const char *) &atsi[ats_count]; | ||
474 | plugin_name = &plugin_address[plugin_address_length]; | ||
475 | plugin_name_length = ntohs (m->plugin_name_length); | ||
476 | if ((plugin_address_length + plugin_name_length + | ||
477 | ats_count * sizeof (struct GNUNET_ATS_Information) + | ||
478 | sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) || | ||
479 | (ats_count > | ||
480 | GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) | ||
481 | || (plugin_name[plugin_name_length - 1] != '\0')) | ||
482 | { | ||
483 | GNUNET_break (0); | ||
484 | force_reconnect (sh); | ||
485 | return; | ||
486 | } | ||
487 | uint32_t session_id = ntohl (m->session_id); | ||
488 | |||
489 | if (0 == session_id) | 456 | if (0 == session_id) |
490 | { | 457 | { |
491 | GNUNET_break (0); | 458 | GNUNET_break (0); |
@@ -499,7 +466,6 @@ process_ats_address_suggestion_message (void *cls, | |||
499 | force_reconnect (sh); | 466 | force_reconnect (sh); |
500 | return; | 467 | return; |
501 | } | 468 | } |
502 | s = ar->session; | ||
503 | if (NULL == sh->suggest_cb) | 469 | if (NULL == sh->suggest_cb) |
504 | return; | 470 | return; |
505 | if ( (GNUNET_YES == ar->in_destroy) && | 471 | if ( (GNUNET_YES == ar->in_destroy) && |
@@ -509,27 +475,17 @@ process_ats_address_suggestion_message (void *cls, | |||
509 | /* ignore suggestion, as this address is dying */ | 475 | /* ignore suggestion, as this address is dying */ |
510 | return; | 476 | return; |
511 | } | 477 | } |
512 | address.peer = m->peer; | 478 | if ( (NULL == ar->session) && |
513 | address.address = plugin_address; | 479 | (GNUNET_HELLO_address_check_option (ar->address, |
514 | address.address_length = plugin_address_length; | 480 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) ) |
515 | address.transport_name = plugin_name; | ||
516 | address.local_info = ntohl(m->address_local_info); | ||
517 | |||
518 | if ((s == NULL) && (0 == address.address_length)) | ||
519 | { | 481 | { |
520 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 482 | GNUNET_break (0); |
521 | "ATS returned invalid address for peer `%s' transport `%s' address length %i, session_id %i\n", | ||
522 | GNUNET_i2s (&address.peer), | ||
523 | address.transport_name, | ||
524 | plugin_address_length, | ||
525 | session_id); | ||
526 | GNUNET_break_op (0); | ||
527 | return; | 483 | return; |
528 | } | 484 | } |
529 | sh->suggest_cb (sh->suggest_cb_cls, | 485 | sh->suggest_cb (sh->suggest_cb_cls, |
530 | &m->peer, | 486 | &m->peer, |
531 | &address, | 487 | ar->address, |
532 | s, | 488 | ar->session, |
533 | m->bandwidth_out, | 489 | m->bandwidth_out, |
534 | m->bandwidth_in); | 490 | m->bandwidth_in); |
535 | } | 491 | } |
@@ -625,7 +581,7 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh) | |||
625 | sizeof (struct SessionReleaseMessage) }, | 581 | sizeof (struct SessionReleaseMessage) }, |
626 | { &process_ats_address_suggestion_message, | 582 | { &process_ats_address_suggestion_message, |
627 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION, | 583 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION, |
628 | 0 }, | 584 | sizeof (struct AddressSuggestionMessage) }, |
629 | { NULL, 0, 0 } }; | 585 | { NULL, 0, 0 } }; |
630 | struct GNUNET_MQ_Envelope *ev; | 586 | struct GNUNET_MQ_Envelope *ev; |
631 | struct ClientStartMessage *init; | 587 | struct ClientStartMessage *init; |