diff options
-rw-r--r-- | src/transport/gnunet-service-tng.c | 412 | ||||
-rw-r--r-- | src/transport/transport.h | 47 |
2 files changed, 415 insertions, 44 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 56ba70b9a..4dc3a137d 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -24,8 +24,6 @@ | |||
24 | * | 24 | * |
25 | * TODO: | 25 | * TODO: |
26 | * Implement next: | 26 | * Implement next: |
27 | * - complete backchannel signature verification and | ||
28 | * forwarding of backchannel messages to communicators! | ||
29 | * - track RTT, distance, loss, etc. => requires extra data structures! | 27 | * - track RTT, distance, loss, etc. => requires extra data structures! |
30 | * - proper use/initialization of timestamps in messages exchanged | 28 | * - proper use/initialization of timestamps in messages exchanged |
31 | * during DV learning | 29 | * during DV learning |
@@ -153,6 +151,13 @@ | |||
153 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | 151 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
154 | 152 | ||
155 | /** | 153 | /** |
154 | * How long do we cache backchannel (struct Backtalker) information | ||
155 | * after a backchannel goes inactive? | ||
156 | */ | ||
157 | #define BACKCHANNEL_INACTIVITY_TIMEOUT \ | ||
158 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | ||
159 | |||
160 | /** | ||
156 | * How long before paths expire would we like to (re)discover DV paths? Should | 161 | * How long before paths expire would we like to (re)discover DV paths? Should |
157 | * be below #DV_PATH_VALIDITY_TIMEOUT. | 162 | * be below #DV_PATH_VALIDITY_TIMEOUT. |
158 | */ | 163 | */ |
@@ -289,7 +294,7 @@ struct TransportBackchannelEncapsulationMessage | |||
289 | /** | 294 | /** |
290 | * Body by which a peer confirms that it is using an ephemeral key. | 295 | * Body by which a peer confirms that it is using an ephemeral key. |
291 | */ | 296 | */ |
292 | struct EphemeralConfirmation | 297 | struct EphemeralConfirmationPS |
293 | { | 298 | { |
294 | 299 | ||
295 | /** | 300 | /** |
@@ -1965,6 +1970,65 @@ struct ValidationState | |||
1965 | 1970 | ||
1966 | 1971 | ||
1967 | /** | 1972 | /** |
1973 | * A Backtalker is a peer sending us backchannel messages. We use this | ||
1974 | * struct to detect monotonic time violations, cache ephemeral key | ||
1975 | * material (to avoid repeatedly checking signatures), and to synchronize | ||
1976 | * monotonic time with the PEERSTORE. | ||
1977 | */ | ||
1978 | struct Backtalker | ||
1979 | { | ||
1980 | /** | ||
1981 | * Peer this is about. | ||
1982 | */ | ||
1983 | struct GNUNET_PeerIdentity pid; | ||
1984 | |||
1985 | /** | ||
1986 | * Last (valid) monotonic time received from this sender. | ||
1987 | */ | ||
1988 | struct GNUNET_TIME_Absolute monotonic_time; | ||
1989 | |||
1990 | /** | ||
1991 | * When will this entry time out? | ||
1992 | */ | ||
1993 | struct GNUNET_TIME_Absolute timeout; | ||
1994 | |||
1995 | /** | ||
1996 | * Last (valid) ephemeral key received from this sender. | ||
1997 | */ | ||
1998 | struct GNUNET_CRYPTO_EcdhePublicKey last_ephemeral; | ||
1999 | |||
2000 | /** | ||
2001 | * Task associated with this backtalker. Can be for timeout, | ||
2002 | * or other asynchronous operations. | ||
2003 | */ | ||
2004 | struct GNUNET_SCHEDULER_Task *task; | ||
2005 | |||
2006 | /** | ||
2007 | * Communicator context waiting on this backchannel's @e get, or NULL. | ||
2008 | */ | ||
2009 | struct CommunicatorMessageContext *cmc; | ||
2010 | |||
2011 | /** | ||
2012 | * Handle for an operation to fetch @e monotonic_time information from the | ||
2013 | * PEERSTORE, or NULL. | ||
2014 | */ | ||
2015 | struct GNUNET_PEERSTORE_IterateContext *get; | ||
2016 | |||
2017 | /** | ||
2018 | * Handle to a PEERSTORE store operation for this @e pid's @e | ||
2019 | * monotonic_time. NULL if no PEERSTORE operation is pending. | ||
2020 | */ | ||
2021 | struct GNUNET_PEERSTORE_StoreContext *sc; | ||
2022 | |||
2023 | /** | ||
2024 | * Number of bytes of the original message body that follows after this | ||
2025 | * struct. | ||
2026 | */ | ||
2027 | size_t body_size; | ||
2028 | }; | ||
2029 | |||
2030 | |||
2031 | /** | ||
1968 | * Head of linked list of all clients to this service. | 2032 | * Head of linked list of all clients to this service. |
1969 | */ | 2033 | */ |
1970 | static struct TransportClient *clients_head; | 2034 | static struct TransportClient *clients_head; |
@@ -2001,6 +2065,12 @@ static struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key; | |||
2001 | static struct GNUNET_CONTAINER_MultiPeerMap *neighbours; | 2065 | static struct GNUNET_CONTAINER_MultiPeerMap *neighbours; |
2002 | 2066 | ||
2003 | /** | 2067 | /** |
2068 | * Map from PIDs to `struct Backtalker` entries. A peer is | ||
2069 | * a backtalker if it recently send us backchannel messages. | ||
2070 | */ | ||
2071 | static struct GNUNET_CONTAINER_MultiPeerMap *backtalkers; | ||
2072 | |||
2073 | /** | ||
2004 | * Map from PIDs to `struct DistanceVector` entries describing | 2074 | * Map from PIDs to `struct DistanceVector` entries describing |
2005 | * known paths to the peer. | 2075 | * known paths to the peer. |
2006 | */ | 2076 | */ |
@@ -3195,7 +3265,7 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid, | |||
3195 | struct GNUNET_TIME_Absolute *ephemeral_validity) | 3265 | struct GNUNET_TIME_Absolute *ephemeral_validity) |
3196 | { | 3266 | { |
3197 | struct EphemeralCacheEntry *ece; | 3267 | struct EphemeralCacheEntry *ece; |
3198 | struct EphemeralConfirmation ec; | 3268 | struct EphemeralConfirmationPS ec; |
3199 | 3269 | ||
3200 | ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, pid); | 3270 | ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, pid); |
3201 | if ((NULL != ece) && | 3271 | if ((NULL != ece) && |
@@ -4570,6 +4640,254 @@ check_backchannel_encapsulation ( | |||
4570 | 4640 | ||
4571 | 4641 | ||
4572 | /** | 4642 | /** |
4643 | * We received the plaintext @a msg from backtalker @a b. Forward | ||
4644 | * it to the respective communicator. | ||
4645 | * | ||
4646 | * @param b a backtalker | ||
4647 | * @param msg a message, consisting of a `struct GNUNET_MessageHeader` | ||
4648 | * followed by the target name of the communicator | ||
4649 | * @param msg_size number of bytes in @a msg | ||
4650 | */ | ||
4651 | static void | ||
4652 | forward_backchannel_payload (struct Backtalker *b, | ||
4653 | const void *msg, | ||
4654 | size_t msg_size) | ||
4655 | { | ||
4656 | struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi; | ||
4657 | struct GNUNET_MQ_Envelope *env; | ||
4658 | struct TransportClient *tc; | ||
4659 | const struct GNUNET_MessageHeader *mh; | ||
4660 | const char *target_communicator; | ||
4661 | uint16_t mhs; | ||
4662 | |||
4663 | /* Determine target_communicator and check @a msg is well-formed */ | ||
4664 | mh = msg; | ||
4665 | mhs = ntohs (mh->size); | ||
4666 | if (mhs <= msg_size) | ||
4667 | { | ||
4668 | GNUNET_break_op (0); | ||
4669 | return; | ||
4670 | } | ||
4671 | target_communicator = &((const char *) msg)[ntohs (mh->size)]; | ||
4672 | if ('\0' != target_communicator[msg_size - mhs - 1]) | ||
4673 | { | ||
4674 | GNUNET_break_op (0); | ||
4675 | return; | ||
4676 | } | ||
4677 | /* Find client providing this communicator */ | ||
4678 | for (tc = clients_head; NULL != tc; tc = tc->next) | ||
4679 | if ((CT_COMMUNICATOR == tc->type) && | ||
4680 | (0 == | ||
4681 | strcmp (tc->details.communicator.address_prefix, target_communicator))) | ||
4682 | break; | ||
4683 | if (NULL == tc) | ||
4684 | { | ||
4685 | char *stastr; | ||
4686 | |||
4687 | GNUNET_asprintf ( | ||
4688 | &stastr, | ||
4689 | "# Backchannel message dropped: target communicator `%s' unknown", | ||
4690 | target_communicator); | ||
4691 | GNUNET_STATISTICS_update (GST_stats, stastr, 1, GNUNET_NO); | ||
4692 | GNUNET_free (stastr); | ||
4693 | return; | ||
4694 | } | ||
4695 | /* Finally, deliver backchannel message to communicator */ | ||
4696 | env = GNUNET_MQ_msg_extra ( | ||
4697 | cbi, | ||
4698 | msg_size, | ||
4699 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING); | ||
4700 | cbi->pid = b->pid; | ||
4701 | memcpy (&cbi[1], msg, msg_size); | ||
4702 | GNUNET_MQ_send (tc->mq, env); | ||
4703 | } | ||
4704 | |||
4705 | |||
4706 | /** | ||
4707 | * Free data structures associated with @a b. | ||
4708 | * | ||
4709 | * @param b data structure to release | ||
4710 | */ | ||
4711 | static void | ||
4712 | free_backtalker (struct Backtalker *b) | ||
4713 | { | ||
4714 | if (NULL != b->get) | ||
4715 | { | ||
4716 | GNUNET_PEERSTORE_iterate_cancel (b->get); | ||
4717 | b->get = NULL; | ||
4718 | GNUNET_assert (NULL != b->cmc); | ||
4719 | finish_cmc_handling (b->cmc); | ||
4720 | b->cmc = NULL; | ||
4721 | } | ||
4722 | if (NULL != b->task) | ||
4723 | { | ||
4724 | GNUNET_SCHEDULER_cancel (b->task); | ||
4725 | b->task = NULL; | ||
4726 | } | ||
4727 | if (NULL != b->sc) | ||
4728 | { | ||
4729 | GNUNET_PEERSTORE_store_cancel (b->sc); | ||
4730 | b->sc = NULL; | ||
4731 | } | ||
4732 | GNUNET_assert ( | ||
4733 | GNUNET_YES == | ||
4734 | GNUNET_CONTAINER_multipeermap_remove (backtalkers, &b->pid, b)); | ||
4735 | GNUNET_free (b); | ||
4736 | } | ||
4737 | |||
4738 | |||
4739 | /** | ||
4740 | * Callback to free backtalker records. | ||
4741 | * | ||
4742 | * @param cls NULL | ||
4743 | * @param pid unused | ||
4744 | * @param value a `struct Backtalker` | ||
4745 | * @return #GNUNET_OK (always) | ||
4746 | */ | ||
4747 | static int | ||
4748 | free_backtalker_cb (void *cls, | ||
4749 | const struct GNUNET_PeerIdentity *pid, | ||
4750 | void *value) | ||
4751 | { | ||
4752 | struct Backtalker *b = value; | ||
4753 | |||
4754 | (void) cls; | ||
4755 | (void) pid; | ||
4756 | free_backtalker (b); | ||
4757 | return GNUNET_OK; | ||
4758 | } | ||
4759 | |||
4760 | |||
4761 | /** | ||
4762 | * Function called when it is time to clean up a backtalker. | ||
4763 | * | ||
4764 | * @param cls a `struct Backtalker` | ||
4765 | */ | ||
4766 | static void | ||
4767 | backtalker_timeout_cb (void *cls) | ||
4768 | { | ||
4769 | struct Backtalker *b = cls; | ||
4770 | |||
4771 | b->task = NULL; | ||
4772 | if (0 != GNUNET_TIME_absolute_get_remaining (b->timeout).rel_value_us) | ||
4773 | { | ||
4774 | b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); | ||
4775 | return; | ||
4776 | } | ||
4777 | GNUNET_assert (NULL == b->sc); | ||
4778 | free_backtalker (b); | ||
4779 | } | ||
4780 | |||
4781 | |||
4782 | /** | ||
4783 | * Function called with the monotonic time of a backtalker | ||
4784 | * by PEERSTORE. Updates the time and continues processing. | ||
4785 | * | ||
4786 | * @param cls a `struct Backtalker` | ||
4787 | * @param record the information found, NULL for the last call | ||
4788 | * @param emsg error message | ||
4789 | */ | ||
4790 | static void | ||
4791 | backtalker_monotime_cb (void *cls, | ||
4792 | const struct GNUNET_PEERSTORE_Record *record, | ||
4793 | const char *emsg) | ||
4794 | { | ||
4795 | struct Backtalker *b = cls; | ||
4796 | struct GNUNET_TIME_AbsoluteNBO *mtbe; | ||
4797 | struct GNUNET_TIME_Absolute mt; | ||
4798 | |||
4799 | (void) emsg; | ||
4800 | if (NULL == record) | ||
4801 | { | ||
4802 | /* we're done with #backtalker_monotime_cb() invocations, | ||
4803 | continue normal processing */ | ||
4804 | b->get = NULL; | ||
4805 | GNUNET_assert (NULL != b->cmc); | ||
4806 | finish_cmc_handling (b->cmc); | ||
4807 | b->cmc = NULL; | ||
4808 | if (0 != b->body_size) | ||
4809 | forward_backchannel_payload (b, &b[1], b->body_size); | ||
4810 | return; | ||
4811 | } | ||
4812 | if (sizeof (*mtbe) != record->value_size) | ||
4813 | { | ||
4814 | GNUNET_break (0); | ||
4815 | return; | ||
4816 | } | ||
4817 | mtbe = record->value; | ||
4818 | mt = GNUNET_TIME_absolute_ntoh (*mtbe); | ||
4819 | if (mt.abs_value_us > b->monotonic_time.abs_value_us) | ||
4820 | { | ||
4821 | GNUNET_STATISTICS_update ( | ||
4822 | GST_stats, | ||
4823 | "# Backchannel messages dropped: monotonic time not increasing", | ||
4824 | 1, | ||
4825 | GNUNET_NO); | ||
4826 | b->monotonic_time = mt; | ||
4827 | /* Setting body_size to 0 prevents call to #forward_backchannel_payload() */ | ||
4828 | b->body_size = 0; | ||
4829 | return; | ||
4830 | } | ||
4831 | } | ||
4832 | |||
4833 | |||
4834 | /** | ||
4835 | * Function called by PEERSTORE when the store operation of | ||
4836 | * a backtalker's monotonic time is complete. | ||
4837 | * | ||
4838 | * @param cls the `struct Backtalker` | ||
4839 | * @param success #GNUNET_OK on success | ||
4840 | */ | ||
4841 | static void | ||
4842 | backtalker_monotime_store_cb (void *cls, int success) | ||
4843 | { | ||
4844 | struct Backtalker *b = cls; | ||
4845 | |||
4846 | if (GNUNET_OK != success) | ||
4847 | { | ||
4848 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
4849 | "Failed to store backtalker's monotonic time in PEERSTORE!\n"); | ||
4850 | } | ||
4851 | b->sc = NULL; | ||
4852 | b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); | ||
4853 | } | ||
4854 | |||
4855 | |||
4856 | /** | ||
4857 | * The backtalker @a b monotonic time changed. Update PEERSTORE. | ||
4858 | * | ||
4859 | * @param b a backtalker with updated monotonic time | ||
4860 | */ | ||
4861 | static void | ||
4862 | update_backtalker_monotime (struct Backtalker *b) | ||
4863 | { | ||
4864 | struct GNUNET_TIME_AbsoluteNBO mtbe; | ||
4865 | |||
4866 | if (NULL != b->sc) | ||
4867 | { | ||
4868 | GNUNET_PEERSTORE_store_cancel (b->sc); | ||
4869 | b->sc = NULL; | ||
4870 | } | ||
4871 | else | ||
4872 | { | ||
4873 | GNUNET_SCHEDULER_cancel (b->task); | ||
4874 | b->task = NULL; | ||
4875 | } | ||
4876 | mtbe = GNUNET_TIME_absolute_hton (b->monotonic_time); | ||
4877 | b->sc = GNUNET_PEERSTORE_store (peerstore, | ||
4878 | "transport", | ||
4879 | &b->pid, | ||
4880 | "transport-backchannel-monotonic-time", | ||
4881 | &mtbe, | ||
4882 | sizeof (mtbe), | ||
4883 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
4884 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | ||
4885 | &backtalker_monotime_store_cb, | ||
4886 | b); | ||
4887 | } | ||
4888 | |||
4889 | |||
4890 | /** | ||
4573 | * Communicator gave us a backchannel encapsulation. Process the request. | 4891 | * Communicator gave us a backchannel encapsulation. Process the request. |
4574 | * (We are not the origin of the backchannel here, the communicator simply | 4892 | * (We are not the origin of the backchannel here, the communicator simply |
4575 | * received a backchannel message and we are expected to forward it.) | 4893 | * received a backchannel message and we are expected to forward it.) |
@@ -4611,6 +4929,8 @@ handle_backchannel_encapsulation ( | |||
4611 | } | 4929 | } |
4612 | /* begin actual decryption */ | 4930 | /* begin actual decryption */ |
4613 | { | 4931 | { |
4932 | struct Backtalker *b; | ||
4933 | struct GNUNET_TIME_Absolute monotime; | ||
4614 | struct TransportBackchannelRequestPayload ppay; | 4934 | struct TransportBackchannelRequestPayload ppay; |
4615 | char body[hdr_len - sizeof (ppay)]; | 4935 | char body[hdr_len - sizeof (ppay)]; |
4616 | 4936 | ||
@@ -4619,15 +4939,77 @@ handle_backchannel_encapsulation ( | |||
4619 | bc_decrypt (&key, &ppay, hdr, sizeof (ppay)); | 4939 | bc_decrypt (&key, &ppay, hdr, sizeof (ppay)); |
4620 | bc_decrypt (&key, &body, &hdr[sizeof (ppay)], hdr_len - sizeof (ppay)); | 4940 | bc_decrypt (&key, &body, &hdr[sizeof (ppay)], hdr_len - sizeof (ppay)); |
4621 | bc_key_clean (&key); | 4941 | bc_key_clean (&key); |
4622 | // FIXME: verify signatures in ppay! | 4942 | monotime = GNUNET_TIME_absolute_ntoh (ppay.monotonic_time); |
4623 | // => check if ephemeral key is known & valid, if not | 4943 | b = GNUNET_CONTAINER_multipeermap_get (backtalkers, &ppay.sender); |
4624 | // => verify sig, cache ephemeral key | 4944 | if ((NULL != b) && (monotime.abs_value_us < b->monotonic_time.abs_value_us)) |
4625 | // => update monotonic_time of sender for replay detection | 4945 | { |
4626 | 4946 | GNUNET_STATISTICS_update ( | |
4627 | // FIXME: forward to specified communicator! | 4947 | GST_stats, |
4628 | // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING) | 4948 | "# Backchannel messages dropped: monotonic time not increasing", |
4949 | 1, | ||
4950 | GNUNET_NO); | ||
4951 | finish_cmc_handling (cmc); | ||
4952 | return; | ||
4953 | } | ||
4954 | if ((NULL == b) || | ||
4955 | (0 != GNUNET_memcmp (&b->last_ephemeral, &be->ephemeral_key))) | ||
4956 | { | ||
4957 | /* Check signature */ | ||
4958 | struct EphemeralConfirmationPS ec; | ||
4959 | |||
4960 | ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); | ||
4961 | ec.purpose.size = htonl (sizeof (ec)); | ||
4962 | ec.target = GST_my_identity; | ||
4963 | ec.ephemeral_key = be->ephemeral_key; | ||
4964 | if ( | ||
4965 | GNUNET_OK != | ||
4966 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL, | ||
4967 | &ec.purpose, | ||
4968 | &ppay.sender_sig, | ||
4969 | &ppay.sender.public_key)) | ||
4970 | { | ||
4971 | /* Signature invalid, disard! */ | ||
4972 | GNUNET_break_op (0); | ||
4973 | finish_cmc_handling (cmc); | ||
4974 | return; | ||
4975 | } | ||
4976 | } | ||
4977 | if (NULL != b) | ||
4978 | { | ||
4979 | /* update key cache and mono time */ | ||
4980 | b->last_ephemeral = be->ephemeral_key; | ||
4981 | b->monotonic_time = monotime; | ||
4982 | update_backtalker_monotime (b); | ||
4983 | forward_backchannel_payload (b, body, sizeof (body)); | ||
4984 | b->timeout = | ||
4985 | GNUNET_TIME_relative_to_absolute (BACKCHANNEL_INACTIVITY_TIMEOUT); | ||
4986 | finish_cmc_handling (cmc); | ||
4987 | return; | ||
4988 | } | ||
4989 | /* setup data structure to cache signature AND check | ||
4990 | monotonic time with PEERSTORE before forwarding backchannel payload */ | ||
4991 | b = GNUNET_malloc (sizeof (struct Backtalker) + sizeof (body)); | ||
4992 | b->pid = ppay.sender; | ||
4993 | b->body_size = sizeof (body); | ||
4994 | memcpy (&b[1], body, sizeof (body)); | ||
4995 | GNUNET_assert (GNUNET_YES == | ||
4996 | GNUNET_CONTAINER_multipeermap_put ( | ||
4997 | backtalkers, | ||
4998 | &b->pid, | ||
4999 | b, | ||
5000 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
5001 | b->monotonic_time = monotime; /* NOTE: to be checked still! */ | ||
5002 | b->cmc = cmc; | ||
5003 | b->timeout = | ||
5004 | GNUNET_TIME_relative_to_absolute (BACKCHANNEL_INACTIVITY_TIMEOUT); | ||
5005 | b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); | ||
5006 | b->get = GNUNET_PEERSTORE_iterate (peerstore, | ||
5007 | "transport", | ||
5008 | &b->pid, | ||
5009 | "transport-backchannel-monotonic-time", | ||
5010 | &backtalker_monotime_cb, | ||
5011 | b); | ||
4629 | } | 5012 | } |
4630 | finish_cmc_handling (cmc); | ||
4631 | } | 5013 | } |
4632 | 5014 | ||
4633 | 5015 | ||
@@ -7453,6 +7835,11 @@ do_shutdown (void *cls) | |||
7453 | } | 7835 | } |
7454 | GNUNET_CONTAINER_multipeermap_destroy (neighbours); | 7836 | GNUNET_CONTAINER_multipeermap_destroy (neighbours); |
7455 | neighbours = NULL; | 7837 | neighbours = NULL; |
7838 | GNUNET_CONTAINER_multipeermap_iterate (backtalkers, | ||
7839 | &free_backtalker_cb, | ||
7840 | NULL); | ||
7841 | GNUNET_CONTAINER_multipeermap_destroy (backtalkers); | ||
7842 | backtalkers = NULL; | ||
7456 | GNUNET_CONTAINER_multipeermap_iterate (validation_map, | 7843 | GNUNET_CONTAINER_multipeermap_iterate (validation_map, |
7457 | &free_validation_state_cb, | 7844 | &free_validation_state_cb, |
7458 | NULL); | 7845 | NULL); |
@@ -7496,6 +7883,7 @@ run (void *cls, | |||
7496 | (void) service; | 7883 | (void) service; |
7497 | /* setup globals */ | 7884 | /* setup globals */ |
7498 | GST_cfg = c; | 7885 | GST_cfg = c; |
7886 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); | ||
7499 | neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); | 7887 | neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
7500 | dv_routes = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); | 7888 | dv_routes = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
7501 | ephemeral_map = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES); | 7889 | ephemeral_map = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES); |
diff --git a/src/transport/transport.h b/src/transport/transport.h index b9c61f306..d2a3a262b 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -54,12 +54,14 @@ | |||
54 | /** | 54 | /** |
55 | * Maximum frequency for re-evaluating latencies for all transport addresses. | 55 | * Maximum frequency for re-evaluating latencies for all transport addresses. |
56 | */ | 56 | */ |
57 | #define LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1) | 57 | #define LATENCY_EVALUATION_MAX_DELAY \ |
58 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 1) | ||
58 | 59 | ||
59 | /** | 60 | /** |
60 | * Maximum frequency for re-evaluating latencies for connected addresses. | 61 | * Maximum frequency for re-evaluating latencies for connected addresses. |
61 | */ | 62 | */ |
62 | #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) | 63 | #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY \ |
64 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) | ||
63 | 65 | ||
64 | /** | 66 | /** |
65 | * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are | 67 | * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are |
@@ -71,11 +73,11 @@ | |||
71 | * @param bandwidth_out outbound bandwidth in NBO | 73 | * @param bandwidth_out outbound bandwidth in NBO |
72 | * | 74 | * |
73 | */ | 75 | */ |
74 | typedef void | 76 | typedef void (*NotifyConnect) ( |
75 | (*NotifyConnect) (void *cls, | 77 | void *cls, |
76 | const struct GNUNET_PeerIdentity *peer, | 78 | const struct GNUNET_PeerIdentity *peer, |
77 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 79 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
78 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); | 80 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); |
79 | 81 | ||
80 | 82 | ||
81 | GNUNET_NETWORK_STRUCT_BEGIN | 83 | GNUNET_NETWORK_STRUCT_BEGIN |
@@ -106,7 +108,6 @@ struct StartMessage | |||
106 | * receiver should print out an error message and disconnect. | 108 | * receiver should print out an error message and disconnect. |
107 | */ | 109 | */ |
108 | struct GNUNET_PeerIdentity self; | 110 | struct GNUNET_PeerIdentity self; |
109 | |||
110 | }; | 111 | }; |
111 | 112 | ||
112 | 113 | ||
@@ -155,7 +156,6 @@ struct DisconnectInfoMessage | |||
155 | * Who got disconnected? | 156 | * Who got disconnected? |
156 | */ | 157 | */ |
157 | struct GNUNET_PeerIdentity peer; | 158 | struct GNUNET_PeerIdentity peer; |
158 | |||
159 | }; | 159 | }; |
160 | 160 | ||
161 | 161 | ||
@@ -181,7 +181,6 @@ struct QuotaSetMessage | |||
181 | * About which peer are we talking here? | 181 | * About which peer are we talking here? |
182 | */ | 182 | */ |
183 | struct GNUNET_PeerIdentity peer; | 183 | struct GNUNET_PeerIdentity peer; |
184 | |||
185 | }; | 184 | }; |
186 | 185 | ||
187 | 186 | ||
@@ -201,7 +200,6 @@ struct InboundMessage | |||
201 | * Which peer sent the message? | 200 | * Which peer sent the message? |
202 | */ | 201 | */ |
203 | struct GNUNET_PeerIdentity peer; | 202 | struct GNUNET_PeerIdentity peer; |
204 | |||
205 | }; | 203 | }; |
206 | 204 | ||
207 | 205 | ||
@@ -240,7 +238,6 @@ struct SendOkMessage | |||
240 | * Which peer can send more now? | 238 | * Which peer can send more now? |
241 | */ | 239 | */ |
242 | struct GNUNET_PeerIdentity peer; | 240 | struct GNUNET_PeerIdentity peer; |
243 | |||
244 | }; | 241 | }; |
245 | 242 | ||
246 | 243 | ||
@@ -270,13 +267,11 @@ struct OutboundMessage | |||
270 | * Which peer should receive the message? | 267 | * Which peer should receive the message? |
271 | */ | 268 | */ |
272 | struct GNUNET_PeerIdentity peer; | 269 | struct GNUNET_PeerIdentity peer; |
273 | |||
274 | }; | 270 | }; |
275 | 271 | ||
276 | 272 | ||
277 | 273 | #if ! (defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION) || \ | |
278 | 274 | defined(GNUNET_TRANSPORT_CORE_VERSION)) | |
279 | #if !(defined(GNUNET_TRANSPORT_COMMUNICATION_VERSION)||defined(GNUNET_TRANSPORT_CORE_VERSION)) | ||
280 | 275 | ||
281 | 276 | ||
282 | /** | 277 | /** |
@@ -428,7 +423,6 @@ struct ValidationMonitorMessage | |||
428 | * The identity of the peer to look up. | 423 | * The identity of the peer to look up. |
429 | */ | 424 | */ |
430 | struct GNUNET_PeerIdentity peer; | 425 | struct GNUNET_PeerIdentity peer; |
431 | |||
432 | }; | 426 | }; |
433 | 427 | ||
434 | 428 | ||
@@ -452,7 +446,6 @@ struct PeerMonitorMessage | |||
452 | * The identity of the peer to look up. | 446 | * The identity of the peer to look up. |
453 | */ | 447 | */ |
454 | struct GNUNET_PeerIdentity peer; | 448 | struct GNUNET_PeerIdentity peer; |
455 | |||
456 | }; | 449 | }; |
457 | 450 | ||
458 | 451 | ||
@@ -545,7 +538,6 @@ struct PeerIterateResponseMessage | |||
545 | * Length of the plugin name | 538 | * Length of the plugin name |
546 | */ | 539 | */ |
547 | uint32_t pluginlen GNUNET_PACKED; | 540 | uint32_t pluginlen GNUNET_PACKED; |
548 | |||
549 | }; | 541 | }; |
550 | 542 | ||
551 | 543 | ||
@@ -572,7 +564,6 @@ struct BlacklistMessage | |||
572 | * Which peer is being blacklisted or queried? | 564 | * Which peer is being blacklisted or queried? |
573 | */ | 565 | */ |
574 | struct GNUNET_PeerIdentity peer; | 566 | struct GNUNET_PeerIdentity peer; |
575 | |||
576 | }; | 567 | }; |
577 | 568 | ||
578 | 569 | ||
@@ -644,7 +635,6 @@ struct TransportPluginMonitorMessage | |||
644 | 635 | ||
645 | /* followed by 0-terminated plugin name and | 636 | /* followed by 0-terminated plugin name and |
646 | @e plugin_address_len bytes of plugin address */ | 637 | @e plugin_address_len bytes of plugin address */ |
647 | |||
648 | }; | 638 | }; |
649 | 639 | ||
650 | #else | 640 | #else |
@@ -717,7 +707,6 @@ struct GNUNET_TRANSPORT_DelAddressMessage | |||
717 | * Address identifier. | 707 | * Address identifier. |
718 | */ | 708 | */ |
719 | uint32_t aid GNUNET_PACKED; | 709 | uint32_t aid GNUNET_PACKED; |
720 | |||
721 | }; | 710 | }; |
722 | 711 | ||
723 | 712 | ||
@@ -783,7 +772,6 @@ struct GNUNET_TRANSPORT_IncomingMessageAck | |||
783 | * Sender identifier of the original message. | 772 | * Sender identifier of the original message. |
784 | */ | 773 | */ |
785 | struct GNUNET_PeerIdentity sender; | 774 | struct GNUNET_PeerIdentity sender; |
786 | |||
787 | }; | 775 | }; |
788 | 776 | ||
789 | 777 | ||
@@ -847,7 +835,6 @@ struct GNUNET_TRANSPORT_DelQueueMessage | |||
847 | * Receiver that can be addressed via the queue. | 835 | * Receiver that can be addressed via the queue. |
848 | */ | 836 | */ |
849 | struct GNUNET_PeerIdentity receiver; | 837 | struct GNUNET_PeerIdentity receiver; |
850 | |||
851 | }; | 838 | }; |
852 | 839 | ||
853 | 840 | ||
@@ -883,7 +870,8 @@ struct GNUNET_TRANSPORT_CreateQueueResponse | |||
883 | { | 870 | { |
884 | 871 | ||
885 | /** | 872 | /** |
886 | * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK or #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL. | 873 | * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK or |
874 | * #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL. | ||
887 | */ | 875 | */ |
888 | struct GNUNET_MessageHeader header; | 876 | struct GNUNET_MessageHeader header; |
889 | 877 | ||
@@ -949,7 +937,6 @@ struct GNUNET_TRANSPORT_SendMessageToAck | |||
949 | * Receiver identifier. | 937 | * Receiver identifier. |
950 | */ | 938 | */ |
951 | struct GNUNET_PeerIdentity receiver; | 939 | struct GNUNET_PeerIdentity receiver; |
952 | |||
953 | }; | 940 | }; |
954 | 941 | ||
955 | 942 | ||
@@ -990,7 +977,8 @@ struct GNUNET_TRANSPORT_CommunicatorBackchannel | |||
990 | struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming | 977 | struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming |
991 | { | 978 | { |
992 | /** | 979 | /** |
993 | * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING | 980 | * Type will be |
981 | * #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING | ||
994 | */ | 982 | */ |
995 | struct GNUNET_MessageHeader header; | 983 | struct GNUNET_MessageHeader header; |
996 | 984 | ||
@@ -1006,11 +994,9 @@ struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming | |||
1006 | 994 | ||
1007 | /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated | 995 | /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated |
1008 | message to the communicator */ | 996 | message to the communicator */ |
1009 | |||
1010 | }; | 997 | }; |
1011 | 998 | ||
1012 | 999 | ||
1013 | |||
1014 | /** | 1000 | /** |
1015 | * Request to start monitoring. | 1001 | * Request to start monitoring. |
1016 | */ | 1002 | */ |
@@ -1031,7 +1017,6 @@ struct GNUNET_TRANSPORT_MonitorStart | |||
1031 | * Target identifier to monitor, all zeros for "all peers". | 1017 | * Target identifier to monitor, all zeros for "all peers". |
1032 | */ | 1018 | */ |
1033 | struct GNUNET_PeerIdentity peer; | 1019 | struct GNUNET_PeerIdentity peer; |
1034 | |||
1035 | }; | 1020 | }; |
1036 | 1021 | ||
1037 | 1022 | ||
@@ -1084,7 +1069,6 @@ struct GNUNET_TRANSPORT_MonitorData | |||
1084 | uint32_t num_bytes_pending GNUNET_PACKED; | 1069 | uint32_t num_bytes_pending GNUNET_PACKED; |
1085 | 1070 | ||
1086 | /* Followed by 0-terminated address of the peer */ | 1071 | /* Followed by 0-terminated address of the peer */ |
1087 | |||
1088 | }; | 1072 | }; |
1089 | 1073 | ||
1090 | 1074 | ||
@@ -1141,7 +1125,6 @@ struct ExpressPreferenceMessage | |||
1141 | * How much bandwidth in bytes/second does the application expect? | 1125 | * How much bandwidth in bytes/second does the application expect? |
1142 | */ | 1126 | */ |
1143 | struct GNUNET_BANDWIDTH_Value32NBO bw; | 1127 | struct GNUNET_BANDWIDTH_Value32NBO bw; |
1144 | |||
1145 | }; | 1128 | }; |
1146 | 1129 | ||
1147 | 1130 | ||