aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-udp.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 03c120cc9..173c86bfb 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1380,9 +1380,13 @@ try_handle_plaintext (struct SenderAddress *sender,
1380 * @param ss shared secret to generate ACKs for 1380 * @param ss shared secret to generate ACKs for
1381 */ 1381 */
1382static void 1382static void
1383consider_ss_ack (struct SharedSecret *ss) 1383consider_ss_ack (struct SharedSecret *ss, int yesno)
1384{ 1384{
1385 GNUNET_assert (NULL != ss->sender); 1385 GNUNET_assert (NULL != ss->sender);
1386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1387 "Considering SS UDPAck %s\n",
1388 GNUNET_i2s_full (&ss->sender->target));
1389
1386 /* drop ancient KeyCacheEntries */ 1390 /* drop ancient KeyCacheEntries */
1387 while ((NULL != ss->kce_head) && 1391 while ((NULL != ss->kce_head) &&
1388 (MAX_SQN_DELTA < 1392 (MAX_SQN_DELTA <
@@ -1392,8 +1396,19 @@ consider_ss_ack (struct SharedSecret *ss)
1392 { 1396 {
1393 struct UDPAck ack; 1397 struct UDPAck ack;
1394 1398
1395 while (ss->active_kce_count < KCN_TARGET) 1399 /**
1400 * If we previously have seen this ss
1401 * we now generate KCN_TARGET KCEs.
1402 * For the initial KX (active_kce_count==0),
1403 * we only generate a single KCE to prevent
1404 * unnecessary overhead.
1405 */
1406 if (0 < ss->active_kce_count) {
1407 while (ss->active_kce_count < KCN_TARGET)
1408 kce_generate (ss, ++ss->sequence_allowed);
1409 } else {
1396 kce_generate (ss, ++ss->sequence_allowed); 1410 kce_generate (ss, ++ss->sequence_allowed);
1411 }
1397 ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); 1412 ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK);
1398 ack.header.size = htons (sizeof(ack)); 1413 ack.header.size = htons (sizeof(ack));
1399 ack.sequence_max = htonl (ss->sequence_allowed); 1414 ack.sequence_max = htonl (ss->sequence_allowed);
@@ -1445,7 +1460,7 @@ decrypt_box (const struct UDPBox *box,
1445 sizeof(out_buf), 1460 sizeof(out_buf),
1446 GNUNET_NO); 1461 GNUNET_NO);
1447 try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf)); 1462 try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf));
1448 consider_ss_ack (ss); 1463 consider_ss_ack (ss, GNUNET_YES);
1449} 1464}
1450 1465
1451 1466
@@ -1715,6 +1730,9 @@ sock_read (void *cls)
1715 1730
1716 kx = (const struct InitialKX *) buf; 1731 kx = (const struct InitialKX *) buf;
1717 ss = setup_shared_secret_dec (&kx->ephemeral); 1732 ss = setup_shared_secret_dec (&kx->ephemeral);
1733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1734 "Before DEC\n");
1735
1718 if (GNUNET_OK != try_decrypt (ss, 1736 if (GNUNET_OK != try_decrypt (ss,
1719 kx->gcm_tag, 1737 kx->gcm_tag,
1720 0, 1738 0,
@@ -1732,6 +1750,9 @@ sock_read (void *cls)
1732 GNUNET_NO); 1750 GNUNET_NO);
1733 return; 1751 return;
1734 } 1752 }
1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1754 "Before VERIFY\n");
1755
1735 uc = (const struct UDPConfirmation *) pbuf; 1756 uc = (const struct UDPConfirmation *) pbuf;
1736 if (GNUNET_OK != verify_confirmation (&kx->ephemeral, uc)) 1757 if (GNUNET_OK != verify_confirmation (&kx->ephemeral, uc))
1737 { 1758 {
@@ -1743,6 +1764,9 @@ sock_read (void *cls)
1743 GNUNET_NO); 1764 GNUNET_NO);
1744 return; 1765 return;
1745 } 1766 }
1767 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1768 "Before SETUP_SENDER\n");
1769
1746 calculate_cmac (ss); 1770 calculate_cmac (ss);
1747 sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen); 1771 sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen);
1748 ss->sender = sender; 1772 ss->sender = sender;
@@ -1754,7 +1778,7 @@ sock_read (void *cls)
1754 1, 1778 1,
1755 GNUNET_NO); 1779 GNUNET_NO);
1756 try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc)); 1780 try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc));
1757 consider_ss_ack (ss); 1781 consider_ss_ack (ss, GNUNET_NO);
1758 if (sender->num_secrets > MAX_SECRETS) 1782 if (sender->num_secrets > MAX_SECRETS)
1759 secret_destroy (sender->ss_tail); 1783 secret_destroy (sender->ss_tail);
1760 } 1784 }