diff options
Diffstat (limited to 'src/transport/gnunet-communicator-udp.c')
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 247 |
1 files changed, 156 insertions, 91 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 579f744e5..1df79745a 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -93,7 +93,7 @@ | |||
93 | */ | 93 | */ |
94 | #define GCM_TAG_SIZE (128 / 8) | 94 | #define GCM_TAG_SIZE (128 / 8) |
95 | 95 | ||
96 | #define GENERATE_AT_ONCE 20 | 96 | #define GENERATE_AT_ONCE 2 |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * If we fall below this number of available KCNs, | 99 | * If we fall below this number of available KCNs, |
@@ -256,6 +256,12 @@ struct UDPAck | |||
256 | uint32_t sequence_max GNUNET_PACKED; | 256 | uint32_t sequence_max GNUNET_PACKED; |
257 | 257 | ||
258 | /** | 258 | /** |
259 | * Sequence acknowledgement limit. Specifies current maximum sequence | ||
260 | * number supported by receiver. | ||
261 | */ | ||
262 | uint32_t acks_available GNUNET_PACKED; | ||
263 | |||
264 | /** | ||
259 | * CMAC of the base key being acknowledged. | 265 | * CMAC of the base key being acknowledged. |
260 | */ | 266 | */ |
261 | struct GNUNET_HashCode cmac; | 267 | struct GNUNET_HashCode cmac; |
@@ -664,6 +670,10 @@ struct BroadcastInterface | |||
664 | int found; | 670 | int found; |
665 | }; | 671 | }; |
666 | 672 | ||
673 | /** | ||
674 | * Shared secret we finished the last kce working queue for. | ||
675 | */ | ||
676 | struct SharedSecret *ss_finished; | ||
667 | 677 | ||
668 | /** | 678 | /** |
669 | * Cache of pre-generated key IDs. | 679 | * Cache of pre-generated key IDs. |
@@ -681,6 +691,16 @@ static struct GNUNET_SCHEDULER_Task *read_task; | |||
681 | static struct GNUNET_SCHEDULER_Task *timeout_task; | 691 | static struct GNUNET_SCHEDULER_Task *timeout_task; |
682 | 692 | ||
683 | /** | 693 | /** |
694 | * ID of kce working queue task | ||
695 | */ | ||
696 | static struct GNUNET_SCHEDULER_Task *kce_task; | ||
697 | |||
698 | /** | ||
699 | * Is the kce_task finished? | ||
700 | */ | ||
701 | static int kce_task_finished = GNUNET_NO; | ||
702 | |||
703 | /** | ||
684 | * ID of master broadcast task | 704 | * ID of master broadcast task |
685 | */ | 705 | */ |
686 | static struct GNUNET_SCHEDULER_Task *broadcast_task; | 706 | static struct GNUNET_SCHEDULER_Task *broadcast_task; |
@@ -807,15 +827,26 @@ bi_destroy (struct BroadcastInterface *bi) | |||
807 | static void | 827 | static void |
808 | receiver_destroy (struct ReceiverAddress *receiver) | 828 | receiver_destroy (struct ReceiverAddress *receiver) |
809 | { | 829 | { |
830 | struct GNUNET_MQ_Handle *mq; | ||
810 | 831 | ||
811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 832 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
812 | "Disconnecting receiver for peer `%s'\n", | 833 | "Disconnecting receiver for peer `%s'\n", |
813 | GNUNET_i2s (&receiver->target)); | 834 | GNUNET_i2s (&receiver->target)); |
835 | if (NULL != (mq = receiver->kx_mq)) | ||
836 | { | ||
837 | receiver->kx_mq = NULL; | ||
838 | GNUNET_MQ_destroy (mq); | ||
839 | } | ||
814 | if (NULL != receiver->kx_qh) | 840 | if (NULL != receiver->kx_qh) |
815 | { | 841 | { |
816 | GNUNET_TRANSPORT_communicator_mq_del (receiver->kx_qh); | 842 | GNUNET_TRANSPORT_communicator_mq_del (receiver->kx_qh); |
817 | receiver->kx_qh = NULL; | 843 | receiver->kx_qh = NULL; |
818 | } | 844 | } |
845 | if (NULL != (mq = receiver->d_mq)) | ||
846 | { | ||
847 | receiver->d_mq = NULL; | ||
848 | GNUNET_MQ_destroy (mq); | ||
849 | } | ||
819 | if (NULL != receiver->d_qh) | 850 | if (NULL != receiver->d_qh) |
820 | { | 851 | { |
821 | GNUNET_TRANSPORT_communicator_mq_del (receiver->d_qh); | 852 | GNUNET_TRANSPORT_communicator_mq_del (receiver->d_qh); |
@@ -932,19 +963,13 @@ secret_destroy (struct SharedSecret *ss) | |||
932 | { | 963 | { |
933 | GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss); | 964 | GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss); |
934 | sender->num_secrets--; | 965 | sender->num_secrets--; |
935 | sender->acks_available -= ss->active_kce_count; | ||
936 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
937 | "%u acks available after secrect destroy.\n", | ||
938 | sender->acks_available); | ||
939 | } | 966 | } |
940 | if (NULL != (receiver = ss->receiver)) | 967 | if (NULL != (receiver = ss->receiver)) |
941 | { | 968 | { |
942 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); | 969 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); |
943 | receiver->num_secrets--; | 970 | receiver->num_secrets--; |
944 | receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used); | 971 | // Uncomment this for alternativ 1 of backchannel functionality |
945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 972 | // receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used); |
946 | "%u acks available after secrect destroy.\n", | ||
947 | receiver->acks_available); | ||
948 | } | 973 | } |
949 | while (NULL != (kce = ss->kce_head)) | 974 | while (NULL != (kce = ss->kce_head)) |
950 | kce_destroy (kce); | 975 | kce_destroy (kce); |
@@ -1259,10 +1284,6 @@ setup_shared_secret_enc (const struct GNUNET_CRYPTO_EcdhePrivateKey *ephemeral, | |||
1259 | &receiver->target.public_key, | 1284 | &receiver->target.public_key, |
1260 | &ss->master); | 1285 | &ss->master); |
1261 | calculate_cmac (ss); | 1286 | calculate_cmac (ss); |
1262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1263 | "Created cmac %s for secret %p.\n", | ||
1264 | GNUNET_h2s (&ss->cmac), | ||
1265 | ss); | ||
1266 | ss->receiver = receiver; | 1287 | ss->receiver = receiver; |
1267 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); | 1288 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); |
1268 | receiver->num_secrets++; | 1289 | receiver->num_secrets++; |
@@ -1311,27 +1332,41 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) | |||
1311 | 1332 | ||
1312 | allowed = ntohl (ack->sequence_max); | 1333 | allowed = ntohl (ack->sequence_max); |
1313 | 1334 | ||
1314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1315 | "%u > %u (%u)\n", allowed, ss->sequence_allowed, | ||
1316 | receiver->acks_available); | ||
1317 | if (allowed > ss->sequence_allowed) | 1335 | if (allowed > ss->sequence_allowed) |
1318 | { | 1336 | { |
1319 | receiver->acks_available += (allowed - ss->sequence_allowed); | 1337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1338 | "%u > %u (%u %u) for secrect %s\n", allowed, | ||
1339 | ss->sequence_allowed, | ||
1340 | receiver->acks_available, | ||
1341 | ack->acks_available, | ||
1342 | GNUNET_h2s (&ss->master)); | ||
1343 | // Uncomment this for alternativ 1 of backchannel functionality | ||
1344 | /*receiver->acks_available += (allowed - ss->sequence_allowed); | ||
1320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1321 | "Tell transport we have more acks!\n"); | 1346 | "Tell transport we have more acks!\n"); |
1322 | GNUNET_TRANSPORT_communicator_mq_update (ch, | 1347 | GNUNET_TRANSPORT_communicator_mq_update (ch, |
1323 | receiver->d_qh, | 1348 | receiver->d_qh, |
1324 | (allowed | 1349 | (allowed |
1325 | - ss->sequence_allowed), | 1350 | - ss->sequence_allowed), |
1326 | 1); | 1351 | 1);*/ |
1327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1328 | "%u acks made available.\n", | ||
1329 | receiver->acks_available); | ||
1330 | ss->sequence_allowed = allowed; | 1352 | ss->sequence_allowed = allowed; |
1331 | /* move ss to head to avoid discarding it anytime soon! */ | 1353 | /* move ss to head to avoid discarding it anytime soon! */ |
1332 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); | 1354 | GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); |
1333 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); | 1355 | GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); |
1334 | } | 1356 | } |
1357 | |||
1358 | // Uncomment this for alternativ 2 of backchannel functionality | ||
1359 | if (receiver->acks_available != ack->acks_available) | ||
1360 | { | ||
1361 | receiver->acks_available = ack->acks_available; | ||
1362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1363 | "Tell transport we have different number of acks!\n"); | ||
1364 | GNUNET_TRANSPORT_communicator_mq_update (ch, | ||
1365 | receiver->d_qh, | ||
1366 | receiver->acks_available, | ||
1367 | 1); | ||
1368 | } | ||
1369 | // Until here for alternativ 2 | ||
1335 | return GNUNET_NO; | 1370 | return GNUNET_NO; |
1336 | } | 1371 | } |
1337 | } | 1372 | } |
@@ -1390,12 +1425,29 @@ kce_generate_cb (void *cls) | |||
1390 | { | 1425 | { |
1391 | struct SharedSecret *ss = cls; | 1426 | struct SharedSecret *ss = cls; |
1392 | 1427 | ||
1393 | for (int i = 0; i < GENERATE_AT_ONCE; i++) | ||
1394 | kce_generate (ss, ++ss->sequence_allowed); | ||
1395 | 1428 | ||
1396 | /*GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL, | 1429 | |
1397 | kce_generate_cb, | 1430 | if (ss->sender->acks_available < KCN_TARGET) |
1398 | ss);*/ | 1431 | { |
1432 | |||
1433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1434 | "Precomputing keys\n"); | ||
1435 | |||
1436 | for (int i = 0; i < GENERATE_AT_ONCE; i++) | ||
1437 | kce_generate (ss, ++ss->sequence_allowed); | ||
1438 | |||
1439 | kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL, | ||
1440 | kce_generate_cb, | ||
1441 | ss); | ||
1442 | } | ||
1443 | else | ||
1444 | { | ||
1445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1446 | "We have enough keys.\n"); | ||
1447 | ss_finished = ss; | ||
1448 | kce_task_finished = GNUNET_YES; | ||
1449 | } | ||
1450 | |||
1399 | 1451 | ||
1400 | } | 1452 | } |
1401 | 1453 | ||
@@ -1406,26 +1458,69 @@ kce_generate_cb (void *cls) | |||
1406 | * recently). | 1458 | * recently). |
1407 | * | 1459 | * |
1408 | * @param ss shared secret to generate ACKs for | 1460 | * @param ss shared secret to generate ACKs for |
1461 | * @param intial The SharedSecret came with initial KX. | ||
1409 | */ | 1462 | */ |
1410 | static void | 1463 | static void |
1411 | consider_ss_ack (struct SharedSecret *ss) | 1464 | consider_ss_ack (struct SharedSecret *ss, int initial) |
1412 | { | 1465 | { |
1413 | GNUNET_assert (NULL != ss->sender); | 1466 | GNUNET_assert (NULL != ss->sender); |
1414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1415 | "Considering SS UDPAck %s\n", | 1468 | "Considering SS UDPAck %s\n", |
1416 | GNUNET_i2s_full (&ss->sender->target)); | 1469 | GNUNET_i2s_full (&ss->sender->target)); |
1417 | 1470 | ||
1471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1472 | "We have %u acks available.\n", | ||
1473 | ss->sender->acks_available); | ||
1418 | /* drop ancient KeyCacheEntries */ | 1474 | /* drop ancient KeyCacheEntries */ |
1419 | while ((NULL != ss->kce_head) && | 1475 | while ((NULL != ss->kce_head) && |
1420 | (MAX_SQN_DELTA < | 1476 | (MAX_SQN_DELTA < |
1421 | ss->kce_head->sequence_number - ss->kce_tail->sequence_number)) | 1477 | ss->kce_head->sequence_number - ss->kce_tail->sequence_number)) |
1422 | kce_destroy (ss->kce_tail); | 1478 | kce_destroy (ss->kce_tail); |
1423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1479 | |
1424 | "%u active count and %u acks available\n", | 1480 | |
1425 | ss->active_kce_count, | 1481 | if (GNUNET_NO == initial) |
1426 | ss->sender->acks_available); | 1482 | kce_generate (ss, ++ss->sequence_allowed); |
1427 | if ((ss->active_kce_count < KCN_THRESHOLD) && (ss->sender->acks_available < | 1483 | |
1428 | KCN_TARGET) ) | 1484 | /*if (0 == ss->sender->acks_available) |
1485 | { | ||
1486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1487 | "Generating keys\n"); | ||
1488 | while (ss->active_kce_count < KCN_TARGET) | ||
1489 | kce_generate (ss, ++ss->sequence_allowed); | ||
1490 | }*/ | ||
1491 | |||
1492 | if (((NULL != kce_task) && kce_task_finished) || (GNUNET_NO == initial)) | ||
1493 | { | ||
1494 | struct UDPAck ack; | ||
1495 | |||
1496 | ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); | ||
1497 | ack.header.size = htons (sizeof(ack)); | ||
1498 | ack.sequence_max = htonl (ss_finished->sequence_allowed); | ||
1499 | ack.acks_available = ss->sender->acks_available; | ||
1500 | ack.cmac = ss_finished->cmac; | ||
1501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1502 | "Notifying transport of UDPAck %s with intial %u\n", | ||
1503 | GNUNET_i2s_full (&ss_finished->sender->target), | ||
1504 | initial); | ||
1505 | GNUNET_TRANSPORT_communicator_notify (ch, | ||
1506 | &ss_finished->sender->target, | ||
1507 | COMMUNICATOR_ADDRESS_PREFIX, | ||
1508 | &ack.header); | ||
1509 | kce_task = NULL; | ||
1510 | } | ||
1511 | else if ((NULL == kce_task) && (KCN_THRESHOLD > ss->sender->acks_available)) | ||
1512 | { | ||
1513 | |||
1514 | // kce_generate (ss, ++ss->sequence_allowed); | ||
1515 | // kce_generate (ss, ++ss->sequence_allowed); | ||
1516 | kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL, | ||
1517 | kce_generate_cb, | ||
1518 | ss); | ||
1519 | |||
1520 | } | ||
1521 | |||
1522 | |||
1523 | /*if (ss->active_kce_count < KCN_THRESHOLD) | ||
1429 | { | 1524 | { |
1430 | struct UDPAck ack; | 1525 | struct UDPAck ack; |
1431 | 1526 | ||
@@ -1435,20 +1530,18 @@ consider_ss_ack (struct SharedSecret *ss) | |||
1435 | * For the initial KX (active_kce_count==0), | 1530 | * For the initial KX (active_kce_count==0), |
1436 | * we only generate a single KCE to prevent | 1531 | * we only generate a single KCE to prevent |
1437 | * unnecessary overhead. | 1532 | * unnecessary overhead. |
1438 | */ | 1533 | |
1439 | GNUNET_SCHEDULER_add_now (kce_generate_cb, ss); | 1534 | if (0 < ss->active_kce_count) |
1440 | /*if (0 < ss->sequence_allowed) | ||
1441 | { | 1535 | { |
1442 | while (ss->active_kce_count < KCN_TARGET) | 1536 | while (ss->active_kce_count < KCN_TARGET) |
1443 | kce_generate (ss, ++ss->sequence_allowed); | 1537 | kce_generate (ss, ++ss->sequence_allowed); |
1444 | } | 1538 | } |
1445 | else {*/ | 1539 | else { |
1446 | /*kce_generate (ss, ++ss->sequence_allowed); | 1540 | kce_generate (ss, ++ss->sequence_allowed); |
1447 | kce_generate (ss, ++ss->sequence_allowed);*/ | 1541 | } |
1448 | // } | ||
1449 | ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); | 1542 | ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); |
1450 | ack.header.size = htons (sizeof(ack)); | 1543 | ack.header.size = htons (sizeof(ack)); |
1451 | ack.sequence_max = htonl (ss->sequence_allowed + GENERATE_AT_ONCE); | 1544 | ack.sequence_max = htonl (ss->sequence_allowed); |
1452 | ack.cmac = ss->cmac; | 1545 | ack.cmac = ss->cmac; |
1453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1546 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1454 | "Notifying transport of UDPAck %s\n", | 1547 | "Notifying transport of UDPAck %s\n", |
@@ -1457,7 +1550,7 @@ consider_ss_ack (struct SharedSecret *ss) | |||
1457 | &ss->sender->target, | 1550 | &ss->sender->target, |
1458 | COMMUNICATOR_ADDRESS_PREFIX, | 1551 | COMMUNICATOR_ADDRESS_PREFIX, |
1459 | &ack.header); | 1552 | &ack.header); |
1460 | } | 1553 | }*/ |
1461 | } | 1554 | } |
1462 | 1555 | ||
1463 | 1556 | ||
@@ -1489,10 +1582,6 @@ decrypt_box (const struct UDPBox *box, | |||
1489 | 1, | 1582 | 1, |
1490 | GNUNET_NO); | 1583 | GNUNET_NO); |
1491 | kce_destroy (kce); | 1584 | kce_destroy (kce); |
1492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1493 | "decrypting of UDPBox with kid %s and cmac %s failed\n", | ||
1494 | GNUNET_sh2s (&box->kid), | ||
1495 | GNUNET_h2s (&ss->cmac)); | ||
1496 | return; | 1585 | return; |
1497 | } | 1586 | } |
1498 | kce_destroy (kce); | 1587 | kce_destroy (kce); |
@@ -1504,7 +1593,7 @@ decrypt_box (const struct UDPBox *box, | |||
1504 | "decrypted UDPBox with kid %s\n", | 1593 | "decrypted UDPBox with kid %s\n", |
1505 | GNUNET_sh2s (&box->kid)); | 1594 | GNUNET_sh2s (&box->kid)); |
1506 | try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf)); | 1595 | try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf)); |
1507 | consider_ss_ack (ss); | 1596 | consider_ss_ack (ss, GNUNET_NO); |
1508 | } | 1597 | } |
1509 | 1598 | ||
1510 | 1599 | ||
@@ -1561,7 +1650,7 @@ find_sender_by_address (void *cls, | |||
1561 | * might already have one, so a fresh one is only allocated | 1650 | * might already have one, so a fresh one is only allocated |
1562 | * if one does not yet exist for @a address. | 1651 | * if one does not yet exist for @a address. |
1563 | * | 1652 | * |
1564 | * @param target peer to generate address for (can be NULL, if we already have one). | 1653 | * @param target peer to generate address for |
1565 | * @param address target address | 1654 | * @param address target address |
1566 | * @param address_len number of bytes in @a address | 1655 | * @param address_len number of bytes in @a address |
1567 | * @return data structure to keep track of key material for | 1656 | * @return data structure to keep track of key material for |
@@ -1581,7 +1670,7 @@ setup_sender (const struct GNUNET_PeerIdentity *target, | |||
1581 | target, | 1670 | target, |
1582 | &find_sender_by_address, | 1671 | &find_sender_by_address, |
1583 | &sc); | 1672 | &sc); |
1584 | if ((NULL != sc.sender)||(NULL == target)) | 1673 | if (NULL != sc.sender) |
1585 | { | 1674 | { |
1586 | reschedule_sender_timeout (sc.sender); | 1675 | reschedule_sender_timeout (sc.sender); |
1587 | return sc.sender; | 1676 | return sc.sender; |
@@ -1704,8 +1793,7 @@ sock_read (void *cls) | |||
1704 | return; | 1793 | return; |
1705 | } | 1794 | } |
1706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1707 | "Read %lu bytes.\n", | 1796 | "Read %lu bytes\n", rcvd); |
1708 | rcvd); | ||
1709 | /* first, see if it is a UDPBox */ | 1797 | /* first, see if it is a UDPBox */ |
1710 | if (rcvd > sizeof(struct UDPBox)) | 1798 | if (rcvd > sizeof(struct UDPBox)) |
1711 | { | 1799 | { |
@@ -1719,9 +1807,6 @@ sock_read (void *cls) | |||
1719 | decrypt_box (box, (size_t) rcvd, kce); | 1807 | decrypt_box (box, (size_t) rcvd, kce); |
1720 | return; | 1808 | return; |
1721 | } | 1809 | } |
1722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1723 | "No kid %s.\n", | ||
1724 | GNUNET_sh2s (&box->kid)); | ||
1725 | } | 1810 | } |
1726 | 1811 | ||
1727 | /* next, check if it is a broadcast */ | 1812 | /* next, check if it is a broadcast */ |
@@ -1779,8 +1864,7 @@ sock_read (void *cls) | |||
1779 | kx = (const struct InitialKX *) buf; | 1864 | kx = (const struct InitialKX *) buf; |
1780 | ss = setup_shared_secret_dec (&kx->ephemeral); | 1865 | ss = setup_shared_secret_dec (&kx->ephemeral); |
1781 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1866 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1782 | "Before DEC with ephemeral %s\n", | 1867 | "Before DEC\n"); |
1783 | GNUNET_e2s (&kx->ephemeral)); | ||
1784 | 1868 | ||
1785 | if (GNUNET_OK != try_decrypt (ss, | 1869 | if (GNUNET_OK != try_decrypt (ss, |
1786 | kx->gcm_tag, | 1870 | kx->gcm_tag, |
@@ -1817,10 +1901,6 @@ sock_read (void *cls) | |||
1817 | "Before SETUP_SENDER\n"); | 1901 | "Before SETUP_SENDER\n"); |
1818 | 1902 | ||
1819 | calculate_cmac (ss); | 1903 | calculate_cmac (ss); |
1820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1821 | "Got cmac %s for secret %p.\n", | ||
1822 | GNUNET_h2s (&ss->cmac), | ||
1823 | ss); | ||
1824 | sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen); | 1904 | sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen); |
1825 | ss->sender = sender; | 1905 | ss->sender = sender; |
1826 | GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss); | 1906 | GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss); |
@@ -1831,12 +1911,9 @@ sock_read (void *cls) | |||
1831 | 1, | 1911 | 1, |
1832 | GNUNET_NO); | 1912 | GNUNET_NO); |
1833 | try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc)); | 1913 | try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc)); |
1834 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1914 | consider_ss_ack (ss, GNUNET_YES); |
1835 | "We have %u secrets\n", | ||
1836 | sender->num_secrets); | ||
1837 | /*if (sender->num_secrets > MAX_SECRETS) | 1915 | /*if (sender->num_secrets > MAX_SECRETS) |
1838 | secret_destroy (sender->ss_tail);*/ | 1916 | secret_destroy (sender->ss_tail);*/ |
1839 | consider_ss_ack (ss); | ||
1840 | } | 1917 | } |
1841 | } | 1918 | } |
1842 | 1919 | ||
@@ -2038,8 +2115,6 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2038 | GNUNET_CRYPTO_ecdhe_key_create (&epriv); | 2115 | GNUNET_CRYPTO_ecdhe_key_create (&epriv); |
2039 | 2116 | ||
2040 | ss = setup_shared_secret_enc (&epriv, receiver); | 2117 | ss = setup_shared_secret_enc (&epriv, receiver); |
2041 | /*if (receiver->num_secrets > MAX_SECRETS) | ||
2042 | secret_destroy (receiver->ss_tail);*/ | ||
2043 | setup_cipher (&ss->master, 0, &out_cipher); | 2118 | setup_cipher (&ss->master, 0, &out_cipher); |
2044 | /* compute 'uc' */ | 2119 | /* compute 'uc' */ |
2045 | uc.sender = my_identity; | 2120 | uc.sender = my_identity; |
@@ -2081,10 +2156,8 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2081 | receiver->address_len)) | 2156 | receiver->address_len)) |
2082 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 2157 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
2083 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2084 | "Sending KX to %s with ephemeral %s\n", | 2159 | "Sending KX to %s\n", GNUNET_a2s (receiver->address, |
2085 | GNUNET_a2s (receiver->address, | 2160 | receiver->address_len)); |
2086 | receiver->address_len), | ||
2087 | GNUNET_e2s (&kx.ephemeral)); | ||
2088 | GNUNET_MQ_impl_send_continue (mq); | 2161 | GNUNET_MQ_impl_send_continue (mq); |
2089 | } | 2162 | } |
2090 | 2163 | ||
@@ -2105,11 +2178,6 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2105 | struct ReceiverAddress *receiver = impl_state; | 2178 | struct ReceiverAddress *receiver = impl_state; |
2106 | uint16_t msize = ntohs (msg->size); | 2179 | uint16_t msize = ntohs (msg->size); |
2107 | 2180 | ||
2108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2109 | "sending to receiver %s with %u acks available.\n", | ||
2110 | receiver->foreign_addr, | ||
2111 | receiver->acks_available); | ||
2112 | |||
2113 | GNUNET_assert (mq == receiver->d_mq); | 2181 | GNUNET_assert (mq == receiver->d_mq); |
2114 | if ((msize > receiver->d_mtu) || | 2182 | if ((msize > receiver->d_mtu) || |
2115 | (0 == receiver->acks_available)) | 2183 | (0 == receiver->acks_available)) |
@@ -2123,7 +2191,16 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2123 | /* begin "BOX" encryption method, scan for ACKs from tail! */ | 2191 | /* begin "BOX" encryption method, scan for ACKs from tail! */ |
2124 | for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev) | 2192 | for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev) |
2125 | { | 2193 | { |
2126 | if (ss->sequence_used >= ss->sequence_allowed) | 2194 | if (0 < ss->sequence_used) |
2195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2196 | "Trying to send UDPBox with shared secrect %s sequence_used %u and ss->sequence_allowed %u\n", | ||
2197 | GNUNET_h2s (&ss->master), | ||
2198 | ss->sequence_used, | ||
2199 | ss->sequence_allowed); | ||
2200 | // Uncomment this for alternativ 1 of backchannel functionality | ||
2201 | // if (ss->sequence_used >= ss->sequence_allowed) | ||
2202 | // Uncomment this for alternativ 2 of backchannel functionality | ||
2203 | if (0 == ss->sequence_allowed) | ||
2127 | { | 2204 | { |
2128 | continue; | 2205 | continue; |
2129 | } | 2206 | } |
@@ -2134,10 +2211,6 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2134 | 2211 | ||
2135 | box = (struct UDPBox *) dgram; | 2212 | box = (struct UDPBox *) dgram; |
2136 | ss->sequence_used++; | 2213 | ss->sequence_used++; |
2137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2138 | "get kid with sequence number %u and cmac %s.\n", | ||
2139 | ss->sequence_used, | ||
2140 | GNUNET_h2s (&ss->cmac)); | ||
2141 | get_kid (&ss->master, ss->sequence_used, &box->kid); | 2214 | get_kid (&ss->master, ss->sequence_used, &box->kid); |
2142 | setup_cipher (&ss->master, ss->sequence_used, &out_cipher); | 2215 | setup_cipher (&ss->master, ss->sequence_used, &out_cipher); |
2143 | /* Append encrypted payload to dgram */ | 2216 | /* Append encrypted payload to dgram */ |
@@ -2157,18 +2230,10 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2157 | receiver->address_len)) | 2230 | receiver->address_len)) |
2158 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 2231 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
2159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2160 | "Sending UDPBox to %s with shared secrect %p and kid %s\n", | 2233 | "Sending UDPBox to %s\n", GNUNET_a2s (receiver->address, |
2161 | GNUNET_a2s ( | 2234 | receiver->address_len)); |
2162 | receiver->address, | ||
2163 | receiver | ||
2164 | ->address_len), | ||
2165 | ss, | ||
2166 | GNUNET_sh2s (&box->kid)); | ||
2167 | GNUNET_MQ_impl_send_continue (mq); | 2235 | GNUNET_MQ_impl_send_continue (mq); |
2168 | receiver->acks_available--; | 2236 | // receiver->acks_available--; |
2169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2170 | "%u acks available after sending.\n", | ||
2171 | receiver->acks_available); | ||
2172 | if (0 == receiver->acks_available) | 2237 | if (0 == receiver->acks_available) |
2173 | { | 2238 | { |
2174 | /* We have no more ACKs */ | 2239 | /* We have no more ACKs */ |