aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-tng.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-04-07 17:22:23 +0200
committerChristian Grothoff <christian@grothoff.org>2019-04-07 17:22:23 +0200
commit0142079ce2e7a5e062d06aa8dddf2fdc1529035d (patch)
treeeb0bd17aec8a7a5501435d11cfe2d53402db5dcd /src/transport/gnunet-service-tng.c
parenta8c2bed07d3d43c34cfcf8fe96e56ea516feaf80 (diff)
downloadgnunet-0142079ce2e7a5e062d06aa8dddf2fdc1529035d.tar.gz
gnunet-0142079ce2e7a5e062d06aa8dddf2fdc1529035d.zip
implement #5551 (UDP broadcast learning in TNG)
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r--src/transport/gnunet-service-tng.c106
1 files changed, 67 insertions, 39 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 6494a5dfd..b41168d82 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -35,17 +35,12 @@
35 * Implement next: 35 * Implement next:
36 * - address validation: what is our plan here? 36 * - address validation: what is our plan here?
37 * #1 Peerstore only gets 'validated' addresses 37 * #1 Peerstore only gets 'validated' addresses
38 * #2 transport needs another API to "trigger" validation! 38 * #2 transport should use validation to also establish
39 * API may be used by core/application or communicators;
40 * => use yet another lib/MQ/connection?
41 * #3 transport should use validation to also establish
42 * effective flow control (for uni-directional transports!) 39 * effective flow control (for uni-directional transports!)
43 * #4 UDP broadcasting logic must be extended to use the new API 40 * #3 only validated addresses are selected for scheduling; that
44 * #5 only validated addresses are selected for scheduling; that
45 * also ensures we know the RTT 41 * also ensures we know the RTT
46 * #6 to ensure flow control and RTT are OK, we always do the 42 * #4 to ensure flow control and RTT are OK, we always do the
47 * 'validation', even if address comes from PEERSTORE 43 * 'validation', even if address comes from PEERSTORE
48 * #7
49 * - ACK handling / retransmission 44 * - ACK handling / retransmission
50 * - address verification 45 * - address verification
51 * - track RTT, distance, loss, etc. 46 * - track RTT, distance, loss, etc.
@@ -58,9 +53,6 @@
58 * - backchannel message encryption & decryption 53 * - backchannel message encryption & decryption
59 * - 54 * -
60 * 55 *
61 * Easy:
62 * - figure out how to call XXX_suggestion_cb!
63 *
64 * Later: 56 * Later:
65 * - change transport-core API to provide proper flow control in both 57 * - change transport-core API to provide proper flow control in both
66 * directions, allow multiple messages per peer simultaneously (tag 58 * directions, allow multiple messages per peer simultaneously (tag
@@ -2612,8 +2604,8 @@ expire_ephemerals (void *cls)
2612 continue; 2604 continue;
2613 } 2605 }
2614 ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity, 2606 ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity,
2615 &expire_ephemerals, 2607 &expire_ephemerals,
2616 NULL); 2608 NULL);
2617 return; 2609 return;
2618 } 2610 }
2619} 2611}
@@ -2640,7 +2632,7 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid,
2640 struct EphemeralConfirmation ec; 2632 struct EphemeralConfirmation ec;
2641 2633
2642 ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, 2634 ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map,
2643 pid); 2635 pid);
2644 if ( (NULL != ece) && 2636 if ( (NULL != ece) &&
2645 (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity).rel_value_us) ) 2637 (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity).rel_value_us) )
2646 { 2638 {
@@ -2652,27 +2644,27 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid,
2652 ece = GNUNET_new (struct EphemeralCacheEntry); 2644 ece = GNUNET_new (struct EphemeralCacheEntry);
2653 ece->target = *pid; 2645 ece->target = *pid;
2654 ece->ephemeral_validity = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get_monotonic (GST_cfg), 2646 ece->ephemeral_validity = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get_monotonic (GST_cfg),
2655 EPHEMERAL_VALIDITY); 2647 EPHEMERAL_VALIDITY);
2656 GNUNET_assert (GNUNET_OK == 2648 GNUNET_assert (GNUNET_OK ==
2657 GNUNET_CRYPTO_ecdhe_key_create2 (&ece->private_key)); 2649 GNUNET_CRYPTO_ecdhe_key_create2 (&ece->private_key));
2658 GNUNET_CRYPTO_ecdhe_key_get_public (&ece->private_key, 2650 GNUNET_CRYPTO_ecdhe_key_get_public (&ece->private_key,
2659 &ece->ephemeral_key); 2651 &ece->ephemeral_key);
2660 ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); 2652 ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
2661 ec.purpose.size = htonl (sizeof (ec)); 2653 ec.purpose.size = htonl (sizeof (ec));
2662 ec.target = *pid; 2654 ec.target = *pid;
2663 ec.ephemeral_key = ece->ephemeral_key; 2655 ec.ephemeral_key = ece->ephemeral_key;
2664 GNUNET_assert (GNUNET_OK == 2656 GNUNET_assert (GNUNET_OK ==
2665 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, 2657 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
2666 &ec.purpose, 2658 &ec.purpose,
2667 &ece->sender_sig)); 2659 &ece->sender_sig));
2668 ece->hn = GNUNET_CONTAINER_heap_insert (ephemeral_heap, 2660 ece->hn = GNUNET_CONTAINER_heap_insert (ephemeral_heap,
2669 ece, 2661 ece,
2670 ece->ephemeral_validity.abs_value_us); 2662 ece->ephemeral_validity.abs_value_us);
2671 GNUNET_assert (GNUNET_OK == 2663 GNUNET_assert (GNUNET_OK ==
2672 GNUNET_CONTAINER_multipeermap_put (ephemeral_map, 2664 GNUNET_CONTAINER_multipeermap_put (ephemeral_map,
2673 &ece->target, 2665 &ece->target,
2674 ece, 2666 ece,
2675 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 2667 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
2676 if (NULL == ephemeral_task) 2668 if (NULL == ephemeral_task)
2677 ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity, 2669 ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity,
2678 &expire_ephemerals, 2670 &expire_ephemerals,
@@ -2733,27 +2725,27 @@ handle_communicator_backchannel (void *cls,
2733 // FIXME: setup 'iv' 2725 // FIXME: setup 'iv'
2734#if FIXME 2726#if FIXME
2735 dh_key_derive (&private_key, 2727 dh_key_derive (&private_key,
2736 &cb->pid, 2728 &cb->pid,
2737 &enc->iv, 2729 &enc->iv,
2738 &key); 2730 &key);
2739#endif 2731#endif
2740 ppay.ephemeral_validity = GNUNET_TIME_absolute_hton (ephemeral_validity); 2732 ppay.ephemeral_validity = GNUNET_TIME_absolute_hton (ephemeral_validity);
2741 ppay.monotonic_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg)); 2733 ppay.monotonic_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg));
2742 mpos = (char *) &enc[1]; 2734 mpos = (char *) &enc[1];
2743#if FIXME 2735#if FIXME
2744 encrypt (key, 2736 encrypt (key,
2745 &ppay, 2737 &ppay,
2746 &mpos, 2738 &mpos,
2747 sizeof (ppay)); 2739 sizeof (ppay));
2748 encrypt (key, 2740 encrypt (key,
2749 &cb[1], 2741 &cb[1],
2750 &mpos, 2742 &mpos,
2751 ntohs (cb->header.size) - sizeof (*cb)); 2743 ntohs (cb->header.size) - sizeof (*cb));
2752 hmac (key, 2744 hmac (key,
2753 &enc->hmac); 2745 &enc->hmac);
2754#endif 2746#endif
2755 route_message (&cb->pid, 2747 route_message (&cb->pid,
2756 &enc->header); 2748 &enc->header);
2757 GNUNET_SERVICE_client_continue (tc->client); 2749 GNUNET_SERVICE_client_continue (tc->client);
2758} 2750}
2759 2751
@@ -4490,10 +4482,10 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid,
4490 cqm->request_id = htonl (idgen++); 4482 cqm->request_id = htonl (idgen++);
4491 cqm->receiver = *pid; 4483 cqm->receiver = *pid;
4492 memcpy (&cqm[1], 4484 memcpy (&cqm[1],
4493 address, 4485 address,
4494 alen); 4486 alen);
4495 GNUNET_MQ_send (tc->mq, 4487 GNUNET_MQ_send (tc->mq,
4496 env); 4488 env);
4497} 4489}
4498 4490
4499 4491
@@ -4642,7 +4634,7 @@ handle_suggest (void *cls,
4642 pr->wc = GNUNET_PEERSTORE_watch (peerstore, 4634 pr->wc = GNUNET_PEERSTORE_watch (peerstore,
4643 "transport", 4635 "transport",
4644 &pr->pid, 4636 &pr->pid,
4645 "hello", 4637 GNUNET_HELLO_PEERSTORE_KEY,
4646 &handle_hello, 4638 &handle_hello,
4647 pr); 4639 pr);
4648 GNUNET_SERVICE_client_continue (tc->client); 4640 GNUNET_SERVICE_client_continue (tc->client);
@@ -4738,6 +4730,38 @@ handle_address_consider_verify (void *cls,
4738 4730
4739 4731
4740/** 4732/**
4733 * Check #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION
4734 * messages.
4735 *
4736 * @param cls a `struct TransportClient *`
4737 * @param m message to verify
4738 * @return #GNUNET_OK on success
4739 */
4740static int
4741check_request_hello_validation (void *cls,
4742 const struct RequestHelloValidationMessage *m)
4743{
4744 GNUNET_MQ_check_zero_termination (m);
4745 return GNUNET_OK;
4746}
4747
4748
4749/**
4750 * A client encountered an address of another peer. Consider validating it,
4751 * and if validation succeeds, persist it to PEERSTORE.
4752 *
4753 * @param cls a `struct TransportClient *`
4754 * @param m message to verify
4755 */
4756static void
4757handle_request_hello_validation (void *cls,
4758 const struct RequestHelloValidationMessage *m)
4759{
4760 // FIXME: implement validation!
4761}
4762
4763
4764/**
4741 * Free neighbour entry. 4765 * Free neighbour entry.
4742 * 4766 *
4743 * @param cls NULL 4767 * @param cls NULL
@@ -4927,6 +4951,10 @@ GNUNET_SERVICE_MAIN
4927 GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, 4951 GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL,
4928 struct ExpressPreferenceMessage, 4952 struct ExpressPreferenceMessage,
4929 NULL), 4953 NULL),
4954 GNUNET_MQ_hd_var_size (request_hello_validation,
4955 GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION,
4956 struct RequestHelloValidationMessage,
4957 NULL),
4930 /* communication with core */ 4958 /* communication with core */
4931 GNUNET_MQ_hd_fixed_size (client_start, 4959 GNUNET_MQ_hd_fixed_size (client_start,
4932 GNUNET_MESSAGE_TYPE_TRANSPORT_START, 4960 GNUNET_MESSAGE_TYPE_TRANSPORT_START,