diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-06-05 00:19:09 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-06-05 00:19:09 +0200 |
commit | 2af1b568199c62152fe7892ec33579aed326c136 (patch) | |
tree | bbb5b8f17aa875fc3d8862602268295bc6709b7a /src/reclaim/reclaim_api.c | |
parent | 761cdce49f33607b0e8e1ef0c4275bf8d7e82c02 (diff) | |
download | gnunet-2af1b568199c62152fe7892ec33579aed326c136.tar.gz gnunet-2af1b568199c62152fe7892ec33579aed326c136.zip |
fix message sizes; pending test
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r-- | src/reclaim/reclaim_api.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c index b0bedfac5..63f8b9ba3 100644 --- a/src/reclaim/reclaim_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -642,9 +642,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
642 | struct GNUNET_RECLAIM_Handle *handle = cls; | 642 | struct GNUNET_RECLAIM_Handle *handle = cls; |
643 | struct GNUNET_RECLAIM_Operation *op; | 643 | struct GNUNET_RECLAIM_Operation *op; |
644 | struct GNUNET_RECLAIM_TicketIterator *it; | 644 | struct GNUNET_RECLAIM_TicketIterator *it; |
645 | const struct GNUNET_RECLAIM_Ticket *ticket; | ||
646 | uint32_t r_id = ntohl (msg->id); | 645 | uint32_t r_id = ntohl (msg->id); |
647 | size_t msg_len; | ||
648 | 646 | ||
649 | for (op = handle->op_head; NULL != op; op = op->next) | 647 | for (op = handle->op_head; NULL != op; op = op->next) |
650 | if (op->r_id == r_id) | 648 | if (op->r_id == r_id) |
@@ -654,30 +652,28 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg) | |||
654 | break; | 652 | break; |
655 | if ((NULL == op) && (NULL == it)) | 653 | if ((NULL == op) && (NULL == it)) |
656 | return; | 654 | return; |
657 | msg_len = ntohs (msg->header.size); | ||
658 | if (NULL != op) { | 655 | if (NULL != op) { |
659 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); | 656 | GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); |
660 | if (msg_len == sizeof (struct TicketResultMessage)) { | 657 | if (memcmp (&msg->ticket, 0, sizeof (struct GNUNET_RECLAIM_Ticket))) |
658 | { | ||
661 | if (NULL != op->tr_cb) | 659 | if (NULL != op->tr_cb) |
662 | op->tr_cb (op->cls, NULL); | 660 | op->tr_cb (op->cls, NULL); |
663 | } else { | 661 | } else { |
664 | ticket = (struct GNUNET_RECLAIM_Ticket *)&msg[1]; | ||
665 | if (NULL != op->tr_cb) | 662 | if (NULL != op->tr_cb) |
666 | op->tr_cb (op->cls, ticket); | 663 | op->tr_cb (op->cls, &msg->ticket); |
667 | } | 664 | } |
668 | free_op (op); | 665 | free_op (op); |
669 | return; | 666 | return; |
670 | } else if (NULL != it) { | 667 | } else if (NULL != it) { |
671 | if (msg_len == sizeof (struct TicketResultMessage)) { | 668 | if (memcmp (&msg->ticket, 0, sizeof (struct GNUNET_RECLAIM_Ticket))) |
672 | if (NULL != it->tr_cb) | 669 | { |
673 | GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, | 670 | GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head, |
674 | handle->ticket_it_tail, it); | 671 | handle->ticket_it_tail, it); |
675 | it->finish_cb (it->finish_cb_cls); | 672 | it->finish_cb (it->finish_cb_cls); |
676 | GNUNET_free (it); | 673 | GNUNET_free (it); |
677 | } else { | 674 | } else { |
678 | ticket = (struct GNUNET_RECLAIM_Ticket *)&msg[1]; | ||
679 | if (NULL != it->tr_cb) | 675 | if (NULL != it->tr_cb) |
680 | it->tr_cb (it->cls, ticket); | 676 | it->tr_cb (it->cls, &msg->ticket); |
681 | } | 677 | } |
682 | return; | 678 | return; |
683 | } | 679 | } |
@@ -1091,14 +1087,10 @@ GNUNET_RECLAIM_ticket_consume ( | |||
1091 | op->r_id = h->r_id_gen++; | 1087 | op->r_id = h->r_id_gen++; |
1092 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1088 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1093 | op->env = | 1089 | op->env = |
1094 | GNUNET_MQ_msg_extra (ctm, sizeof (const struct GNUNET_RECLAIM_Ticket), | 1090 | GNUNET_MQ_msg (ctm, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); |
1095 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); | ||
1096 | ctm->identity = *identity; | 1091 | ctm->identity = *identity; |
1097 | ctm->id = htonl (op->r_id); | 1092 | ctm->id = htonl (op->r_id); |
1098 | 1093 | ctm->ticket = *ticket; | |
1099 | GNUNET_memcpy ((char *)&ctm[1], ticket, | ||
1100 | sizeof (const struct GNUNET_RECLAIM_Ticket)); | ||
1101 | |||
1102 | if (NULL != h->mq) | 1094 | if (NULL != h->mq) |
1103 | GNUNET_MQ_send_copy (h->mq, op->env); | 1095 | GNUNET_MQ_send_copy (h->mq, op->env); |
1104 | return op; | 1096 | return op; |
@@ -1231,11 +1223,10 @@ GNUNET_RECLAIM_ticket_revoke ( | |||
1231 | op->cls = cb_cls; | 1223 | op->cls = cb_cls; |
1232 | op->r_id = rid; | 1224 | op->r_id = rid; |
1233 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 1225 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); |
1234 | op->env = GNUNET_MQ_msg_extra (msg, sizeof (struct GNUNET_RECLAIM_Ticket), | 1226 | op->env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); |
1235 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); | ||
1236 | msg->id = htonl (rid); | 1227 | msg->id = htonl (rid); |
1237 | msg->identity = *identity; | 1228 | msg->identity = *identity; |
1238 | GNUNET_memcpy (&msg[1], ticket, sizeof (struct GNUNET_RECLAIM_Ticket)); | 1229 | msg->ticket = *ticket; |
1239 | if (NULL != h->mq) { | 1230 | if (NULL != h->mq) { |
1240 | GNUNET_MQ_send (h->mq, op->env); | 1231 | GNUNET_MQ_send (h->mq, op->env); |
1241 | op->env = NULL; | 1232 | op->env = NULL; |