diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-30 10:16:43 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-30 10:16:43 +0000 |
commit | 1031c6d5dcba9b7d8396296a61e608a5371215be (patch) | |
tree | 99c15a28cc0565e9024c29de1f1c80040776b718 /src/transport | |
parent | c188e8a0cae8ede61e4f8924e8b52558d0ac1861 (diff) | |
download | gnunet-1031c6d5dcba9b7d8396296a61e608a5371215be.tar.gz gnunet-1031c6d5dcba9b7d8396296a61e608a5371215be.zip |
Transmitting ATS information to transport api
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 24 | ||||
-rw-r--r-- | src/transport/transport_api.c | 5 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index e2168b970..c7fb59458 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -3383,10 +3383,12 @@ schedule_next_ping (struct ForeignAddressList *fal) | |||
3383 | * | 3383 | * |
3384 | * @param message the payload | 3384 | * @param message the payload |
3385 | * @param n peer who claimed to be the sender | 3385 | * @param n peer who claimed to be the sender |
3386 | * @param ats ATS information | ||
3387 | * @param ats_count numbers of elements following the ats struct (excluding the 0-terminator) | ||
3386 | */ | 3388 | */ |
3387 | static void | 3389 | static void |
3388 | handle_payload_message (const struct GNUNET_MessageHeader *message, | 3390 | handle_payload_message (const struct GNUNET_MessageHeader *message, |
3389 | struct NeighbourList *n) | 3391 | struct NeighbourList *n, struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) |
3390 | { | 3392 | { |
3391 | struct InboundMessage *im; | 3393 | struct InboundMessage *im; |
3392 | struct TransportClient *cpos; | 3394 | struct TransportClient *cpos; |
@@ -3441,14 +3443,23 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, | |||
3441 | gettext_noop ("# payload received from other peers"), | 3443 | gettext_noop ("# payload received from other peers"), |
3442 | msize, | 3444 | msize, |
3443 | GNUNET_NO); | 3445 | GNUNET_NO); |
3446 | |||
3444 | /* transmit message to all clients */ | 3447 | /* transmit message to all clients */ |
3445 | im = GNUNET_malloc (sizeof (struct InboundMessage) + msize); | 3448 | im = GNUNET_malloc (sizeof (struct InboundMessage) + ats_count * sizeof(struct GNUNET_TRANSPORT_ATS_Information) + msize); |
3446 | im->header.size = htons (sizeof (struct InboundMessage) + msize); | 3449 | im->header.size = htons (sizeof (struct InboundMessage) + ats_count * sizeof(struct GNUNET_TRANSPORT_ATS_Information) + msize); |
3447 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); | 3450 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); |
3448 | im->latency = GNUNET_TIME_relative_hton (n->latency); | 3451 | im->latency = GNUNET_TIME_relative_hton (n->latency); |
3449 | im->peer = n->id; | 3452 | im->peer = n->id; |
3450 | im->distance = ntohl(n->distance); | 3453 | im->distance = ntohl(n->distance); |
3451 | memcpy (&im[1], message, msize); | 3454 | im->ats_count = htonl(ats_count); |
3455 | /* insert ATS elements */ | ||
3456 | memcpy (&(im->ats), ats, ats_count * sizeof(struct GNUNET_TRANSPORT_ATS_Information)); | ||
3457 | /* insert ATS terminator */ | ||
3458 | (&im->ats)[ats_count].type = htonl(0); | ||
3459 | (&im->ats)[ats_count].value = htonl(0); | ||
3460 | /* insert msg after terminator */ | ||
3461 | memcpy (&(&im->ats)[ats_count+1], message, msize); | ||
3462 | |||
3452 | cpos = clients; | 3463 | cpos = clients; |
3453 | while (cpos != NULL) | 3464 | while (cpos != NULL) |
3454 | { | 3465 | { |
@@ -3669,7 +3680,8 @@ check_pending_validation (void *cls, | |||
3669 | if (NULL != (prem = n->pre_connect_message_buffer)) | 3680 | if (NULL != (prem = n->pre_connect_message_buffer)) |
3670 | { | 3681 | { |
3671 | n->pre_connect_message_buffer = NULL; | 3682 | n->pre_connect_message_buffer = NULL; |
3672 | handle_payload_message (prem, n); | 3683 | /* FIXME: */ |
3684 | handle_payload_message (prem, n, NULL, 0); | ||
3673 | GNUNET_free (prem); | 3685 | GNUNET_free (prem); |
3674 | } | 3686 | } |
3675 | } | 3687 | } |
@@ -4759,7 +4771,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4759 | handle_pong (plugin, message, peer, sender_address, sender_address_len); | 4771 | handle_pong (plugin, message, peer, sender_address, sender_address_len); |
4760 | break; | 4772 | break; |
4761 | default: | 4773 | default: |
4762 | handle_payload_message (message, n); | 4774 | handle_payload_message (message, n, NULL, 0); |
4763 | break; | 4775 | break; |
4764 | } | 4776 | } |
4765 | } | 4777 | } |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 13fae962b..05e12e1f3 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -1661,8 +1661,9 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1661 | } | 1661 | } |
1662 | im = (const struct InboundMessage *) msg; | 1662 | im = (const struct InboundMessage *) msg; |
1663 | GNUNET_break (0 == ntohl (im->reserved)); | 1663 | GNUNET_break (0 == ntohl (im->reserved)); |
1664 | imm = (const struct GNUNET_MessageHeader *) &im[1]; | 1664 | GNUNET_assert(sizeof (struct InboundMessage) + ntohl(im->ats_count) * sizeof(struct GNUNET_TRANSPORT_ATS_Information) + sizeof (struct GNUNET_MessageHeader) <= size); |
1665 | if (ntohs (imm->size) + sizeof (struct InboundMessage) != size) | 1665 | imm = (const struct GNUNET_MessageHeader *) &((&im->ats)[ntohl(im->ats_count)+1]); |
1666 | if (ntohs (imm->size) + sizeof (struct InboundMessage) + ntohl(im->ats_count) * sizeof(struct GNUNET_TRANSPORT_ATS_Information) != size) | ||
1666 | { | 1667 | { |
1667 | GNUNET_break (0); | 1668 | GNUNET_break (0); |
1668 | break; | 1669 | break; |