diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-12-11 03:42:38 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-12-11 03:42:38 +0000 |
commit | 1cc94f2fc2d5378d71c4e740271b0ae99e6c554e (patch) | |
tree | 8d992094daf59814dc37be0e4061517c881c7b21 /src | |
parent | c969aad2bb74e7dfbffa8b55bd1b6b7fbd0b2bcb (diff) | |
download | gnunet-1cc94f2fc2d5378d71c4e740271b0ae99e6c554e.tar.gz gnunet-1cc94f2fc2d5378d71c4e740271b0ae99e6c554e.zip |
Add maximum message size
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/cadet_api.c | 12 | ||||
-rw-r--r-- | src/include/gnunet_constants.h | 14 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index d5faf65ba..3c7829330 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -1352,6 +1352,7 @@ send_callback (void *cls, size_t size, void *buf) | |||
1352 | psize = th->notify (th->notify_cls, | 1352 | psize = th->notify (th->notify_cls, |
1353 | size - sizeof (struct GNUNET_CADET_LocalData), | 1353 | size - sizeof (struct GNUNET_CADET_LocalData), |
1354 | mh); | 1354 | mh); |
1355 | |||
1355 | if (psize > 0) | 1356 | if (psize > 0) |
1356 | { | 1357 | { |
1357 | psize += sizeof (struct GNUNET_CADET_LocalData); | 1358 | psize += sizeof (struct GNUNET_CADET_LocalData); |
@@ -1379,6 +1380,8 @@ send_callback (void *cls, size_t size, void *buf) | |||
1379 | memcpy (cbuf, &th[1], th->size); | 1380 | memcpy (cbuf, &th[1], th->size); |
1380 | psize = th->size; | 1381 | psize = th->size; |
1381 | } | 1382 | } |
1383 | GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= psize); | ||
1384 | |||
1382 | if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 1385 | if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
1383 | GNUNET_SCHEDULER_cancel (th->timeout_task); | 1386 | GNUNET_SCHEDULER_cancel (th->timeout_task); |
1384 | GNUNET_CONTAINER_DLL_remove (h->th_head, h->th_tail, th); | 1387 | GNUNET_CONTAINER_DLL_remove (h->th_head, h->th_tail, th); |
@@ -1709,14 +1712,15 @@ GNUNET_CADET_channel_get_info (struct GNUNET_CADET_Channel *channel, | |||
1709 | 1712 | ||
1710 | struct GNUNET_CADET_TransmitHandle * | 1713 | struct GNUNET_CADET_TransmitHandle * |
1711 | GNUNET_CADET_notify_transmit_ready (struct GNUNET_CADET_Channel *channel, int cork, | 1714 | GNUNET_CADET_notify_transmit_ready (struct GNUNET_CADET_Channel *channel, int cork, |
1712 | struct GNUNET_TIME_Relative maxdelay, | 1715 | struct GNUNET_TIME_Relative maxdelay, |
1713 | size_t notify_size, | 1716 | size_t notify_size, |
1714 | GNUNET_CONNECTION_TransmitReadyNotify notify, | 1717 | GNUNET_CONNECTION_TransmitReadyNotify notify, |
1715 | void *notify_cls) | 1718 | void *notify_cls) |
1716 | { | 1719 | { |
1717 | struct GNUNET_CADET_TransmitHandle *th; | 1720 | struct GNUNET_CADET_TransmitHandle *th; |
1718 | 1721 | ||
1719 | GNUNET_assert (NULL != channel); | 1722 | GNUNET_assert (NULL != channel); |
1723 | GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= notify_size); | ||
1720 | LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY\n"); | 1724 | LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY\n"); |
1721 | LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", channel->chid); | 1725 | LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", channel->chid); |
1722 | LOG (GNUNET_ERROR_TYPE_DEBUG, " allow_send %d\n", channel->allow_send); | 1726 | LOG (GNUNET_ERROR_TYPE_DEBUG, " allow_send %d\n", channel->allow_send); |
diff --git a/src/include/gnunet_constants.h b/src/include/gnunet_constants.h index 705809186..1d2e65581 100644 --- a/src/include/gnunet_constants.h +++ b/src/include/gnunet_constants.h | |||
@@ -121,6 +121,20 @@ extern "C" | |||
121 | #define GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE (63 * 1024) | 121 | #define GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE (63 * 1024) |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * Size of the CADET message overhead | ||
125 | * - sizeof(GNUNET_CADET_Encrypted) // FIXME use GNUNET_CADET_EncryptedAck when available | ||
126 | * - sizeof(GNUNET_CADET_Data) | ||
127 | |||
128 | */ | ||
129 | #define GNUNET_CONSTANTS_CADET_P2P_OVERHEAD (sizeof (struct GNUNET_CADET_Encrypted) + sizeof (struct GNUNET_CADET_Data)) | ||
130 | |||
131 | /** | ||
132 | * Same as core, the conservative value would be: | ||
133 | * GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE - GNUNET_CONSTANTS_CADET_P2P_OVERHEAD | ||
134 | */ | ||
135 | #define GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE (62 * 1024) | ||
136 | |||
137 | /** | ||
124 | * Largest block that can be stored in the DHT. | 138 | * Largest block that can be stored in the DHT. |
125 | */ | 139 | */ |
126 | #define GNUNET_CONSTANTS_MAX_BLOCK_SIZE (62 * 1024) | 140 | #define GNUNET_CONSTANTS_MAX_BLOCK_SIZE (62 * 1024) |