diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-12 09:02:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-12 09:02:38 +0000 |
commit | f76896d09afabb721219d3217037cc7a7f26d570 (patch) | |
tree | b5910f5b68aa22954dcdca675017db18481a96d0 /src/transport/gnunet-service-transport_neighbours.c | |
parent | d220651a00e92367387e6f0d881c8115fc9e2973 (diff) | |
download | gnunet-f76896d09afabb721219d3217037cc7a7f26d570.tar.gz gnunet-f76896d09afabb721219d3217037cc7a7f26d570.zip |
implementing client's send
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 742fa9caf..a7c1136f2 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -521,20 +521,21 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target) | |||
521 | * | 521 | * |
522 | * @param target destination | 522 | * @param target destination |
523 | * @param msg message to send | 523 | * @param msg message to send |
524 | * @param msg_size number of bytes in msg | ||
524 | * @param timeout when to fail with timeout | 525 | * @param timeout when to fail with timeout |
525 | * @param cont function to call when done | 526 | * @param cont function to call when done |
526 | * @param cont_cls closure for 'cont' | 527 | * @param cont_cls closure for 'cont' |
527 | */ | 528 | */ |
528 | void | 529 | void |
529 | GST_neighbours_send (const struct GNUNET_PeerIdentity *target, | 530 | GST_neighbours_send (const struct GNUNET_PeerIdentity *target, |
530 | const struct GNUNET_MessageHeader *msg, | 531 | const void *msg, |
532 | size_t msg_size, | ||
531 | struct GNUNET_TIME_Relative timeout, | 533 | struct GNUNET_TIME_Relative timeout, |
532 | GST_NeighbourSendContinuation cont, | 534 | GST_NeighbourSendContinuation cont, |
533 | void *cont_cls) | 535 | void *cont_cls) |
534 | { | 536 | { |
535 | struct NeighbourMapEntry *n; | 537 | struct NeighbourMapEntry *n; |
536 | struct MessageQueue *mq; | 538 | struct MessageQueue *mq; |
537 | uint16_t message_buf_size; | ||
538 | 539 | ||
539 | n = lookup_neighbour (target); | 540 | n = lookup_neighbour (target); |
540 | if ( (n == NULL) || | 541 | if ( (n == NULL) || |
@@ -549,17 +550,16 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, | |||
549 | GNUNET_SYSERR); | 550 | GNUNET_SYSERR); |
550 | return; | 551 | return; |
551 | } | 552 | } |
552 | message_buf_size = ntohs (msg->size); | 553 | GNUNET_assert (msg_size >= sizeof (struct GNUNET_MessageHeader)); |
553 | GNUNET_assert (message_buf_size >= sizeof (struct GNUNET_MessageHeader)); | ||
554 | GNUNET_STATISTICS_update (GST_stats, | 554 | GNUNET_STATISTICS_update (GST_stats, |
555 | gettext_noop ("# bytes in message queue for other peers"), | 555 | gettext_noop ("# bytes in message queue for other peers"), |
556 | message_buf_size, | 556 | msg_size, |
557 | GNUNET_NO); | 557 | GNUNET_NO); |
558 | mq = GNUNET_malloc (sizeof (struct MessageQueue) + message_buf_size); | 558 | mq = GNUNET_malloc (sizeof (struct MessageQueue) + msg_size); |
559 | /* FIXME: this memcpy can be up to 7% of our total runtime! */ | 559 | /* FIXME: this memcpy can be up to 7% of our total runtime! */ |
560 | memcpy (&mq[1], msg, message_buf_size); | 560 | memcpy (&mq[1], msg, msg_size); |
561 | mq->message_buf = (const char*) &mq[1]; | 561 | mq->message_buf = (const char*) &mq[1]; |
562 | mq->message_buf_size = message_buf_size; | 562 | mq->message_buf_size = msg_size; |
563 | mq->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 563 | mq->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
564 | GNUNET_CONTAINER_DLL_insert_tail (n->messages_head, | 564 | GNUNET_CONTAINER_DLL_insert_tail (n->messages_head, |
565 | n->messages_tail, | 565 | n->messages_tail, |