diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-22 23:07:10 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-22 23:07:10 +0100 |
commit | 03a99aa00618ecb002bb116f98b2bf33fdd61fc0 (patch) | |
tree | 9c9370a81607e1227eae642522d88343ba365e0b /src/cadet/gnunet-service-cadet-new_channel.c | |
parent | ffbed5b3745b92041d1bdff1bd22e95778bdc7bf (diff) | |
download | gnunet-03a99aa00618ecb002bb116f98b2bf33fdd61fc0.tar.gz gnunet-03a99aa00618ecb002bb116f98b2bf33fdd61fc0.zip |
allow client's payload to include more than one message
Diffstat (limited to 'src/cadet/gnunet-service-cadet-new_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index 690b91f28..42565d276 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -214,7 +214,7 @@ struct CadetChannel | |||
214 | */ | 214 | */ |
215 | struct GNUNET_SCHEDULER_Task *retry_control_task; | 215 | struct GNUNET_SCHEDULER_Task *retry_control_task; |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * Task to resend/poll in case no ACK is received. | 218 | * Task to resend/poll in case no ACK is received. |
219 | */ | 219 | */ |
220 | struct GNUNET_SCHEDULER_Task *retry_data_task; | 220 | struct GNUNET_SCHEDULER_Task *retry_data_task; |
@@ -1280,15 +1280,16 @@ data_sent_cb (void *cls) | |||
1280 | * buffer space in the tunnel. | 1280 | * buffer space in the tunnel. |
1281 | * | 1281 | * |
1282 | * @param ch Channel. | 1282 | * @param ch Channel. |
1283 | * @param message payload to transmit. | 1283 | * @param buf payload to transmit. |
1284 | * @param buf_len number of bytes in @a buf | ||
1284 | * @return #GNUNET_OK if everything goes well, | 1285 | * @return #GNUNET_OK if everything goes well, |
1285 | * #GNUNET_SYSERR in case of an error. | 1286 | * #GNUNET_SYSERR in case of an error. |
1286 | */ | 1287 | */ |
1287 | int | 1288 | int |
1288 | GCCH_handle_local_data (struct CadetChannel *ch, | 1289 | GCCH_handle_local_data (struct CadetChannel *ch, |
1289 | const struct GNUNET_MessageHeader *message) | 1290 | const char *buf, |
1291 | size_t buf_len) | ||
1290 | { | 1292 | { |
1291 | uint16_t payload_size = ntohs (message->size); | ||
1292 | struct CadetReliableMessage *crm; | 1293 | struct CadetReliableMessage *crm; |
1293 | 1294 | ||
1294 | if (GNUNET_NO == ch->client_allowed) | 1295 | if (GNUNET_NO == ch->client_allowed) |
@@ -1300,22 +1301,22 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1300 | ch->pending_messages++; | 1301 | ch->pending_messages++; |
1301 | 1302 | ||
1302 | /* Everything is correct, send the message. */ | 1303 | /* Everything is correct, send the message. */ |
1303 | crm = GNUNET_malloc (sizeof (*crm) + payload_size); | 1304 | crm = GNUNET_malloc (sizeof (*crm) + buf_len); |
1304 | crm->ch = ch; | 1305 | crm->ch = ch; |
1305 | crm->data_message.header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + payload_size); | 1306 | crm->data_message.header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len); |
1306 | crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); | 1307 | crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); |
1307 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); | 1308 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); |
1308 | crm->data_message.mid = ch->mid_send; | 1309 | crm->data_message.mid = ch->mid_send; |
1309 | crm->data_message.ctn = ch->ctn; | 1310 | crm->data_message.ctn = ch->ctn; |
1310 | GNUNET_memcpy (&crm[1], | 1311 | GNUNET_memcpy (&crm[1], |
1311 | message, | 1312 | buf, |
1312 | payload_size); | 1313 | buf_len); |
1313 | GNUNET_CONTAINER_DLL_insert (ch->head_sent, | 1314 | GNUNET_CONTAINER_DLL_insert (ch->head_sent, |
1314 | ch->tail_sent, | 1315 | ch->tail_sent, |
1315 | crm); | 1316 | crm); |
1316 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1317 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1317 | "Sending %u bytes from local client to %s\n", | 1318 | "Sending %u bytes from local client to %s\n", |
1318 | payload_size, | 1319 | buf_len, |
1319 | GCCH_2s (ch)); | 1320 | GCCH_2s (ch)); |
1320 | crm->qe = GCT_send (ch->t, | 1321 | crm->qe = GCT_send (ch->t, |
1321 | &crm->data_message.header, | 1322 | &crm->data_message.header, |