aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-04-16 19:03:56 +0200
committerChristian Grothoff <christian@grothoff.org>2019-04-16 19:03:56 +0200
commit309e1d242625e0984728076bda6a153316196dbc (patch)
tree037194cb954888e736123091cef82519333acbe3 /src/transport
parent0afe7f35883d40fbcef42eab8232d09934af5bf9 (diff)
downloadgnunet-309e1d242625e0984728076bda6a153316196dbc.tar.gz
gnunet-309e1d242625e0984728076bda6a153316196dbc.zip
revert Martin's reformatting
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-tng.c2722
1 files changed, 1578 insertions, 1144 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 45d8086ef..e55491990 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -138,55 +138,47 @@
138 * of seconds we log a warning. Note: this is for testing, 138 * of seconds we log a warning. Note: this is for testing,
139 * the value chosen here might be too aggressively low! 139 * the value chosen here might be too aggressively low!
140 */ 140 */
141#define DELAY_WARN_THRESHOLD \ 141#define DELAY_WARN_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
142 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
143 142
144/** 143/**
145 * We only consider queues as "quality" connections when 144 * We only consider queues as "quality" connections when
146 * suppressing the generation of DV initiation messages if 145 * suppressing the generation of DV initiation messages if
147 * the latency of the queue is below this threshold. 146 * the latency of the queue is below this threshold.
148 */ 147 */
149#define DV_QUALITY_RTT_THRESHOLD \ 148#define DV_QUALITY_RTT_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
150 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
151 149
152/** 150/**
153 * How long do we consider a DV path valid if we see no 151 * How long do we consider a DV path valid if we see no
154 * further updates on it? Note: the value chosen here might be too low! 152 * further updates on it? Note: the value chosen here might be too low!
155 */ 153 */
156#define DV_PATH_VALIDITY_TIMEOUT \ 154#define DV_PATH_VALIDITY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
157 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
158 155
159/** 156/**
160 * How long before paths expire would we like to (re)discover DV paths? Should 157 * How long before paths expire would we like to (re)discover DV paths? Should
161 * be below #DV_PATH_VALIDITY_TIMEOUT. 158 * be below #DV_PATH_VALIDITY_TIMEOUT.
162 */ 159 */
163#define DV_PATH_DISCOVERY_FREQUENCY \ 160#define DV_PATH_DISCOVERY_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
164 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
165 161
166/** 162/**
167 * How long are ephemeral keys valid? 163 * How long are ephemeral keys valid?
168 */ 164 */
169#define EPHEMERAL_VALIDITY \ 165#define EPHEMERAL_VALIDITY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
170 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
171 166
172/** 167/**
173 * How long do we keep partially reassembled messages around before giving up? 168 * How long do we keep partially reassembled messages around before giving up?
174 */ 169 */
175#define REASSEMBLY_EXPIRATION \ 170#define REASSEMBLY_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
176 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
177 171
178/** 172/**
179 * What is the fastest rate at which we send challenges *if* we keep learning 173 * What is the fastest rate at which we send challenges *if* we keep learning
180 * an address (gossip, DHT, etc.)? 174 * an address (gossip, DHT, etc.)?
181 */ 175 */
182#define FAST_VALIDATION_CHALLENGE_FREQ \ 176#define FAST_VALIDATION_CHALLENGE_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
183 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
184 177
185/** 178/**
186 * What is the slowest rate at which we send challenges? 179 * What is the slowest rate at which we send challenges?
187 */ 180 */
188#define MAX_VALIDATION_CHALLENGE_FREQ \ 181#define MAX_VALIDATION_CHALLENGE_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
189 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
190 182
191/** 183/**
192 * What is the non-randomized base frequency at which we 184 * What is the non-randomized base frequency at which we
@@ -203,13 +195,11 @@
203/** 195/**
204 * When do we forget an invalid address for sure? 196 * When do we forget an invalid address for sure?
205 */ 197 */
206#define MAX_ADDRESS_VALID_UNTIL \ 198#define MAX_ADDRESS_VALID_UNTIL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
207 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
208/** 199/**
209 * How long do we consider an address valid if we just checked? 200 * How long do we consider an address valid if we just checked?
210 */ 201 */
211#define ADDRESS_VALIDATION_LIFETIME \ 202#define ADDRESS_VALIDATION_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
212 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
213 203
214/** 204/**
215 * What is the maximum frequency at which we do address validation? 205 * What is the maximum frequency at which we do address validation?
@@ -329,6 +319,7 @@ struct EphemeralConfirmation
329 * to encrypt the payload. 319 * to encrypt the payload.
330 */ 320 */
331 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key; 321 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
322
332}; 323};
333 324
334 325
@@ -383,6 +374,7 @@ struct TransportBackchannelRequestPayload
383 374
384 /* Followed by a 0-termianted string specifying the name of 375 /* Followed by a 0-termianted string specifying the name of
385 the communicator which is to receive the message */ 376 the communicator which is to receive the message */
377
386}; 378};
387 379
388 380
@@ -481,6 +473,7 @@ struct TransportFragmentBox
481 * Total size of the message that is being fragmented. 473 * Total size of the message that is being fragmented.
482 */ 474 */
483 uint16_t msg_size GNUNET_PACKED; 475 uint16_t msg_size GNUNET_PACKED;
476
484}; 477};
485 478
486 479
@@ -574,6 +567,7 @@ struct DvInitPS
574 * Challenge value used by the initiator to re-identify the path. 567 * Challenge value used by the initiator to re-identify the path.
575 */ 568 */
576 struct GNUNET_ShortHashCode challenge; 569 struct GNUNET_ShortHashCode challenge;
570
577}; 571};
578 572
579 573
@@ -614,6 +608,7 @@ struct DvHopPS
614 * Challenge value used by the initiator to re-identify the path. 608 * Challenge value used by the initiator to re-identify the path.
615 */ 609 */
616 struct GNUNET_ShortHashCode challenge; 610 struct GNUNET_ShortHashCode challenge;
611
617}; 612};
618 613
619 614
@@ -633,6 +628,7 @@ struct DVPathEntryP
633 * #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP 628 * #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP
634 */ 629 */
635 struct GNUNET_CRYPTO_EddsaSignature hop_sig; 630 struct GNUNET_CRYPTO_EddsaSignature hop_sig;
631
636}; 632};
637 633
638 634
@@ -698,6 +694,7 @@ struct TransportDVLearn
698 /* Followed by @e num_hops `struct DVPathEntryP` values, 694 /* Followed by @e num_hops `struct DVPathEntryP` values,
699 excluding the initiator of the DV trace; the last entry is the 695 excluding the initiator of the DV trace; the last entry is the
700 current sender; the current peer must not be included. */ 696 current sender; the current peer must not be included. */
697
701}; 698};
702 699
703 700
@@ -802,6 +799,7 @@ struct TransportValidationPS
802 * Challenge signed by the receiving peer. 799 * Challenge signed by the receiving peer.
803 */ 800 */
804 struct GNUNET_ShortHashCode challenge; 801 struct GNUNET_ShortHashCode challenge;
802
805}; 803};
806 804
807 805
@@ -847,13 +845,15 @@ struct TransportValidationResponse
847}; 845};
848 846
849 847
848
850GNUNET_NETWORK_STRUCT_END 849GNUNET_NETWORK_STRUCT_END
851 850
852 851
853/** 852/**
854 * What type of client is the `struct TransportClient` about? 853 * What type of client is the `struct TransportClient` about?
855 */ 854 */
856enum ClientType { 855enum ClientType
856{
857 /** 857 /**
858 * We do not know yet (client is fresh). 858 * We do not know yet (client is fresh).
859 */ 859 */
@@ -907,6 +907,7 @@ struct LearnLaunchEntry
907 * determine freshness of paths learned via this operation. 907 * determine freshness of paths learned via this operation.
908 */ 908 */
909 struct GNUNET_TIME_Absolute launch_time; 909 struct GNUNET_TIME_Absolute launch_time;
910
910}; 911};
911 912
912 913
@@ -1031,9 +1032,8 @@ struct DistanceVectorHop
1031 struct GNUNET_TIME_Absolute freshness; 1032 struct GNUNET_TIME_Absolute freshness;
1032 1033
1033 /** 1034 /**
1034 * How many hops in total to the `target` (excluding @e next_hop and `target` 1035 * How many hops in total to the `target` (excluding @e next_hop and `target` itself),
1035 * itself), thus 0 still means a distance of 2 hops (to @e next_hop and then 1036 * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)?
1036 * to `target`)?
1037 */ 1037 */
1038 unsigned int distance; 1038 unsigned int distance;
1039}; 1039};
@@ -1313,8 +1313,7 @@ struct ReassemblyContext
1313 */ 1313 */
1314 uint16_t msg_missing; 1314 uint16_t msg_missing;
1315 1315
1316 /* Followed by @e msg_size bytes of the (partially) defragmented original 1316 /* Followed by @e msg_size bytes of the (partially) defragmented original message */
1317 * message */
1318 1317
1319 /* Followed by @e bitfield data */ 1318 /* Followed by @e bitfield data */
1320}; 1319};
@@ -1402,6 +1401,7 @@ struct Neighbour
1402 * What is the earliest timeout of any message in @e pending_msg_tail? 1401 * What is the earliest timeout of any message in @e pending_msg_tail?
1403 */ 1402 */
1404 struct GNUNET_TIME_Absolute earliest_timeout; 1403 struct GNUNET_TIME_Absolute earliest_timeout;
1404
1405}; 1405};
1406 1406
1407 1407
@@ -1435,13 +1435,15 @@ struct PeerRequest
1435 * How much bandwidth would this @e tc like to see? 1435 * How much bandwidth would this @e tc like to see?
1436 */ 1436 */
1437 struct GNUNET_BANDWIDTH_Value32NBO bw; 1437 struct GNUNET_BANDWIDTH_Value32NBO bw;
1438
1438}; 1439};
1439 1440
1440 1441
1441/** 1442/**
1442 * Types of different pending messages. 1443 * Types of different pending messages.
1443 */ 1444 */
1444enum PendingMessageType { 1445enum PendingMessageType
1446{
1445 1447
1446 /** 1448 /**
1447 * Ordinary message received from the CORE service. 1449 * Ordinary message received from the CORE service.
@@ -1515,20 +1517,17 @@ struct PendingMessage
1515 struct PendingMessage *prev_client; 1517 struct PendingMessage *prev_client;
1516 1518
1517 /** 1519 /**
1518 * Kept in a MDLL of messages from this @a cpm (if @e pmt is 1520 * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx)
1519 * #PMT_FRAGMENT_BOx)
1520 */ 1521 */
1521 struct PendingMessage *next_frag; 1522 struct PendingMessage *next_frag;
1522 1523
1523 /** 1524 /**
1524 * Kept in a MDLL of messages from this @a cpm (if @e pmt is 1525 * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX)
1525 * #PMT_FRAGMENT_BOX)
1526 */ 1526 */
1527 struct PendingMessage *prev_frag; 1527 struct PendingMessage *prev_frag;
1528 1528
1529 /** 1529 /**
1530 * This message, reliability boxed. Only possibly available if @e pmt is 1530 * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE.
1531 * #PMT_CORE.
1532 */ 1531 */
1533 struct PendingMessage *bpm; 1532 struct PendingMessage *bpm;
1534 1533
@@ -1653,6 +1652,7 @@ struct AddressListEntry
1653 * Network type offered by this address. 1652 * Network type offered by this address.
1654 */ 1653 */
1655 enum GNUNET_NetworkType nt; 1654 enum GNUNET_NetworkType nt;
1655
1656}; 1656};
1657 1657
1658 1658
@@ -1693,8 +1693,7 @@ struct TransportClient
1693 /** 1693 /**
1694 * Information for @e type #CT_CORE. 1694 * Information for @e type #CT_CORE.
1695 */ 1695 */
1696 struct 1696 struct {
1697 {
1698 1697
1699 /** 1698 /**
1700 * Head of list of messages pending for this client, sorted by 1699 * Head of list of messages pending for this client, sorted by
@@ -1712,8 +1711,7 @@ struct TransportClient
1712 /** 1711 /**
1713 * Information for @e type #CT_MONITOR. 1712 * Information for @e type #CT_MONITOR.
1714 */ 1713 */
1715 struct 1714 struct {
1716 {
1717 1715
1718 /** 1716 /**
1719 * Peer identity to monitor the addresses of. 1717 * Peer identity to monitor the addresses of.
@@ -1733,8 +1731,7 @@ struct TransportClient
1733 /** 1731 /**
1734 * Information for @e type #CT_COMMUNICATOR. 1732 * Information for @e type #CT_COMMUNICATOR.
1735 */ 1733 */
1736 struct 1734 struct {
1737 {
1738 /** 1735 /**
1739 * If @e type is #CT_COMMUNICATOR, this communicator 1736 * If @e type is #CT_COMMUNICATOR, this communicator
1740 * supports communicating using these addresses. 1737 * supports communicating using these addresses.
@@ -1752,14 +1749,12 @@ struct TransportClient
1752 struct Queue *queue_tail; 1749 struct Queue *queue_tail;
1753 1750
1754 /** 1751 /**
1755 * Head of list of the addresses of this peer offered by this 1752 * Head of list of the addresses of this peer offered by this communicator.
1756 * communicator.
1757 */ 1753 */
1758 struct AddressListEntry *addr_head; 1754 struct AddressListEntry *addr_head;
1759 1755
1760 /** 1756 /**
1761 * Tail of list of the addresses of this peer offered by this 1757 * Tail of list of the addresses of this peer offered by this communicator.
1762 * communicator.
1763 */ 1758 */
1764 struct AddressListEntry *addr_tail; 1759 struct AddressListEntry *addr_tail;
1765 1760
@@ -1780,8 +1775,7 @@ struct TransportClient
1780 /** 1775 /**
1781 * Information for @e type #CT_APPLICATION 1776 * Information for @e type #CT_APPLICATION
1782 */ 1777 */
1783 struct 1778 struct {
1784 {
1785 1779
1786 /** 1780 /**
1787 * Map of requests for peers the given client application would like to 1781 * Map of requests for peers the given client application would like to
@@ -1792,6 +1786,7 @@ struct TransportClient
1792 } application; 1786 } application;
1793 1787
1794 } details; 1788 } details;
1789
1795}; 1790};
1796 1791
1797 1792
@@ -1895,6 +1890,7 @@ struct ValidationState
1895 * the respective queue to become available for transmission. 1890 * the respective queue to become available for transmission.
1896 */ 1891 */
1897 int awaiting_queue; 1892 int awaiting_queue;
1893
1898}; 1894};
1899 1895
1900 1896
@@ -2012,7 +2008,9 @@ static struct GNUNET_SCHEDULER_Task *validation_task;
2012static void 2008static void
2013free_ephemeral (struct EphemeralCacheEntry *ece) 2009free_ephemeral (struct EphemeralCacheEntry *ece)
2014{ 2010{
2015 GNUNET_CONTAINER_multipeermap_remove (ephemeral_map, &ece->target, ece); 2011 GNUNET_CONTAINER_multipeermap_remove (ephemeral_map,
2012 &ece->target,
2013 ece);
2016 GNUNET_CONTAINER_heap_remove_node (ece->hn); 2014 GNUNET_CONTAINER_heap_remove_node (ece->hn);
2017 GNUNET_free (ece); 2015 GNUNET_free (ece);
2018} 2016}
@@ -2026,10 +2024,13 @@ free_ephemeral (struct EphemeralCacheEntry *ece)
2026static void 2024static void
2027free_validation_state (struct ValidationState *vs) 2025free_validation_state (struct ValidationState *vs)
2028{ 2026{
2029 GNUNET_CONTAINER_multipeermap_remove (validation_map, &vs->pid, vs); 2027 GNUNET_CONTAINER_multipeermap_remove (validation_map,
2028 &vs->pid,
2029 vs);
2030 GNUNET_CONTAINER_heap_remove_node (vs->hn); 2030 GNUNET_CONTAINER_heap_remove_node (vs->hn);
2031 vs->hn = NULL; 2031 vs->hn = NULL;
2032 if (NULL != vs->sc) { 2032 if (NULL != vs->sc)
2033 {
2033 GNUNET_PEERSTORE_store_cancel (vs->sc); 2034 GNUNET_PEERSTORE_store_cancel (vs->sc);
2034 vs->sc = NULL; 2035 vs->sc = NULL;
2035 } 2036 }
@@ -2047,7 +2048,8 @@ free_validation_state (struct ValidationState *vs)
2047static struct Neighbour * 2048static struct Neighbour *
2048lookup_neighbour (const struct GNUNET_PeerIdentity *pid) 2049lookup_neighbour (const struct GNUNET_PeerIdentity *pid)
2049{ 2050{
2050 return GNUNET_CONTAINER_multipeermap_get (neighbours, pid); 2051 return GNUNET_CONTAINER_multipeermap_get (neighbours,
2052 pid);
2051} 2053}
2052 2054
2053 2055
@@ -2082,6 +2084,8 @@ struct MonitorEvent
2082 * Bytes pending. 2084 * Bytes pending.
2083 */ 2085 */
2084 uint32_t num_bytes_pending; 2086 uint32_t num_bytes_pending;
2087
2088
2085}; 2089};
2086 2090
2087 2091
@@ -2099,8 +2103,14 @@ free_distance_vector_hop (struct DistanceVectorHop *dvh)
2099 struct Neighbour *n = dvh->next_hop; 2103 struct Neighbour *n = dvh->next_hop;
2100 struct DistanceVector *dv = dvh->dv; 2104 struct DistanceVector *dv = dvh->dv;
2101 2105
2102 GNUNET_CONTAINER_MDLL_remove (neighbour, n->dv_head, n->dv_tail, dvh); 2106 GNUNET_CONTAINER_MDLL_remove (neighbour,
2103 GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, dvh); 2107 n->dv_head,
2108 n->dv_tail,
2109 dvh);
2110 GNUNET_CONTAINER_MDLL_remove (dv,
2111 dv->dv_head,
2112 dv->dv_tail,
2113 dvh);
2104 GNUNET_free (dvh); 2114 GNUNET_free (dvh);
2105} 2115}
2106 2116
@@ -2118,10 +2128,12 @@ free_dv_route (struct DistanceVector *dv)
2118 2128
2119 while (NULL != (dvh = dv->dv_head)) 2129 while (NULL != (dvh = dv->dv_head))
2120 free_distance_vector_hop (dvh); 2130 free_distance_vector_hop (dvh);
2121 if (NULL == dv->dv_head) { 2131 if (NULL == dv->dv_head)
2122 GNUNET_assert ( 2132 {
2123 GNUNET_YES 2133 GNUNET_assert (GNUNET_YES ==
2124 == GNUNET_CONTAINER_multipeermap_remove (dv_routes, &dv->target, dv)); 2134 GNUNET_CONTAINER_multipeermap_remove (dv_routes,
2135 &dv->target,
2136 dv));
2125 if (NULL != dv->timeout_task) 2137 if (NULL != dv->timeout_task)
2126 GNUNET_SCHEDULER_cancel (dv->timeout_task); 2138 GNUNET_SCHEDULER_cancel (dv->timeout_task);
2127 GNUNET_free (dv); 2139 GNUNET_free (dv);
@@ -2156,17 +2168,20 @@ notify_monitor (struct TransportClient *tc,
2156 env = GNUNET_MQ_msg_extra (md, 2168 env = GNUNET_MQ_msg_extra (md,
2157 addr_len, 2169 addr_len,
2158 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA); 2170 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA);
2159 md->nt = htonl ((uint32_t)nt); 2171 md->nt = htonl ((uint32_t) nt);
2160 md->peer = *peer; 2172 md->peer = *peer;
2161 md->last_validation = GNUNET_TIME_absolute_hton (me->last_validation); 2173 md->last_validation = GNUNET_TIME_absolute_hton (me->last_validation);
2162 md->valid_until = GNUNET_TIME_absolute_hton (me->valid_until); 2174 md->valid_until = GNUNET_TIME_absolute_hton (me->valid_until);
2163 md->next_validation = GNUNET_TIME_absolute_hton (me->next_validation); 2175 md->next_validation = GNUNET_TIME_absolute_hton (me->next_validation);
2164 md->rtt = GNUNET_TIME_relative_hton (me->rtt); 2176 md->rtt = GNUNET_TIME_relative_hton (me->rtt);
2165 md->cs = htonl ((uint32_t)me->cs); 2177 md->cs = htonl ((uint32_t) me->cs);
2166 md->num_msg_pending = htonl (me->num_msg_pending); 2178 md->num_msg_pending = htonl (me->num_msg_pending);
2167 md->num_bytes_pending = htonl (me->num_bytes_pending); 2179 md->num_bytes_pending = htonl (me->num_bytes_pending);
2168 memcpy (&md[1], address, addr_len); 2180 memcpy (&md[1],
2169 GNUNET_MQ_send (tc->mq, env); 2181 address,
2182 addr_len);
2183 GNUNET_MQ_send (tc->mq,
2184 env);
2170} 2185}
2171 2186
2172 2187
@@ -2185,15 +2200,23 @@ notify_monitors (const struct GNUNET_PeerIdentity *peer,
2185 enum GNUNET_NetworkType nt, 2200 enum GNUNET_NetworkType nt,
2186 const struct MonitorEvent *me) 2201 const struct MonitorEvent *me)
2187{ 2202{
2188 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) { 2203 for (struct TransportClient *tc = clients_head;
2204 NULL != tc;
2205 tc = tc->next)
2206 {
2189 if (CT_MONITOR != tc->type) 2207 if (CT_MONITOR != tc->type)
2190 continue; 2208 continue;
2191 if (tc->details.monitor.one_shot) 2209 if (tc->details.monitor.one_shot)
2192 continue; 2210 continue;
2193 if ((0 != GNUNET_is_zero (&tc->details.monitor.peer)) 2211 if ( (0 != GNUNET_is_zero (&tc->details.monitor.peer)) &&
2194 && (0 != GNUNET_memcmp (&tc->details.monitor.peer, peer))) 2212 (0 != GNUNET_memcmp (&tc->details.monitor.peer,
2213 peer)) )
2195 continue; 2214 continue;
2196 notify_monitor (tc, peer, address, nt, me); 2215 notify_monitor (tc,
2216 peer,
2217 address,
2218 nt,
2219 me);
2197 } 2220 }
2198} 2221}
2199 2222
@@ -2214,12 +2237,16 @@ client_connect_cb (void *cls,
2214{ 2237{
2215 struct TransportClient *tc; 2238 struct TransportClient *tc;
2216 2239
2217 (void)cls; 2240 (void) cls;
2218 tc = GNUNET_new (struct TransportClient); 2241 tc = GNUNET_new (struct TransportClient);
2219 tc->client = client; 2242 tc->client = client;
2220 tc->mq = mq; 2243 tc->mq = mq;
2221 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); 2244 GNUNET_CONTAINER_DLL_insert (clients_head,
2222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc); 2245 clients_tail,
2246 tc);
2247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2248 "Client %p connected\n",
2249 tc);
2223 return tc; 2250 return tc;
2224} 2251}
2225 2252
@@ -2234,11 +2261,12 @@ free_reassembly_context (struct ReassemblyContext *rc)
2234{ 2261{
2235 struct Neighbour *n = rc->neighbour; 2262 struct Neighbour *n = rc->neighbour;
2236 2263
2237 GNUNET_assert (rc == GNUNET_CONTAINER_heap_remove_node (rc->hn)); 2264 GNUNET_assert (rc ==
2238 GNUNET_assert (GNUNET_OK 2265 GNUNET_CONTAINER_heap_remove_node (rc->hn));
2239 == GNUNET_CONTAINER_multishortmap_remove (n->reassembly_map, 2266 GNUNET_assert (GNUNET_OK ==
2240 &rc->msg_uuid, 2267 GNUNET_CONTAINER_multishortmap_remove (n->reassembly_map,
2241 rc)); 2268 &rc->msg_uuid,
2269 rc));
2242 GNUNET_free (rc); 2270 GNUNET_free (rc);
2243} 2271}
2244 2272
@@ -2255,18 +2283,17 @@ reassembly_cleanup_task (void *cls)
2255 struct ReassemblyContext *rc; 2283 struct ReassemblyContext *rc;
2256 2284
2257 n->reassembly_timeout_task = NULL; 2285 n->reassembly_timeout_task = NULL;
2258 while (NULL != (rc = GNUNET_CONTAINER_heap_peek (n->reassembly_heap))) { 2286 while (NULL != (rc = GNUNET_CONTAINER_heap_peek (n->reassembly_heap)))
2259 if (0 2287 {
2260 == GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout) 2288 if (0 == GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout).rel_value_us)
2261 .rel_value_us) { 2289 {
2262 free_reassembly_context (rc); 2290 free_reassembly_context (rc);
2263 continue; 2291 continue;
2264 } 2292 }
2265 GNUNET_assert (NULL == n->reassembly_timeout_task); 2293 GNUNET_assert (NULL == n->reassembly_timeout_task);
2266 n->reassembly_timeout_task 2294 n->reassembly_timeout_task = GNUNET_SCHEDULER_add_at (rc->reassembly_timeout,
2267 = GNUNET_SCHEDULER_add_at (rc->reassembly_timeout, 2295 &reassembly_cleanup_task,
2268 &reassembly_cleanup_task, 2296 n);
2269 n);
2270 return; 2297 return;
2271 } 2298 }
2272} 2299}
@@ -2286,8 +2313,8 @@ free_reassembly_cb (void *cls,
2286 void *value) 2313 void *value)
2287{ 2314{
2288 struct ReassemblyContext *rc = value; 2315 struct ReassemblyContext *rc = value;
2289 (void)cls; 2316 (void) cls;
2290 (void)key; 2317 (void) key;
2291 2318
2292 free_reassembly_context (rc); 2319 free_reassembly_context (rc);
2293 return GNUNET_OK; 2320 return GNUNET_OK;
@@ -2305,13 +2332,14 @@ free_neighbour (struct Neighbour *neighbour)
2305 struct DistanceVectorHop *dvh; 2332 struct DistanceVectorHop *dvh;
2306 2333
2307 GNUNET_assert (NULL == neighbour->queue_head); 2334 GNUNET_assert (NULL == neighbour->queue_head);
2308 GNUNET_assert (GNUNET_YES 2335 GNUNET_assert (GNUNET_YES ==
2309 == GNUNET_CONTAINER_multipeermap_remove (neighbours, 2336 GNUNET_CONTAINER_multipeermap_remove (neighbours,
2310 &neighbour->pid, 2337 &neighbour->pid,
2311 neighbour)); 2338 neighbour));
2312 if (NULL != neighbour->timeout_task) 2339 if (NULL != neighbour->timeout_task)
2313 GNUNET_SCHEDULER_cancel (neighbour->timeout_task); 2340 GNUNET_SCHEDULER_cancel (neighbour->timeout_task);
2314 if (NULL != neighbour->reassembly_map) { 2341 if (NULL != neighbour->reassembly_map)
2342 {
2315 GNUNET_CONTAINER_multishortmap_iterate (neighbour->reassembly_map, 2343 GNUNET_CONTAINER_multishortmap_iterate (neighbour->reassembly_map,
2316 &free_reassembly_cb, 2344 &free_reassembly_cb,
2317 NULL); 2345 NULL);
@@ -2320,7 +2348,8 @@ free_neighbour (struct Neighbour *neighbour)
2320 GNUNET_CONTAINER_heap_destroy (neighbour->reassembly_heap); 2348 GNUNET_CONTAINER_heap_destroy (neighbour->reassembly_heap);
2321 neighbour->reassembly_heap = NULL; 2349 neighbour->reassembly_heap = NULL;
2322 } 2350 }
2323 while (NULL != (dvh = neighbour->dv_head)) { 2351 while (NULL != (dvh = neighbour->dv_head))
2352 {
2324 struct DistanceVector *dv = dvh->dv; 2353 struct DistanceVector *dv = dvh->dv;
2325 2354
2326 free_distance_vector_hop (dvh); 2355 free_distance_vector_hop (dvh);
@@ -2349,10 +2378,12 @@ core_send_connect_info (struct TransportClient *tc,
2349 struct ConnectInfoMessage *cim; 2378 struct ConnectInfoMessage *cim;
2350 2379
2351 GNUNET_assert (CT_CORE == tc->type); 2380 GNUNET_assert (CT_CORE == tc->type);
2352 env = GNUNET_MQ_msg (cim, GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 2381 env = GNUNET_MQ_msg (cim,
2382 GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
2353 cim->quota_out = quota_out; 2383 cim->quota_out = quota_out;
2354 cim->id = *pid; 2384 cim->id = *pid;
2355 GNUNET_MQ_send (tc->mq, env); 2385 GNUNET_MQ_send (tc->mq,
2386 env);
2356} 2387}
2357 2388
2358 2389
@@ -2366,10 +2397,15 @@ static void
2366cores_send_connect_info (const struct GNUNET_PeerIdentity *pid, 2397cores_send_connect_info (const struct GNUNET_PeerIdentity *pid,
2367 struct GNUNET_BANDWIDTH_Value32NBO quota_out) 2398 struct GNUNET_BANDWIDTH_Value32NBO quota_out)
2368{ 2399{
2369 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) { 2400 for (struct TransportClient *tc = clients_head;
2401 NULL != tc;
2402 tc = tc->next)
2403 {
2370 if (CT_CORE != tc->type) 2404 if (CT_CORE != tc->type)
2371 continue; 2405 continue;
2372 core_send_connect_info (tc, pid, quota_out); 2406 core_send_connect_info (tc,
2407 pid,
2408 quota_out);
2373 } 2409 }
2374} 2410}
2375 2411
@@ -2382,15 +2418,20 @@ cores_send_connect_info (const struct GNUNET_PeerIdentity *pid,
2382static void 2418static void
2383cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid) 2419cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid)
2384{ 2420{
2385 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) { 2421 for (struct TransportClient *tc = clients_head;
2422 NULL != tc;
2423 tc = tc->next)
2424 {
2386 struct GNUNET_MQ_Envelope *env; 2425 struct GNUNET_MQ_Envelope *env;
2387 struct DisconnectInfoMessage *dim; 2426 struct DisconnectInfoMessage *dim;
2388 2427
2389 if (CT_CORE != tc->type) 2428 if (CT_CORE != tc->type)
2390 continue; 2429 continue;
2391 env = GNUNET_MQ_msg (dim, GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); 2430 env = GNUNET_MQ_msg (dim,
2431 GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
2392 dim->peer = *pid; 2432 dim->peer = *pid;
2393 GNUNET_MQ_send (tc->mq, env); 2433 GNUNET_MQ_send (tc->mq,
2434 env);
2394 } 2435 }
2395} 2436}
2396 2437
@@ -2425,45 +2466,50 @@ schedule_transmit_on_queue (struct Queue *queue)
2425 unsigned int wsize; 2466 unsigned int wsize;
2426 2467
2427 GNUNET_assert (NULL != pm); 2468 GNUNET_assert (NULL != pm);
2428 if (queue->tc->details.communicator.total_queue_length 2469 if (queue->tc->details.communicator.total_queue_length >=
2429 >= COMMUNICATOR_TOTAL_QUEUE_LIMIT) { 2470 COMMUNICATOR_TOTAL_QUEUE_LIMIT)
2430 GNUNET_STATISTICS_update ( 2471 {
2431 GST_stats, 2472 GNUNET_STATISTICS_update (GST_stats,
2432 "# Transmission throttled due to communicator queue limit", 2473 "# Transmission throttled due to communicator queue limit",
2433 1, 2474 1,
2434 GNUNET_NO); 2475 GNUNET_NO);
2435 return; 2476 return;
2436 } 2477 }
2437 if (queue->queue_length >= QUEUE_LENGTH_LIMIT) { 2478 if (queue->queue_length >= QUEUE_LENGTH_LIMIT)
2438 GNUNET_STATISTICS_update ( 2479 {
2439 GST_stats, 2480 GNUNET_STATISTICS_update (GST_stats,
2440 "# Transmission throttled due to queue queue limit", 2481 "# Transmission throttled due to queue queue limit",
2441 1, 2482 1,
2442 GNUNET_NO); 2483 GNUNET_NO);
2443 return; 2484 return;
2444 } 2485 }
2445 2486
2446 wsize = (0 == queue->mtu) ? pm->bytes_msg /* FIXME: add overheads? */ 2487 wsize = (0 == queue->mtu)
2447 : queue->mtu; 2488 ? pm->bytes_msg /* FIXME: add overheads? */
2448 out_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_out, wsize); 2489 : queue->mtu;
2449 out_delay = GNUNET_TIME_relative_max ( 2490 out_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_out,
2450 GNUNET_TIME_absolute_get_remaining (pm->next_attempt), 2491 wsize);
2451 out_delay); 2492 out_delay = GNUNET_TIME_relative_max (GNUNET_TIME_absolute_get_remaining (pm->next_attempt),
2493 out_delay);
2452 if (0 == out_delay.rel_value_us) 2494 if (0 == out_delay.rel_value_us)
2453 return; /* we should run immediately! */ 2495 return; /* we should run immediately! */
2454 /* queue has changed since we were scheduled, reschedule again */ 2496 /* queue has changed since we were scheduled, reschedule again */
2455 queue->transmit_task 2497 queue->transmit_task
2456 = GNUNET_SCHEDULER_add_delayed (out_delay, &transmit_on_queue, queue); 2498 = GNUNET_SCHEDULER_add_delayed (out_delay,
2499 &transmit_on_queue,
2500 queue);
2457 if (out_delay.rel_value_us > DELAY_WARN_THRESHOLD.rel_value_us) 2501 if (out_delay.rel_value_us > DELAY_WARN_THRESHOLD.rel_value_us)
2458 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2502 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2459 "Next transmission on queue `%s' in %s (high delay)\n", 2503 "Next transmission on queue `%s' in %s (high delay)\n",
2460 queue->address, 2504 queue->address,
2461 GNUNET_STRINGS_relative_time_to_string (out_delay, GNUNET_YES)); 2505 GNUNET_STRINGS_relative_time_to_string (out_delay,
2506 GNUNET_YES));
2462 else 2507 else
2463 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2464 "Next transmission on queue `%s' in %s\n", 2509 "Next transmission on queue `%s' in %s\n",
2465 queue->address, 2510 queue->address,
2466 GNUNET_STRINGS_relative_time_to_string (out_delay, GNUNET_YES)); 2511 GNUNET_STRINGS_relative_time_to_string (out_delay,
2512 GNUNET_YES));
2467} 2513}
2468 2514
2469 2515
@@ -2477,12 +2523,15 @@ free_queue (struct Queue *queue)
2477{ 2523{
2478 struct Neighbour *neighbour = queue->neighbour; 2524 struct Neighbour *neighbour = queue->neighbour;
2479 struct TransportClient *tc = queue->tc; 2525 struct TransportClient *tc = queue->tc;
2480 struct MonitorEvent me 2526 struct MonitorEvent me = {
2481 = {.cs = GNUNET_TRANSPORT_CS_DOWN, .rtt = GNUNET_TIME_UNIT_FOREVER_REL}; 2527 .cs = GNUNET_TRANSPORT_CS_DOWN,
2528 .rtt = GNUNET_TIME_UNIT_FOREVER_REL
2529 };
2482 struct QueueEntry *qe; 2530 struct QueueEntry *qe;
2483 int maxxed; 2531 int maxxed;
2484 2532
2485 if (NULL != queue->transmit_task) { 2533 if (NULL != queue->transmit_task)
2534 {
2486 GNUNET_SCHEDULER_cancel (queue->transmit_task); 2535 GNUNET_SCHEDULER_cancel (queue->transmit_task);
2487 queue->transmit_task = NULL; 2536 queue->transmit_task = NULL;
2488 } 2537 }
@@ -2494,33 +2543,39 @@ free_queue (struct Queue *queue)
2494 tc->details.communicator.queue_head, 2543 tc->details.communicator.queue_head,
2495 tc->details.communicator.queue_tail, 2544 tc->details.communicator.queue_tail,
2496 queue); 2545 queue);
2497 maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT 2546 maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >= tc->details.communicator.total_queue_length);
2498 >= tc->details.communicator.total_queue_length); 2547 while (NULL != (qe = queue->queue_head))
2499 while (NULL != (qe = queue->queue_head)) { 2548 {
2500 GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe); 2549 GNUNET_CONTAINER_DLL_remove (queue->queue_head,
2550 queue->queue_tail,
2551 qe);
2501 queue->queue_length--; 2552 queue->queue_length--;
2502 tc->details.communicator.total_queue_length--; 2553 tc->details.communicator.total_queue_length--;
2503 GNUNET_free (qe); 2554 GNUNET_free (qe);
2504 } 2555 }
2505 GNUNET_assert (0 == queue->queue_length); 2556 GNUNET_assert (0 == queue->queue_length);
2506 if ((maxxed) 2557 if ( (maxxed) &&
2507 && (COMMUNICATOR_TOTAL_QUEUE_LIMIT 2558 (COMMUNICATOR_TOTAL_QUEUE_LIMIT < tc->details.communicator.total_queue_length) )
2508 < tc->details.communicator.total_queue_length)) { 2559 {
2509 /* Communicator dropped below threshold, resume all queues */ 2560 /* Communicator dropped below threshold, resume all queues */
2510 GNUNET_STATISTICS_update ( 2561 GNUNET_STATISTICS_update (GST_stats,
2511 GST_stats, 2562 "# Transmission throttled due to communicator queue limit",
2512 "# Transmission throttled due to communicator queue limit", 2563 -1,
2513 -1, 2564 GNUNET_NO);
2514 GNUNET_NO); 2565 for (struct Queue *s = tc->details.communicator.queue_head;
2515 for (struct Queue *s = tc->details.communicator.queue_head; NULL != s; 2566 NULL != s;
2516 s = s->next_client) 2567 s = s->next_client)
2517 schedule_transmit_on_queue (s); 2568 schedule_transmit_on_queue (s);
2518 } 2569 }
2519 notify_monitors (&neighbour->pid, queue->address, queue->nt, &me); 2570 notify_monitors (&neighbour->pid,
2571 queue->address,
2572 queue->nt,
2573 &me);
2520 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in); 2574 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in);
2521 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out); 2575 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out);
2522 GNUNET_free (queue); 2576 GNUNET_free (queue);
2523 if (NULL == neighbour->queue_head) { 2577 if (NULL == neighbour->queue_head)
2578 {
2524 cores_send_disconnect_info (&neighbour->pid); 2579 cores_send_disconnect_info (&neighbour->pid);
2525 free_neighbour (neighbour); 2580 free_neighbour (neighbour);
2526 } 2581 }
@@ -2540,11 +2595,13 @@ free_address_list_entry (struct AddressListEntry *ale)
2540 GNUNET_CONTAINER_DLL_remove (tc->details.communicator.addr_head, 2595 GNUNET_CONTAINER_DLL_remove (tc->details.communicator.addr_head,
2541 tc->details.communicator.addr_tail, 2596 tc->details.communicator.addr_tail,
2542 ale); 2597 ale);
2543 if (NULL != ale->sc) { 2598 if (NULL != ale->sc)
2599 {
2544 GNUNET_PEERSTORE_store_cancel (ale->sc); 2600 GNUNET_PEERSTORE_store_cancel (ale->sc);
2545 ale->sc = NULL; 2601 ale->sc = NULL;
2546 } 2602 }
2547 if (NULL != ale->st) { 2603 if (NULL != ale->st)
2604 {
2548 GNUNET_SCHEDULER_cancel (ale->st); 2605 GNUNET_SCHEDULER_cancel (ale->st);
2549 ale->st = NULL; 2606 ale->st = NULL;
2550 } 2607 }
@@ -2569,11 +2626,10 @@ stop_peer_request (void *cls,
2569 struct PeerRequest *pr = value; 2626 struct PeerRequest *pr = value;
2570 2627
2571 GNUNET_PEERSTORE_watch_cancel (pr->wc); 2628 GNUNET_PEERSTORE_watch_cancel (pr->wc);
2572 GNUNET_assert ( 2629 GNUNET_assert (GNUNET_YES ==
2573 GNUNET_YES 2630 GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests,
2574 == GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests, 2631 pid,
2575 pid, 2632 pr));
2576 pr));
2577 GNUNET_free (pr); 2633 GNUNET_free (pr);
2578 2634
2579 return GNUNET_OK; 2635 return GNUNET_OK;
@@ -2595,37 +2651,45 @@ client_disconnect_cb (void *cls,
2595{ 2651{
2596 struct TransportClient *tc = app_ctx; 2652 struct TransportClient *tc = app_ctx;
2597 2653
2598 (void)cls; 2654 (void) cls;
2599 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2655 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2600 "Client %p disconnected, cleaning up.\n", 2656 "Client %p disconnected, cleaning up.\n",
2601 tc); 2657 tc);
2602 GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc); 2658 GNUNET_CONTAINER_DLL_remove (clients_head,
2603 switch (tc->type) { 2659 clients_tail,
2660 tc);
2661 switch (tc->type)
2662 {
2604 case CT_NONE: 2663 case CT_NONE:
2605 break; 2664 break;
2606 case CT_CORE: { 2665 case CT_CORE:
2607 struct PendingMessage *pm; 2666 {
2608 2667 struct PendingMessage *pm;
2609 while (NULL != (pm = tc->details.core.pending_msg_head)) { 2668
2610 GNUNET_CONTAINER_MDLL_remove (client, 2669 while (NULL != (pm = tc->details.core.pending_msg_head))
2611 tc->details.core.pending_msg_head, 2670 {
2612 tc->details.core.pending_msg_tail, 2671 GNUNET_CONTAINER_MDLL_remove (client,
2613 pm); 2672 tc->details.core.pending_msg_head,
2614 pm->client = NULL; 2673 tc->details.core.pending_msg_tail,
2674 pm);
2675 pm->client = NULL;
2676 }
2615 } 2677 }
2616 } break; 2678 break;
2617 case CT_MONITOR: 2679 case CT_MONITOR:
2618 break; 2680 break;
2619 case CT_COMMUNICATOR: { 2681 case CT_COMMUNICATOR:
2620 struct Queue *q; 2682 {
2621 struct AddressListEntry *ale; 2683 struct Queue *q;
2622 2684 struct AddressListEntry *ale;
2623 while (NULL != (q = tc->details.communicator.queue_head)) 2685
2624 free_queue (q); 2686 while (NULL != (q = tc->details.communicator.queue_head))
2625 while (NULL != (ale = tc->details.communicator.addr_head)) 2687 free_queue (q);
2626 free_address_list_entry (ale); 2688 while (NULL != (ale = tc->details.communicator.addr_head))
2627 GNUNET_free (tc->details.communicator.address_prefix); 2689 free_address_list_entry (ale);
2628 } break; 2690 GNUNET_free (tc->details.communicator.address_prefix);
2691 }
2692 break;
2629 case CT_APPLICATION: 2693 case CT_APPLICATION:
2630 GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests, 2694 GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
2631 &stop_peer_request, 2695 &stop_peer_request,
@@ -2654,7 +2718,9 @@ notify_client_connect_info (void *cls,
2654 struct TransportClient *tc = cls; 2718 struct TransportClient *tc = cls;
2655 struct Neighbour *neighbour = value; 2719 struct Neighbour *neighbour = value;
2656 2720
2657 core_send_connect_info (tc, pid, neighbour->quota_out); 2721 core_send_connect_info (tc,
2722 pid,
2723 neighbour->quota_out);
2658 return GNUNET_OK; 2724 return GNUNET_OK;
2659} 2725}
2660 2726
@@ -2668,20 +2734,25 @@ notify_client_connect_info (void *cls,
2668 * @param start the start message that was sent 2734 * @param start the start message that was sent
2669 */ 2735 */
2670static void 2736static void
2671handle_client_start (void *cls, const struct StartMessage *start) 2737handle_client_start (void *cls,
2738 const struct StartMessage *start)
2672{ 2739{
2673 struct TransportClient *tc = cls; 2740 struct TransportClient *tc = cls;
2674 uint32_t options; 2741 uint32_t options;
2675 2742
2676 options = ntohl (start->options); 2743 options = ntohl (start->options);
2677 if ((0 != (1 & options)) 2744 if ( (0 != (1 & options)) &&
2678 && (0 != GNUNET_memcmp (&start->self, &GST_my_identity))) { 2745 (0 !=
2746 GNUNET_memcmp (&start->self,
2747 &GST_my_identity)) )
2748 {
2679 /* client thinks this is a different peer, reject */ 2749 /* client thinks this is a different peer, reject */
2680 GNUNET_break (0); 2750 GNUNET_break (0);
2681 GNUNET_SERVICE_client_drop (tc->client); 2751 GNUNET_SERVICE_client_drop (tc->client);
2682 return; 2752 return;
2683 } 2753 }
2684 if (CT_NONE != tc->type) { 2754 if (CT_NONE != tc->type)
2755 {
2685 GNUNET_break (0); 2756 GNUNET_break (0);
2686 GNUNET_SERVICE_client_drop (tc->client); 2757 GNUNET_SERVICE_client_drop (tc->client);
2687 return; 2758 return;
@@ -2701,23 +2772,27 @@ handle_client_start (void *cls, const struct StartMessage *start)
2701 * @param obm the send message that was sent 2772 * @param obm the send message that was sent
2702 */ 2773 */
2703static int 2774static int
2704check_client_send (void *cls, const struct OutboundMessage *obm) 2775check_client_send (void *cls,
2776 const struct OutboundMessage *obm)
2705{ 2777{
2706 struct TransportClient *tc = cls; 2778 struct TransportClient *tc = cls;
2707 uint16_t size; 2779 uint16_t size;
2708 const struct GNUNET_MessageHeader *obmm; 2780 const struct GNUNET_MessageHeader *obmm;
2709 2781
2710 if (CT_CORE != tc->type) { 2782 if (CT_CORE != tc->type)
2783 {
2711 GNUNET_break (0); 2784 GNUNET_break (0);
2712 return GNUNET_SYSERR; 2785 return GNUNET_SYSERR;
2713 } 2786 }
2714 size = ntohs (obm->header.size) - sizeof (struct OutboundMessage); 2787 size = ntohs (obm->header.size) - sizeof (struct OutboundMessage);
2715 if (size < sizeof (struct GNUNET_MessageHeader)) { 2788 if (size < sizeof (struct GNUNET_MessageHeader))
2789 {
2716 GNUNET_break (0); 2790 GNUNET_break (0);
2717 return GNUNET_SYSERR; 2791 return GNUNET_SYSERR;
2718 } 2792 }
2719 obmm = (const struct GNUNET_MessageHeader *)&obm[1]; 2793 obmm = (const struct GNUNET_MessageHeader *) &obm[1];
2720 if (size != ntohs (obmm->size)) { 2794 if (size != ntohs (obmm->size))
2795 {
2721 GNUNET_break (0); 2796 GNUNET_break (0);
2722 return GNUNET_SYSERR; 2797 return GNUNET_SYSERR;
2723 } 2798 }
@@ -2735,9 +2810,13 @@ free_fragment_tree (struct PendingMessage *root)
2735{ 2810{
2736 struct PendingMessage *frag; 2811 struct PendingMessage *frag;
2737 2812
2738 while (NULL != (frag = root->head_frag)) { 2813 while (NULL != (frag = root->head_frag))
2814 {
2739 free_fragment_tree (frag); 2815 free_fragment_tree (frag);
2740 GNUNET_CONTAINER_MDLL_remove (frag, root->head_frag, root->tail_frag, frag); 2816 GNUNET_CONTAINER_MDLL_remove (frag,
2817 root->head_frag,
2818 root->tail_frag,
2819 frag);
2741 GNUNET_free (frag); 2820 GNUNET_free (frag);
2742 } 2821 }
2743} 2822}
@@ -2756,7 +2835,8 @@ free_pending_message (struct PendingMessage *pm)
2756 struct TransportClient *tc = pm->client; 2835 struct TransportClient *tc = pm->client;
2757 struct Neighbour *target = pm->target; 2836 struct Neighbour *target = pm->target;
2758 2837
2759 if (NULL != tc) { 2838 if (NULL != tc)
2839 {
2760 GNUNET_CONTAINER_MDLL_remove (client, 2840 GNUNET_CONTAINER_MDLL_remove (client,
2761 tc->details.core.pending_msg_head, 2841 tc->details.core.pending_msg_head,
2762 tc->details.core.pending_msg_tail, 2842 tc->details.core.pending_msg_tail,
@@ -2794,13 +2874,16 @@ client_send_response (struct PendingMessage *pm,
2794 struct GNUNET_MQ_Envelope *env; 2874 struct GNUNET_MQ_Envelope *env;
2795 struct SendOkMessage *som; 2875 struct SendOkMessage *som;
2796 2876
2797 if (NULL != tc) { 2877 if (NULL != tc)
2798 env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); 2878 {
2799 som->success = htonl ((uint32_t)success); 2879 env = GNUNET_MQ_msg (som,
2880 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
2881 som->success = htonl ((uint32_t) success);
2800 som->bytes_msg = htons (pm->bytes_msg); 2882 som->bytes_msg = htons (pm->bytes_msg);
2801 som->bytes_physical = htonl (bytes_physical); 2883 som->bytes_physical = htonl (bytes_physical);
2802 som->peer = target->pid; 2884 som->peer = target->pid;
2803 GNUNET_MQ_send (tc->mq, env); 2885 GNUNET_MQ_send (tc->mq,
2886 env);
2804 } 2887 }
2805 free_pending_message (pm); 2888 free_pending_message (pm);
2806} 2889}
@@ -2823,25 +2906,30 @@ check_queue_timeouts (void *cls)
2823 n->timeout_task = NULL; 2906 n->timeout_task = NULL;
2824 earliest_timeout = GNUNET_TIME_UNIT_FOREVER_ABS; 2907 earliest_timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
2825 now = GNUNET_TIME_absolute_get (); 2908 now = GNUNET_TIME_absolute_get ();
2826 for (struct PendingMessage *pos = n->pending_msg_head; NULL != pos; 2909 for (struct PendingMessage *pos = n->pending_msg_head;
2827 pos = pm) { 2910 NULL != pos;
2911 pos = pm)
2912 {
2828 pm = pos->next_neighbour; 2913 pm = pos->next_neighbour;
2829 if (pos->timeout.abs_value_us <= now.abs_value_us) { 2914 if (pos->timeout.abs_value_us <= now.abs_value_us)
2830 GNUNET_STATISTICS_update ( 2915 {
2831 GST_stats, 2916 GNUNET_STATISTICS_update (GST_stats,
2832 "# messages dropped (timeout before confirmation)", 2917 "# messages dropped (timeout before confirmation)",
2833 1, 2918 1,
2834 GNUNET_NO); 2919 GNUNET_NO);
2835 client_send_response (pm, GNUNET_NO, 0); 2920 client_send_response (pm,
2921 GNUNET_NO,
2922 0);
2836 continue; 2923 continue;
2837 } 2924 }
2838 earliest_timeout 2925 earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout,
2839 = GNUNET_TIME_absolute_min (earliest_timeout, pos->timeout); 2926 pos->timeout);
2840 } 2927 }
2841 n->earliest_timeout = earliest_timeout; 2928 n->earliest_timeout = earliest_timeout;
2842 if (NULL != n->pending_msg_head) 2929 if (NULL != n->pending_msg_head)
2843 n->timeout_task 2930 n->timeout_task = GNUNET_SCHEDULER_add_at (earliest_timeout,
2844 = GNUNET_SCHEDULER_add_at (earliest_timeout, &check_queue_timeouts, n); 2931 &check_queue_timeouts,
2932 n);
2845} 2933}
2846 2934
2847 2935
@@ -2852,7 +2940,8 @@ check_queue_timeouts (void *cls)
2852 * @param obm the send message that was sent 2940 * @param obm the send message that was sent
2853 */ 2941 */
2854static void 2942static void
2855handle_client_send (void *cls, const struct OutboundMessage *obm) 2943handle_client_send (void *cls,
2944 const struct OutboundMessage *obm)
2856{ 2945{
2857 struct TransportClient *tc = cls; 2946 struct TransportClient *tc = cls;
2858 struct PendingMessage *pm; 2947 struct PendingMessage *pm;
@@ -2862,10 +2951,11 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
2862 int was_empty; 2951 int was_empty;
2863 2952
2864 GNUNET_assert (CT_CORE == tc->type); 2953 GNUNET_assert (CT_CORE == tc->type);
2865 obmm = (const struct GNUNET_MessageHeader *)&obm[1]; 2954 obmm = (const struct GNUNET_MessageHeader *) &obm[1];
2866 bytes_msg = ntohs (obmm->size); 2955 bytes_msg = ntohs (obmm->size);
2867 target = lookup_neighbour (&obm->peer); 2956 target = lookup_neighbour (&obm->peer);
2868 if (NULL == target) { 2957 if (NULL == target)
2958 {
2869 /* Failure: don't have this peer as a neighbour (anymore). 2959 /* Failure: don't have this peer as a neighbour (anymore).
2870 Might have gone down asynchronously, so this is NOT 2960 Might have gone down asynchronously, so this is NOT
2871 a protocol violation by CORE. Still count the event, 2961 a protocol violation by CORE. Still count the event,
@@ -2873,12 +2963,14 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
2873 struct GNUNET_MQ_Envelope *env; 2963 struct GNUNET_MQ_Envelope *env;
2874 struct SendOkMessage *som; 2964 struct SendOkMessage *som;
2875 2965
2876 env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); 2966 env = GNUNET_MQ_msg (som,
2967 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
2877 som->success = htonl (GNUNET_SYSERR); 2968 som->success = htonl (GNUNET_SYSERR);
2878 som->bytes_msg = htonl (bytes_msg); 2969 som->bytes_msg = htonl (bytes_msg);
2879 som->bytes_physical = htonl (0); 2970 som->bytes_physical = htonl (0);
2880 som->peer = obm->peer; 2971 som->peer = obm->peer;
2881 GNUNET_MQ_send (tc->mq, env); 2972 GNUNET_MQ_send (tc->mq,
2973 env);
2882 GNUNET_SERVICE_client_continue (tc->client); 2974 GNUNET_SERVICE_client_continue (tc->client);
2883 GNUNET_STATISTICS_update (GST_stats, 2975 GNUNET_STATISTICS_update (GST_stats,
2884 "# messages dropped (neighbour unknown)", 2976 "# messages dropped (neighbour unknown)",
@@ -2891,9 +2983,10 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
2891 pm->client = tc; 2983 pm->client = tc;
2892 pm->target = target; 2984 pm->target = target;
2893 pm->bytes_msg = bytes_msg; 2985 pm->bytes_msg = bytes_msg;
2894 pm->timeout = GNUNET_TIME_relative_to_absolute ( 2986 pm->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (obm->timeout));
2895 GNUNET_TIME_relative_ntoh (obm->timeout)); 2987 memcpy (&pm[1],
2896 memcpy (&pm[1], &obm[1], bytes_msg); 2988 &obm[1],
2989 bytes_msg);
2897 GNUNET_CONTAINER_MDLL_insert (neighbour, 2990 GNUNET_CONTAINER_MDLL_insert (neighbour,
2898 target->pending_msg_head, 2991 target->pending_msg_head,
2899 target->pending_msg_tail, 2992 target->pending_msg_tail,
@@ -2902,22 +2995,26 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
2902 tc->details.core.pending_msg_head, 2995 tc->details.core.pending_msg_head,
2903 tc->details.core.pending_msg_tail, 2996 tc->details.core.pending_msg_tail,
2904 pm); 2997 pm);
2905 if (target->earliest_timeout.abs_value_us > pm->timeout.abs_value_us) { 2998 if (target->earliest_timeout.abs_value_us > pm->timeout.abs_value_us)
2999 {
2906 target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us; 3000 target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us;
2907 if (NULL != target->timeout_task) 3001 if (NULL != target->timeout_task)
2908 GNUNET_SCHEDULER_cancel (target->timeout_task); 3002 GNUNET_SCHEDULER_cancel (target->timeout_task);
2909 target->timeout_task = GNUNET_SCHEDULER_add_at (target->earliest_timeout, 3003 target->timeout_task
2910 &check_queue_timeouts, 3004 = GNUNET_SCHEDULER_add_at (target->earliest_timeout,
2911 target); 3005 &check_queue_timeouts,
3006 target);
2912 } 3007 }
2913 if (! was_empty) 3008 if (! was_empty)
2914 return; /* all queues must already be busy */ 3009 return; /* all queues must already be busy */
2915 for (struct Queue *queue = target->queue_head; NULL != queue; 3010 for (struct Queue *queue = target->queue_head;
2916 queue = queue->next_neighbour) { 3011 NULL != queue;
3012 queue = queue->next_neighbour)
3013 {
2917 /* try transmission on any queue that is idle */ 3014 /* try transmission on any queue that is idle */
2918 if (NULL == queue->transmit_task) 3015 if (NULL == queue->transmit_task)
2919 queue->transmit_task 3016 queue->transmit_task = GNUNET_SCHEDULER_add_now (&transmit_on_queue,
2920 = GNUNET_SCHEDULER_add_now (&transmit_on_queue, queue); 3017 queue);
2921 } 3018 }
2922} 3019}
2923 3020
@@ -2929,14 +3026,14 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
2929 * @param cam the send message that was sent 3026 * @param cam the send message that was sent
2930 */ 3027 */
2931static int 3028static int
2932check_communicator_available ( 3029check_communicator_available (void *cls,
2933 void *cls, 3030 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
2934 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
2935{ 3031{
2936 struct TransportClient *tc = cls; 3032 struct TransportClient *tc = cls;
2937 uint16_t size; 3033 uint16_t size;
2938 3034
2939 if (CT_NONE != tc->type) { 3035 if (CT_NONE != tc->type)
3036 {
2940 GNUNET_break (0); 3037 GNUNET_break (0);
2941 return GNUNET_SYSERR; 3038 return GNUNET_SYSERR;
2942 } 3039 }
@@ -2956,9 +3053,8 @@ check_communicator_available (
2956 * @param cam the send message that was sent 3053 * @param cam the send message that was sent
2957 */ 3054 */
2958static void 3055static void
2959handle_communicator_available ( 3056handle_communicator_available (void *cls,
2960 void *cls, 3057 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
2961 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
2962{ 3058{
2963 struct TransportClient *tc = cls; 3059 struct TransportClient *tc = cls;
2964 uint16_t size; 3060 uint16_t size;
@@ -2967,9 +3063,9 @@ handle_communicator_available (
2967 if (0 == size) 3063 if (0 == size)
2968 return; /* receive-only communicator */ 3064 return; /* receive-only communicator */
2969 tc->details.communicator.address_prefix 3065 tc->details.communicator.address_prefix
2970 = GNUNET_strdup ((const char *)&cam[1]); 3066 = GNUNET_strdup ((const char *) &cam[1]);
2971 tc->details.communicator.cc 3067 tc->details.communicator.cc
2972 = (enum GNUNET_TRANSPORT_CommunicatorCharacteristics)ntohl (cam->cc); 3068 = (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc);
2973 GNUNET_SERVICE_client_continue (tc->client); 3069 GNUNET_SERVICE_client_continue (tc->client);
2974} 3070}
2975 3071
@@ -2982,34 +3078,36 @@ handle_communicator_available (
2982 * @return #GNUNET_OK if message is well-formed 3078 * @return #GNUNET_OK if message is well-formed
2983 */ 3079 */
2984static int 3080static int
2985check_communicator_backchannel ( 3081check_communicator_backchannel (void *cls,
2986 void *cls, 3082 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
2987 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
2988{ 3083{
2989 const struct GNUNET_MessageHeader *inbox; 3084 const struct GNUNET_MessageHeader *inbox;
2990 const char *is; 3085 const char *is;
2991 uint16_t msize; 3086 uint16_t msize;
2992 uint16_t isize; 3087 uint16_t isize;
2993 3088
2994 (void)cls; 3089 (void) cls;
2995 msize = ntohs (cb->header.size) - sizeof (*cb); 3090 msize = ntohs (cb->header.size) - sizeof (*cb);
2996 if (UINT16_MAX - msize 3091 if (UINT16_MAX - msize >
2997 > sizeof (struct TransportBackchannelEncapsulationMessage) 3092 sizeof (struct TransportBackchannelEncapsulationMessage) +
2998 + sizeof (struct TransportBackchannelRequestPayload)) { 3093 sizeof (struct TransportBackchannelRequestPayload) )
3094 {
2999 GNUNET_break (0); 3095 GNUNET_break (0);
3000 return GNUNET_SYSERR; 3096 return GNUNET_SYSERR;
3001 } 3097 }
3002 inbox = (const struct GNUNET_MessageHeader *)&cb[1]; 3098 inbox = (const struct GNUNET_MessageHeader *) &cb[1];
3003 isize = ntohs (inbox->size); 3099 isize = ntohs (inbox->size);
3004 if (isize >= msize) { 3100 if (isize >= msize)
3101 {
3005 GNUNET_break (0); 3102 GNUNET_break (0);
3006 return GNUNET_SYSERR; 3103 return GNUNET_SYSERR;
3007 } 3104 }
3008 is = (const char *)inbox; 3105 is = (const char *) inbox;
3009 is += isize; 3106 is += isize;
3010 msize -= isize; 3107 msize -= isize;
3011 GNUNET_assert (msize > 0); 3108 GNUNET_assert (msize > 0);
3012 if ('\0' != is[msize - 1]) { 3109 if ('\0' != is[msize-1])
3110 {
3013 GNUNET_break (0); 3111 GNUNET_break (0);
3014 return GNUNET_SYSERR; 3112 return GNUNET_SYSERR;
3015 } 3113 }
@@ -3027,12 +3125,12 @@ expire_ephemerals (void *cls)
3027{ 3125{
3028 struct EphemeralCacheEntry *ece; 3126 struct EphemeralCacheEntry *ece;
3029 3127
3030 (void)cls; 3128 (void) cls;
3031 ephemeral_task = NULL; 3129 ephemeral_task = NULL;
3032 while (NULL != (ece = GNUNET_CONTAINER_heap_peek (ephemeral_heap))) { 3130 while (NULL != (ece = GNUNET_CONTAINER_heap_peek (ephemeral_heap)))
3033 if (0 3131 {
3034 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity) 3132 if (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity).rel_value_us)
3035 .rel_value_us) { 3133 {
3036 free_ephemeral (ece); 3134 free_ephemeral (ece);
3037 continue; 3135 continue;
3038 } 3136 }
@@ -3064,41 +3162,40 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid,
3064 struct EphemeralCacheEntry *ece; 3162 struct EphemeralCacheEntry *ece;
3065 struct EphemeralConfirmation ec; 3163 struct EphemeralConfirmation ec;
3066 3164
3067 ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, pid); 3165 ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map,
3068 if ((NULL != ece) 3166 pid);
3069 && (0 3167 if ( (NULL != ece) &&
3070 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity) 3168 (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity).rel_value_us) )
3071 .rel_value_us)) { 3169 {
3072 free_ephemeral (ece); 3170 free_ephemeral (ece);
3073 ece = NULL; 3171 ece = NULL;
3074 } 3172 }
3075 if (NULL == ece) { 3173 if (NULL == ece)
3174 {
3076 ece = GNUNET_new (struct EphemeralCacheEntry); 3175 ece = GNUNET_new (struct EphemeralCacheEntry);
3077 ece->target = *pid; 3176 ece->target = *pid;
3078 ece->ephemeral_validity 3177 ece->ephemeral_validity = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get_monotonic (GST_cfg),
3079 = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get_monotonic (GST_cfg), 3178 EPHEMERAL_VALIDITY);
3080 EPHEMERAL_VALIDITY); 3179 GNUNET_assert (GNUNET_OK ==
3081 GNUNET_assert (GNUNET_OK 3180 GNUNET_CRYPTO_ecdhe_key_create2 (&ece->private_key));
3082 == GNUNET_CRYPTO_ecdhe_key_create2 (&ece->private_key)); 3181 GNUNET_CRYPTO_ecdhe_key_get_public (&ece->private_key,
3083 GNUNET_CRYPTO_ecdhe_key_get_public (&ece->private_key, &ece->ephemeral_key); 3182 &ece->ephemeral_key);
3084 ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); 3183 ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
3085 ec.purpose.size = htonl (sizeof (ec)); 3184 ec.purpose.size = htonl (sizeof (ec));
3086 ec.target = *pid; 3185 ec.target = *pid;
3087 ec.ephemeral_key = ece->ephemeral_key; 3186 ec.ephemeral_key = ece->ephemeral_key;
3088 GNUNET_assert (GNUNET_OK 3187 GNUNET_assert (GNUNET_OK ==
3089 == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, 3188 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
3090 &ec.purpose, 3189 &ec.purpose,
3091 &ece->sender_sig)); 3190 &ece->sender_sig));
3092 ece->hn 3191 ece->hn = GNUNET_CONTAINER_heap_insert (ephemeral_heap,
3093 = GNUNET_CONTAINER_heap_insert (ephemeral_heap, 3192 ece,
3094 ece, 3193 ece->ephemeral_validity.abs_value_us);
3095 ece->ephemeral_validity.abs_value_us); 3194 GNUNET_assert (GNUNET_OK ==
3096 GNUNET_assert (GNUNET_OK 3195 GNUNET_CONTAINER_multipeermap_put (ephemeral_map,
3097 == GNUNET_CONTAINER_multipeermap_put ( 3196 &ece->target,
3098 ephemeral_map, 3197 ece,
3099 &ece->target, 3198 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
3100 ece,
3101 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
3102 if (NULL == ephemeral_task) 3199 if (NULL == ephemeral_task)
3103 ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity, 3200 ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity,
3104 &expire_ephemerals, 3201 &expire_ephemerals,
@@ -3131,8 +3228,7 @@ route_message (const struct GNUNET_PeerIdentity *target,
3131 // a path back! - if all else fails 3228 // a path back! - if all else fails
3132 // => need more on DV first! 3229 // => need more on DV first!
3133 3230
3134 // FIXME: send hdr to target, free hdr (possibly using DV, possibly 3231 // FIXME: send hdr to target, free hdr (possibly using DV, possibly broadcasting)
3135 // broadcasting)
3136 GNUNET_free (hdr); 3232 GNUNET_free (hdr);
3137} 3233}
3138 3234
@@ -3161,20 +3257,20 @@ struct BackchannelKeyState
3161 3257
3162 3258
3163static void 3259static void
3164bc_setup_key_state_from_km (const struct GNUNET_HashCode *km, 3260setup_key_state_from_km (const struct GNUNET_HashCode *km,
3165 const struct GNUNET_HashCode *iv, 3261 const struct GNUNET_HashCode *iv,
3166 struct BackchannelKeyState *key) 3262 struct BackchannelKeyState *key)
3167{ 3263{
3168 /* must match #dh_key_derive_eph_pub */ 3264 /* must match #dh_key_derive_eph_pub */
3169 GNUNET_assert (GNUNET_YES 3265 GNUNET_assert (GNUNET_YES ==
3170 == GNUNET_CRYPTO_kdf (key, 3266 GNUNET_CRYPTO_kdf (key,
3171 sizeof (*key), 3267 sizeof (*key),
3172 "transport-backchannel-key", 3268 "transport-backchannel-key",
3173 strlen ("transport-backchannel-key"), 3269 strlen ("transport-backchannel-key"),
3174 &km, 3270 &km,
3175 sizeof (km), 3271 sizeof (km),
3176 iv, 3272 iv,
3177 sizeof (*iv))); 3273 sizeof (*iv)));
3178} 3274}
3179 3275
3180 3276
@@ -3188,18 +3284,20 @@ bc_setup_key_state_from_km (const struct GNUNET_HashCode *km,
3188 * @param key[out] set to the key material 3284 * @param key[out] set to the key material
3189 */ 3285 */
3190static void 3286static void
3191dh_key_derive_eph_pid ( 3287dh_key_derive_eph_pid (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral,
3192 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral, 3288 const struct GNUNET_PeerIdentity *target,
3193 const struct GNUNET_PeerIdentity *target, 3289 const struct GNUNET_ShortHashCode *iv,
3194 const struct GNUNET_ShortHashCode *iv, 3290 struct BackchannelKeyState *key)
3195 struct BackchannelKeyState *key)
3196{ 3291{
3197 struct GNUNET_HashCode km; 3292 struct GNUNET_HashCode km;
3198 3293
3199 GNUNET_assert ( 3294 GNUNET_assert (GNUNET_YES ==
3200 GNUNET_YES 3295 GNUNET_CRYPTO_ecdsa_ecdh (priv_ephemeral,
3201 == GNUNET_CRYPTO_ecdsa_ecdh (priv_ephemeral, &target->public_key, &km)); 3296 &target->public_key,
3202 bc_setup_key_state_from_km (&km, iv, key); 3297 &km));
3298 bc_setup_key_state_from_km (&km,
3299 iv,
3300 key);
3203} 3301}
3204 3302
3205 3303
@@ -3219,10 +3317,13 @@ dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral,
3219{ 3317{
3220 struct GNUNET_HashCode km; 3318 struct GNUNET_HashCode km;
3221 3319
3222 GNUNET_assert ( 3320 GNUNET_assert (GNUNET_YES ==
3223 GNUNET_YES 3321 GNUNET_CRYPTO_ecdsa_ecdh (GST_my_private_key,
3224 == GNUNET_CRYPTO_ecdsa_ecdh (GST_my_private_key, pub_ephemeral, &km)); 3322 pub_ephemeral,
3225 bc_setup_key_state_from_km (&km, iv, key); 3323 &km));
3324 bc_setup_key_state_from_km (&km,
3325 iv,
3326 key);
3226} 3327}
3227 3328
3228 3329
@@ -3302,9 +3403,8 @@ bc_key_clean (struct BackchannelKeyState *key)
3302 * @param cb the send message that was sent 3403 * @param cb the send message that was sent
3303 */ 3404 */
3304static void 3405static void
3305handle_communicator_backchannel ( 3406handle_communicator_backchannel (void *cls,
3306 void *cls, 3407 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
3307 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
3308{ 3408{
3309 struct TransportClient *tc = cls; 3409 struct TransportClient *tc = cls;
3310 struct GNUNET_CRYPTO_EcdhePrivateKey private_key; 3410 struct GNUNET_CRYPTO_EcdhePrivateKey private_key;
@@ -3316,11 +3416,9 @@ handle_communicator_backchannel (
3316 uint16_t msize; 3416 uint16_t msize;
3317 3417
3318 /* encapsulate and encrypt message */ 3418 /* encapsulate and encrypt message */
3319 msize = ntohs (cb->header.size) - sizeof (*cb) 3419 msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload);
3320 + sizeof (struct TransportBackchannelRequestPayload);
3321 enc = GNUNET_malloc (sizeof (*enc) + msize); 3420 enc = GNUNET_malloc (sizeof (*enc) + msize);
3322 enc->header.type 3421 enc->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION);
3323 = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION);
3324 enc->header.size = htons (sizeof (*enc) + msize); 3422 enc->header.size = htons (sizeof (*enc) + msize);
3325 enc->target = cb->pid; 3423 enc->target = cb->pid;
3326 lookup_ephemeral (&cb->pid, 3424 lookup_ephemeral (&cb->pid,
@@ -3331,12 +3429,17 @@ handle_communicator_backchannel (
3331 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, 3429 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
3332 &enc->iv, 3430 &enc->iv,
3333 sizeof (enc->iv)); 3431 sizeof (enc->iv));
3334 dh_key_derive_eph_pid (&private_key, &cb->pid, &enc->iv, &key); 3432 dh_key_derive (&private_key,
3433 &cb->pid,
3434 &enc->iv,
3435 &key);
3335 ppay.ephemeral_validity = GNUNET_TIME_absolute_hton (ephemeral_validity); 3436 ppay.ephemeral_validity = GNUNET_TIME_absolute_hton (ephemeral_validity);
3336 ppay.monotonic_time 3437 ppay.monotonic_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg));
3337 = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg)); 3438 mpos = (char *) &enc[1];
3338 mpos = (char *)&enc[1]; 3439 bc_encrypt (&key,
3339 bc_encrypt (&key, &ppay, mpos, sizeof (ppay)); 3440 &ppay,
3441 mpos,
3442 sizeof (ppay));
3340 bc_encrypt (&key, 3443 bc_encrypt (&key,
3341 &cb[1], 3444 &cb[1],
3342 &mpos[sizeof (ppay)], 3445 &mpos[sizeof (ppay)],
@@ -3346,7 +3449,8 @@ handle_communicator_backchannel (
3346 mpos, 3449 mpos,
3347 sizeof (ppay) + ntohs (cb->header.size) - sizeof (*cb)); 3450 sizeof (ppay) + ntohs (cb->header.size) - sizeof (*cb));
3348 bc_key_clean (&key); 3451 bc_key_clean (&key);
3349 route_message (&cb->pid, &enc->header); 3452 route_message (&cb->pid,
3453 &enc->header);
3350 GNUNET_SERVICE_client_continue (tc->client); 3454 GNUNET_SERVICE_client_continue (tc->client);
3351} 3455}
3352 3456
@@ -3364,7 +3468,8 @@ check_add_address (void *cls,
3364{ 3468{
3365 struct TransportClient *tc = cls; 3469 struct TransportClient *tc = cls;
3366 3470
3367 if (CT_COMMUNICATOR != tc->type) { 3471 if (CT_COMMUNICATOR != tc->type)
3472 {
3368 GNUNET_break (0); 3473 GNUNET_break (0);
3369 return GNUNET_SYSERR; 3474 return GNUNET_SYSERR;
3370 } 3475 }
@@ -3389,7 +3494,8 @@ store_pi (void *cls);
3389 * @param success #GNUNET_YES if peerstore was successful 3494 * @param success #GNUNET_YES if peerstore was successful
3390 */ 3495 */
3391static void 3496static void
3392peerstore_store_own_cb (void *cls, int success) 3497peerstore_store_own_cb (void *cls,
3498 int success)
3393{ 3499{
3394 struct AddressListEntry *ale = cls; 3500 struct AddressListEntry *ale = cls;
3395 3501
@@ -3400,10 +3506,10 @@ peerstore_store_own_cb (void *cls, int success)
3400 ale->address); 3506 ale->address);
3401 /* refresh period is 1/4 of expiration time, that should be plenty 3507 /* refresh period is 1/4 of expiration time, that should be plenty
3402 without being excessive. */ 3508 without being excessive. */
3403 ale->st = GNUNET_SCHEDULER_add_delayed ( 3509 ale->st = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (ale->expiration,
3404 GNUNET_TIME_relative_divide (ale->expiration, 4ULL), 3510 4ULL),
3405 &store_pi, 3511 &store_pi,
3406 ale); 3512 ale);
3407} 3513}
3408 3514
3409 3515
@@ -3439,12 +3545,14 @@ store_pi (void *cls)
3439 &peerstore_store_own_cb, 3545 &peerstore_store_own_cb,
3440 ale); 3546 ale);
3441 GNUNET_free (addr); 3547 GNUNET_free (addr);
3442 if (NULL == ale->sc) { 3548 if (NULL == ale->sc)
3549 {
3443 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3550 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3444 "Failed to store our address `%s' with peerstore\n", 3551 "Failed to store our address `%s' with peerstore\n",
3445 ale->address); 3552 ale->address);
3446 ale->st 3553 ale->st = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
3447 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &store_pi, ale); 3554 &store_pi,
3555 ale);
3448 } 3556 }
3449} 3557}
3450 3558
@@ -3466,15 +3574,18 @@ handle_add_address (void *cls,
3466 slen = ntohs (aam->header.size) - sizeof (*aam); 3574 slen = ntohs (aam->header.size) - sizeof (*aam);
3467 ale = GNUNET_malloc (sizeof (struct AddressListEntry) + slen); 3575 ale = GNUNET_malloc (sizeof (struct AddressListEntry) + slen);
3468 ale->tc = tc; 3576 ale->tc = tc;
3469 ale->address = (const char *)&ale[1]; 3577 ale->address = (const char *) &ale[1];
3470 ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration); 3578 ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration);
3471 ale->aid = aam->aid; 3579 ale->aid = aam->aid;
3472 ale->nt = (enum GNUNET_NetworkType)ntohl (aam->nt); 3580 ale->nt = (enum GNUNET_NetworkType) ntohl (aam->nt);
3473 memcpy (&ale[1], &aam[1], slen); 3581 memcpy (&ale[1],
3582 &aam[1],
3583 slen);
3474 GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head, 3584 GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head,
3475 tc->details.communicator.addr_tail, 3585 tc->details.communicator.addr_tail,
3476 ale); 3586 ale);
3477 ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale); 3587 ale->st = GNUNET_SCHEDULER_add_now (&store_pi,
3588 ale);
3478 GNUNET_SERVICE_client_continue (tc->client); 3589 GNUNET_SERVICE_client_continue (tc->client);
3479} 3590}
3480 3591
@@ -3491,14 +3602,16 @@ handle_del_address (void *cls,
3491{ 3602{
3492 struct TransportClient *tc = cls; 3603 struct TransportClient *tc = cls;
3493 3604
3494 if (CT_COMMUNICATOR != tc->type) { 3605 if (CT_COMMUNICATOR != tc->type)
3606 {
3495 GNUNET_break (0); 3607 GNUNET_break (0);
3496 GNUNET_SERVICE_client_drop (tc->client); 3608 GNUNET_SERVICE_client_drop (tc->client);
3497 return; 3609 return;
3498 } 3610 }
3499 for (struct AddressListEntry *ale = tc->details.communicator.addr_head; 3611 for (struct AddressListEntry *ale = tc->details.communicator.addr_head;
3500 NULL != ale; 3612 NULL != ale;
3501 ale = ale->next) { 3613 ale = ale->next)
3614 {
3502 if (dam->aid != ale->aid) 3615 if (dam->aid != ale->aid)
3503 continue; 3616 continue;
3504 GNUNET_assert (ale->tc == tc); 3617 GNUNET_assert (ale->tc == tc);
@@ -3554,16 +3667,19 @@ demultiplex_with_cmc (struct CommunicatorMessageContext *cmc,
3554static void 3667static void
3555finish_cmc_handling (struct CommunicatorMessageContext *cmc) 3668finish_cmc_handling (struct CommunicatorMessageContext *cmc)
3556{ 3669{
3557 if (0 != ntohl (cmc->im.fc_on)) { 3670 if (0 != ntohl (cmc->im.fc_on))
3671 {
3558 /* send ACK when done to communicator for flow control! */ 3672 /* send ACK when done to communicator for flow control! */
3559 struct GNUNET_MQ_Envelope *env; 3673 struct GNUNET_MQ_Envelope *env;
3560 struct GNUNET_TRANSPORT_IncomingMessageAck *ack; 3674 struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
3561 3675
3562 env = GNUNET_MQ_msg (ack, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK); 3676 env = GNUNET_MQ_msg (ack,
3677 GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK);
3563 ack->reserved = htonl (0); 3678 ack->reserved = htonl (0);
3564 ack->fc_id = cmc->im.fc_id; 3679 ack->fc_id = cmc->im.fc_id;
3565 ack->sender = cmc->im.sender; 3680 ack->sender = cmc->im.sender;
3566 GNUNET_MQ_send (cmc->tc->mq, env); 3681 GNUNET_MQ_send (cmc->tc->mq,
3682 env);
3567 } 3683 }
3568 GNUNET_SERVICE_client_continue (cmc->tc->client); 3684 GNUNET_SERVICE_client_continue (cmc->tc->client);
3569 GNUNET_free (cmc); 3685 GNUNET_free (cmc);
@@ -3574,18 +3690,19 @@ finish_cmc_handling (struct CommunicatorMessageContext *cmc)
3574 * Communicator gave us an unencapsulated message to pass as-is to 3690 * Communicator gave us an unencapsulated message to pass as-is to
3575 * CORE. Process the request. 3691 * CORE. Process the request.
3576 * 3692 *
3577 * @param cls a `struct CommunicatorMessageContext` (must call 3693 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
3578 * #finish_cmc_handling() when done)
3579 * @param mh the message that was received 3694 * @param mh the message that was received
3580 */ 3695 */
3581static void 3696static void
3582handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) 3697handle_raw_message (void *cls,
3698 const struct GNUNET_MessageHeader *mh)
3583{ 3699{
3584 struct CommunicatorMessageContext *cmc = cls; 3700 struct CommunicatorMessageContext *cmc = cls;
3585 uint16_t size = ntohs (mh->size); 3701 uint16_t size = ntohs (mh->size);
3586 3702
3587 if ((size > UINT16_MAX - sizeof (struct InboundMessage)) 3703 if ( (size > UINT16_MAX - sizeof (struct InboundMessage)) ||
3588 || (size < sizeof (struct GNUNET_MessageHeader))) { 3704 (size < sizeof (struct GNUNET_MessageHeader)) )
3705 {
3589 struct GNUNET_SERVICE_Client *client = cmc->tc->client; 3706 struct GNUNET_SERVICE_Client *client = cmc->tc->client;
3590 3707
3591 GNUNET_break (0); 3708 GNUNET_break (0);
@@ -3594,16 +3711,24 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
3594 return; 3711 return;
3595 } 3712 }
3596 /* Forward to all CORE clients */ 3713 /* Forward to all CORE clients */
3597 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) { 3714 for (struct TransportClient *tc = clients_head;
3715 NULL != tc;
3716 tc = tc->next)
3717 {
3598 struct GNUNET_MQ_Envelope *env; 3718 struct GNUNET_MQ_Envelope *env;
3599 struct InboundMessage *im; 3719 struct InboundMessage *im;
3600 3720
3601 if (CT_CORE != tc->type) 3721 if (CT_CORE != tc->type)
3602 continue; 3722 continue;
3603 env = GNUNET_MQ_msg_extra (im, size, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); 3723 env = GNUNET_MQ_msg_extra (im,
3724 size,
3725 GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
3604 im->peer = cmc->im.sender; 3726 im->peer = cmc->im.sender;
3605 memcpy (&im[1], mh, size); 3727 memcpy (&im[1],
3606 GNUNET_MQ_send (tc->mq, env); 3728 mh,
3729 size);
3730 GNUNET_MQ_send (tc->mq,
3731 env);
3607 } 3732 }
3608 /* FIXME: consider doing this _only_ once the message 3733 /* FIXME: consider doing this _only_ once the message
3609 was drained from the CORE MQs to extend flow control to CORE! 3734 was drained from the CORE MQs to extend flow control to CORE!
@@ -3620,20 +3745,24 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
3620 * @return #GNUNET_YES if message is well-formed 3745 * @return #GNUNET_YES if message is well-formed
3621 */ 3746 */
3622static int 3747static int
3623check_fragment_box (void *cls, const struct TransportFragmentBox *fb) 3748check_fragment_box (void *cls,
3749 const struct TransportFragmentBox *fb)
3624{ 3750{
3625 uint16_t size = ntohs (fb->header.size); 3751 uint16_t size = ntohs (fb->header.size);
3626 uint16_t bsize = size - sizeof (*fb); 3752 uint16_t bsize = size - sizeof (*fb);
3627 3753
3628 if (0 == bsize) { 3754 if (0 == bsize)
3755 {
3629 GNUNET_break_op (0); 3756 GNUNET_break_op (0);
3630 return GNUNET_SYSERR; 3757 return GNUNET_SYSERR;
3631 } 3758 }
3632 if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) { 3759 if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size))
3760 {
3633 GNUNET_break_op (0); 3761 GNUNET_break_op (0);
3634 return GNUNET_SYSERR; 3762 return GNUNET_SYSERR;
3635 } 3763 }
3636 if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) { 3764 if (ntohs (fb->frag_off) >= ntohs (fb->msg_size))
3765 {
3637 GNUNET_break_op (0); 3766 GNUNET_break_op (0);
3638 return GNUNET_SYSERR; 3767 return GNUNET_SYSERR;
3639 } 3768 }
@@ -3659,12 +3788,13 @@ send_fragment_ack (struct ReassemblyContext *rc)
3659 ack->msg_uuid = rc->msg_uuid; 3788 ack->msg_uuid = rc->msg_uuid;
3660 ack->avg_ack_delay = GNUNET_TIME_relative_hton (rc->avg_ack_delay); 3789 ack->avg_ack_delay = GNUNET_TIME_relative_hton (rc->avg_ack_delay);
3661 if (0 == rc->msg_missing) 3790 if (0 == rc->msg_missing)
3662 ack->reassembly_timeout = GNUNET_TIME_relative_hton ( 3791 ack->reassembly_timeout
3663 GNUNET_TIME_UNIT_FOREVER_REL); /* signal completion */ 3792 = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_FOREVER_REL); /* signal completion */
3664 else 3793 else
3665 ack->reassembly_timeout = GNUNET_TIME_relative_hton ( 3794 ack->reassembly_timeout
3666 GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout)); 3795 = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout));
3667 route_message (&rc->neighbour->pid, &ack->header); 3796 route_message (&rc->neighbour->pid,
3797 &ack->header);
3668 rc->avg_ack_delay = GNUNET_TIME_UNIT_ZERO; 3798 rc->avg_ack_delay = GNUNET_TIME_UNIT_ZERO;
3669 rc->num_acks = 0; 3799 rc->num_acks = 0;
3670 rc->extra_acks = 0LLU; 3800 rc->extra_acks = 0LLU;
@@ -3674,12 +3804,12 @@ send_fragment_ack (struct ReassemblyContext *rc)
3674/** 3804/**
3675 * Communicator gave us a fragment. Process the request. 3805 * Communicator gave us a fragment. Process the request.
3676 * 3806 *
3677 * @param cls a `struct CommunicatorMessageContext` (must call 3807 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
3678 * #finish_cmc_handling() when done)
3679 * @param fb the message that was received 3808 * @param fb the message that was received
3680 */ 3809 */
3681static void 3810static void
3682handle_fragment_box (void *cls, const struct TransportFragmentBox *fb) 3811handle_fragment_box (void *cls,
3812 const struct TransportFragmentBox *fb)
3683{ 3813{
3684 struct CommunicatorMessageContext *cmc = cls; 3814 struct CommunicatorMessageContext *cmc = cls;
3685 struct Neighbour *n; 3815 struct Neighbour *n;
@@ -3693,8 +3823,10 @@ handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
3693 struct GNUNET_TIME_Relative cdelay; 3823 struct GNUNET_TIME_Relative cdelay;
3694 int ack_now; 3824 int ack_now;
3695 3825
3696 n = GNUNET_CONTAINER_multipeermap_get (neighbours, &cmc->im.sender); 3826 n = GNUNET_CONTAINER_multipeermap_get (neighbours,
3697 if (NULL == n) { 3827 &cmc->im.sender);
3828 if (NULL == n)
3829 {
3698 struct GNUNET_SERVICE_Client *client = cmc->tc->client; 3830 struct GNUNET_SERVICE_Client *client = cmc->tc->client;
3699 3831
3700 GNUNET_break (0); 3832 GNUNET_break (0);
@@ -3702,42 +3834,46 @@ handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
3702 GNUNET_SERVICE_client_drop (client); 3834 GNUNET_SERVICE_client_drop (client);
3703 return; 3835 return;
3704 } 3836 }
3705 if (NULL == n->reassembly_map) { 3837 if (NULL == n->reassembly_map)
3706 n->reassembly_map = GNUNET_CONTAINER_multishortmap_create (8, GNUNET_YES); 3838 {
3707 n->reassembly_heap 3839 n->reassembly_map = GNUNET_CONTAINER_multishortmap_create (8,
3708 = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 3840 GNUNET_YES);
3709 n->reassembly_timeout_task 3841 n->reassembly_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
3710 = GNUNET_SCHEDULER_add_delayed (REASSEMBLY_EXPIRATION, 3842 n->reassembly_timeout_task = GNUNET_SCHEDULER_add_delayed (REASSEMBLY_EXPIRATION,
3711 &reassembly_cleanup_task, 3843 &reassembly_cleanup_task,
3712 n); 3844 n);
3713 } 3845 }
3714 msize = ntohs (fb->msg_size); 3846 msize = ntohs (fb->msg_size);
3715 rc = GNUNET_CONTAINER_multishortmap_get (n->reassembly_map, &fb->msg_uuid); 3847 rc = GNUNET_CONTAINER_multishortmap_get (n->reassembly_map,
3716 if (NULL == rc) { 3848 &fb->msg_uuid);
3717 rc = GNUNET_malloc (sizeof (*rc) + msize + /* reassembly payload buffer */ 3849 if (NULL == rc)
3718 (msize + 7) / 8 * sizeof (uint8_t) /* bitfield */); 3850 {
3851 rc = GNUNET_malloc (sizeof (*rc) +
3852 msize + /* reassembly payload buffer */
3853 (msize + 7) / 8 * sizeof (uint8_t) /* bitfield */);
3719 rc->msg_uuid = fb->msg_uuid; 3854 rc->msg_uuid = fb->msg_uuid;
3720 rc->neighbour = n; 3855 rc->neighbour = n;
3721 rc->msg_size = msize; 3856 rc->msg_size = msize;
3722 rc->reassembly_timeout 3857 rc->reassembly_timeout = GNUNET_TIME_relative_to_absolute (REASSEMBLY_EXPIRATION);
3723 = GNUNET_TIME_relative_to_absolute (REASSEMBLY_EXPIRATION);
3724 rc->last_frag = GNUNET_TIME_absolute_get (); 3858 rc->last_frag = GNUNET_TIME_absolute_get ();
3725 rc->hn = GNUNET_CONTAINER_heap_insert (n->reassembly_heap, 3859 rc->hn = GNUNET_CONTAINER_heap_insert (n->reassembly_heap,
3726 rc, 3860 rc,
3727 rc->reassembly_timeout.abs_value_us); 3861 rc->reassembly_timeout.abs_value_us);
3728 GNUNET_assert (GNUNET_OK 3862 GNUNET_assert (GNUNET_OK ==
3729 == GNUNET_CONTAINER_multishortmap_put ( 3863 GNUNET_CONTAINER_multishortmap_put (n->reassembly_map,
3730 n->reassembly_map, 3864 &rc->msg_uuid,
3731 &rc->msg_uuid, 3865 rc,
3732 rc, 3866 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
3733 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 3867 target = (char *) &rc[1];
3734 target = (char *)&rc[1]; 3868 rc->bitfield = (uint8_t *) (target + rc->msg_size);
3735 rc->bitfield = (uint8_t *)(target + rc->msg_size);
3736 rc->msg_missing = rc->msg_size; 3869 rc->msg_missing = rc->msg_size;
3737 } else {
3738 target = (char *)&rc[1];
3739 } 3870 }
3740 if (msize != rc->msg_size) { 3871 else
3872 {
3873 target = (char *) &rc[1];
3874 }
3875 if (msize != rc->msg_size)
3876 {
3741 GNUNET_break (0); 3877 GNUNET_break (0);
3742 finish_cmc_handling (cmc); 3878 finish_cmc_handling (cmc);
3743 return; 3879 return;
@@ -3746,10 +3882,14 @@ handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
3746 /* reassemble */ 3882 /* reassemble */
3747 fsize = ntohs (fb->header.size) - sizeof (*fb); 3883 fsize = ntohs (fb->header.size) - sizeof (*fb);
3748 frag_off = ntohs (fb->frag_off); 3884 frag_off = ntohs (fb->frag_off);
3749 memcpy (&target[frag_off], &fb[1], fsize); 3885 memcpy (&target[frag_off],
3886 &fb[1],
3887 fsize);
3750 /* update bitfield and msg_missing */ 3888 /* update bitfield and msg_missing */
3751 for (unsigned int i = frag_off; i < frag_off + fsize; i++) { 3889 for (unsigned int i=frag_off;i<frag_off+fsize;i++)
3752 if (0 == (rc->bitfield[i / 8] & (1 << (i % 8)))) { 3890 {
3891 if (0 == (rc->bitfield[i / 8] & (1 << (i % 8))))
3892 {
3753 rc->bitfield[i / 8] |= (1 << (i % 8)); 3893 rc->bitfield[i / 8] |= (1 << (i % 8));
3754 rc->msg_missing--; 3894 rc->msg_missing--;
3755 } 3895 }
@@ -3758,34 +3898,41 @@ handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
3758 /* Compute cummulative ACK */ 3898 /* Compute cummulative ACK */
3759 frag_uuid = ntohl (fb->frag_uuid); 3899 frag_uuid = ntohl (fb->frag_uuid);
3760 cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); 3900 cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag);
3761 cdelay = GNUNET_TIME_relative_multiply (cdelay, rc->num_acks); 3901 cdelay = GNUNET_TIME_relative_multiply (cdelay,
3902 rc->num_acks);
3762 rc->last_frag = GNUNET_TIME_absolute_get (); 3903 rc->last_frag = GNUNET_TIME_absolute_get ();
3763 rc->avg_ack_delay = GNUNET_TIME_relative_add (rc->avg_ack_delay, cdelay); 3904 rc->avg_ack_delay = GNUNET_TIME_relative_add (rc->avg_ack_delay,
3905 cdelay);
3764 ack_now = GNUNET_NO; 3906 ack_now = GNUNET_NO;
3765 if (0 == rc->num_acks) { 3907 if (0 == rc->num_acks)
3908 {
3766 /* case one: first ack */ 3909 /* case one: first ack */
3767 rc->frag_uuid = frag_uuid; 3910 rc->frag_uuid = frag_uuid;
3768 rc->extra_acks = 0LLU; 3911 rc->extra_acks = 0LLU;
3769 rc->num_acks = 1; 3912 rc->num_acks = 1;
3770 } else if ((frag_uuid >= rc->frag_uuid) 3913 }
3771 && (frag_uuid <= rc->frag_uuid + 64)) { 3914 else if ( (frag_uuid >= rc->frag_uuid) &&
3915 (frag_uuid <= rc->frag_uuid + 64) )
3916 {
3772 /* case two: ack fits after existing min UUID */ 3917 /* case two: ack fits after existing min UUID */
3773 if ((frag_uuid == rc->frag_uuid) 3918 if ( (frag_uuid == rc->frag_uuid) ||
3774 || (0 3919 (0 != (rc->extra_acks & (1LLU << (frag_uuid - rc->frag_uuid - 1)))) )
3775 != (rc->extra_acks & (1LLU << (frag_uuid - rc->frag_uuid - 1))))) { 3920 {
3776 /* duplicate fragment, ack now! */ 3921 /* duplicate fragment, ack now! */
3777 ack_now = GNUNET_YES; 3922 ack_now = GNUNET_YES;
3778 } else { 3923 }
3924 else
3925 {
3779 rc->extra_acks |= (1LLU << (frag_uuid - rc->frag_uuid - 1)); 3926 rc->extra_acks |= (1LLU << (frag_uuid - rc->frag_uuid - 1));
3780 rc->num_acks++; 3927 rc->num_acks++;
3781 } 3928 }
3782 } else if ((rc->frag_uuid > frag_uuid) 3929 }
3783 && (((rc->frag_uuid == frag_uuid + 64) && (0 == rc->extra_acks)) 3930 else if ( (rc->frag_uuid > frag_uuid) &&
3784 || ((rc->frag_uuid < frag_uuid + 64) 3931 ( ( (rc->frag_uuid == frag_uuid + 64) &&
3785 && (rc->extra_acks 3932 (0 == rc->extra_acks) ) ||
3786 == (rc->extra_acks 3933 ( (rc->frag_uuid < frag_uuid + 64) &&
3787 & ~((1LLU << (64 - (rc->frag_uuid - frag_uuid))) 3934 (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) )
3788 - 1LLU)))))) { 3935 {
3789 /* can fit ack by shifting extra acks and starting at 3936 /* can fit ack by shifting extra acks and starting at
3790 frag_uid, test above esured that the bits we will 3937 frag_uid, test above esured that the bits we will
3791 shift 'extra_acks' by are all zero. */ 3938 shift 'extra_acks' by are all zero. */
@@ -3794,22 +3941,23 @@ handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
3794 rc->frag_uuid = frag_uuid; 3941 rc->frag_uuid = frag_uuid;
3795 rc->num_acks++; 3942 rc->num_acks++;
3796 } 3943 }
3797 if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very 3944 if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */
3798 aggressive. */
3799 ack_now = GNUNET_YES; /* maximum acks received */ 3945 ack_now = GNUNET_YES; /* maximum acks received */
3800 // FIXME: possibly also ACK based on RTT (but for that we'd need to 3946 // FIXME: possibly also ACK based on RTT (but for that we'd need to
3801 // determine the queue used for the ACK first!) 3947 // determine the queue used for the ACK first!)
3802 3948
3803 /* is reassembly complete? */ 3949 /* is reassembly complete? */
3804 if (0 != rc->msg_missing) { 3950 if (0 != rc->msg_missing)
3951 {
3805 if (ack_now) 3952 if (ack_now)
3806 send_fragment_ack (rc); 3953 send_fragment_ack (rc);
3807 finish_cmc_handling (cmc); 3954 finish_cmc_handling (cmc);
3808 return; 3955 return;
3809 } 3956 }
3810 /* reassembly is complete, verify result */ 3957 /* reassembly is complete, verify result */
3811 msg = (const struct GNUNET_MessageHeader *)&rc[1]; 3958 msg = (const struct GNUNET_MessageHeader *) &rc[1];
3812 if (ntohs (msg->size) != rc->msg_size) { 3959 if (ntohs (msg->size) != rc->msg_size)
3960 {
3813 GNUNET_break (0); 3961 GNUNET_break (0);
3814 free_reassembly_context (rc); 3962 free_reassembly_context (rc);
3815 finish_cmc_handling (cmc); 3963 finish_cmc_handling (cmc);
@@ -3817,7 +3965,8 @@ handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
3817 } 3965 }
3818 /* successful reassembly */ 3966 /* successful reassembly */
3819 send_fragment_ack (rc); 3967 send_fragment_ack (rc);
3820 demultiplex_with_cmc (cmc, msg); 3968 demultiplex_with_cmc (cmc,
3969 msg);
3821 /* FIXME: really free here? Might be bad if fragments are still 3970 /* FIXME: really free here? Might be bad if fragments are still
3822 en-route and we forget that we finished this reassembly immediately! 3971 en-route and we forget that we finished this reassembly immediately!
3823 -> keep around until timeout? 3972 -> keep around until timeout?
@@ -3845,17 +3994,22 @@ check_ack_against_pm (struct PendingMessage *pm,
3845 uint64_t xtra = GNUNET_ntohll (fa->extra_acks); 3994 uint64_t xtra = GNUNET_ntohll (fa->extra_acks);
3846 3995
3847 match = GNUNET_NO; 3996 match = GNUNET_NO;
3848 for (struct PendingMessage *frag = pm->head_frag; NULL != frag; frag = nxt) { 3997 for (struct PendingMessage *frag = pm->head_frag;
3998 NULL != frag;
3999 frag = nxt)
4000 {
3849 const struct TransportFragmentBox *tfb 4001 const struct TransportFragmentBox *tfb
3850 = (const struct TransportFragmentBox *)&pm[1]; 4002 = (const struct TransportFragmentBox *) &pm[1];
3851 uint32_t fu = ntohl (tfb->frag_uuid); 4003 uint32_t fu = ntohl (tfb->frag_uuid);
3852 4004
3853 GNUNET_assert (PMT_FRAGMENT_BOX == frag->pmt); 4005 GNUNET_assert (PMT_FRAGMENT_BOX == frag->pmt);
3854 nxt = frag->next_frag; 4006 nxt = frag->next_frag;
3855 /* Check for exact match or match in the 'xtra' bitmask */ 4007 /* Check for exact match or match in the 'xtra' bitmask */
3856 if ((fu == fs) 4008 if ( (fu == fs) ||
3857 || ((fu > fs) && (fu <= fs + 64) 4009 ( (fu > fs) &&
3858 && (0 != (1LLU << (fu - fs - 1) & xtra)))) { 4010 (fu <= fs + 64) &&
4011 (0 != (1LLU << (fu - fs - 1) & xtra)) ) )
4012 {
3859 match = GNUNET_YES; 4013 match = GNUNET_YES;
3860 free_fragment_tree (frag); 4014 free_fragment_tree (frag);
3861 } 4015 }
@@ -3867,19 +4021,21 @@ check_ack_against_pm (struct PendingMessage *pm,
3867/** 4021/**
3868 * Communicator gave us a fragment acknowledgement. Process the request. 4022 * Communicator gave us a fragment acknowledgement. Process the request.
3869 * 4023 *
3870 * @param cls a `struct CommunicatorMessageContext` (must call 4024 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
3871 * #finish_cmc_handling() when done)
3872 * @param fa the message that was received 4025 * @param fa the message that was received
3873 */ 4026 */
3874static void 4027static void
3875handle_fragment_ack (void *cls, const struct TransportFragmentAckMessage *fa) 4028handle_fragment_ack (void *cls,
4029 const struct TransportFragmentAckMessage *fa)
3876{ 4030{
3877 struct CommunicatorMessageContext *cmc = cls; 4031 struct CommunicatorMessageContext *cmc = cls;
3878 struct Neighbour *n; 4032 struct Neighbour *n;
3879 int matched; 4033 int matched;
3880 4034
3881 n = GNUNET_CONTAINER_multipeermap_get (neighbours, &cmc->im.sender); 4035 n = GNUNET_CONTAINER_multipeermap_get (neighbours,
3882 if (NULL == n) { 4036 &cmc->im.sender);
4037 if (NULL == n)
4038 {
3883 struct GNUNET_SERVICE_Client *client = cmc->tc->client; 4039 struct GNUNET_SERVICE_Client *client = cmc->tc->client;
3884 4040
3885 GNUNET_break (0); 4041 GNUNET_break (0);
@@ -3889,12 +4045,19 @@ handle_fragment_ack (void *cls, const struct TransportFragmentAckMessage *fa)
3889 } 4045 }
3890 /* FIXME-OPTIMIZE: maybe use another hash map here? */ 4046 /* FIXME-OPTIMIZE: maybe use another hash map here? */
3891 matched = GNUNET_NO; 4047 matched = GNUNET_NO;
3892 for (struct PendingMessage *pm = n->pending_msg_head; NULL != pm; 4048 for (struct PendingMessage *pm = n->pending_msg_head;
3893 pm = pm->prev_neighbour) { 4049 NULL != pm;
3894 if (0 != GNUNET_memcmp (&fa->msg_uuid, &pm->msg_uuid)) 4050 pm = pm->prev_neighbour)
4051 {
4052 if (0 !=
4053 GNUNET_memcmp (&fa->msg_uuid,
4054 &pm->msg_uuid))
3895 continue; 4055 continue;
3896 matched = GNUNET_YES; 4056 matched = GNUNET_YES;
3897 if (GNUNET_YES == check_ack_against_pm (pm, fa)) { 4057 if (GNUNET_YES ==
4058 check_ack_against_pm (pm,
4059 fa))
4060 {
3898 struct GNUNET_TIME_Relative avg_ack_delay 4061 struct GNUNET_TIME_Relative avg_ack_delay
3899 = GNUNET_TIME_relative_ntoh (fa->avg_ack_delay); 4062 = GNUNET_TIME_relative_ntoh (fa->avg_ack_delay);
3900 // FIXME: update RTT and other reliability data! 4063 // FIXME: update RTT and other reliability data!
@@ -3908,32 +4071,36 @@ handle_fragment_ack (void *cls, const struct TransportFragmentAckMessage *fa)
3908 // IDEA: generate MULTIPLE frag-uuids per fragment and track 4071 // IDEA: generate MULTIPLE frag-uuids per fragment and track
3909 // the queue with the fragment! (-> this logic must 4072 // the queue with the fragment! (-> this logic must
3910 // be moved into check_ack_against_pm!) 4073 // be moved into check_ack_against_pm!)
3911 (void)avg_ack_delay; 4074 (void) avg_ack_delay;
3912 } else { 4075 }
4076 else
4077 {
3913 GNUNET_STATISTICS_update (GST_stats, 4078 GNUNET_STATISTICS_update (GST_stats,
3914 "# FRAGMENT_ACKS dropped, no matching fragment", 4079 "# FRAGMENT_ACKS dropped, no matching fragment",
3915 1, 4080 1,
3916 GNUNET_NO); 4081 GNUNET_NO);
3917 } 4082 }
3918 if (NULL == pm->head_frag) { 4083 if (NULL == pm->head_frag)
4084 {
3919 // if entire message is ACKed, handle that as well. 4085 // if entire message is ACKed, handle that as well.
3920 // => clean up PM, any post actions? 4086 // => clean up PM, any post actions?
3921 free_pending_message (pm); 4087 free_pending_message (pm);
3922 } else { 4088 }
4089 else
4090 {
3923 struct GNUNET_TIME_Relative reassembly_timeout 4091 struct GNUNET_TIME_Relative reassembly_timeout
3924 = GNUNET_TIME_relative_ntoh (fa->reassembly_timeout); 4092 = GNUNET_TIME_relative_ntoh (fa->reassembly_timeout);
3925 // OPTIMIZE-FIXME: adjust retransmission strategy based on 4093 // OPTIMIZE-FIXME: adjust retransmission strategy based on reassembly_timeout!
3926 // reassembly_timeout! 4094 (void) reassembly_timeout;
3927 (void)reassembly_timeout;
3928 } 4095 }
3929 break; 4096 break;
3930 } 4097 }
3931 if (GNUNET_NO == matched) { 4098 if (GNUNET_NO == matched)
3932 GNUNET_STATISTICS_update ( 4099 {
3933 GST_stats, 4100 GNUNET_STATISTICS_update (GST_stats,
3934 "# FRAGMENT_ACKS dropped, no matching pending message", 4101 "# FRAGMENT_ACKS dropped, no matching pending message",
3935 1, 4102 1,
3936 GNUNET_NO); 4103 GNUNET_NO);
3937 } 4104 }
3938 finish_cmc_handling (cmc); 4105 finish_cmc_handling (cmc);
3939} 4106}
@@ -3947,7 +4114,8 @@ handle_fragment_ack (void *cls, const struct TransportFragmentAckMessage *fa)
3947 * @return #GNUNET_YES if message is well-formed 4114 * @return #GNUNET_YES if message is well-formed
3948 */ 4115 */
3949static int 4116static int
3950check_reliability_box (void *cls, const struct TransportReliabilityBox *rb) 4117check_reliability_box (void *cls,
4118 const struct TransportReliabilityBox *rb)
3951{ 4119{
3952 GNUNET_MQ_check_boxed_message (rb); 4120 GNUNET_MQ_check_boxed_message (rb);
3953 return GNUNET_YES; 4121 return GNUNET_YES;
@@ -3957,39 +4125,43 @@ check_reliability_box (void *cls, const struct TransportReliabilityBox *rb)
3957/** 4125/**
3958 * Communicator gave us a reliability box. Process the request. 4126 * Communicator gave us a reliability box. Process the request.
3959 * 4127 *
3960 * @param cls a `struct CommunicatorMessageContext` (must call 4128 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
3961 * #finish_cmc_handling() when done)
3962 * @param rb the message that was received 4129 * @param rb the message that was received
3963 */ 4130 */
3964static void 4131static void
3965handle_reliability_box (void *cls, const struct TransportReliabilityBox *rb) 4132handle_reliability_box (void *cls,
4133 const struct TransportReliabilityBox *rb)
3966{ 4134{
3967 struct CommunicatorMessageContext *cmc = cls; 4135 struct CommunicatorMessageContext *cmc = cls;
3968 const struct GNUNET_MessageHeader *inbox 4136 const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &rb[1];
3969 = (const struct GNUNET_MessageHeader *)&rb[1];
3970 4137
3971 if (0 == ntohl (rb->ack_countdown)) { 4138 if (0 == ntohl (rb->ack_countdown))
4139 {
3972 struct TransportReliabilityAckMessage *ack; 4140 struct TransportReliabilityAckMessage *ack;
3973 4141
3974 /* FIXME: implement cummulative ACKs and ack_countdown, 4142 /* FIXME: implement cummulative ACKs and ack_countdown,
3975 then setting the avg_ack_delay field below: */ 4143 then setting the avg_ack_delay field below: */
3976 ack = GNUNET_malloc (sizeof (*ack) + sizeof (struct GNUNET_ShortHashCode)); 4144 ack = GNUNET_malloc (sizeof (*ack) +
4145 sizeof (struct GNUNET_ShortHashCode));
3977 ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); 4146 ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK);
3978 ack->header.size 4147 ack->header.size = htons (sizeof (*ack) +
3979 = htons (sizeof (*ack) + sizeof (struct GNUNET_ShortHashCode)); 4148 sizeof (struct GNUNET_ShortHashCode));
3980 memcpy (&ack[1], &rb->msg_uuid, sizeof (struct GNUNET_ShortHashCode)); 4149 memcpy (&ack[1],
3981 route_message (&cmc->im.sender, &ack->header); 4150 &rb->msg_uuid,
4151 sizeof (struct GNUNET_ShortHashCode));
4152 route_message (&cmc->im.sender,
4153 &ack->header);
3982 } 4154 }
3983 /* continue with inner message */ 4155 /* continue with inner message */
3984 demultiplex_with_cmc (cmc, inbox); 4156 demultiplex_with_cmc (cmc,
4157 inbox);
3985} 4158}
3986 4159
3987 4160
3988/** 4161/**
3989 * Communicator gave us a reliability ack. Process the request. 4162 * Communicator gave us a reliability ack. Process the request.
3990 * 4163 *
3991 * @param cls a `struct CommunicatorMessageContext` (must call 4164 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
3992 * #finish_cmc_handling() when done)
3993 * @param ra the message that was received 4165 * @param ra the message that was received
3994 */ 4166 */
3995static void 4167static void
@@ -4003,8 +4175,10 @@ handle_reliability_ack (void *cls,
4003 struct PendingMessage *nxt; 4175 struct PendingMessage *nxt;
4004 int matched; 4176 int matched;
4005 4177
4006 n = GNUNET_CONTAINER_multipeermap_get (neighbours, &cmc->im.sender); 4178 n = GNUNET_CONTAINER_multipeermap_get (neighbours,
4007 if (NULL == n) { 4179 &cmc->im.sender);
4180 if (NULL == n)
4181 {
4008 struct GNUNET_SERVICE_Client *client = cmc->tc->client; 4182 struct GNUNET_SERVICE_Client *client = cmc->tc->client;
4009 4183
4010 GNUNET_break (0); 4184 GNUNET_break (0);
@@ -4013,18 +4187,24 @@ handle_reliability_ack (void *cls,
4013 return; 4187 return;
4014 } 4188 }
4015 n_acks = (ntohs (ra->header.size) - sizeof (*ra)) 4189 n_acks = (ntohs (ra->header.size) - sizeof (*ra))
4016 / sizeof (struct GNUNET_ShortHashCode); 4190 / sizeof (struct GNUNET_ShortHashCode);
4017 msg_uuids = (const struct GNUNET_ShortHashCode *)&ra[1]; 4191 msg_uuids = (const struct GNUNET_ShortHashCode *) &ra[1];
4018 4192
4019 /* FIXME-OPTIMIZE: maybe use another hash map here? */ 4193 /* FIXME-OPTIMIZE: maybe use another hash map here? */
4020 matched = GNUNET_NO; 4194 matched = GNUNET_NO;
4021 for (struct PendingMessage *pm = n->pending_msg_head; NULL != pm; pm = nxt) { 4195 for (struct PendingMessage *pm = n->pending_msg_head;
4196 NULL != pm;
4197 pm = nxt)
4198 {
4022 int in_list; 4199 int in_list;
4023 4200
4024 nxt = pm->next_neighbour; 4201 nxt = pm->next_neighbour;
4025 in_list = GNUNET_NO; 4202 in_list = GNUNET_NO;
4026 for (unsigned int i = 0; i < n_acks; i++) { 4203 for (unsigned int i=0;i<n_acks;i++)
4027 if (0 != GNUNET_memcmp (&msg_uuids[i], &pm->msg_uuid)) 4204 {
4205 if (0 !=
4206 GNUNET_memcmp (&msg_uuids[i],
4207 &pm->msg_uuid))
4028 continue; 4208 continue;
4029 in_list = GNUNET_YES; 4209 in_list = GNUNET_YES;
4030 break; 4210 break;
@@ -4048,15 +4228,15 @@ handle_reliability_ack (void *cls,
4048 // -> how can we get loss rates? 4228 // -> how can we get loss rates?
4049 // -> or, add extra state to MSG and ACKs to identify queue? 4229 // -> or, add extra state to MSG and ACKs to identify queue?
4050 // -> if we do this, might just do the same for the avg_ack_delay! 4230 // -> if we do this, might just do the same for the avg_ack_delay!
4051 (void)avg_ack_delay; 4231 (void) avg_ack_delay;
4052 } 4232 }
4053 } 4233 }
4054 if (GNUNET_NO == matched) { 4234 if (GNUNET_NO == matched)
4055 GNUNET_STATISTICS_update ( 4235 {
4056 GST_stats, 4236 GNUNET_STATISTICS_update (GST_stats,
4057 "# FRAGMENT_ACKS dropped, no matching pending message", 4237 "# FRAGMENT_ACKS dropped, no matching pending message",
4058 1, 4238 1,
4059 GNUNET_NO); 4239 GNUNET_NO);
4060 } 4240 }
4061 finish_cmc_handling (cmc); 4241 finish_cmc_handling (cmc);
4062} 4242}
@@ -4070,15 +4250,16 @@ handle_reliability_ack (void *cls,
4070 * @return #GNUNET_YES if message is well-formed 4250 * @return #GNUNET_YES if message is well-formed
4071 */ 4251 */
4072static int 4252static int
4073check_backchannel_encapsulation ( 4253check_backchannel_encapsulation (void *cls,
4074 void *cls, 4254 const struct TransportBackchannelEncapsulationMessage *be)
4075 const struct TransportBackchannelEncapsulationMessage *be)
4076{ 4255{
4077 uint16_t size = ntohs (be->header.size); 4256 uint16_t size = ntohs (be->header.size);
4078 4257
4079 (void)cls; 4258 (void) cls;
4080 if (size - sizeof (*be) < sizeof (struct TransportBackchannelRequestPayload) 4259 if (size - sizeof (*be) <
4081 + sizeof (struct GNUNET_MessageHeader)) { 4260 sizeof (struct TransportBackchannelRequestPayload) +
4261 sizeof (struct GNUNET_MessageHeader) )
4262 {
4082 GNUNET_break_op (0); 4263 GNUNET_break_op (0);
4083 return GNUNET_SYSERR; 4264 return GNUNET_SYSERR;
4084 } 4265 }
@@ -4089,35 +4270,44 @@ check_backchannel_encapsulation (
4089/** 4270/**
4090 * Communicator gave us a backchannel encapsulation. Process the request. 4271 * Communicator gave us a backchannel encapsulation. Process the request.
4091 * 4272 *
4092 * @param cls a `struct CommunicatorMessageContext` (must call 4273 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
4093 * #finish_cmc_handling() when done)
4094 * @param be the message that was received 4274 * @param be the message that was received
4095 */ 4275 */
4096static void 4276static void
4097handle_backchannel_encapsulation ( 4277handle_backchannel_encapsulation (void *cls,
4098 void *cls, 4278 const struct TransportBackchannelEncapsulationMessage *be)
4099 const struct TransportBackchannelEncapsulationMessage *be)
4100{ 4279{
4101 struct CommunicatorMessageContext *cmc = cls; 4280 struct CommunicatorMessageContext *cmc = cls;
4102 struct BackchannelKeyState key; 4281 struct BackchannelKeyState key;
4103 struct GNUNET_HashCode hmac; 4282 struct GNUNET_HashCode hmac;
4104 const char *hdr; 4283 const char *hdr;
4105 size_t hdr_len; 4284 size_t hrd_len;
4106 4285
4107 if (0 != GNUNET_memcmp (&be->target, &GST_my_identity)) { 4286 if (0 != GNUNET_memcmp (&be->target,
4287 &GST_my_identity))
4288 {
4108 /* not for me, try to route to target */ 4289 /* not for me, try to route to target */
4109 /* FIXME: someone needs to update be->distance! */ 4290 /* FIXME: someone needs to update be->distance! */
4110 /* FIXME: BE routing can be special, should we put all of this 4291 /* FIXME: BE routing can be special, should we put all of this
4111 on 'route_message'? Maybe at least pass some more arguments? */ 4292 on 'route_message'? Maybe at least pass some more arguments? */
4112 route_message (&be->target, GNUNET_copy_message (&be->header)); 4293 route_message (&be->target,
4294 GNUNET_copy_message (&be->header));
4113 finish_cmc_handling (cmc); 4295 finish_cmc_handling (cmc);
4114 return; 4296 return;
4115 } 4297 }
4116 dh_key_derive_eph_pub (&be->ephemeral_key, &be->iv, &key); 4298 dh_key_derive_eph_pub (&be->ephemeral_key,
4117 hdr = (const char *)&be[1]; 4299 &be->iv,
4300 &key);
4301 hdr = (const char *) &be[1];
4118 hdr_len = ntohs (be->header.size) - sizeof (*be); 4302 hdr_len = ntohs (be->header.size) - sizeof (*be);
4119 bc_hmac (&key, &hmac, hdr, hdr_len); 4303 bc_hmac (&key,
4120 if (0 != GNUNET_memcmp (&hmac, &be->hmac)) { 4304 &hmac,
4305 hdr,
4306 hdr_len);
4307 if (0 !=
4308 GNUNET_memcmp (&hmac,
4309 &be->hmac))
4310 {
4121 /* HMAC missmatch, disard! */ 4311 /* HMAC missmatch, disard! */
4122 GNUNET_break_op (0); 4312 GNUNET_break_op (0);
4123 finish_cmc_handling (cmc); 4313 finish_cmc_handling (cmc);
@@ -4128,10 +4318,15 @@ handle_backchannel_encapsulation (
4128 struct TransportBackchannelRequestPayload ppay; 4318 struct TransportBackchannelRequestPayload ppay;
4129 char body[hdr_len - sizeof (ppay)]; 4319 char body[hdr_len - sizeof (ppay)];
4130 4320
4131 GNUNET_assert (hdr_len 4321 GNUNET_assert (hdr_len >= sizeof (ppay) + sizeof (struct GNUNET_MessageHeader));
4132 >= sizeof (ppay) + sizeof (struct GNUNET_MessageHeader)); 4322 bc_decrypt (&key,
4133 bc_decrypt (&key, &ppay, hdr, sizeof (ppay)); 4323 &ppay,
4134 bc_decrypt (&key, &body, &hdr[sizeof (ppay)], hdr_len - sizeof (ppay)); 4324 hdr,
4325 sizeof (ppay));
4326 bc_decrypt (&key,
4327 &body,
4328 &hdr[sizeof (ppay)],
4329 hdr_len - sizeof (ppay));
4135 bc_key_clean (&key); 4330 bc_key_clean (&key);
4136 // FIXME: verify signatures in ppay! 4331 // FIXME: verify signatures in ppay!
4137 // => check if ephemeral key is known & valid, if not 4332 // => check if ephemeral key is known & valid, if not
@@ -4161,18 +4356,21 @@ path_cleanup_cb (void *cls)
4161 struct DistanceVectorHop *pos; 4356 struct DistanceVectorHop *pos;
4162 4357
4163 dv->timeout_task = NULL; 4358 dv->timeout_task = NULL;
4164 while (NULL != (pos = dv->dv_head)) { 4359 while (NULL != (pos = dv->dv_head))
4360 {
4165 GNUNET_assert (dv == pos->dv); 4361 GNUNET_assert (dv == pos->dv);
4166 if (GNUNET_TIME_absolute_get_remaining (pos->timeout).rel_value_us > 0) 4362 if (GNUNET_TIME_absolute_get_remaining (pos->timeout).rel_value_us > 0)
4167 break; 4363 break;
4168 free_distance_vector_hop (pos); 4364 free_distance_vector_hop (pos);
4169 } 4365 }
4170 if (NULL == pos) { 4366 if (NULL == pos)
4367 {
4171 free_dv_route (dv); 4368 free_dv_route (dv);
4172 return; 4369 return;
4173 } 4370 }
4174 dv->timeout_task 4371 dv->timeout_task = GNUNET_SCHEDULER_add_at (pos->timeout,
4175 = GNUNET_SCHEDULER_add_at (pos->timeout, &path_cleanup_cb, dv); 4372 &path_cleanup_cb,
4373 dv);
4176} 4374}
4177 4375
4178 4376
@@ -4191,8 +4389,8 @@ path_cleanup_cb (void *cls)
4191 * and then path contains a valid path from us to `path[path_len-1]` 4389 * and then path contains a valid path from us to `path[path_len-1]`
4192 * path[1] should be a direct neighbour (we should check!) 4390 * path[1] should be a direct neighbour (we should check!)
4193 * @param path_len number of entries on the @a path, at least three! 4391 * @param path_len number of entries on the @a path, at least three!
4194 * @param network_latency how long does the message take from us to 4392 * @param network_latency how long does the message take from us to `path[path_len-1]`?
4195 * `path[path_len-1]`? set to "forever" if unknown 4393 * set to "forever" if unknown
4196 * @return #GNUNET_YES on success, 4394 * @return #GNUNET_YES on success,
4197 * #GNUNET_NO if we have better path(s) to the target 4395 * #GNUNET_NO if we have better path(s) to the target
4198 * #GNUNET_SYSERR if the path is useless and/or invalid 4396 * #GNUNET_SYSERR if the path is useless and/or invalid
@@ -4209,58 +4407,76 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
4209 struct Neighbour *next_hop; 4407 struct Neighbour *next_hop;
4210 unsigned int shorter_distance; 4408 unsigned int shorter_distance;
4211 4409
4212 if (path_len < 3) { 4410 if (path_len < 3)
4411 {
4213 /* what a boring path! not allowed! */ 4412 /* what a boring path! not allowed! */
4214 GNUNET_break (0); 4413 GNUNET_break (0);
4215 return GNUNET_SYSERR; 4414 return GNUNET_SYSERR;
4216 } 4415 }
4217 GNUNET_assert (0 == GNUNET_memcmp (&GST_my_identity, &path[0])); 4416 GNUNET_assert (0 ==
4218 next_hop = GNUNET_CONTAINER_multipeermap_get (neighbours, &path[1]); 4417 GNUNET_memcmp (&GST_my_identity,
4219 if (NULL == next_hop) { 4418 &path[0]));
4419 next_hop = GNUNET_CONTAINER_multipeermap_get (neighbours,
4420 &path[1]);
4421 if (NULL == next_hop)
4422 {
4220 /* next hop must be a neighbour, otherwise this whole thing is useless! */ 4423 /* next hop must be a neighbour, otherwise this whole thing is useless! */
4221 GNUNET_break (0); 4424 GNUNET_break (0);
4222 return GNUNET_SYSERR; 4425 return GNUNET_SYSERR;
4223 } 4426 }
4224 for (unsigned int i = 2; i < path_len; i++) 4427 for (unsigned int i=2;i<path_len;i++)
4225 if (NULL != GNUNET_CONTAINER_multipeermap_get (neighbours, &path[i])) { 4428 if (NULL !=
4429 GNUNET_CONTAINER_multipeermap_get (neighbours,
4430 &path[i]))
4431 {
4226 /* Useless path, we have a direct connection to some hop 4432 /* Useless path, we have a direct connection to some hop
4227 in the middle of the path, so this one doesn't even 4433 in the middle of the path, so this one doesn't even
4228 seem terribly useful for redundancy */ 4434 seem terribly useful for redundancy */
4229 return GNUNET_SYSERR; 4435 return GNUNET_SYSERR;
4230 } 4436 }
4231 dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &path[path_len - 1]); 4437 dv = GNUNET_CONTAINER_multipeermap_get (dv_routes,
4232 if (NULL == dv) { 4438 &path[path_len - 1]);
4439 if (NULL == dv)
4440 {
4233 dv = GNUNET_new (struct DistanceVector); 4441 dv = GNUNET_new (struct DistanceVector);
4234 dv->target = path[path_len - 1]; 4442 dv->target = path[path_len - 1];
4235 dv->timeout_task = GNUNET_SCHEDULER_add_delayed (DV_PATH_VALIDITY_TIMEOUT, 4443 dv->timeout_task = GNUNET_SCHEDULER_add_delayed (DV_PATH_VALIDITY_TIMEOUT,
4236 &path_cleanup_cb, 4444 &path_cleanup_cb,
4237 dv); 4445 dv);
4238 GNUNET_assert (GNUNET_OK 4446 GNUNET_assert (GNUNET_OK ==
4239 == GNUNET_CONTAINER_multipeermap_put ( 4447 GNUNET_CONTAINER_multipeermap_put (dv_routes,
4240 dv_routes, 4448 &dv->target,
4241 &dv->target, 4449 dv,
4242 dv, 4450 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4243 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4244 } 4451 }
4245 /* Check if we have this path already! */ 4452 /* Check if we have this path already! */
4246 shorter_distance = 0; 4453 shorter_distance = 0;
4247 for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; 4454 for (struct DistanceVectorHop *pos = dv->dv_head;
4248 pos = pos->next_dv) { 4455 NULL != pos;
4456 pos = pos->next_dv)
4457 {
4249 if (pos->distance < path_len - 2) 4458 if (pos->distance < path_len - 2)
4250 shorter_distance++; 4459 shorter_distance++;
4251 /* Note that the distances in 'pos' excludes us (path[0]) and 4460 /* Note that the distances in 'pos' excludes us (path[0]) and
4252 the next_hop (path[1]), so we need to subtract two 4461 the next_hop (path[1]), so we need to subtract two
4253 and check next_hop explicitly */ 4462 and check next_hop explicitly */
4254 if ((pos->distance == path_len - 2) && (pos->next_hop == next_hop)) { 4463 if ( (pos->distance == path_len - 2) &&
4464 (pos->next_hop == next_hop) )
4465 {
4255 int match = GNUNET_YES; 4466 int match = GNUNET_YES;
4256 4467
4257 for (unsigned int i = 0; i < pos->distance; i++) { 4468 for (unsigned int i=0;i<pos->distance;i++)
4258 if (0 != GNUNET_memcmp (&pos->path[i], &path[i + 2])) { 4469 {
4470 if (0 !=
4471 GNUNET_memcmp (&pos->path[i],
4472 &path[i+2]))
4473 {
4259 match = GNUNET_NO; 4474 match = GNUNET_NO;
4260 break; 4475 break;
4261 } 4476 }
4262 } 4477 }
4263 if (GNUNET_YES == match) { 4478 if (GNUNET_YES == match)
4479 {
4264 struct GNUNET_TIME_Relative last_timeout; 4480 struct GNUNET_TIME_Relative last_timeout;
4265 4481
4266 /* Re-discovered known path, update timeout */ 4482 /* Re-discovered known path, update timeout */
@@ -4271,12 +4487,18 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
4271 last_timeout = GNUNET_TIME_absolute_get_remaining (pos->timeout); 4487 last_timeout = GNUNET_TIME_absolute_get_remaining (pos->timeout);
4272 pos->timeout 4488 pos->timeout
4273 = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT); 4489 = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT);
4274 GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, pos); 4490 GNUNET_CONTAINER_MDLL_remove (dv,
4275 GNUNET_CONTAINER_MDLL_insert (dv, dv->dv_head, dv->dv_tail, pos); 4491 dv->dv_head,
4276 if (last_timeout.rel_value_us 4492 dv->dv_tail,
4277 < GNUNET_TIME_relative_subtract (DV_PATH_VALIDITY_TIMEOUT, 4493 pos);
4278 DV_PATH_DISCOVERY_FREQUENCY) 4494 GNUNET_CONTAINER_MDLL_insert (dv,
4279 .rel_value_us) { 4495 dv->dv_head,
4496 dv->dv_tail,
4497 pos);
4498 if (last_timeout.rel_value_us <
4499 GNUNET_TIME_relative_subtract (DV_PATH_VALIDITY_TIMEOUT,
4500 DV_PATH_DISCOVERY_FREQUENCY).rel_value_us)
4501 {
4280 /* Some peer send DV learn messages too often, we are learning 4502 /* Some peer send DV learn messages too often, we are learning
4281 the same path faster than it would be useful; do not forward! */ 4503 the same path faster than it would be useful; do not forward! */
4282 return GNUNET_NO; 4504 return GNUNET_NO;
@@ -4287,22 +4509,26 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
4287 } 4509 }
4288 /* Count how many shorter paths we have (incl. direct 4510 /* Count how many shorter paths we have (incl. direct
4289 neighbours) before simply giving up on this one! */ 4511 neighbours) before simply giving up on this one! */
4290 if (shorter_distance >= MAX_DV_PATHS_TO_TARGET) { 4512 if (shorter_distance >= MAX_DV_PATHS_TO_TARGET)
4513 {
4291 /* We have a shorter path already! */ 4514 /* We have a shorter path already! */
4292 return GNUNET_NO; 4515 return GNUNET_NO;
4293 } 4516 }
4294 /* create new DV path entry */ 4517 /* create new DV path entry */
4295 hop = GNUNET_malloc (sizeof (struct DistanceVectorHop) 4518 hop = GNUNET_malloc (sizeof (struct DistanceVectorHop) +
4296 + sizeof (struct GNUNET_PeerIdentity) * (path_len - 2)); 4519 sizeof (struct GNUNET_PeerIdentity) * (path_len - 2));
4297 hop->next_hop = next_hop; 4520 hop->next_hop = next_hop;
4298 hop->dv = dv; 4521 hop->dv = dv;
4299 hop->path = (const struct GNUNET_PeerIdentity *)&hop[1]; 4522 hop->path = (const struct GNUNET_PeerIdentity *) &hop[1];
4300 memcpy (&hop[1], 4523 memcpy (&hop[1],
4301 &path[2], 4524 &path[2],
4302 sizeof (struct GNUNET_PeerIdentity) * (path_len - 2)); 4525 sizeof (struct GNUNET_PeerIdentity) * (path_len - 2));
4303 hop->timeout = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT); 4526 hop->timeout = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT);
4304 hop->distance = path_len - 2; 4527 hop->distance = path_len - 2;
4305 GNUNET_CONTAINER_MDLL_insert (dv, dv->dv_head, dv->dv_tail, hop); 4528 GNUNET_CONTAINER_MDLL_insert (dv,
4529 dv->dv_head,
4530 dv->dv_tail,
4531 hop);
4306 GNUNET_CONTAINER_MDLL_insert (neighbour, 4532 GNUNET_CONTAINER_MDLL_insert (neighbour,
4307 next_hop->dv_head, 4533 next_hop->dv_head,
4308 next_hop->dv_tail, 4534 next_hop->dv_tail,
@@ -4319,27 +4545,35 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
4319 * @return #GNUNET_YES if message is well-formed 4545 * @return #GNUNET_YES if message is well-formed
4320 */ 4546 */
4321static int 4547static int
4322check_dv_learn (void *cls, const struct TransportDVLearn *dvl) 4548check_dv_learn (void *cls,
4549 const struct TransportDVLearn *dvl)
4323{ 4550{
4324 uint16_t size = ntohs (dvl->header.size); 4551 uint16_t size = ntohs (dvl->header.size);
4325 uint16_t num_hops = ntohs (dvl->num_hops); 4552 uint16_t num_hops = ntohs (dvl->num_hops);
4326 const struct DVPathEntryP *hops = (const struct DVPathEntryP *)&dvl[1]; 4553 const struct DVPathEntryP *hops = (const struct DVPathEntryP *) &dvl[1];
4327 4554
4328 (void)cls; 4555 (void) cls;
4329 if (size != sizeof (*dvl) + num_hops * sizeof (struct DVPathEntryP)) { 4556 if (size != sizeof (*dvl) + num_hops * sizeof (struct DVPathEntryP))
4557 {
4330 GNUNET_break_op (0); 4558 GNUNET_break_op (0);
4331 return GNUNET_SYSERR; 4559 return GNUNET_SYSERR;
4332 } 4560 }
4333 if (num_hops > MAX_DV_HOPS_ALLOWED) { 4561 if (num_hops > MAX_DV_HOPS_ALLOWED)
4562 {
4334 GNUNET_break_op (0); 4563 GNUNET_break_op (0);
4335 return GNUNET_SYSERR; 4564 return GNUNET_SYSERR;
4336 } 4565 }
4337 for (unsigned int i = 0; i < num_hops; i++) { 4566 for (unsigned int i=0;i<num_hops;i++)
4338 if (0 == GNUNET_memcmp (&dvl->initiator, &hops[i].hop)) { 4567 {
4568 if (0 == GNUNET_memcmp (&dvl->initiator,
4569 &hops[i].hop))
4570 {
4339 GNUNET_break_op (0); 4571 GNUNET_break_op (0);
4340 return GNUNET_SYSERR; 4572 return GNUNET_SYSERR;
4341 } 4573 }
4342 if (0 == GNUNET_memcmp (&GST_my_identity, &hops[i].hop)) { 4574 if (0 == GNUNET_memcmp (&GST_my_identity,
4575 &hops[i].hop))
4576 {
4343 GNUNET_break_op (0); 4577 GNUNET_break_op (0);
4344 return GNUNET_SYSERR; 4578 return GNUNET_SYSERR;
4345 } 4579 }
@@ -4356,8 +4590,7 @@ check_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4356 * @param bi_history bitmask specifying hops on path that were bidirectional 4590 * @param bi_history bitmask specifying hops on path that were bidirectional
4357 * @param nhops length of the @a hops array 4591 * @param nhops length of the @a hops array
4358 * @param hops path the message traversed so far 4592 * @param hops path the message traversed so far
4359 * @param in_time when did we receive the message, used to calculate network 4593 * @param in_time when did we receive the message, used to calculate network delay
4360 * delay
4361 */ 4594 */
4362static void 4595static void
4363forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop, 4596forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
@@ -4373,37 +4606,40 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
4373 4606
4374 /* compute message for forwarding */ 4607 /* compute message for forwarding */
4375 GNUNET_assert (nhops < MAX_DV_HOPS_ALLOWED); 4608 GNUNET_assert (nhops < MAX_DV_HOPS_ALLOWED);
4376 fwd = GNUNET_malloc (sizeof (struct TransportDVLearn) 4609 fwd = GNUNET_malloc (sizeof (struct TransportDVLearn) +
4377 + (nhops + 1) * sizeof (struct DVPathEntryP)); 4610 (nhops + 1) * sizeof (struct DVPathEntryP));
4378 fwd->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN); 4611 fwd->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN);
4379 fwd->header.size = htons (sizeof (struct TransportDVLearn) 4612 fwd->header.size = htons (sizeof (struct TransportDVLearn) +
4380 + (nhops + 1) * sizeof (struct DVPathEntryP)); 4613 (nhops + 1) * sizeof (struct DVPathEntryP));
4381 fwd->num_hops = htons (nhops + 1); 4614 fwd->num_hops = htons (nhops + 1);
4382 fwd->bidirectional = htons (bi_history); 4615 fwd->bidirectional = htons (bi_history);
4383 nnd = GNUNET_TIME_relative_add ( 4616 nnd = GNUNET_TIME_relative_add (GNUNET_TIME_absolute_get_duration (in_time),
4384 GNUNET_TIME_absolute_get_duration (in_time), 4617 GNUNET_TIME_relative_ntoh (msg->non_network_delay));
4385 GNUNET_TIME_relative_ntoh (msg->non_network_delay));
4386 fwd->non_network_delay = GNUNET_TIME_relative_hton (nnd); 4618 fwd->non_network_delay = GNUNET_TIME_relative_hton (nnd);
4387 fwd->init_sig = msg->init_sig; 4619 fwd->init_sig = msg->init_sig;
4388 fwd->initiator = msg->initiator; 4620 fwd->initiator = msg->initiator;
4389 fwd->challenge = msg->challenge; 4621 fwd->challenge = msg->challenge;
4390 dhops = (struct DVPathEntryP *)&fwd[1]; 4622 dhops = (struct DVPathEntryP *) &fwd[1];
4391 GNUNET_memcpy (dhops, hops, sizeof (struct DVPathEntryP) * nhops); 4623 GNUNET_memcpy (dhops,
4624 hops,
4625 sizeof (struct DVPathEntryP) * nhops);
4392 dhops[nhops].hop = GST_my_identity; 4626 dhops[nhops].hop = GST_my_identity;
4393 { 4627 {
4394 struct DvHopPS dhp 4628 struct DvHopPS dhp = {
4395 = {.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), 4629 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
4396 .purpose.size = htonl (sizeof (dhp)), 4630 .purpose.size = htonl (sizeof (dhp)),
4397 .pred = dhops[nhops - 1].hop, 4631 .pred = dhops[nhops-1].hop,
4398 .succ = *next_hop, 4632 .succ = *next_hop,
4399 .challenge = msg->challenge}; 4633 .challenge = msg->challenge
4400 4634 };
4401 GNUNET_assert (GNUNET_OK 4635
4402 == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, 4636 GNUNET_assert (GNUNET_OK ==
4403 &dhp.purpose, 4637 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
4404 &dhops[nhops].hop_sig)); 4638 &dhp.purpose,
4405 } 4639 &dhops[nhops].hop_sig));
4406 route_message (next_hop, &fwd->header); 4640 }
4641 route_message (next_hop,
4642 &fwd->header);
4407} 4643}
4408 4644
4409 4645
@@ -4416,22 +4652,22 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
4416 * @return #GNUNET_OK if the signature is valid 4652 * @return #GNUNET_OK if the signature is valid
4417 */ 4653 */
4418static int 4654static int
4419validate_dv_initiator_signature ( 4655validate_dv_initiator_signature (const struct GNUNET_PeerIdentity *init,
4420 const struct GNUNET_PeerIdentity *init, 4656 const struct GNUNET_ShortHashCode *challenge,
4421 const struct GNUNET_ShortHashCode *challenge, 4657 const struct GNUNET_CRYPTO_EddsaSignature *init_sig)
4422 const struct GNUNET_CRYPTO_EddsaSignature *init_sig)
4423{ 4658{
4424 struct DvInitPS ip = { 4659 struct DvInitPS ip = {
4425 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR), 4660 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
4426 .purpose.size = htonl (sizeof (ip)), 4661 .purpose.size = htonl (sizeof (ip)),
4427 .challenge = *challenge}; 4662 .challenge = *challenge
4428 4663 };
4429 if (GNUNET_OK 4664
4430 != GNUNET_CRYPTO_eddsa_verify ( 4665 if (GNUNET_OK !=
4431 GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR, 4666 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR,
4432 &ip.purpose, 4667 &ip.purpose,
4433 init_sig, 4668 init_sig,
4434 &init->public_key)) { 4669 &init->public_key))
4670 {
4435 GNUNET_break_op (0); 4671 GNUNET_break_op (0);
4436 return GNUNET_SYSERR; 4672 return GNUNET_SYSERR;
4437 } 4673 }
@@ -4442,12 +4678,12 @@ validate_dv_initiator_signature (
4442/** 4678/**
4443 * Communicator gave us a DV learn message. Process the request. 4679 * Communicator gave us a DV learn message. Process the request.
4444 * 4680 *
4445 * @param cls a `struct CommunicatorMessageContext` (must call 4681 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
4446 * #finish_cmc_handling() when done)
4447 * @param dvl the message that was received 4682 * @param dvl the message that was received
4448 */ 4683 */
4449static void 4684static void
4450handle_dv_learn (void *cls, const struct TransportDVLearn *dvl) 4685handle_dv_learn (void *cls,
4686 const struct TransportDVLearn *dvl)
4451{ 4687{
4452 struct CommunicatorMessageContext *cmc = cls; 4688 struct CommunicatorMessageContext *cmc = cls;
4453 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc; 4689 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
@@ -4461,17 +4697,24 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4461 4697
4462 nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */ 4698 nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */
4463 bi_history = ntohs (dvl->bidirectional); 4699 bi_history = ntohs (dvl->bidirectional);
4464 hops = (const struct DVPathEntryP *)&dvl[1]; 4700 hops = (const struct DVPathEntryP *) &dvl[1];
4465 if (0 == nhops) { 4701 if (0 == nhops)
4702 {
4466 /* sanity check */ 4703 /* sanity check */
4467 if (0 != GNUNET_memcmp (&dvl->initiator, &cmc->im.sender)) { 4704 if (0 != GNUNET_memcmp (&dvl->initiator,
4705 &cmc->im.sender))
4706 {
4468 GNUNET_break (0); 4707 GNUNET_break (0);
4469 finish_cmc_handling (cmc); 4708 finish_cmc_handling (cmc);
4470 return; 4709 return;
4471 } 4710 }
4472 } else { 4711 }
4712 else
4713 {
4473 /* sanity check */ 4714 /* sanity check */
4474 if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender)) { 4715 if (0 != GNUNET_memcmp (&hops[nhops - 1].hop,
4716 &cmc->im.sender))
4717 {
4475 GNUNET_break (0); 4718 GNUNET_break (0);
4476 finish_cmc_handling (cmc); 4719 finish_cmc_handling (cmc);
4477 return; 4720 return;
@@ -4480,18 +4723,18 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4480 4723
4481 GNUNET_assert (CT_COMMUNICATOR == cmc->tc->type); 4724 GNUNET_assert (CT_COMMUNICATOR == cmc->tc->type);
4482 cc = cmc->tc->details.communicator.cc; 4725 cc = cmc->tc->details.communicator.cc;
4483 bi_hop = (GNUNET_TRANSPORT_CC_RELIABLE 4726 bi_hop = (GNUNET_TRANSPORT_CC_RELIABLE == cc); // FIXME: add bi-directional flag to cc?
4484 == cc); // FIXME: add bi-directional flag to cc?
4485 in_time = GNUNET_TIME_absolute_get (); 4727 in_time = GNUNET_TIME_absolute_get ();
4486 4728
4487 /* continue communicator here, everything else can happen asynchronous! */ 4729 /* continue communicator here, everything else can happen asynchronous! */
4488 finish_cmc_handling (cmc); 4730 finish_cmc_handling (cmc);
4489 4731
4490 // FIXME: should we bother to verify _every_ DV initiator signature? 4732 // FIXME: should we bother to verify _every_ DV initiator signature?
4491 if (GNUNET_OK 4733 if (GNUNET_OK !=
4492 != validate_dv_initiator_signature (&dvl->initiator, 4734 validate_dv_initiator_signature (&dvl->initiator,
4493 &dvl->challenge, 4735 &dvl->challenge,
4494 &dvl->init_sig)) { 4736 &dvl->init_sig))
4737 {
4495 GNUNET_break_op (0); 4738 GNUNET_break_op (0);
4496 return; 4739 return;
4497 } 4740 }
@@ -4499,7 +4742,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4499 // => if signature verification load too high, implement random drop strategy! 4742 // => if signature verification load too high, implement random drop strategy!
4500 4743
4501 do_fwd = GNUNET_YES; 4744 do_fwd = GNUNET_YES;
4502 if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator)) { 4745 if (0 == GNUNET_memcmp (&GST_my_identity,
4746 &dvl->initiator))
4747 {
4503 struct GNUNET_PeerIdentity path[nhops + 1]; 4748 struct GNUNET_PeerIdentity path[nhops + 1];
4504 struct GNUNET_TIME_Relative host_latency_sum; 4749 struct GNUNET_TIME_Relative host_latency_sum;
4505 struct GNUNET_TIME_Relative latency; 4750 struct GNUNET_TIME_Relative latency;
@@ -4515,53 +4760,69 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4515 latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly 4760 latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly
4516 // (based on dvl->challenge, we can identify time of origin!) 4761 // (based on dvl->challenge, we can identify time of origin!)
4517 4762
4518 network_latency = GNUNET_TIME_relative_subtract (latency, host_latency_sum); 4763 network_latency = GNUNET_TIME_relative_subtract (latency,
4764 host_latency_sum);
4519 /* assumption: latency on all links is the same */ 4765 /* assumption: latency on all links is the same */
4520 network_latency = GNUNET_TIME_relative_divide (network_latency, nhops); 4766 network_latency = GNUNET_TIME_relative_divide (network_latency,
4767 nhops);
4521 4768
4522 for (unsigned int i = 2; i <= nhops; i++) { 4769 for (unsigned int i=2;i<=nhops;i++)
4770 {
4523 struct GNUNET_TIME_Relative ilat; 4771 struct GNUNET_TIME_Relative ilat;
4524 4772
4525 /* assumption: linear latency increase per hop */ 4773 /* assumption: linear latency increase per hop */
4526 ilat = GNUNET_TIME_relative_multiply (network_latency, i); 4774 ilat = GNUNET_TIME_relative_multiply (network_latency,
4527 path[i] = hops[i - 1].hop; 4775 i);
4528 learn_dv_path (path, i, ilat); 4776 path[i] = hops[i-1].hop;
4777 learn_dv_path (path,
4778 i,
4779 ilat);
4529 } 4780 }
4530 /* as we initiated, do not forward again (would be circular!) */ 4781 /* as we initiated, do not forward again (would be circular!) */
4531 do_fwd = GNUNET_NO; 4782 do_fwd = GNUNET_NO;
4532 return; 4783 return;
4533 } else if (bi_hop) { 4784 }
4785 else if (bi_hop)
4786 {
4534 /* last hop was bi-directional, we could learn something here! */ 4787 /* last hop was bi-directional, we could learn something here! */
4535 struct GNUNET_PeerIdentity path[nhops + 2]; 4788 struct GNUNET_PeerIdentity path[nhops + 2];
4536 4789
4537 path[0] = GST_my_identity; 4790 path[0] = GST_my_identity;
4538 path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */ 4791 path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */
4539 for (unsigned int i = 0; i < nhops; i++) { 4792 for (unsigned int i=0;i<nhops;i++)
4793 {
4540 int iret; 4794 int iret;
4541 4795
4542 if (0 == (bi_history & (1 << i))) 4796 if (0 == (bi_history & (1 << i)))
4543 break; /* i-th hop not bi-directional, stop learning! */ 4797 break; /* i-th hop not bi-directional, stop learning! */
4544 if (i == nhops) { 4798 if (i == nhops)
4799 {
4545 path[i + 2] = dvl->initiator; 4800 path[i + 2] = dvl->initiator;
4546 } else { 4801 }
4802 else
4803 {
4547 path[i + 2] = hops[nhops - i - 2].hop; 4804 path[i + 2] = hops[nhops - i - 2].hop;
4548 } 4805 }
4549 4806
4550 iret = learn_dv_path (path, i + 2, GNUNET_TIME_UNIT_FOREVER_REL); 4807 iret = learn_dv_path (path,
4551 if (GNUNET_SYSERR == iret) { 4808 i + 2,
4809 GNUNET_TIME_UNIT_FOREVER_REL);
4810 if (GNUNET_SYSERR == iret)
4811 {
4552 /* path invalid or too long to be interesting for US, thus should also 4812 /* path invalid or too long to be interesting for US, thus should also
4553 not be interesting to our neighbours, cut path when forwarding to 4813 not be interesting to our neighbours, cut path when forwarding to
4554 'i' hops, except of course for the one that goes back to the 4814 'i' hops, except of course for the one that goes back to the
4555 initiator */ 4815 initiator */
4556 GNUNET_STATISTICS_update ( 4816 GNUNET_STATISTICS_update (GST_stats,
4557 GST_stats, 4817 "# DV learn not forwarded due invalidity of path",
4558 "# DV learn not forwarded due invalidity of path", 4818 1,
4559 1, 4819 GNUNET_NO);
4560 GNUNET_NO);
4561 do_fwd = GNUNET_NO; 4820 do_fwd = GNUNET_NO;
4562 break; 4821 break;
4563 } 4822 }
4564 if ((GNUNET_NO == iret) && (nhops == i + 1)) { 4823 if ( (GNUNET_NO == iret) &&
4824 (nhops == i + 1) )
4825 {
4565 /* we have better paths, and this is the longest target, 4826 /* we have better paths, and this is the longest target,
4566 so there cannot be anything interesting later */ 4827 so there cannot be anything interesting later */
4567 GNUNET_STATISTICS_update (GST_stats, 4828 GNUNET_STATISTICS_update (GST_stats,
@@ -4574,7 +4835,8 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4574 } 4835 }
4575 } 4836 }
4576 4837
4577 if (MAX_DV_HOPS_ALLOWED == nhops) { 4838 if (MAX_DV_HOPS_ALLOWED == nhops)
4839 {
4578 /* At limit, we're out of here! */ 4840 /* At limit, we're out of here! */
4579 finish_cmc_handling (cmc); 4841 finish_cmc_handling (cmc);
4580 return; 4842 return;
@@ -4583,21 +4845,28 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4583 /* Forward to initiator, if path non-trivial and possible */ 4845 /* Forward to initiator, if path non-trivial and possible */
4584 bi_history = (bi_history << 1) | (bi_hop ? 1 : 0); 4846 bi_history = (bi_history << 1) | (bi_hop ? 1 : 0);
4585 did_initiator = GNUNET_NO; 4847 did_initiator = GNUNET_NO;
4586 if ((1 < nhops) 4848 if ( (1 < nhops) &&
4587 && (GNUNET_YES 4849 (GNUNET_YES ==
4588 == GNUNET_CONTAINER_multipeermap_contains (neighbours, 4850 GNUNET_CONTAINER_multipeermap_contains (neighbours,
4589 &dvl->initiator))) { 4851 &dvl->initiator)) )
4852 {
4590 /* send back to origin! */ 4853 /* send back to origin! */
4591 forward_dv_learn (&dvl->initiator, dvl, bi_history, nhops, hops, in_time); 4854 forward_dv_learn (&dvl->initiator,
4855 dvl,
4856 bi_history,
4857 nhops,
4858 hops,
4859 in_time);
4592 did_initiator = GNUNET_YES; 4860 did_initiator = GNUNET_YES;
4593 } 4861 }
4594 /* We forward under two conditions: either we still learned something 4862 /* We forward under two conditions: either we still learned something
4595 ourselves (do_fwd), or the path was darn short and thus the initiator is 4863 ourselves (do_fwd), or the path was darn short and thus the initiator is
4596 likely to still be very interested in this (and we did NOT already 4864 likely to still be very interested in this (and we did NOT already
4597 send it back to the initiator) */ 4865 send it back to the initiator) */
4598 if ((do_fwd) 4866 if ( (do_fwd) ||
4599 || ((nhops < MIN_DV_PATH_LENGTH_FOR_INITIATOR) 4867 ( (nhops < MIN_DV_PATH_LENGTH_FOR_INITIATOR) &&
4600 && (GNUNET_NO == did_initiator))) { 4868 (GNUNET_NO == did_initiator) ) )
4869 {
4601 /* FIXME: loop over all neighbours, pick those with low 4870 /* FIXME: loop over all neighbours, pick those with low
4602 queues AND that are not yet on the path; possibly 4871 queues AND that are not yet on the path; possibly
4603 adapt threshold to nhops! */ 4872 adapt threshold to nhops! */
@@ -4621,33 +4890,32 @@ handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
4621 * @return #GNUNET_YES if message is well-formed 4890 * @return #GNUNET_YES if message is well-formed
4622 */ 4891 */
4623static int 4892static int
4624check_dv_box (void *cls, const struct TransportDVBox *dvb) 4893check_dv_box (void *cls,
4894 const struct TransportDVBox *dvb)
4625{ 4895{
4626 uint16_t size = ntohs (dvb->header.size); 4896 uint16_t size = ntohs (dvb->header.size);
4627 uint16_t num_hops = ntohs (dvb->num_hops); 4897 uint16_t num_hops = ntohs (dvb->num_hops);
4628 const struct GNUNET_PeerIdentity *hops 4898 const struct GNUNET_PeerIdentity *hops = (const struct GNUNET_PeerIdentity *) &dvb[1];
4629 = (const struct GNUNET_PeerIdentity *)&dvb[1]; 4899 const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &hops[num_hops];
4630 const struct GNUNET_MessageHeader *inbox
4631 = (const struct GNUNET_MessageHeader *)&hops[num_hops];
4632 uint16_t isize; 4900 uint16_t isize;
4633 uint16_t itype; 4901 uint16_t itype;
4634 4902
4635 (void)cls; 4903 (void) cls;
4636 if (size < sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) 4904 if (size < sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + sizeof (struct GNUNET_MessageHeader))
4637 + sizeof (struct GNUNET_MessageHeader)) { 4905 {
4638 GNUNET_break_op (0); 4906 GNUNET_break_op (0);
4639 return GNUNET_SYSERR; 4907 return GNUNET_SYSERR;
4640 } 4908 }
4641 isize = ntohs (inbox->size); 4909 isize = ntohs (inbox->size);
4642 if (size 4910 if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize)
4643 != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) 4911 {
4644 + isize) {
4645 GNUNET_break_op (0); 4912 GNUNET_break_op (0);
4646 return GNUNET_SYSERR; 4913 return GNUNET_SYSERR;
4647 } 4914 }
4648 itype = ntohs (inbox->type); 4915 itype = ntohs (inbox->type);
4649 if ((GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX == itype) 4916 if ( (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX == itype) ||
4650 || (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN == itype)) { 4917 (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN == itype) )
4918 {
4651 GNUNET_break_op (0); 4919 GNUNET_break_op (0);
4652 return GNUNET_SYSERR; 4920 return GNUNET_SYSERR;
4653 } 4921 }
@@ -4658,22 +4926,21 @@ check_dv_box (void *cls, const struct TransportDVBox *dvb)
4658/** 4926/**
4659 * Communicator gave us a DV box. Process the request. 4927 * Communicator gave us a DV box. Process the request.
4660 * 4928 *
4661 * @param cls a `struct CommunicatorMessageContext` (must call 4929 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
4662 * #finish_cmc_handling() when done)
4663 * @param dvb the message that was received 4930 * @param dvb the message that was received
4664 */ 4931 */
4665static void 4932static void
4666handle_dv_box (void *cls, const struct TransportDVBox *dvb) 4933handle_dv_box (void *cls,
4934 const struct TransportDVBox *dvb)
4667{ 4935{
4668 struct CommunicatorMessageContext *cmc = cls; 4936 struct CommunicatorMessageContext *cmc = cls;
4669 uint16_t size = ntohs (dvb->header.size) - sizeof (*dvb); 4937 uint16_t size = ntohs (dvb->header.size) - sizeof (*dvb);
4670 uint16_t num_hops = ntohs (dvb->num_hops); 4938 uint16_t num_hops = ntohs (dvb->num_hops);
4671 const struct GNUNET_PeerIdentity *hops 4939 const struct GNUNET_PeerIdentity *hops = (const struct GNUNET_PeerIdentity *) &dvb[1];
4672 = (const struct GNUNET_PeerIdentity *)&dvb[1]; 4940 const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &hops[num_hops];
4673 const struct GNUNET_MessageHeader *inbox
4674 = (const struct GNUNET_MessageHeader *)&hops[num_hops];
4675 4941
4676 if (num_hops > 0) { 4942 if (num_hops > 0)
4943 {
4677 // FIXME: if we are not the target, shorten path and forward along. 4944 // FIXME: if we are not the target, shorten path and forward along.
4678 // Try from the _end_ of hops array if we know the given 4945 // Try from the _end_ of hops array if we know the given
4679 // neighbour (shortening the path!). 4946 // neighbour (shortening the path!).
@@ -4684,7 +4951,8 @@ handle_dv_box (void *cls, const struct TransportDVBox *dvb)
4684 /* We are the target. Unbox and handle message. */ 4951 /* We are the target. Unbox and handle message. */
4685 cmc->im.sender = dvb->origin; 4952 cmc->im.sender = dvb->origin;
4686 cmc->total_hops = ntohs (dvb->total_hops); 4953 cmc->total_hops = ntohs (dvb->total_hops);
4687 demultiplex_with_cmc (cmc, inbox); 4954 demultiplex_with_cmc (cmc,
4955 inbox);
4688} 4956}
4689 4957
4690 4958
@@ -4701,7 +4969,8 @@ check_incoming_msg (void *cls,
4701{ 4969{
4702 struct TransportClient *tc = cls; 4970 struct TransportClient *tc = cls;
4703 4971
4704 if (CT_COMMUNICATOR != tc->type) { 4972 if (CT_COMMUNICATOR != tc->type)
4973 {
4705 GNUNET_break (0); 4974 GNUNET_break (0);
4706 return GNUNET_SYSERR; 4975 return GNUNET_SYSERR;
4707 } 4976 }
@@ -4711,11 +4980,9 @@ check_incoming_msg (void *cls,
4711 4980
4712 4981
4713/** 4982/**
4714 * Communicator gave us a transport address validation challenge. Process the 4983 * Communicator gave us a transport address validation challenge. Process the request.
4715 * request.
4716 * 4984 *
4717 * @param cls a `struct CommunicatorMessageContext` (must call 4985 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
4718 * #finish_cmc_handling() when done)
4719 * @param tvc the message that was received 4986 * @param tvc the message that was received
4720 */ 4987 */
4721static void 4988static void
@@ -4725,15 +4992,15 @@ handle_validation_challenge (void *cls,
4725 struct CommunicatorMessageContext *cmc = cls; 4992 struct CommunicatorMessageContext *cmc = cls;
4726 struct TransportValidationResponse *tvr; 4993 struct TransportValidationResponse *tvr;
4727 4994
4728 if (cmc->total_hops > 0) { 4995 if (cmc->total_hops > 0)
4996 {
4729 /* DV routing is not allowed for validation challenges! */ 4997 /* DV routing is not allowed for validation challenges! */
4730 GNUNET_break_op (0); 4998 GNUNET_break_op (0);
4731 finish_cmc_handling (cmc); 4999 finish_cmc_handling (cmc);
4732 return; 5000 return;
4733 } 5001 }
4734 tvr = GNUNET_new (struct TransportValidationResponse); 5002 tvr = GNUNET_new (struct TransportValidationResponse);
4735 tvr->header.type 5003 tvr->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE);
4736 = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE);
4737 tvr->header.size = htons (sizeof (*tvr)); 5004 tvr->header.size = htons (sizeof (*tvr));
4738 tvr->challenge = tvc->challenge; 5005 tvr->challenge = tvc->challenge;
4739 tvr->origin_time = tvc->sender_time; 5006 tvr->origin_time = tvc->sender_time;
@@ -4744,14 +5011,16 @@ handle_validation_challenge (void *cls,
4744 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE), 5011 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
4745 .purpose.size = htonl (sizeof (tvp)), 5012 .purpose.size = htonl (sizeof (tvp)),
4746 .validity_duration = tvr->validity_duration, 5013 .validity_duration = tvr->validity_duration,
4747 .challenge = tvc->challenge}; 5014 .challenge = tvc->challenge
5015 };
4748 5016
4749 GNUNET_assert (GNUNET_OK 5017 GNUNET_assert (GNUNET_OK ==
4750 == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, 5018 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
4751 &tvp.purpose, 5019 &tvp.purpose,
4752 &tvr->signature)); 5020 &tvr->signature));
4753 } 5021 }
4754 route_message (&cmc->im.sender, &tvr->header); 5022 route_message (&cmc->im.sender,
5023 &tvr->header);
4755 finish_cmc_handling (cmc); 5024 finish_cmc_handling (cmc);
4756} 5025}
4757 5026
@@ -4790,8 +5059,9 @@ check_known_challenge (void *cls,
4790 struct CheckKnownChallengeContext *ckac = cls; 5059 struct CheckKnownChallengeContext *ckac = cls;
4791 struct ValidationState *vs = value; 5060 struct ValidationState *vs = value;
4792 5061
4793 (void)pid; 5062 (void) pid;
4794 if (0 != GNUNET_memcmp (&vs->challenge, ckac->challenge)) 5063 if (0 != GNUNET_memcmp (&vs->challenge,
5064 ckac->challenge))
4795 return GNUNET_OK; 5065 return GNUNET_OK;
4796 ckac->vs = vs; 5066 ckac->vs = vs;
4797 return GNUNET_NO; 5067 return GNUNET_NO;
@@ -4806,7 +5076,8 @@ check_known_challenge (void *cls,
4806 * @param success #GNUNET_YES on success 5076 * @param success #GNUNET_YES on success
4807 */ 5077 */
4808static void 5078static void
4809peerstore_store_validation_cb (void *cls, int success) 5079peerstore_store_validation_cb (void *cls,
5080 int success)
4810{ 5081{
4811 struct ValidationState *vs = cls; 5082 struct ValidationState *vs = cls;
4812 5083
@@ -4850,28 +5121,28 @@ update_next_challenge_time (struct ValidationState *vs,
4850 vs, 5121 vs,
4851 new_time.abs_value_us); 5122 new_time.abs_value_us);
4852 else 5123 else
4853 GNUNET_CONTAINER_heap_update_cost (vs->hn, new_time.abs_value_us); 5124 GNUNET_CONTAINER_heap_update_cost (vs->hn,
4854 if ((vs != GNUNET_CONTAINER_heap_peek (validation_heap)) 5125 new_time.abs_value_us);
4855 && (NULL != validation_task)) 5126 if ( (vs != GNUNET_CONTAINER_heap_peek (validation_heap)) &&
5127 (NULL != validation_task) )
4856 return; 5128 return;
4857 if (NULL != validation_task) 5129 if (NULL != validation_task)
4858 GNUNET_SCHEDULER_cancel (validation_task); 5130 GNUNET_SCHEDULER_cancel (validation_task);
4859 /* randomize a bit */ 5131 /* randomize a bit */
4860 delta.rel_value_us 5132 delta.rel_value_us = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
4861 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 5133 MIN_DELAY_ADDRESS_VALIDATION.rel_value_us);
4862 MIN_DELAY_ADDRESS_VALIDATION.rel_value_us); 5134 new_time = GNUNET_TIME_absolute_add (new_time,
4863 new_time = GNUNET_TIME_absolute_add (new_time, delta); 5135 delta);
4864 validation_task 5136 validation_task = GNUNET_SCHEDULER_add_at (new_time,
4865 = GNUNET_SCHEDULER_add_at (new_time, &validation_start_cb, NULL); 5137 &validation_start_cb,
5138 NULL);
4866} 5139}
4867 5140
4868 5141
4869/** 5142/**
4870 * Communicator gave us a transport address validation response. Process the 5143 * Communicator gave us a transport address validation response. Process the request.
4871 * request.
4872 * 5144 *
4873 * @param cls a `struct CommunicatorMessageContext` (must call 5145 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
4874 * #finish_cmc_handling() when done)
4875 * @param tvr the message that was received 5146 * @param tvr the message that was received
4876 */ 5147 */
4877static void 5148static void
@@ -4880,16 +5151,19 @@ handle_validation_response (void *cls,
4880{ 5151{
4881 struct CommunicatorMessageContext *cmc = cls; 5152 struct CommunicatorMessageContext *cmc = cls;
4882 struct ValidationState *vs; 5153 struct ValidationState *vs;
4883 struct CheckKnownChallengeContext ckac 5154 struct CheckKnownChallengeContext ckac = {
4884 = {.challenge = &tvr->challenge, .vs = NULL}; 5155 .challenge = &tvr->challenge,
5156 .vs = NULL
5157 };
4885 struct GNUNET_TIME_Absolute origin_time; 5158 struct GNUNET_TIME_Absolute origin_time;
4886 5159
4887 /* check this is one of our challenges */ 5160 /* check this is one of our challenges */
4888 (void)GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, 5161 (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
4889 &cmc->im.sender, 5162 &cmc->im.sender,
4890 &check_known_challenge, 5163 &check_known_challenge,
4891 &ckac); 5164 &ckac);
4892 if (NULL == (vs = ckac.vs)) { 5165 if (NULL == (vs = ckac.vs))
5166 {
4893 /* This can happen simply if we 'forgot' the challenge by now, 5167 /* This can happen simply if we 'forgot' the challenge by now,
4894 i.e. because we received the validation response twice */ 5168 i.e. because we received the validation response twice */
4895 GNUNET_STATISTICS_update (GST_stats, 5169 GNUNET_STATISTICS_update (GST_stats,
@@ -4902,8 +5176,9 @@ handle_validation_response (void *cls,
4902 5176
4903 /* sanity check on origin time */ 5177 /* sanity check on origin time */
4904 origin_time = GNUNET_TIME_absolute_ntoh (tvr->origin_time); 5178 origin_time = GNUNET_TIME_absolute_ntoh (tvr->origin_time);
4905 if ((origin_time.abs_value_us < vs->first_challenge_use.abs_value_us) 5179 if ( (origin_time.abs_value_us < vs->first_challenge_use.abs_value_us) ||
4906 || (origin_time.abs_value_us > vs->last_challenge_use.abs_value_us)) { 5180 (origin_time.abs_value_us > vs->last_challenge_use.abs_value_us) )
5181 {
4907 GNUNET_break_op (0); 5182 GNUNET_break_op (0);
4908 finish_cmc_handling (cmc); 5183 finish_cmc_handling (cmc);
4909 return; 5184 return;
@@ -4915,14 +5190,15 @@ handle_validation_response (void *cls,
4915 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE), 5190 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
4916 .purpose.size = htonl (sizeof (tvp)), 5191 .purpose.size = htonl (sizeof (tvp)),
4917 .validity_duration = tvr->validity_duration, 5192 .validity_duration = tvr->validity_duration,
4918 .challenge = tvr->challenge}; 5193 .challenge = tvr->challenge
4919 5194 };
4920 if (GNUNET_OK 5195
4921 != GNUNET_CRYPTO_eddsa_verify ( 5196 if (GNUNET_OK !=
4922 GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE, 5197 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE,
4923 &tvp.purpose, 5198 &tvp.purpose,
4924 &tvr->signature, 5199 &tvr->signature,
4925 &cmc->im.sender.public_key)) { 5200 &cmc->im.sender.public_key))
5201 {
4926 GNUNET_break_op (0); 5202 GNUNET_break_op (0);
4927 finish_cmc_handling (cmc); 5203 finish_cmc_handling (cmc);
4928 return; 5204 return;
@@ -4931,24 +5207,23 @@ handle_validation_response (void *cls,
4931 5207
4932 /* validity is capped by our willingness to keep track of the 5208 /* validity is capped by our willingness to keep track of the
4933 validation entry and the maximum the other peer allows */ 5209 validation entry and the maximum the other peer allows */
4934 vs->valid_until = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_min ( 5210 vs->valid_until
4935 GNUNET_TIME_relative_ntoh (tvr->validity_duration), 5211 = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_min (GNUNET_TIME_relative_ntoh (tvr->validity_duration),
4936 MAX_ADDRESS_VALID_UNTIL)); 5212 MAX_ADDRESS_VALID_UNTIL));
4937 vs->validated_until = GNUNET_TIME_absolute_min ( 5213 vs->validated_until
4938 vs->valid_until, 5214 = GNUNET_TIME_absolute_min (vs->valid_until,
4939 GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME)); 5215 GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME));
4940 vs->validation_rtt = GNUNET_TIME_absolute_get_duration (origin_time); 5216 vs->validation_rtt = GNUNET_TIME_absolute_get_duration (origin_time);
4941 vs->challenge_backoff = GNUNET_TIME_UNIT_ZERO; 5217 vs->challenge_backoff = GNUNET_TIME_UNIT_ZERO;
4942 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, 5218 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
4943 &vs->challenge, 5219 &vs->challenge,
4944 sizeof (vs->challenge)); 5220 sizeof (vs->challenge));
4945 vs->first_challenge_use = GNUNET_TIME_absolute_subtract ( 5221 vs->first_challenge_use = GNUNET_TIME_absolute_subtract (vs->validated_until,
4946 vs->validated_until, 5222 GNUNET_TIME_relative_multiply (vs->validation_rtt,
4947 GNUNET_TIME_relative_multiply (vs->validation_rtt, 5223 VALIDATION_RTT_BUFFER_FACTOR));
4948 VALIDATION_RTT_BUFFER_FACTOR)); 5224 vs->last_challenge_use = GNUNET_TIME_UNIT_ZERO_ABS; /* challenge was not yet used */
4949 vs->last_challenge_use 5225 update_next_challenge_time (vs,
4950 = GNUNET_TIME_UNIT_ZERO_ABS; /* challenge was not yet used */ 5226 vs->first_challenge_use);
4951 update_next_challenge_time (vs, vs->first_challenge_use);
4952 vs->sc = GNUNET_PEERSTORE_store (peerstore, 5227 vs->sc = GNUNET_PEERSTORE_store (peerstore,
4953 "transport", 5228 "transport",
4954 &cmc->im.sender, 5229 &cmc->im.sender,
@@ -4974,12 +5249,12 @@ handle_incoming_msg (void *cls,
4974 const struct GNUNET_TRANSPORT_IncomingMessage *im) 5249 const struct GNUNET_TRANSPORT_IncomingMessage *im)
4975{ 5250{
4976 struct TransportClient *tc = cls; 5251 struct TransportClient *tc = cls;
4977 struct CommunicatorMessageContext *cmc 5252 struct CommunicatorMessageContext *cmc = GNUNET_new (struct CommunicatorMessageContext);
4978 = GNUNET_new (struct CommunicatorMessageContext);
4979 5253
4980 cmc->tc = tc; 5254 cmc->tc = tc;
4981 cmc->im = *im; 5255 cmc->im = *im;
4982 demultiplex_with_cmc (cmc, (const struct GNUNET_MessageHeader *)&im[1]); 5256 demultiplex_with_cmc (cmc,
5257 (const struct GNUNET_MessageHeader *) &im[1]);
4983} 5258}
4984 5259
4985 5260
@@ -4994,59 +5269,61 @@ static void
4994demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, 5269demultiplex_with_cmc (struct CommunicatorMessageContext *cmc,
4995 const struct GNUNET_MessageHeader *msg) 5270 const struct GNUNET_MessageHeader *msg)
4996{ 5271{
4997 struct GNUNET_MQ_MessageHandler handlers[] 5272 struct GNUNET_MQ_MessageHandler handlers[] = {
4998 = {GNUNET_MQ_hd_var_size (fragment_box, 5273 GNUNET_MQ_hd_var_size (fragment_box,
4999 GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT, 5274 GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT,
5000 struct TransportFragmentBox, 5275 struct TransportFragmentBox,
5001 &cmc), 5276 &cmc),
5002 GNUNET_MQ_hd_fixed_size (fragment_ack, 5277 GNUNET_MQ_hd_fixed_size (fragment_ack,
5003 GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK, 5278 GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK,
5004 struct TransportFragmentAckMessage, 5279 struct TransportFragmentAckMessage,
5005 &cmc), 5280 &cmc),
5006 GNUNET_MQ_hd_var_size (reliability_box, 5281 GNUNET_MQ_hd_var_size (reliability_box,
5007 GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX, 5282 GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX,
5008 struct TransportReliabilityBox, 5283 struct TransportReliabilityBox,
5009 &cmc), 5284 &cmc),
5010 GNUNET_MQ_hd_fixed_size (reliability_ack, 5285 GNUNET_MQ_hd_fixed_size (reliability_ack,
5011 GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK, 5286 GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK,
5012 struct TransportReliabilityAckMessage, 5287 struct TransportReliabilityAckMessage,
5013 &cmc), 5288 &cmc),
5014 GNUNET_MQ_hd_var_size ( 5289 GNUNET_MQ_hd_var_size (backchannel_encapsulation,
5015 backchannel_encapsulation, 5290 GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION,
5016 GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION, 5291 struct TransportBackchannelEncapsulationMessage,
5017 struct TransportBackchannelEncapsulationMessage, 5292 &cmc),
5018 &cmc), 5293 GNUNET_MQ_hd_var_size (dv_learn,
5019 GNUNET_MQ_hd_var_size (dv_learn, 5294 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN,
5020 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN, 5295 struct TransportDVLearn,
5021 struct TransportDVLearn, 5296 &cmc),
5022 &cmc), 5297 GNUNET_MQ_hd_var_size (dv_box,
5023 GNUNET_MQ_hd_var_size (dv_box, 5298 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX,
5024 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX, 5299 struct TransportDVBox,
5025 struct TransportDVBox, 5300 &cmc),
5026 &cmc), 5301 GNUNET_MQ_hd_fixed_size (validation_challenge,
5027 GNUNET_MQ_hd_fixed_size ( 5302 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE,
5028 validation_challenge, 5303 struct TransportValidationChallenge,
5029 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE, 5304 &cmc),
5030 struct TransportValidationChallenge, 5305 GNUNET_MQ_hd_fixed_size (validation_response,
5031 &cmc), 5306 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE,
5032 GNUNET_MQ_hd_fixed_size ( 5307 struct TransportValidationResponse,
5033 validation_response, 5308 &cmc),
5034 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE, 5309 GNUNET_MQ_handler_end()
5035 struct TransportValidationResponse, 5310 };
5036 &cmc),
5037 GNUNET_MQ_handler_end ()};
5038 int ret; 5311 int ret;
5039 5312
5040 ret = GNUNET_MQ_handle_message (handlers, msg); 5313 ret = GNUNET_MQ_handle_message (handlers,
5041 if (GNUNET_SYSERR == ret) { 5314 msg);
5315 if (GNUNET_SYSERR == ret)
5316 {
5042 GNUNET_break (0); 5317 GNUNET_break (0);
5043 GNUNET_SERVICE_client_drop (cmc->tc->client); 5318 GNUNET_SERVICE_client_drop (cmc->tc->client);
5044 GNUNET_free (cmc); 5319 GNUNET_free (cmc);
5045 return; 5320 return;
5046 } 5321 }
5047 if (GNUNET_NO == ret) { 5322 if (GNUNET_NO == ret)
5323 {
5048 /* unencapsulated 'raw' message */ 5324 /* unencapsulated 'raw' message */
5049 handle_raw_message (&cmc, msg); 5325 handle_raw_message (&cmc,
5326 msg);
5050 } 5327 }
5051} 5328}
5052 5329
@@ -5063,7 +5340,8 @@ check_add_queue_message (void *cls,
5063{ 5340{
5064 struct TransportClient *tc = cls; 5341 struct TransportClient *tc = cls;
5065 5342
5066 if (CT_COMMUNICATOR != tc->type) { 5343 if (CT_COMMUNICATOR != tc->type)
5344 {
5067 GNUNET_break (0); 5345 GNUNET_break (0);
5068 return GNUNET_SYSERR; 5346 return GNUNET_SYSERR;
5069 } 5347 }
@@ -5086,7 +5364,8 @@ tracker_update_in_cb (void *cls)
5086 unsigned int rsize; 5364 unsigned int rsize;
5087 5365
5088 rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu; 5366 rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu;
5089 in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, rsize); 5367 in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in,
5368 rsize);
5090 // FIXME: how exactly do we do inbound flow control? 5369 // FIXME: how exactly do we do inbound flow control?
5091} 5370}
5092 5371
@@ -5119,7 +5398,8 @@ set_pending_message_uuid (struct PendingMessage *pm)
5119 * @return new message to transmit 5398 * @return new message to transmit
5120 */ 5399 */
5121static struct PendingMessage * 5400static struct PendingMessage *
5122fragment_message (struct PendingMessage *pm, uint16_t mtu) 5401fragment_message (struct PendingMessage *pm,
5402 uint16_t mtu)
5123{ 5403{
5124 struct PendingMessage *ff; 5404 struct PendingMessage *ff;
5125 5405
@@ -5129,15 +5409,20 @@ fragment_message (struct PendingMessage *pm, uint16_t mtu)
5129 GNUNET_assert (mtu > sizeof (struct TransportFragmentBox)); 5409 GNUNET_assert (mtu > sizeof (struct TransportFragmentBox));
5130 5410
5131 /* select fragment for transmission, descending the tree if it has 5411 /* select fragment for transmission, descending the tree if it has
5132 been expanded until we are at a leaf or at a fragment that is small enough 5412 been expanded until we are at a leaf or at a fragment that is small enough */
5133 */
5134 ff = pm; 5413 ff = pm;
5135 while (((ff->bytes_msg > mtu) || (pm == ff)) 5414 while ( ( (ff->bytes_msg > mtu) ||
5136 && (ff->frag_off == ff->bytes_msg) && (NULL != ff->head_frag)) { 5415 (pm == ff) ) &&
5416 (ff->frag_off == ff->bytes_msg) &&
5417 (NULL != ff->head_frag) )
5418 {
5137 ff = ff->head_frag; /* descent into fragmented fragments */ 5419 ff = ff->head_frag; /* descent into fragmented fragments */
5138 } 5420 }
5139 5421
5140 if (((ff->bytes_msg > mtu) || (pm == ff)) && (pm->frag_off < pm->bytes_msg)) { 5422 if ( ( (ff->bytes_msg > mtu) ||
5423 (pm == ff) ) &&
5424 (pm->frag_off < pm->bytes_msg) )
5425 {
5141 /* Did not yet calculate all fragments, calculate next fragment */ 5426 /* Did not yet calculate all fragments, calculate next fragment */
5142 struct PendingMessage *frag; 5427 struct PendingMessage *frag;
5143 struct TransportFragmentBox tfb; 5428 struct TransportFragmentBox tfb;
@@ -5148,48 +5433,59 @@ fragment_message (struct PendingMessage *pm, uint16_t mtu)
5148 uint16_t msize; 5433 uint16_t msize;
5149 uint16_t xoff = 0; 5434 uint16_t xoff = 0;
5150 5435
5151 orig = (const char *)&ff[1]; 5436 orig = (const char *) &ff[1];
5152 msize = ff->bytes_msg; 5437 msize = ff->bytes_msg;
5153 if (pm != ff) { 5438 if (pm != ff)
5439 {
5154 const struct TransportFragmentBox *tfbo; 5440 const struct TransportFragmentBox *tfbo;
5155 5441
5156 tfbo = (const struct TransportFragmentBox *)orig; 5442 tfbo = (const struct TransportFragmentBox *) orig;
5157 orig += sizeof (struct TransportFragmentBox); 5443 orig += sizeof (struct TransportFragmentBox);
5158 msize -= sizeof (struct TransportFragmentBox); 5444 msize -= sizeof (struct TransportFragmentBox);
5159 xoff = ntohs (tfbo->frag_off); 5445 xoff = ntohs (tfbo->frag_off);
5160 } 5446 }
5161 fragmax = mtu - sizeof (struct TransportFragmentBox); 5447 fragmax = mtu - sizeof (struct TransportFragmentBox);
5162 fragsize = GNUNET_MIN (msize - ff->frag_off, fragmax); 5448 fragsize = GNUNET_MIN (msize - ff->frag_off,
5163 frag = GNUNET_malloc (sizeof (struct PendingMessage) 5449 fragmax);
5164 + sizeof (struct TransportFragmentBox) + fragsize); 5450 frag = GNUNET_malloc (sizeof (struct PendingMessage) +
5451 sizeof (struct TransportFragmentBox) +
5452 fragsize);
5165 frag->target = pm->target; 5453 frag->target = pm->target;
5166 frag->frag_parent = ff; 5454 frag->frag_parent = ff;
5167 frag->timeout = pm->timeout; 5455 frag->timeout = pm->timeout;
5168 frag->bytes_msg = sizeof (struct TransportFragmentBox) + fragsize; 5456 frag->bytes_msg = sizeof (struct TransportFragmentBox) + fragsize;
5169 frag->pmt = PMT_FRAGMENT_BOX; 5457 frag->pmt = PMT_FRAGMENT_BOX;
5170 msg = (char *)&frag[1]; 5458 msg = (char *) &frag[1];
5171 tfb.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT); 5459 tfb.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT);
5172 tfb.header.size = htons (sizeof (struct TransportFragmentBox) + fragsize); 5460 tfb.header.size = htons (sizeof (struct TransportFragmentBox) +
5461 fragsize);
5173 tfb.frag_uuid = htonl (pm->frag_uuidgen++); 5462 tfb.frag_uuid = htonl (pm->frag_uuidgen++);
5174 tfb.msg_uuid = pm->msg_uuid; 5463 tfb.msg_uuid = pm->msg_uuid;
5175 tfb.frag_off = htons (ff->frag_off + xoff); 5464 tfb.frag_off = htons (ff->frag_off + xoff);
5176 tfb.msg_size = htons (pm->bytes_msg); 5465 tfb.msg_size = htons (pm->bytes_msg);
5177 memcpy (msg, &tfb, sizeof (tfb)); 5466 memcpy (msg,
5178 memcpy (&msg[sizeof (tfb)], &orig[ff->frag_off], fragsize); 5467 &tfb,
5179 GNUNET_CONTAINER_MDLL_insert (frag, ff->head_frag, ff->tail_frag, frag); 5468 sizeof (tfb));
5469 memcpy (&msg[sizeof (tfb)],
5470 &orig[ff->frag_off],
5471 fragsize);
5472 GNUNET_CONTAINER_MDLL_insert (frag,
5473 ff->head_frag,
5474 ff->tail_frag,
5475 frag);
5180 ff->frag_off += fragsize; 5476 ff->frag_off += fragsize;
5181 ff = frag; 5477 ff = frag;
5182 } 5478 }
5183 5479
5184 /* Move head to the tail and return it */ 5480 /* Move head to the tail and return it */
5185 GNUNET_CONTAINER_MDLL_remove (frag, 5481 GNUNET_CONTAINER_MDLL_remove (frag,
5186 ff->frag_parent->head_frag, 5482 ff->frag_parent->head_frag,
5187 ff->frag_parent->tail_frag, 5483 ff->frag_parent->tail_frag,
5188 ff); 5484 ff);
5189 GNUNET_CONTAINER_MDLL_insert_tail (frag, 5485 GNUNET_CONTAINER_MDLL_insert_tail (frag,
5190 ff->frag_parent->head_frag, 5486 ff->frag_parent->head_frag,
5191 ff->frag_parent->tail_frag, 5487 ff->frag_parent->tail_frag,
5192 ff); 5488 ff);
5193 return ff; 5489 return ff;
5194} 5490}
5195 5491
@@ -5212,22 +5508,28 @@ reliability_box_message (struct PendingMessage *pm)
5212 char *msg; 5508 char *msg;
5213 5509
5214 if (PMT_CORE != pm->pmt) 5510 if (PMT_CORE != pm->pmt)
5215 return pm; /* already fragmented or reliability boxed, or control message: 5511 return pm; /* already fragmented or reliability boxed, or control message: do nothing */
5216 do nothing */
5217 if (NULL != pm->bpm) 5512 if (NULL != pm->bpm)
5218 return pm->bpm; /* already computed earlier: do nothing */ 5513 return pm->bpm; /* already computed earlier: do nothing */
5219 GNUNET_assert (NULL == pm->head_frag); 5514 GNUNET_assert (NULL == pm->head_frag);
5220 if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX) { 5515 if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX)
5516 {
5221 /* failed hard */ 5517 /* failed hard */
5222 GNUNET_break (0); 5518 GNUNET_break (0);
5223 client_send_response (pm, GNUNET_NO, 0); 5519 client_send_response (pm,
5520 GNUNET_NO,
5521 0);
5224 return NULL; 5522 return NULL;
5225 } 5523 }
5226 bpm = GNUNET_malloc (sizeof (struct PendingMessage) + sizeof (rbox) 5524 bpm = GNUNET_malloc (sizeof (struct PendingMessage) +
5227 + pm->bytes_msg); 5525 sizeof (rbox) +
5526 pm->bytes_msg);
5228 bpm->target = pm->target; 5527 bpm->target = pm->target;
5229 bpm->frag_parent = pm; 5528 bpm->frag_parent = pm;
5230 GNUNET_CONTAINER_MDLL_insert (frag, pm->head_frag, pm->tail_frag, bpm); 5529 GNUNET_CONTAINER_MDLL_insert (frag,
5530 pm->head_frag,
5531 pm->tail_frag,
5532 bpm);
5231 bpm->timeout = pm->timeout; 5533 bpm->timeout = pm->timeout;
5232 bpm->pmt = PMT_RELIABILITY_BOX; 5534 bpm->pmt = PMT_RELIABILITY_BOX;
5233 bpm->bytes_msg = pm->bytes_msg + sizeof (rbox); 5535 bpm->bytes_msg = pm->bytes_msg + sizeof (rbox);
@@ -5236,9 +5538,13 @@ reliability_box_message (struct PendingMessage *pm)
5236 rbox.header.size = htons (sizeof (rbox) + pm->bytes_msg); 5538 rbox.header.size = htons (sizeof (rbox) + pm->bytes_msg);
5237 rbox.ack_countdown = htonl (0); // FIXME: implement ACK countdown support 5539 rbox.ack_countdown = htonl (0); // FIXME: implement ACK countdown support
5238 rbox.msg_uuid = pm->msg_uuid; 5540 rbox.msg_uuid = pm->msg_uuid;
5239 msg = (char *)&bpm[1]; 5541 msg = (char *) &bpm[1];
5240 memcpy (msg, &rbox, sizeof (rbox)); 5542 memcpy (msg,
5241 memcpy (&msg[sizeof (rbox)], &pm[1], pm->bytes_msg); 5543 &rbox,
5544 sizeof (rbox));
5545 memcpy (&msg[sizeof (rbox)],
5546 &pm[1],
5547 pm->bytes_msg);
5242 pm->bpm = bpm; 5548 pm->bpm = bpm;
5243 return bpm; 5549 return bpm;
5244} 5550}
@@ -5264,7 +5570,8 @@ transmit_on_queue (void *cls)
5264 struct GNUNET_MQ_Envelope *env; 5570 struct GNUNET_MQ_Envelope *env;
5265 5571
5266 queue->transmit_task = NULL; 5572 queue->transmit_task = NULL;
5267 if (NULL == (pm = n->pending_msg_head)) { 5573 if (NULL == (pm = n->pending_msg_head))
5574 {
5268 /* no message pending, nothing to do here! */ 5575 /* no message pending, nothing to do here! */
5269 return; 5576 return;
5270 } 5577 }
@@ -5283,17 +5590,18 @@ transmit_on_queue (void *cls)
5283 this queue */) ) 5590 this queue */) )
5284 s = fragment_message (s, 5591 s = fragment_message (s,
5285 (0 == queue->mtu) 5592 (0 == queue->mtu)
5286 ? UINT16_MAX 5593 ? UINT16_MAX - sizeof (struct GNUNET_TRANSPORT_SendMessageTo)
5287 - sizeof (struct GNUNET_TRANSPORT_SendMessageTo) 5594 : queue->mtu);
5288 : queue->mtu); 5595 if (NULL == s)
5289 if (NULL == s) { 5596 {
5290 /* Fragmentation failed, try next message... */ 5597 /* Fragmentation failed, try next message... */
5291 schedule_transmit_on_queue (queue); 5598 schedule_transmit_on_queue (queue);
5292 return; 5599 return;
5293 } 5600 }
5294 if (GNUNET_TRANSPORT_CC_RELIABLE != queue->tc->details.communicator.cc) 5601 if (GNUNET_TRANSPORT_CC_RELIABLE != queue->tc->details.communicator.cc)
5295 s = reliability_box_message (s); 5602 s = reliability_box_message (s);
5296 if (NULL == s) { 5603 if (NULL == s)
5604 {
5297 /* Reliability boxing failed, try next message... */ 5605 /* Reliability boxing failed, try next message... */
5298 schedule_transmit_on_queue (queue); 5606 schedule_transmit_on_queue (queue);
5299 return; 5607 return;
@@ -5306,7 +5614,9 @@ transmit_on_queue (void *cls)
5306 smt->qid = queue->qid; 5614 smt->qid = queue->qid;
5307 smt->mid = queue->mid_gen; 5615 smt->mid = queue->mid_gen;
5308 smt->receiver = n->pid; 5616 smt->receiver = n->pid;
5309 memcpy (&smt[1], &s[1], s->bytes_msg); 5617 memcpy (&smt[1],
5618 &s[1],
5619 s->bytes_msg);
5310 { 5620 {
5311 /* Pass the env to the communicator of queue for transmission. */ 5621 /* Pass the env to the communicator of queue for transmission. */
5312 struct QueueEntry *qe; 5622 struct QueueEntry *qe;
@@ -5315,11 +5625,14 @@ transmit_on_queue (void *cls)
5315 qe->mid = queue->mid_gen++; 5625 qe->mid = queue->mid_gen++;
5316 qe->queue = queue; 5626 qe->queue = queue;
5317 // qe->pm = s; // FIXME: not so easy, reference management on 'free(s)'! 5627 // qe->pm = s; // FIXME: not so easy, reference management on 'free(s)'!
5318 GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe); 5628 GNUNET_CONTAINER_DLL_insert (queue->queue_head,
5629 queue->queue_tail,
5630 qe);
5319 GNUNET_assert (CT_COMMUNICATOR == queue->tc->type); 5631 GNUNET_assert (CT_COMMUNICATOR == queue->tc->type);
5320 queue->queue_length++; 5632 queue->queue_length++;
5321 queue->tc->details.communicator.total_queue_length++; 5633 queue->tc->details.communicator.total_queue_length++;
5322 GNUNET_MQ_send (queue->tc->mq, env); 5634 GNUNET_MQ_send (queue->tc->mq,
5635 env);
5323 } 5636 }
5324 5637
5325 // FIXME: do something similar to the logic below 5638 // FIXME: do something similar to the logic below
@@ -5327,39 +5640,55 @@ transmit_on_queue (void *cls)
5327 5640
5328 /* Check if this transmission somehow conclusively finished handing 'pm' 5641 /* Check if this transmission somehow conclusively finished handing 'pm'
5329 even without any explicit ACKs */ 5642 even without any explicit ACKs */
5330 if ((PMT_CORE == s->pmt) 5643 if ( (PMT_CORE == s->pmt) &&
5331 && (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc)) { 5644 (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) )
5645 {
5332 /* Full message sent, and over reliabile channel */ 5646 /* Full message sent, and over reliabile channel */
5333 client_send_response (pm, GNUNET_YES, pm->bytes_msg); 5647 client_send_response (pm,
5334 } else if ((GNUNET_TRANSPORT_CC_RELIABLE 5648 GNUNET_YES,
5335 == queue->tc->details.communicator.cc) 5649 pm->bytes_msg);
5336 && (PMT_FRAGMENT_BOX == s->pmt)) { 5650 }
5651 else if ( (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) &&
5652 (PMT_FRAGMENT_BOX == s->pmt) )
5653 {
5337 struct PendingMessage *pos; 5654 struct PendingMessage *pos;
5338 5655
5339 /* Fragment sent over reliabile channel */ 5656 /* Fragment sent over reliabile channel */
5340 free_fragment_tree (s); 5657 free_fragment_tree (s);
5341 pos = s->frag_parent; 5658 pos = s->frag_parent;
5342 GNUNET_CONTAINER_MDLL_remove (frag, pos->head_frag, pos->tail_frag, s); 5659 GNUNET_CONTAINER_MDLL_remove (frag,
5660 pos->head_frag,
5661 pos->tail_frag,
5662 s);
5343 GNUNET_free (s); 5663 GNUNET_free (s);
5344 /* check if subtree is done */ 5664 /* check if subtree is done */
5345 while ((NULL == pos->head_frag) && (pos->frag_off == pos->bytes_msg) 5665 while ( (NULL == pos->head_frag) &&
5346 && (pos != pm)) { 5666 (pos->frag_off == pos->bytes_msg) &&
5667 (pos != pm) )
5668 {
5347 s = pos; 5669 s = pos;
5348 pos = s->frag_parent; 5670 pos = s->frag_parent;
5349 GNUNET_CONTAINER_MDLL_remove (frag, pos->head_frag, pos->tail_frag, s); 5671 GNUNET_CONTAINER_MDLL_remove (frag,
5672 pos->head_frag,
5673 pos->tail_frag,
5674 s);
5350 GNUNET_free (s); 5675 GNUNET_free (s);
5351 } 5676 }
5352 5677
5353 /* Was this the last applicable fragmment? */ 5678 /* Was this the last applicable fragmment? */
5354 if ((NULL == pm->head_frag) && (pm->frag_off == pm->bytes_msg)) 5679 if ( (NULL == pm->head_frag) &&
5355 client_send_response ( 5680 (pm->frag_off == pm->bytes_msg) )
5356 pm, 5681 client_send_response (pm,
5357 GNUNET_YES, 5682 GNUNET_YES,
5358 pm->bytes_msg /* FIXME: calculate and add overheads! */); 5683 pm->bytes_msg /* FIXME: calculate and add overheads! */);
5359 } else if (PMT_CORE != pm->pmt) { 5684 }
5685 else if (PMT_CORE != pm->pmt)
5686 {
5360 /* This was an acknowledgement of some type, always free */ 5687 /* This was an acknowledgement of some type, always free */
5361 free_pending_message (pm); 5688 free_pending_message (pm);
5362 } else { 5689 }
5690 else
5691 {
5363 /* message not finished, waiting for acknowledgement */ 5692 /* message not finished, waiting for acknowledgement */
5364 struct Neighbour *neighbour = pm->target; 5693 struct Neighbour *neighbour = pm->target;
5365 /* Update time by which we might retransmit 's' based on queue 5694 /* Update time by which we might retransmit 's' based on queue
@@ -5369,9 +5698,11 @@ transmit_on_queue (void *cls)
5369 retransmitting. Note that in the future this heuristic should 5698 retransmitting. Note that in the future this heuristic should
5370 likely be improved further (measure RTT stability, consider 5699 likely be improved further (measure RTT stability, consider
5371 message urgency and size when delaying ACKs, etc.) */ 5700 message urgency and size when delaying ACKs, etc.) */
5372 s->next_attempt = GNUNET_TIME_relative_to_absolute ( 5701 s->next_attempt = GNUNET_TIME_relative_to_absolute
5373 GNUNET_TIME_relative_multiply (queue->rtt, 4)); 5702 (GNUNET_TIME_relative_multiply (queue->rtt,
5374 if (s == pm) { 5703 4));
5704 if (s == pm)
5705 {
5375 struct PendingMessage *pos; 5706 struct PendingMessage *pos;
5376 5707
5377 /* re-insert sort in neighbour list */ 5708 /* re-insert sort in neighbour list */
@@ -5380,24 +5711,28 @@ transmit_on_queue (void *cls)
5380 neighbour->pending_msg_tail, 5711 neighbour->pending_msg_tail,
5381 pm); 5712 pm);
5382 pos = neighbour->pending_msg_tail; 5713 pos = neighbour->pending_msg_tail;
5383 while ( 5714 while ( (NULL != pos) &&
5384 (NULL != pos) 5715 (pm->next_attempt.abs_value_us > pos->next_attempt.abs_value_us) )
5385 && (pm->next_attempt.abs_value_us > pos->next_attempt.abs_value_us))
5386 pos = pos->prev_neighbour; 5716 pos = pos->prev_neighbour;
5387 GNUNET_CONTAINER_MDLL_insert_after (neighbour, 5717 GNUNET_CONTAINER_MDLL_insert_after (neighbour,
5388 neighbour->pending_msg_head, 5718 neighbour->pending_msg_head,
5389 neighbour->pending_msg_tail, 5719 neighbour->pending_msg_tail,
5390 pos, 5720 pos,
5391 pm); 5721 pm);
5392 } else { 5722 }
5723 else
5724 {
5393 /* re-insert sort in fragment list */ 5725 /* re-insert sort in fragment list */
5394 struct PendingMessage *fp = s->frag_parent; 5726 struct PendingMessage *fp = s->frag_parent;
5395 struct PendingMessage *pos; 5727 struct PendingMessage *pos;
5396 5728
5397 GNUNET_CONTAINER_MDLL_remove (frag, fp->head_frag, fp->tail_frag, s); 5729 GNUNET_CONTAINER_MDLL_remove (frag,
5730 fp->head_frag,
5731 fp->tail_frag,
5732 s);
5398 pos = fp->tail_frag; 5733 pos = fp->tail_frag;
5399 while ((NULL != pos) 5734 while ( (NULL != pos) &&
5400 && (s->next_attempt.abs_value_us > pos->next_attempt.abs_value_us)) 5735 (s->next_attempt.abs_value_us > pos->next_attempt.abs_value_us) )
5401 pos = pos->prev_frag; 5736 pos = pos->prev_frag;
5402 GNUNET_CONTAINER_MDLL_insert_after (frag, 5737 GNUNET_CONTAINER_MDLL_insert_after (frag,
5403 fp->head_frag, 5738 fp->head_frag,
@@ -5424,11 +5759,11 @@ tracker_update_out_cb (void *cls)
5424 struct Queue *queue = cls; 5759 struct Queue *queue = cls;
5425 struct Neighbour *n = queue->neighbour; 5760 struct Neighbour *n = queue->neighbour;
5426 5761
5427 if (NULL == n->pending_msg_head) { 5762 if (NULL == n->pending_msg_head)
5428 GNUNET_log ( 5763 {
5429 GNUNET_ERROR_TYPE_DEBUG, 5764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5430 "Bandwidth allocation updated for empty transmission queue `%s'\n", 5765 "Bandwidth allocation updated for empty transmission queue `%s'\n",
5431 queue->address); 5766 queue->address);
5432 return; /* no message pending, nothing to do here! */ 5767 return; /* no message pending, nothing to do here! */
5433 } 5768 }
5434 GNUNET_SCHEDULER_cancel (queue->transmit_task); 5769 GNUNET_SCHEDULER_cancel (queue->transmit_task);
@@ -5446,7 +5781,7 @@ tracker_update_out_cb (void *cls)
5446static void 5781static void
5447tracker_excess_out_cb (void *cls) 5782tracker_excess_out_cb (void *cls)
5448{ 5783{
5449 (void)cls; 5784 (void) cls;
5450 5785
5451 /* FIXME: trigger excess bandwidth report to core? Right now, 5786 /* FIXME: trigger excess bandwidth report to core? Right now,
5452 this is done internally within transport_api2_core already, 5787 this is done internally within transport_api2_core already,
@@ -5460,6 +5795,7 @@ tracker_excess_out_cb (void *cls)
5460} 5795}
5461 5796
5462 5797
5798
5463/** 5799/**
5464 * Bandwidth tracker informs us that excessive inbound bandwidth was allocated 5800 * Bandwidth tracker informs us that excessive inbound bandwidth was allocated
5465 * which is not being used. 5801 * which is not being used.
@@ -5469,7 +5805,7 @@ tracker_excess_out_cb (void *cls)
5469static void 5805static void
5470tracker_excess_in_cb (void *cls) 5806tracker_excess_in_cb (void *cls)
5471{ 5807{
5472 (void)cls; 5808 (void) cls;
5473 5809
5474 /* TODO: maybe inform somone at this point? */ 5810 /* TODO: maybe inform somone at this point? */
5475 GNUNET_STATISTICS_update (GST_stats, 5811 GNUNET_STATISTICS_update (GST_stats,
@@ -5491,17 +5827,21 @@ handle_del_queue_message (void *cls,
5491{ 5827{
5492 struct TransportClient *tc = cls; 5828 struct TransportClient *tc = cls;
5493 5829
5494 if (CT_COMMUNICATOR != tc->type) { 5830 if (CT_COMMUNICATOR != tc->type)
5831 {
5495 GNUNET_break (0); 5832 GNUNET_break (0);
5496 GNUNET_SERVICE_client_drop (tc->client); 5833 GNUNET_SERVICE_client_drop (tc->client);
5497 return; 5834 return;
5498 } 5835 }
5499 for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; 5836 for (struct Queue *queue = tc->details.communicator.queue_head;
5500 queue = queue->next_client) { 5837 NULL != queue;
5838 queue = queue->next_client)
5839 {
5501 struct Neighbour *neighbour = queue->neighbour; 5840 struct Neighbour *neighbour = queue->neighbour;
5502 5841
5503 if ((dqm->qid != queue->qid) 5842 if ( (dqm->qid != queue->qid) ||
5504 || (0 != GNUNET_memcmp (&dqm->receiver, &neighbour->pid))) 5843 (0 != GNUNET_memcmp (&dqm->receiver,
5844 &neighbour->pid)) )
5505 continue; 5845 continue;
5506 free_queue (queue); 5846 free_queue (queue);
5507 GNUNET_SERVICE_client_continue (tc->client); 5847 GNUNET_SERVICE_client_continue (tc->client);
@@ -5525,7 +5865,8 @@ handle_send_message_ack (void *cls,
5525 struct TransportClient *tc = cls; 5865 struct TransportClient *tc = cls;
5526 struct QueueEntry *qe; 5866 struct QueueEntry *qe;
5527 5867
5528 if (CT_COMMUNICATOR != tc->type) { 5868 if (CT_COMMUNICATOR != tc->type)
5869 {
5529 GNUNET_break (0); 5870 GNUNET_break (0);
5530 GNUNET_SERVICE_client_drop (tc->client); 5871 GNUNET_SERVICE_client_drop (tc->client);
5531 return; 5872 return;
@@ -5533,12 +5874,17 @@ handle_send_message_ack (void *cls,
5533 5874
5534 /* find our queue entry matching the ACK */ 5875 /* find our queue entry matching the ACK */
5535 qe = NULL; 5876 qe = NULL;
5536 for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; 5877 for (struct Queue *queue = tc->details.communicator.queue_head;
5537 queue = queue->next_client) { 5878 NULL != queue;
5538 if (0 != GNUNET_memcmp (&queue->neighbour->pid, &sma->receiver)) 5879 queue = queue->next_client)
5880 {
5881 if (0 != GNUNET_memcmp (&queue->neighbour->pid,
5882 &sma->receiver))
5539 continue; 5883 continue;
5540 for (struct QueueEntry *qep = queue->queue_head; NULL != qep; 5884 for (struct QueueEntry *qep = queue->queue_head;
5541 qep = qep->next) { 5885 NULL != qep;
5886 qep = qep->next)
5887 {
5542 if (qep->mid != sma->mid) 5888 if (qep->mid != sma->mid)
5543 continue; 5889 continue;
5544 qe = qep; 5890 qe = qep;
@@ -5546,7 +5892,8 @@ handle_send_message_ack (void *cls,
5546 } 5892 }
5547 break; 5893 break;
5548 } 5894 }
5549 if (NULL == qe) { 5895 if (NULL == qe)
5896 {
5550 /* this should never happen */ 5897 /* this should never happen */
5551 GNUNET_break (0); 5898 GNUNET_break (0);
5552 GNUNET_SERVICE_client_drop (tc->client); 5899 GNUNET_SERVICE_client_drop (tc->client);
@@ -5560,25 +5907,25 @@ handle_send_message_ack (void *cls,
5560 GNUNET_SERVICE_client_continue (tc->client); 5907 GNUNET_SERVICE_client_continue (tc->client);
5561 5908
5562 /* if applicable, resume transmissions that waited on ACK */ 5909 /* if applicable, resume transmissions that waited on ACK */
5563 if (COMMUNICATOR_TOTAL_QUEUE_LIMIT - 1 5910 if (COMMUNICATOR_TOTAL_QUEUE_LIMIT - 1 == tc->details.communicator.total_queue_length)
5564 == tc->details.communicator.total_queue_length) { 5911 {
5565 /* Communicator dropped below threshold, resume all queues */ 5912 /* Communicator dropped below threshold, resume all queues */
5566 GNUNET_STATISTICS_update ( 5913 GNUNET_STATISTICS_update (GST_stats,
5567 GST_stats, 5914 "# Transmission throttled due to communicator queue limit",
5568 "# Transmission throttled due to communicator queue limit", 5915 -1,
5569 -1, 5916 GNUNET_NO);
5570 GNUNET_NO);
5571 for (struct Queue *queue = tc->details.communicator.queue_head; 5917 for (struct Queue *queue = tc->details.communicator.queue_head;
5572 NULL != queue; 5918 NULL != queue;
5573 queue = queue->next_client) 5919 queue = queue->next_client)
5574 schedule_transmit_on_queue (queue); 5920 schedule_transmit_on_queue (queue);
5575 } else if (QUEUE_LENGTH_LIMIT - 1 == qe->queue->queue_length) { 5921 }
5922 else if (QUEUE_LENGTH_LIMIT - 1 == qe->queue->queue_length)
5923 {
5576 /* queue dropped below threshold; only resume this one queue */ 5924 /* queue dropped below threshold; only resume this one queue */
5577 GNUNET_STATISTICS_update ( 5925 GNUNET_STATISTICS_update (GST_stats,
5578 GST_stats, 5926 "# Transmission throttled due to queue queue limit",
5579 "# Transmission throttled due to queue queue limit", 5927 -1,
5580 -1, 5928 GNUNET_NO);
5581 GNUNET_NO);
5582 schedule_transmit_on_queue (qe->queue); 5929 schedule_transmit_on_queue (qe->queue);
5583 } 5930 }
5584 5931
@@ -5609,14 +5956,22 @@ notify_client_queues (void *cls,
5609 struct Neighbour *neighbour = value; 5956 struct Neighbour *neighbour = value;
5610 5957
5611 GNUNET_assert (CT_MONITOR == tc->type); 5958 GNUNET_assert (CT_MONITOR == tc->type);
5612 for (struct Queue *q = neighbour->queue_head; NULL != q; 5959 for (struct Queue *q = neighbour->queue_head;
5613 q = q->next_neighbour) { 5960 NULL != q;
5614 struct MonitorEvent me = {.rtt = q->rtt, 5961 q = q->next_neighbour)
5615 .cs = q->cs, 5962 {
5616 .num_msg_pending = q->num_msg_pending, 5963 struct MonitorEvent me = {
5617 .num_bytes_pending = q->num_bytes_pending}; 5964 .rtt = q->rtt,
5618 5965 .cs = q->cs,
5619 notify_monitor (tc, pid, q->address, q->nt, &me); 5966 .num_msg_pending = q->num_msg_pending,
5967 .num_bytes_pending = q->num_bytes_pending
5968 };
5969
5970 notify_monitor (tc,
5971 pid,
5972 q->address,
5973 q->nt,
5974 &me);
5620 } 5975 }
5621 return GNUNET_OK; 5976 return GNUNET_OK;
5622} 5977}
@@ -5634,7 +5989,8 @@ handle_monitor_start (void *cls,
5634{ 5989{
5635 struct TransportClient *tc = cls; 5990 struct TransportClient *tc = cls;
5636 5991
5637 if (CT_NONE != tc->type) { 5992 if (CT_NONE != tc->type)
5993 {
5638 GNUNET_break (0); 5994 GNUNET_break (0);
5639 GNUNET_SERVICE_client_drop (tc->client); 5995 GNUNET_SERVICE_client_drop (tc->client);
5640 return; 5996 return;
@@ -5642,7 +5998,9 @@ handle_monitor_start (void *cls,
5642 tc->type = CT_MONITOR; 5998 tc->type = CT_MONITOR;
5643 tc->details.monitor.peer = start->peer; 5999 tc->details.monitor.peer = start->peer;
5644 tc->details.monitor.one_shot = ntohl (start->one_shot); 6000 tc->details.monitor.one_shot = ntohl (start->one_shot);
5645 GNUNET_CONTAINER_multipeermap_iterate (neighbours, &notify_client_queues, tc); 6001 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
6002 &notify_client_queues,
6003 tc);
5646 GNUNET_SERVICE_client_mark_monitor (tc->client); 6004 GNUNET_SERVICE_client_mark_monitor (tc->client);
5647 GNUNET_SERVICE_client_continue (tc->client); 6005 GNUNET_SERVICE_client_continue (tc->client);
5648} 6006}
@@ -5658,16 +6016,19 @@ handle_monitor_start (void *cls,
5658static struct TransportClient * 6016static struct TransportClient *
5659lookup_communicator (const char *prefix) 6017lookup_communicator (const char *prefix)
5660{ 6018{
5661 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) { 6019 for (struct TransportClient *tc = clients_head;
6020 NULL != tc;
6021 tc = tc->next)
6022 {
5662 if (CT_COMMUNICATOR != tc->type) 6023 if (CT_COMMUNICATOR != tc->type)
5663 continue; 6024 continue;
5664 if (0 == strcmp (prefix, tc->details.communicator.address_prefix)) 6025 if (0 == strcmp (prefix,
6026 tc->details.communicator.address_prefix))
5665 return tc; 6027 return tc;
5666 } 6028 }
5667 GNUNET_log ( 6029 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5668 GNUNET_ERROR_TYPE_WARNING, 6030 "Somone suggested use of communicator for `%s', but we do not have such a communicator!\n",
5669 "Somone suggested use of communicator for `%s', but we do not have such a communicator!\n", 6031 prefix);
5670 prefix);
5671 return NULL; 6032 return NULL;
5672} 6033}
5673 6034
@@ -5680,7 +6041,8 @@ lookup_communicator (const char *prefix)
5680 * @param address the address to try 6041 * @param address the address to try
5681 */ 6042 */
5682static void 6043static void
5683suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address) 6044suggest_to_connect (const struct GNUNET_PeerIdentity *pid,
6045 const char *address)
5684{ 6046{
5685 static uint32_t idgen; 6047 static uint32_t idgen;
5686 struct TransportClient *tc; 6048 struct TransportClient *tc;
@@ -5690,23 +6052,24 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
5690 size_t alen; 6052 size_t alen;
5691 6053
5692 prefix = GNUNET_HELLO_address_to_prefix (address); 6054 prefix = GNUNET_HELLO_address_to_prefix (address);
5693 if (NULL == prefix) { 6055 if (NULL == prefix)
6056 {
5694 GNUNET_break (0); /* We got an invalid address!? */ 6057 GNUNET_break (0); /* We got an invalid address!? */
5695 return; 6058 return;
5696 } 6059 }
5697 tc = lookup_communicator (prefix); 6060 tc = lookup_communicator (prefix);
5698 if (NULL == tc) { 6061 if (NULL == tc)
5699 GNUNET_STATISTICS_update ( 6062 {
5700 GST_stats, 6063 GNUNET_STATISTICS_update (GST_stats,
5701 "# Suggestions ignored due to missing communicator", 6064 "# Suggestions ignored due to missing communicator",
5702 1, 6065 1,
5703 GNUNET_NO); 6066 GNUNET_NO);
5704 return; 6067 return;
5705 } 6068 }
5706 /* forward suggestion for queue creation to communicator */ 6069 /* forward suggestion for queue creation to communicator */
5707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6070 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5708 "Request #%u for `%s' communicator to create queue to `%s'\n", 6071 "Request #%u for `%s' communicator to create queue to `%s'\n",
5709 (unsigned int)idgen, 6072 (unsigned int) idgen,
5710 prefix, 6073 prefix,
5711 address); 6074 address);
5712 alen = strlen (address) + 1; 6075 alen = strlen (address) + 1;
@@ -5715,8 +6078,11 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
5715 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE); 6078 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
5716 cqm->request_id = htonl (idgen++); 6079 cqm->request_id = htonl (idgen++);
5717 cqm->receiver = *pid; 6080 cqm->receiver = *pid;
5718 memcpy (&cqm[1], address, alen); 6081 memcpy (&cqm[1],
5719 GNUNET_MQ_send (tc->mq, env); 6082 address,
6083 alen);
6084 GNUNET_MQ_send (tc->mq,
6085 env);
5720} 6086}
5721 6087
5722 6088
@@ -5728,21 +6094,22 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
5728 * @param vs state to derive validation challenge from 6094 * @param vs state to derive validation challenge from
5729 */ 6095 */
5730static void 6096static void
5731validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs) 6097validation_transmit_on_queue (struct Queue *q,
6098 struct ValidationState *vs)
5732{ 6099{
5733 struct GNUNET_MQ_Envelope *env; 6100 struct GNUNET_MQ_Envelope *env;
5734 struct TransportValidationChallenge *tvc; 6101 struct TransportValidationChallenge *tvc;
5735 6102
5736 vs->last_challenge_use = GNUNET_TIME_absolute_get (); 6103 vs->last_challenge_use = GNUNET_TIME_absolute_get ();
5737 env = GNUNET_MQ_msg ( 6104 env = GNUNET_MQ_msg (tvc,
5738 tvc, 6105 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
5739 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
5740 tvc->reserved = htonl (0); 6106 tvc->reserved = htonl (0);
5741 tvc->challenge = vs->challenge; 6107 tvc->challenge = vs->challenge;
5742 tvc->sender_time = GNUNET_TIME_absolute_hton (vs->last_challenge_use); 6108 tvc->sender_time = GNUNET_TIME_absolute_hton (vs->last_challenge_use);
5743 // FIXME: not so easy, need to BOX this message 6109 // FIXME: not so easy, need to BOX this message
5744 // in a transmission request! (mistake also done elsewhere!) 6110 // in a transmission request! (mistake also done elsewhere!)
5745 GNUNET_MQ_send (q->tc->mq, env); 6111 GNUNET_MQ_send (q->tc->mq,
6112 env);
5746} 6113}
5747 6114
5748 6115
@@ -5758,43 +6125,50 @@ validation_start_cb (void *cls)
5758 struct Neighbour *n; 6125 struct Neighbour *n;
5759 struct Queue *q; 6126 struct Queue *q;
5760 6127
5761 (void)cls; 6128 (void) cls;
5762 validation_task = NULL; 6129 validation_task = NULL;
5763 vs = GNUNET_CONTAINER_heap_peek (validation_heap); 6130 vs = GNUNET_CONTAINER_heap_peek (validation_heap);
5764 /* drop validations past their expiration */ 6131 /* drop validations past their expiration */
5765 while ( 6132 while ( (NULL != vs) &&
5766 (NULL != vs) 6133 (0 == GNUNET_TIME_absolute_get_remaining (vs->valid_until).rel_value_us) )
5767 && (0 6134 {
5768 == GNUNET_TIME_absolute_get_remaining (vs->valid_until).rel_value_us)) {
5769 free_validation_state (vs); 6135 free_validation_state (vs);
5770 vs = GNUNET_CONTAINER_heap_peek (validation_heap); 6136 vs = GNUNET_CONTAINER_heap_peek (validation_heap);
5771 } 6137 }
5772 if (NULL == vs) 6138 if (NULL == vs)
5773 return; /* woopsie, no more addresses known, should only 6139 return; /* woopsie, no more addresses known, should only
5774 happen if we're really a lonely peer */ 6140 happen if we're really a lonely peer */
5775 n = GNUNET_CONTAINER_multipeermap_get (neighbours, &vs->pid); 6141 n = GNUNET_CONTAINER_multipeermap_get (neighbours,
6142 &vs->pid);
5776 q = NULL; 6143 q = NULL;
5777 if (NULL != n) { 6144 if (NULL != n)
5778 for (struct Queue *pos = n->queue_head; NULL != pos; 6145 {
5779 pos = pos->next_neighbour) { 6146 for (struct Queue *pos = n->queue_head;
5780 if (0 == strcmp (pos->address, vs->address)) { 6147 NULL != pos;
6148 pos = pos->next_neighbour)
6149 {
6150 if (0 == strcmp (pos->address,
6151 vs->address))
6152 {
5781 q = pos; 6153 q = pos;
5782 break; 6154 break;
5783 } 6155 }
5784 } 6156 }
5785 } 6157 }
5786 if (NULL == q) { 6158 if (NULL == q)
6159 {
5787 vs->awaiting_queue = GNUNET_YES; 6160 vs->awaiting_queue = GNUNET_YES;
5788 suggest_to_connect (&vs->pid, vs->address); 6161 suggest_to_connect (&vs->pid,
5789 } else 6162 vs->address);
5790 validation_transmit_on_queue (q, vs); 6163 }
6164 else
6165 validation_transmit_on_queue (q,
6166 vs);
5791 /* Finally, reschedule next attempt */ 6167 /* Finally, reschedule next attempt */
5792 vs->challenge_backoff 6168 vs->challenge_backoff = GNUNET_TIME_randomized_backoff (vs->challenge_backoff,
5793 = GNUNET_TIME_randomized_backoff (vs->challenge_backoff, 6169 MAX_VALIDATION_CHALLENGE_FREQ);
5794 MAX_VALIDATION_CHALLENGE_FREQ); 6170 update_next_challenge_time (vs,
5795 update_next_challenge_time ( 6171 GNUNET_TIME_relative_to_absolute (vs->challenge_backoff));
5796 vs,
5797 GNUNET_TIME_relative_to_absolute (vs->challenge_backoff));
5798} 6172}
5799 6173
5800 6174
@@ -5823,6 +6197,7 @@ struct QueueQualityContext
5823 * k-th queue in @e q. 6197 * k-th queue in @e q.
5824 */ 6198 */
5825 unsigned int k; 6199 unsigned int k;
6200
5826}; 6201};
5827 6202
5828 6203
@@ -5846,9 +6221,12 @@ check_connection_quality (void *cls,
5846 struct Neighbour *n = value; 6221 struct Neighbour *n = value;
5847 int do_inc; 6222 int do_inc;
5848 6223
5849 (void)pid; 6224 (void) pid;
5850 do_inc = GNUNET_NO; 6225 do_inc = GNUNET_NO;
5851 for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) { 6226 for (struct Queue *q = n->queue_head;
6227 NULL != q;
6228 q = q->next_neighbour)
6229 {
5852 if (0 != q->distance) 6230 if (0 != q->distance)
5853 continue; /* DV does not count */ 6231 continue; /* DV does not count */
5854 ctx->num_queues++; 6232 ctx->num_queues++;
@@ -5884,34 +6262,42 @@ start_dv_learn (void *cls)
5884 struct GNUNET_MQ_Envelope *env; 6262 struct GNUNET_MQ_Envelope *env;
5885 struct TransportDVLearn *dvl; 6263 struct TransportDVLearn *dvl;
5886 6264
5887 (void)cls; 6265 (void) cls;
5888 dvlearn_task = NULL; 6266 dvlearn_task = NULL;
5889 if (0 == GNUNET_CONTAINER_multipeermap_size (neighbours)) 6267 if (0 ==
6268 GNUNET_CONTAINER_multipeermap_size (neighbours))
5890 return; /* lost all connectivity, cannot do learning */ 6269 return; /* lost all connectivity, cannot do learning */
5891 qqc.quality_count = 0; 6270 qqc.quality_count = 0;
5892 qqc.num_queues = 0; 6271 qqc.num_queues = 0;
5893 GNUNET_CONTAINER_multipeermap_iterate (neighbours, 6272 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
5894 &check_connection_quality, 6273 &check_connection_quality,
5895 &qqc); 6274 &qqc);
5896 if (qqc.quality_count > DV_LEARN_QUALITY_THRESHOLD) { 6275 if (qqc.quality_count > DV_LEARN_QUALITY_THRESHOLD)
6276 {
5897 struct GNUNET_TIME_Relative delay; 6277 struct GNUNET_TIME_Relative delay;
5898 unsigned int factor; 6278 unsigned int factor;
5899 6279
5900 /* scale our retries by how far we are above the threshold */ 6280 /* scale our retries by how far we are above the threshold */
5901 factor = qqc.quality_count / DV_LEARN_QUALITY_THRESHOLD; 6281 factor = qqc.quality_count / DV_LEARN_QUALITY_THRESHOLD;
5902 delay = GNUNET_TIME_relative_multiply (DV_LEARN_BASE_FREQUENCY, factor); 6282 delay = GNUNET_TIME_relative_multiply (DV_LEARN_BASE_FREQUENCY,
5903 dvlearn_task = GNUNET_SCHEDULER_add_delayed (delay, &start_dv_learn, NULL); 6283 factor);
6284 dvlearn_task = GNUNET_SCHEDULER_add_delayed (delay,
6285 &start_dv_learn,
6286 NULL);
5904 return; 6287 return;
5905 } 6288 }
5906 /* remove old entries in #dvlearn_map if it has grown too big */ 6289 /* remove old entries in #dvlearn_map if it has grown too big */
5907 while (MAX_DV_LEARN_PENDING 6290 while (MAX_DV_LEARN_PENDING >=
5908 >= GNUNET_CONTAINER_multishortmap_size (dvlearn_map)) { 6291 GNUNET_CONTAINER_multishortmap_size (dvlearn_map))
6292 {
5909 lle = lle_tail; 6293 lle = lle_tail;
5910 GNUNET_assert (GNUNET_YES 6294 GNUNET_assert (GNUNET_YES ==
5911 == GNUNET_CONTAINER_multishortmap_remove (dvlearn_map, 6295 GNUNET_CONTAINER_multishortmap_remove (dvlearn_map,
5912 &lle->challenge, 6296 &lle->challenge,
5913 lle)); 6297 lle));
5914 GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle); 6298 GNUNET_CONTAINER_DLL_remove (lle_head,
6299 lle_tail,
6300 lle);
5915 GNUNET_free (lle); 6301 GNUNET_free (lle);
5916 } 6302 }
5917 /* setup data structure for learning */ 6303 /* setup data structure for learning */
@@ -5919,33 +6305,37 @@ start_dv_learn (void *cls)
5919 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, 6305 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
5920 &lle->challenge, 6306 &lle->challenge,
5921 sizeof (lle->challenge)); 6307 sizeof (lle->challenge));
5922 GNUNET_CONTAINER_DLL_insert (lle_head, lle_tail, lle); 6308 GNUNET_CONTAINER_DLL_insert (lle_head,
5923 GNUNET_break (GNUNET_YES 6309 lle_tail,
5924 == GNUNET_CONTAINER_multishortmap_put ( 6310 lle);
5925 dvlearn_map, 6311 GNUNET_break (GNUNET_YES ==
5926 &lle->challenge, 6312 GNUNET_CONTAINER_multishortmap_put (dvlearn_map,
5927 lle, 6313 &lle->challenge,
5928 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 6314 lle,
5929 env = GNUNET_MQ_msg (dvl, GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN); 6315 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
6316 env = GNUNET_MQ_msg (dvl,
6317 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN);
5930 dvl->num_hops = htons (0); 6318 dvl->num_hops = htons (0);
5931 dvl->bidirectional = htons (0); 6319 dvl->bidirectional = htons (0);
5932 dvl->non_network_delay = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO); 6320 dvl->non_network_delay = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO);
5933 { 6321 {
5934 struct DvInitPS dvip = {.purpose.purpose = htonl ( 6322 struct DvInitPS dvip = {
5935 GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR), 6323 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
5936 .purpose.size = htonl (sizeof (dvip)), 6324 .purpose.size = htonl (sizeof (dvip)),
5937 .challenge = lle->challenge}; 6325 .challenge = lle->challenge
6326 };
5938 6327
5939 GNUNET_assert (GNUNET_OK 6328 GNUNET_assert (GNUNET_OK ==
5940 == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, 6329 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
5941 &dvip.purpose, 6330 &dvip.purpose,
5942 &dvl->init_sig)); 6331 &dvl->init_sig));
5943 } 6332 }
5944 dvl->initiator = GST_my_identity; 6333 dvl->initiator = GST_my_identity;
5945 dvl->challenge = lle->challenge; 6334 dvl->challenge = lle->challenge;
5946 6335
5947 qqc.quality_count = 0; 6336 qqc.quality_count = 0;
5948 qqc.k = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, qqc.num_queues); 6337 qqc.k = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
6338 qqc.num_queues);
5949 qqc.num_queues = 0; 6339 qqc.num_queues = 0;
5950 qqc.q = NULL; 6340 qqc.q = NULL;
5951 GNUNET_CONTAINER_multipeermap_iterate (neighbours, 6341 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
@@ -5957,14 +6347,15 @@ start_dv_learn (void *cls)
5957 lle->launch_time = GNUNET_TIME_absolute_get (); 6347 lle->launch_time = GNUNET_TIME_absolute_get ();
5958 // FIXME: not so easy, need to BOX this message 6348 // FIXME: not so easy, need to BOX this message
5959 // in a transmission request! (mistake also done elsewhere!) 6349 // in a transmission request! (mistake also done elsewhere!)
5960 GNUNET_MQ_send (qqc.q->tc->mq, env); 6350 GNUNET_MQ_send (qqc.q->tc->mq,
6351 env);
5961 6352
5962 /* reschedule this job, randomizing the time it runs (but no 6353 /* reschedule this job, randomizing the time it runs (but no
5963 actual backoff!) */ 6354 actual backoff!) */
5964 dvlearn_task = GNUNET_SCHEDULER_add_delayed ( 6355 dvlearn_task
5965 GNUNET_TIME_randomize (DV_LEARN_BASE_FREQUENCY), 6356 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_randomize (DV_LEARN_BASE_FREQUENCY),
5966 &start_dv_learn, 6357 &start_dv_learn,
5967 NULL); 6358 NULL);
5968} 6359}
5969 6360
5970 6361
@@ -5985,11 +6376,14 @@ check_validation_request_pending (void *cls,
5985 struct Queue *q = cls; 6376 struct Queue *q = cls;
5986 struct ValidationState *vs = value; 6377 struct ValidationState *vs = value;
5987 6378
5988 (void)pid; 6379 (void) pid;
5989 if ((GNUNET_YES == vs->awaiting_queue) 6380 if ( (GNUNET_YES == vs->awaiting_queue) &&
5990 && (0 == strcmp (vs->address, q->address))) { 6381 (0 == strcmp (vs->address,
6382 q->address)) )
6383 {
5991 vs->awaiting_queue = GNUNET_NO; 6384 vs->awaiting_queue = GNUNET_NO;
5992 validation_transmit_on_queue (q, vs); 6385 validation_transmit_on_queue (q,
6386 vs);
5993 return GNUNET_NO; 6387 return GNUNET_NO;
5994 } 6388 }
5995 return GNUNET_OK; 6389 return GNUNET_OK;
@@ -6012,7 +6406,8 @@ handle_add_queue_message (void *cls,
6012 const char *addr; 6406 const char *addr;
6013 uint16_t addr_len; 6407 uint16_t addr_len;
6014 6408
6015 if (ntohl (aqm->mtu) <= sizeof (struct TransportFragmentBox)) { 6409 if (ntohl (aqm->mtu) <= sizeof (struct TransportFragmentBox))
6410 {
6016 /* MTU so small as to be useless for transmissions, 6411 /* MTU so small as to be useless for transmissions,
6017 required for #fragment_message()! */ 6412 required for #fragment_message()! */
6018 GNUNET_break_op (0); 6413 GNUNET_break_op (0);
@@ -6020,29 +6415,30 @@ handle_add_queue_message (void *cls,
6020 return; 6415 return;
6021 } 6416 }
6022 neighbour = lookup_neighbour (&aqm->receiver); 6417 neighbour = lookup_neighbour (&aqm->receiver);
6023 if (NULL == neighbour) { 6418 if (NULL == neighbour)
6419 {
6024 neighbour = GNUNET_new (struct Neighbour); 6420 neighbour = GNUNET_new (struct Neighbour);
6025 neighbour->earliest_timeout = GNUNET_TIME_UNIT_FOREVER_ABS; 6421 neighbour->earliest_timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
6026 neighbour->pid = aqm->receiver; 6422 neighbour->pid = aqm->receiver;
6027 GNUNET_assert (GNUNET_OK 6423 GNUNET_assert (GNUNET_OK ==
6028 == GNUNET_CONTAINER_multipeermap_put ( 6424 GNUNET_CONTAINER_multipeermap_put (neighbours,
6029 neighbours, 6425 &neighbour->pid,
6030 &neighbour->pid, 6426 neighbour,
6031 neighbour, 6427 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
6032 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 6428 cores_send_connect_info (&neighbour->pid,
6033 cores_send_connect_info (&neighbour->pid, GNUNET_BANDWIDTH_ZERO); 6429 GNUNET_BANDWIDTH_ZERO);
6034 } 6430 }
6035 addr_len = ntohs (aqm->header.size) - sizeof (*aqm); 6431 addr_len = ntohs (aqm->header.size) - sizeof (*aqm);
6036 addr = (const char *)&aqm[1]; 6432 addr = (const char *) &aqm[1];
6037 6433
6038 queue = GNUNET_malloc (sizeof (struct Queue) + addr_len); 6434 queue = GNUNET_malloc (sizeof (struct Queue) + addr_len);
6039 queue->tc = tc; 6435 queue->tc = tc;
6040 queue->address = (const char *)&queue[1]; 6436 queue->address = (const char *) &queue[1];
6041 queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL; 6437 queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL;
6042 queue->qid = aqm->qid; 6438 queue->qid = aqm->qid;
6043 queue->mtu = ntohl (aqm->mtu); 6439 queue->mtu = ntohl (aqm->mtu);
6044 queue->nt = (enum GNUNET_NetworkType)ntohl (aqm->nt); 6440 queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt);
6045 queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus)ntohl (aqm->cs); 6441 queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs);
6046 queue->neighbour = neighbour; 6442 queue->neighbour = neighbour;
6047 GNUNET_BANDWIDTH_tracker_init2 (&queue->tracker_in, 6443 GNUNET_BANDWIDTH_tracker_init2 (&queue->tracker_in,
6048 &tracker_update_in_cb, 6444 &tracker_update_in_cb,
@@ -6058,12 +6454,20 @@ handle_add_queue_message (void *cls,
6058 GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S, 6454 GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S,
6059 &tracker_excess_out_cb, 6455 &tracker_excess_out_cb,
6060 queue); 6456 queue);
6061 memcpy (&queue[1], addr, addr_len); 6457 memcpy (&queue[1],
6458 addr,
6459 addr_len);
6062 /* notify monitors about new queue */ 6460 /* notify monitors about new queue */
6063 { 6461 {
6064 struct MonitorEvent me = {.rtt = queue->rtt, .cs = queue->cs}; 6462 struct MonitorEvent me = {
6463 .rtt = queue->rtt,
6464 .cs = queue->cs
6465 };
6065 6466
6066 notify_monitors (&neighbour->pid, queue->address, queue->nt, &me); 6467 notify_monitors (&neighbour->pid,
6468 queue->address,
6469 queue->nt,
6470 &me);
6067 } 6471 }
6068 GNUNET_CONTAINER_MDLL_insert (neighbour, 6472 GNUNET_CONTAINER_MDLL_insert (neighbour,
6069 neighbour->queue_head, 6473 neighbour->queue_head,
@@ -6074,14 +6478,14 @@ handle_add_queue_message (void *cls,
6074 tc->details.communicator.queue_tail, 6478 tc->details.communicator.queue_tail,
6075 queue); 6479 queue);
6076 /* check if valdiations are waiting for the queue */ 6480 /* check if valdiations are waiting for the queue */
6077 (void)GNUNET_CONTAINER_multipeermap_get_multiple ( 6481 (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
6078 validation_map, 6482 &aqm->receiver,
6079 &aqm->receiver, 6483 &check_validation_request_pending,
6080 &check_validation_request_pending, 6484 queue);
6081 queue);
6082 /* might be our first queue, try launching DV learning */ 6485 /* might be our first queue, try launching DV learning */
6083 if (NULL == dvlearn_task) 6486 if (NULL == dvlearn_task)
6084 dvlearn_task = GNUNET_SCHEDULER_add_now (&start_dv_learn, NULL); 6487 dvlearn_task = GNUNET_SCHEDULER_add_now (&start_dv_learn,
6488 NULL);
6085 GNUNET_SERVICE_client_continue (tc->client); 6489 GNUNET_SERVICE_client_continue (tc->client);
6086} 6490}
6087 6491
@@ -6099,7 +6503,8 @@ handle_queue_create_ok (void *cls,
6099{ 6503{
6100 struct TransportClient *tc = cls; 6504 struct TransportClient *tc = cls;
6101 6505
6102 if (CT_COMMUNICATOR != tc->type) { 6506 if (CT_COMMUNICATOR != tc->type)
6507 {
6103 GNUNET_break (0); 6508 GNUNET_break (0);
6104 GNUNET_SERVICE_client_drop (tc->client); 6509 GNUNET_SERVICE_client_drop (tc->client);
6105 return; 6510 return;
@@ -6110,69 +6515,72 @@ handle_queue_create_ok (void *cls,
6110 GNUNET_NO); 6515 GNUNET_NO);
6111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6112 "Request #%u for communicator to create queue succeeded\n", 6517 "Request #%u for communicator to create queue succeeded\n",
6113 (unsigned int)ntohs (cqr->request_id)); 6518 (unsigned int) ntohs (cqr->request_id));
6114 GNUNET_SERVICE_client_continue (tc->client); 6519 GNUNET_SERVICE_client_continue (tc->client);
6115} 6520}
6116 6521
6117 6522
6118/** 6523/**
6119 * Communicator tells us that our request to create a queue failed. This usually 6524 * Communicator tells us that our request to create a queue failed. This usually
6120 * indicates that the provided address is simply invalid or that the 6525 * indicates that the provided address is simply invalid or that the communicator's
6121 * communicator's resources are exhausted. 6526 * resources are exhausted.
6122 * 6527 *
6123 * @param cls the `struct TransportClient` 6528 * @param cls the `struct TransportClient`
6124 * @param cqr failure message 6529 * @param cqr failure message
6125 */ 6530 */
6126static void 6531static void
6127handle_queue_create_fail ( 6532handle_queue_create_fail (void *cls,
6128 void *cls, 6533 const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
6129 const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
6130{ 6534{
6131 struct TransportClient *tc = cls; 6535 struct TransportClient *tc = cls;
6132 6536
6133 if (CT_COMMUNICATOR != tc->type) { 6537 if (CT_COMMUNICATOR != tc->type)
6538 {
6134 GNUNET_break (0); 6539 GNUNET_break (0);
6135 GNUNET_SERVICE_client_drop (tc->client); 6540 GNUNET_SERVICE_client_drop (tc->client);
6136 return; 6541 return;
6137 } 6542 }
6138 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6139 "Request #%u for communicator to create queue failed\n", 6544 "Request #%u for communicator to create queue failed\n",
6140 (unsigned int)ntohs (cqr->request_id)); 6545 (unsigned int) ntohs (cqr->request_id));
6141 GNUNET_STATISTICS_update ( 6546 GNUNET_STATISTICS_update (GST_stats,
6142 GST_stats, 6547 "# Suggestions failed in queue creation at communicator",
6143 "# Suggestions failed in queue creation at communicator", 6548 1,
6144 1, 6549 GNUNET_NO);
6145 GNUNET_NO);
6146 GNUNET_SERVICE_client_continue (tc->client); 6550 GNUNET_SERVICE_client_continue (tc->client);
6147} 6551}
6148 6552
6149 6553
6150/** 6554/**
6151 * We have received a `struct ExpressPreferenceMessage` from an application 6555 * We have received a `struct ExpressPreferenceMessage` from an application client.
6152 * client.
6153 * 6556 *
6154 * @param cls handle to the client 6557 * @param cls handle to the client
6155 * @param msg the start message 6558 * @param msg the start message
6156 */ 6559 */
6157static void 6560static void
6158handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg) 6561handle_suggest_cancel (void *cls,
6562 const struct ExpressPreferenceMessage *msg)
6159{ 6563{
6160 struct TransportClient *tc = cls; 6564 struct TransportClient *tc = cls;
6161 struct PeerRequest *pr; 6565 struct PeerRequest *pr;
6162 6566
6163 if (CT_APPLICATION != tc->type) { 6567 if (CT_APPLICATION != tc->type)
6568 {
6164 GNUNET_break (0); 6569 GNUNET_break (0);
6165 GNUNET_SERVICE_client_drop (tc->client); 6570 GNUNET_SERVICE_client_drop (tc->client);
6166 return; 6571 return;
6167 } 6572 }
6168 pr = GNUNET_CONTAINER_multipeermap_get (tc->details.application.requests, 6573 pr = GNUNET_CONTAINER_multipeermap_get (tc->details.application.requests,
6169 &msg->peer); 6574 &msg->peer);
6170 if (NULL == pr) { 6575 if (NULL == pr)
6576 {
6171 GNUNET_break (0); 6577 GNUNET_break (0);
6172 GNUNET_SERVICE_client_drop (tc->client); 6578 GNUNET_SERVICE_client_drop (tc->client);
6173 return; 6579 return;
6174 } 6580 }
6175 (void)stop_peer_request (tc, &pr->pid, pr); 6581 (void) stop_peer_request (tc,
6582 &pr->pid,
6583 pr);
6176 GNUNET_SERVICE_client_continue (tc->client); 6584 GNUNET_SERVICE_client_continue (tc->client);
6177} 6585}
6178 6586
@@ -6186,12 +6594,11 @@ handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg)
6186 * @return #GNUNET_OK 6594 * @return #GNUNET_OK
6187 */ 6595 */
6188static int 6596static int
6189check_address_consider_verify ( 6597check_address_consider_verify (void *cls,
6190 void *cls, 6598 const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
6191 const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
6192{ 6599{
6193 (void)cls; 6600 (void) cls;
6194 (void)hdr; 6601 (void) hdr;
6195 return GNUNET_OK; 6602 return GNUNET_OK;
6196} 6603}
6197 6604
@@ -6230,8 +6637,9 @@ check_known_address (void *cls,
6230 struct CheckKnownAddressContext *ckac = cls; 6637 struct CheckKnownAddressContext *ckac = cls;
6231 struct ValidationState *vs = value; 6638 struct ValidationState *vs = value;
6232 6639
6233 (void)pid; 6640 (void) pid;
6234 if (0 != strcmp (vs->address, ckac->address)) 6641 if (0 != strcmp (vs->address,
6642 ckac->address))
6235 return GNUNET_OK; 6643 return GNUNET_OK;
6236 ckac->vs = vs; 6644 ckac->vs = vs;
6237 return GNUNET_NO; 6645 return GNUNET_NO;
@@ -6252,29 +6660,32 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid,
6252{ 6660{
6253 struct GNUNET_TIME_Absolute now; 6661 struct GNUNET_TIME_Absolute now;
6254 struct ValidationState *vs; 6662 struct ValidationState *vs;
6255 struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL}; 6663 struct CheckKnownAddressContext ckac = {
6664 .address = address,
6665 .vs = NULL
6666 };
6256 6667
6257 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) 6668 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
6258 return; /* expired */ 6669 return; /* expired */
6259 (void)GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, 6670 (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
6260 pid, 6671 pid,
6261 &check_known_address, 6672 &check_known_address,
6262 &ckac); 6673 &ckac);
6263 if (NULL != (vs = ckac.vs)) { 6674 if (NULL != (vs = ckac.vs))
6264 /* if 'vs' is not currently valid, we need to speed up retrying the 6675 {
6265 * validation */ 6676 /* if 'vs' is not currently valid, we need to speed up retrying the validation */
6266 if (vs->validated_until.abs_value_us < vs->next_challenge.abs_value_us) { 6677 if (vs->validated_until.abs_value_us < vs->next_challenge.abs_value_us)
6678 {
6267 /* reduce backoff as we got a fresh advertisement */ 6679 /* reduce backoff as we got a fresh advertisement */
6268 vs->challenge_backoff = GNUNET_TIME_relative_min ( 6680 vs->challenge_backoff = GNUNET_TIME_relative_min (FAST_VALIDATION_CHALLENGE_FREQ,
6269 FAST_VALIDATION_CHALLENGE_FREQ, 6681 GNUNET_TIME_relative_divide (vs->challenge_backoff,
6270 GNUNET_TIME_relative_divide (vs->challenge_backoff, 2)); 6682 2));
6271 update_next_challenge_time ( 6683 update_next_challenge_time (vs,
6272 vs, 6684 GNUNET_TIME_relative_to_absolute (vs->challenge_backoff));
6273 GNUNET_TIME_relative_to_absolute (vs->challenge_backoff));
6274 } 6685 }
6275 return; 6686 return;
6276 } 6687 }
6277 now = GNUNET_TIME_absolute_get (); 6688 now = GNUNET_TIME_absolute_get();
6278 vs = GNUNET_new (struct ValidationState); 6689 vs = GNUNET_new (struct ValidationState);
6279 vs->pid = *pid; 6690 vs->pid = *pid;
6280 vs->valid_until = expiration; 6691 vs->valid_until = expiration;
@@ -6284,13 +6695,13 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid,
6284 &vs->challenge, 6695 &vs->challenge,
6285 sizeof (vs->challenge)); 6696 sizeof (vs->challenge));
6286 vs->address = GNUNET_strdup (address); 6697 vs->address = GNUNET_strdup (address);
6287 GNUNET_assert (GNUNET_YES 6698 GNUNET_assert (GNUNET_YES ==
6288 == GNUNET_CONTAINER_multipeermap_put ( 6699 GNUNET_CONTAINER_multipeermap_put (validation_map,
6289 validation_map, 6700 &vs->pid,
6290 &vs->pid, 6701 vs,
6291 vs, 6702 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
6292 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 6703 update_next_challenge_time (vs,
6293 update_next_challenge_time (vs, now); 6704 now);
6294} 6705}
6295 6706
6296 6707
@@ -6309,42 +6720,48 @@ handle_hello (void *cls,
6309 struct PeerRequest *pr = cls; 6720 struct PeerRequest *pr = cls;
6310 const char *val; 6721 const char *val;
6311 6722
6312 if (NULL != emsg) { 6723 if (NULL != emsg)
6724 {
6313 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 6725 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
6314 "Got failure from PEERSTORE: %s\n", 6726 "Got failure from PEERSTORE: %s\n",
6315 emsg); 6727 emsg);
6316 return; 6728 return;
6317 } 6729 }
6318 val = record->value; 6730 val = record->value;
6319 if ((0 == record->value_size) || ('\0' != val[record->value_size - 1])) { 6731 if ( (0 == record->value_size) ||
6732 ('\0' != val[record->value_size - 1]) )
6733 {
6320 GNUNET_break (0); 6734 GNUNET_break (0);
6321 return; 6735 return;
6322 } 6736 }
6323 start_address_validation (&pr->pid, 6737 start_address_validation (&pr->pid,
6324 (const char *)record->value, 6738 (const char *) record->value,
6325 record->expiry); 6739 record->expiry);
6326} 6740}
6327 6741
6328 6742
6329/** 6743/**
6330 * We have received a `struct ExpressPreferenceMessage` from an application 6744 * We have received a `struct ExpressPreferenceMessage` from an application client.
6331 * client.
6332 * 6745 *
6333 * @param cls handle to the client 6746 * @param cls handle to the client
6334 * @param msg the start message 6747 * @param msg the start message
6335 */ 6748 */
6336static void 6749static void
6337handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg) 6750handle_suggest (void *cls,
6751 const struct ExpressPreferenceMessage *msg)
6338{ 6752{
6339 struct TransportClient *tc = cls; 6753 struct TransportClient *tc = cls;
6340 struct PeerRequest *pr; 6754 struct PeerRequest *pr;
6341 6755
6342 if (CT_NONE == tc->type) { 6756 if (CT_NONE == tc->type)
6757 {
6343 tc->type = CT_APPLICATION; 6758 tc->type = CT_APPLICATION;
6344 tc->details.application.requests 6759 tc->details.application.requests
6345 = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); 6760 = GNUNET_CONTAINER_multipeermap_create (16,
6761 GNUNET_YES);
6346 } 6762 }
6347 if (CT_APPLICATION != tc->type) { 6763 if (CT_APPLICATION != tc->type)
6764 {
6348 GNUNET_break (0); 6765 GNUNET_break (0);
6349 GNUNET_SERVICE_client_drop (tc->client); 6766 GNUNET_SERVICE_client_drop (tc->client);
6350 return; 6767 return;
@@ -6352,19 +6769,19 @@ handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
6352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6353 "Client suggested we talk to %s with preference %d at rate %u\n", 6770 "Client suggested we talk to %s with preference %d at rate %u\n",
6354 GNUNET_i2s (&msg->peer), 6771 GNUNET_i2s (&msg->peer),
6355 (int)ntohl (msg->pk), 6772 (int) ntohl (msg->pk),
6356 (int)ntohl (msg->bw.value__)); 6773 (int) ntohl (msg->bw.value__));
6357 pr = GNUNET_new (struct PeerRequest); 6774 pr = GNUNET_new (struct PeerRequest);
6358 pr->tc = tc; 6775 pr->tc = tc;
6359 pr->pid = msg->peer; 6776 pr->pid = msg->peer;
6360 pr->bw = msg->bw; 6777 pr->bw = msg->bw;
6361 pr->pk = (enum GNUNET_MQ_PreferenceKind)ntohl (msg->pk); 6778 pr->pk = (enum GNUNET_MQ_PreferenceKind) ntohl (msg->pk);
6362 if (GNUNET_YES 6779 if (GNUNET_YES !=
6363 != GNUNET_CONTAINER_multipeermap_put ( 6780 GNUNET_CONTAINER_multipeermap_put (tc->details.application.requests,
6364 tc->details.application.requests, 6781 &pr->pid,
6365 &pr->pid, 6782 pr,
6366 pr, 6783 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
6367 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) { 6784 {
6368 GNUNET_break (0); 6785 GNUNET_break (0);
6369 GNUNET_free (pr); 6786 GNUNET_free (pr);
6370 GNUNET_SERVICE_client_drop (tc->client); 6787 GNUNET_SERVICE_client_drop (tc->client);
@@ -6389,30 +6806,31 @@ handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
6389 * signature in the body, see #GNUNET_HELLO_extract_address() 6806 * signature in the body, see #GNUNET_HELLO_extract_address()
6390 */ 6807 */
6391static void 6808static void
6392handle_address_consider_verify ( 6809handle_address_consider_verify (void *cls,
6393 void *cls, 6810 const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
6394 const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
6395{ 6811{
6396 struct TransportClient *tc = cls; 6812 struct TransportClient *tc = cls;
6397 char *address; 6813 char *address;
6398 enum GNUNET_NetworkType nt; 6814 enum GNUNET_NetworkType nt;
6399 struct GNUNET_TIME_Absolute expiration; 6815 struct GNUNET_TIME_Absolute expiration;
6400 6816
6401 (void)cls; 6817 (void) cls;
6402 // FIXME: checking that we know this address already should 6818 // FIXME: checking that we know this address already should
6403 // be done BEFORE checking the signature => HELLO API change! 6819 // be done BEFORE checking the signature => HELLO API change!
6404 // FIXME: pre-check: rate-limit signature verification / validation?! 6820 // FIXME: pre-check: rate-limit signature verification / validation?!
6405 address 6821 address = GNUNET_HELLO_extract_address (&hdr[1],
6406 = GNUNET_HELLO_extract_address (&hdr[1], 6822 ntohs (hdr->header.size) - sizeof (*hdr),
6407 ntohs (hdr->header.size) - sizeof (*hdr), 6823 &hdr->peer,
6408 &hdr->peer, 6824 &nt,
6409 &nt, 6825 &expiration);
6410 &expiration); 6826 if (NULL == address)
6411 if (NULL == address) { 6827 {
6412 GNUNET_break_op (0); 6828 GNUNET_break_op (0);
6413 return; 6829 return;
6414 } 6830 }
6415 start_address_validation (&hdr->peer, address, expiration); 6831 start_address_validation (&hdr->peer,
6832 address,
6833 expiration);
6416 GNUNET_free (address); 6834 GNUNET_free (address);
6417 GNUNET_SERVICE_client_continue (tc->client); 6835 GNUNET_SERVICE_client_continue (tc->client);
6418} 6836}
@@ -6430,7 +6848,7 @@ static int
6430check_request_hello_validation (void *cls, 6848check_request_hello_validation (void *cls,
6431 const struct RequestHelloValidationMessage *m) 6849 const struct RequestHelloValidationMessage *m)
6432{ 6850{
6433 (void)cls; 6851 (void) cls;
6434 GNUNET_MQ_check_zero_termination (m); 6852 GNUNET_MQ_check_zero_termination (m);
6435 return GNUNET_OK; 6853 return GNUNET_OK;
6436} 6854}
@@ -6450,7 +6868,7 @@ handle_request_hello_validation (void *cls,
6450 struct TransportClient *tc = cls; 6868 struct TransportClient *tc = cls;
6451 6869
6452 start_address_validation (&m->peer, 6870 start_address_validation (&m->peer,
6453 (const char *)&m[1], 6871 (const char *) &m[1],
6454 GNUNET_TIME_absolute_ntoh (m->expiration)); 6872 GNUNET_TIME_absolute_ntoh (m->expiration));
6455 GNUNET_SERVICE_client_continue (tc->client); 6873 GNUNET_SERVICE_client_continue (tc->client);
6456} 6874}
@@ -6471,8 +6889,8 @@ free_neighbour_cb (void *cls,
6471{ 6889{
6472 struct Neighbour *neighbour = value; 6890 struct Neighbour *neighbour = value;
6473 6891
6474 (void)cls; 6892 (void) cls;
6475 (void)pid; 6893 (void) pid;
6476 GNUNET_break (0); // should this ever happen? 6894 GNUNET_break (0); // should this ever happen?
6477 free_neighbour (neighbour); 6895 free_neighbour (neighbour);
6478 6896
@@ -6495,8 +6913,8 @@ free_dv_routes_cb (void *cls,
6495{ 6913{
6496 struct DistanceVector *dv = value; 6914 struct DistanceVector *dv = value;
6497 6915
6498 (void)cls; 6916 (void) cls;
6499 (void)pid; 6917 (void) pid;
6500 free_dv_route (dv); 6918 free_dv_route (dv);
6501 6919
6502 return GNUNET_OK; 6920 return GNUNET_OK;
@@ -6518,8 +6936,8 @@ free_ephemeral_cb (void *cls,
6518{ 6936{
6519 struct EphemeralCacheEntry *ece = value; 6937 struct EphemeralCacheEntry *ece = value;
6520 6938
6521 (void)cls; 6939 (void) cls;
6522 (void)pid; 6940 (void) pid;
6523 free_ephemeral (ece); 6941 free_ephemeral (ece);
6524 return GNUNET_OK; 6942 return GNUNET_OK;
6525} 6943}
@@ -6540,8 +6958,8 @@ free_validation_state_cb (void *cls,
6540{ 6958{
6541 struct ValidationState *vs = value; 6959 struct ValidationState *vs = value;
6542 6960
6543 (void)cls; 6961 (void) cls;
6544 (void)pid; 6962 (void) pid;
6545 free_validation_state (vs); 6963 free_validation_state (vs);
6546 return GNUNET_OK; 6964 return GNUNET_OK;
6547} 6965}
@@ -6557,22 +6975,30 @@ static void
6557do_shutdown (void *cls) 6975do_shutdown (void *cls)
6558{ 6976{
6559 struct LearnLaunchEntry *lle; 6977 struct LearnLaunchEntry *lle;
6560 (void)cls; 6978 (void) cls;
6561 6979
6562 if (NULL != ephemeral_task) { 6980 if (NULL != ephemeral_task)
6981 {
6563 GNUNET_SCHEDULER_cancel (ephemeral_task); 6982 GNUNET_SCHEDULER_cancel (ephemeral_task);
6564 ephemeral_task = NULL; 6983 ephemeral_task = NULL;
6565 } 6984 }
6566 GNUNET_CONTAINER_multipeermap_iterate (neighbours, &free_neighbour_cb, NULL); 6985 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
6567 if (NULL != peerstore) { 6986 &free_neighbour_cb,
6568 GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); 6987 NULL);
6988 if (NULL != peerstore)
6989 {
6990 GNUNET_PEERSTORE_disconnect (peerstore,
6991 GNUNET_NO);
6569 peerstore = NULL; 6992 peerstore = NULL;
6570 } 6993 }
6571 if (NULL != GST_stats) { 6994 if (NULL != GST_stats)
6572 GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); 6995 {
6996 GNUNET_STATISTICS_destroy (GST_stats,
6997 GNUNET_NO);
6573 GST_stats = NULL; 6998 GST_stats = NULL;
6574 } 6999 }
6575 if (NULL != GST_my_private_key) { 7000 if (NULL != GST_my_private_key)
7001 {
6576 GNUNET_free (GST_my_private_key); 7002 GNUNET_free (GST_my_private_key);
6577 GST_my_private_key = NULL; 7003 GST_my_private_key = NULL;
6578 } 7004 }
@@ -6583,15 +7009,20 @@ do_shutdown (void *cls)
6583 NULL); 7009 NULL);
6584 GNUNET_CONTAINER_multipeermap_destroy (validation_map); 7010 GNUNET_CONTAINER_multipeermap_destroy (validation_map);
6585 validation_map = NULL; 7011 validation_map = NULL;
6586 while (NULL != (lle = lle_head)) { 7012 while (NULL != (lle = lle_head))
6587 GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle); 7013 {
7014 GNUNET_CONTAINER_DLL_remove (lle_head,
7015 lle_tail,
7016 lle);
6588 GNUNET_free (lle); 7017 GNUNET_free (lle);
6589 } 7018 }
6590 GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map); 7019 GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map);
6591 dvlearn_map = NULL; 7020 dvlearn_map = NULL;
6592 GNUNET_CONTAINER_heap_destroy (validation_heap); 7021 GNUNET_CONTAINER_heap_destroy (validation_heap);
6593 validation_heap = NULL; 7022 validation_heap = NULL;
6594 GNUNET_CONTAINER_multipeermap_iterate (dv_routes, &free_dv_routes_cb, NULL); 7023 GNUNET_CONTAINER_multipeermap_iterate (dv_routes,
7024 &free_dv_routes_cb,
7025 NULL);
6595 GNUNET_CONTAINER_multipeermap_destroy (dv_routes); 7026 GNUNET_CONTAINER_multipeermap_destroy (dv_routes);
6596 dv_routes = NULL; 7027 dv_routes = NULL;
6597 GNUNET_CONTAINER_multipeermap_iterate (ephemeral_map, 7028 GNUNET_CONTAINER_multipeermap_iterate (ephemeral_map,
@@ -6616,39 +7047,42 @@ run (void *cls,
6616 const struct GNUNET_CONFIGURATION_Handle *c, 7047 const struct GNUNET_CONFIGURATION_Handle *c,
6617 struct GNUNET_SERVICE_Handle *service) 7048 struct GNUNET_SERVICE_Handle *service)
6618{ 7049{
6619 (void)cls; 7050 (void) cls;
6620 (void)service; 7051 (void) service;
6621 /* setup globals */ 7052 /* setup globals */
6622 GST_cfg = c; 7053 GST_cfg = c;
6623 neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); 7054 neighbours = GNUNET_CONTAINER_multipeermap_create (1024,
6624 dv_routes = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); 7055 GNUNET_YES);
6625 ephemeral_map = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES); 7056 dv_routes = GNUNET_CONTAINER_multipeermap_create (1024,
6626 ephemeral_heap 7057 GNUNET_YES);
6627 = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 7058 ephemeral_map = GNUNET_CONTAINER_multipeermap_create (32,
7059 GNUNET_YES);
7060 ephemeral_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
6628 dvlearn_map = GNUNET_CONTAINER_multishortmap_create (2 * MAX_DV_LEARN_PENDING, 7061 dvlearn_map = GNUNET_CONTAINER_multishortmap_create (2 * MAX_DV_LEARN_PENDING,
6629 GNUNET_YES); 7062 GNUNET_YES);
6630 validation_map = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); 7063 validation_map = GNUNET_CONTAINER_multipeermap_create (1024,
6631 validation_heap 7064 GNUNET_YES);
6632 = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 7065 validation_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
6633 GST_my_private_key 7066 GST_my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg);
6634 = GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg); 7067 if (NULL == GST_my_private_key)
6635 if (NULL == GST_my_private_key) { 7068 {
6636 GNUNET_log ( 7069 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
6637 GNUNET_ERROR_TYPE_ERROR, 7070 _("Transport service is lacking key configuration settings. Exiting.\n"));
6638 _ (
6639 "Transport service is lacking key configuration settings. Exiting.\n"));
6640 GNUNET_SCHEDULER_shutdown (); 7071 GNUNET_SCHEDULER_shutdown ();
6641 return; 7072 return;
6642 } 7073 }
6643 GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key, 7074 GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key,
6644 &GST_my_identity.public_key); 7075 &GST_my_identity.public_key);
6645 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 7076 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
6646 "My identity is `%s'\n", 7077 "My identity is `%s'\n",
6647 GNUNET_i2s_full (&GST_my_identity)); 7078 GNUNET_i2s_full (&GST_my_identity));
6648 GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); 7079 GST_stats = GNUNET_STATISTICS_create ("transport",
6649 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); 7080 GST_cfg);
7081 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
7082 NULL);
6650 peerstore = GNUNET_PEERSTORE_connect (GST_cfg); 7083 peerstore = GNUNET_PEERSTORE_connect (GST_cfg);
6651 if (NULL == peerstore) { 7084 if (NULL == peerstore)
7085 {
6652 GNUNET_break (0); 7086 GNUNET_break (0);
6653 GNUNET_SCHEDULER_shutdown (); 7087 GNUNET_SCHEDULER_shutdown ();
6654 return; 7088 return;
@@ -6659,86 +7093,86 @@ run (void *cls,
6659/** 7093/**
6660 * Define "main" method using service macro. 7094 * Define "main" method using service macro.
6661 */ 7095 */
6662GNUNET_SERVICE_MAIN ( 7096GNUNET_SERVICE_MAIN
6663 "transport", 7097("transport",
6664 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN, 7098 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN,
6665 &run, 7099 &run,
6666 &client_connect_cb, 7100 &client_connect_cb,
6667 &client_disconnect_cb, 7101 &client_disconnect_cb,
6668 NULL, 7102 NULL,
6669 /* communication with applications */ 7103 /* communication with applications */
6670 GNUNET_MQ_hd_fixed_size (suggest, 7104 GNUNET_MQ_hd_fixed_size (suggest,
6671 GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST, 7105 GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST,
6672 struct ExpressPreferenceMessage, 7106 struct ExpressPreferenceMessage,
6673 NULL), 7107 NULL),
6674 GNUNET_MQ_hd_fixed_size (suggest_cancel, 7108 GNUNET_MQ_hd_fixed_size (suggest_cancel,
6675 GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, 7109 GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL,
6676 struct ExpressPreferenceMessage, 7110 struct ExpressPreferenceMessage,
6677 NULL), 7111 NULL),
6678 GNUNET_MQ_hd_var_size (request_hello_validation, 7112 GNUNET_MQ_hd_var_size (request_hello_validation,
6679 GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, 7113 GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION,
6680 struct RequestHelloValidationMessage, 7114 struct RequestHelloValidationMessage,
6681 NULL), 7115 NULL),
6682 /* communication with core */ 7116 /* communication with core */
6683 GNUNET_MQ_hd_fixed_size (client_start, 7117 GNUNET_MQ_hd_fixed_size (client_start,
6684 GNUNET_MESSAGE_TYPE_TRANSPORT_START, 7118 GNUNET_MESSAGE_TYPE_TRANSPORT_START,
6685 struct StartMessage, 7119 struct StartMessage,
6686 NULL), 7120 NULL),
6687 GNUNET_MQ_hd_var_size (client_send, 7121 GNUNET_MQ_hd_var_size (client_send,
6688 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 7122 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
6689 struct OutboundMessage, 7123 struct OutboundMessage,
6690 NULL), 7124 NULL),
6691 /* communication with communicators */ 7125 /* communication with communicators */
6692 GNUNET_MQ_hd_var_size (communicator_available, 7126 GNUNET_MQ_hd_var_size (communicator_available,
6693 GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, 7127 GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
6694 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, 7128 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
6695 NULL), 7129 NULL),
6696 GNUNET_MQ_hd_var_size (communicator_backchannel, 7130 GNUNET_MQ_hd_var_size (communicator_backchannel,
6697 GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, 7131 GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
6698 struct GNUNET_TRANSPORT_CommunicatorBackchannel, 7132 struct GNUNET_TRANSPORT_CommunicatorBackchannel,
6699 NULL), 7133 NULL),
6700 GNUNET_MQ_hd_var_size (add_address, 7134 GNUNET_MQ_hd_var_size (add_address,
6701 GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, 7135 GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
6702 struct GNUNET_TRANSPORT_AddAddressMessage, 7136 struct GNUNET_TRANSPORT_AddAddressMessage,
6703 NULL), 7137 NULL),
6704 GNUNET_MQ_hd_fixed_size (del_address, 7138 GNUNET_MQ_hd_fixed_size (del_address,
6705 GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, 7139 GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
6706 struct GNUNET_TRANSPORT_DelAddressMessage, 7140 struct GNUNET_TRANSPORT_DelAddressMessage,
6707 NULL), 7141 NULL),
6708 GNUNET_MQ_hd_var_size (incoming_msg, 7142 GNUNET_MQ_hd_var_size (incoming_msg,
6709 GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, 7143 GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG,
6710 struct GNUNET_TRANSPORT_IncomingMessage, 7144 struct GNUNET_TRANSPORT_IncomingMessage,
6711 NULL), 7145 NULL),
6712 GNUNET_MQ_hd_fixed_size (queue_create_ok, 7146 GNUNET_MQ_hd_fixed_size (queue_create_ok,
6713 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, 7147 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
6714 struct GNUNET_TRANSPORT_CreateQueueResponse, 7148 struct GNUNET_TRANSPORT_CreateQueueResponse,
6715 NULL), 7149 NULL),
6716 GNUNET_MQ_hd_fixed_size (queue_create_fail, 7150 GNUNET_MQ_hd_fixed_size (queue_create_fail,
6717 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, 7151 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL,
6718 struct GNUNET_TRANSPORT_CreateQueueResponse, 7152 struct GNUNET_TRANSPORT_CreateQueueResponse,
6719 NULL), 7153 NULL),
6720 GNUNET_MQ_hd_var_size (add_queue_message, 7154 GNUNET_MQ_hd_var_size (add_queue_message,
6721 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, 7155 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
6722 struct GNUNET_TRANSPORT_AddQueueMessage, 7156 struct GNUNET_TRANSPORT_AddQueueMessage,
6723 NULL), 7157 NULL),
6724 GNUNET_MQ_hd_var_size (address_consider_verify, 7158 GNUNET_MQ_hd_var_size (address_consider_verify,
6725 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY, 7159 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY,
6726 struct GNUNET_TRANSPORT_AddressToVerify, 7160 struct GNUNET_TRANSPORT_AddressToVerify,
6727 NULL), 7161 NULL),
6728 GNUNET_MQ_hd_fixed_size (del_queue_message, 7162 GNUNET_MQ_hd_fixed_size (del_queue_message,
6729 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, 7163 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
6730 struct GNUNET_TRANSPORT_DelQueueMessage, 7164 struct GNUNET_TRANSPORT_DelQueueMessage,
6731 NULL), 7165 NULL),
6732 GNUNET_MQ_hd_fixed_size (send_message_ack, 7166 GNUNET_MQ_hd_fixed_size (send_message_ack,
6733 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, 7167 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
6734 struct GNUNET_TRANSPORT_SendMessageToAck, 7168 struct GNUNET_TRANSPORT_SendMessageToAck,
6735 NULL), 7169 NULL),
6736 /* communication with monitors */ 7170 /* communication with monitors */
6737 GNUNET_MQ_hd_fixed_size (monitor_start, 7171 GNUNET_MQ_hd_fixed_size (monitor_start,
6738 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START, 7172 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START,
6739 struct GNUNET_TRANSPORT_MonitorStart, 7173 struct GNUNET_TRANSPORT_MonitorStart,
6740 NULL), 7174 NULL),
6741 GNUNET_MQ_handler_end ()); 7175 GNUNET_MQ_handler_end ());
6742 7176
6743 7177
6744/* end of file gnunet-service-transport.c */ 7178/* end of file gnunet-service-transport.c */