diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/transport/gnunet-service-tng.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r-- | src/transport/gnunet-service-tng.c | 7587 |
1 files changed, 3825 insertions, 3762 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 09e15655f..66a836b84 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -176,14 +176,14 @@ | |||
176 | * the value chosen here might be too aggressively low! | 176 | * the value chosen here might be too aggressively low! |
177 | */ | 177 | */ |
178 | #define DELAY_WARN_THRESHOLD \ | 178 | #define DELAY_WARN_THRESHOLD \ |
179 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) | 179 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * If a DVBox could not be forwarded after this number of | 182 | * If a DVBox could not be forwarded after this number of |
183 | * seconds we drop it. | 183 | * seconds we drop it. |
184 | */ | 184 | */ |
185 | #define DV_FORWARD_TIMEOUT \ | 185 | #define DV_FORWARD_TIMEOUT \ |
186 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) | 186 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * We only consider queues as "quality" connections when | 189 | * We only consider queues as "quality" connections when |
@@ -191,53 +191,53 @@ | |||
191 | * the latency of the queue is below this threshold. | 191 | * the latency of the queue is below this threshold. |
192 | */ | 192 | */ |
193 | #define DV_QUALITY_RTT_THRESHOLD \ | 193 | #define DV_QUALITY_RTT_THRESHOLD \ |
194 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) | 194 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * How long do we consider a DV path valid if we see no | 197 | * How long do we consider a DV path valid if we see no |
198 | * further updates on it? Note: the value chosen here might be too low! | 198 | * further updates on it? Note: the value chosen here might be too low! |
199 | */ | 199 | */ |
200 | #define DV_PATH_VALIDITY_TIMEOUT \ | 200 | #define DV_PATH_VALIDITY_TIMEOUT \ |
201 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) | 201 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * How long do we cache backchannel (struct Backtalker) information | 204 | * How long do we cache backchannel (struct Backtalker) information |
205 | * after a backchannel goes inactive? | 205 | * after a backchannel goes inactive? |
206 | */ | 206 | */ |
207 | #define BACKCHANNEL_INACTIVITY_TIMEOUT \ | 207 | #define BACKCHANNEL_INACTIVITY_TIMEOUT \ |
208 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) | 208 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * How long before paths expire would we like to (re)discover DV paths? Should | 211 | * How long before paths expire would we like to (re)discover DV paths? Should |
212 | * be below #DV_PATH_VALIDITY_TIMEOUT. | 212 | * be below #DV_PATH_VALIDITY_TIMEOUT. |
213 | */ | 213 | */ |
214 | #define DV_PATH_DISCOVERY_FREQUENCY \ | 214 | #define DV_PATH_DISCOVERY_FREQUENCY \ |
215 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 4) | 215 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4) |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * How long are ephemeral keys valid? | 218 | * How long are ephemeral keys valid? |
219 | */ | 219 | */ |
220 | #define EPHEMERAL_VALIDITY \ | 220 | #define EPHEMERAL_VALIDITY \ |
221 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 4) | 221 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * How long do we keep partially reassembled messages around before giving up? | 224 | * How long do we keep partially reassembled messages around before giving up? |
225 | */ | 225 | */ |
226 | #define REASSEMBLY_EXPIRATION \ | 226 | #define REASSEMBLY_EXPIRATION \ |
227 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 4) | 227 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4) |
228 | 228 | ||
229 | /** | 229 | /** |
230 | * What is the fastest rate at which we send challenges *if* we keep learning | 230 | * What is the fastest rate at which we send challenges *if* we keep learning |
231 | * an address (gossip, DHT, etc.)? | 231 | * an address (gossip, DHT, etc.)? |
232 | */ | 232 | */ |
233 | #define FAST_VALIDATION_CHALLENGE_FREQ \ | 233 | #define FAST_VALIDATION_CHALLENGE_FREQ \ |
234 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1) | 234 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * What is the slowest rate at which we send challenges? | 237 | * What is the slowest rate at which we send challenges? |
238 | */ | 238 | */ |
239 | #define MAX_VALIDATION_CHALLENGE_FREQ \ | 239 | #define MAX_VALIDATION_CHALLENGE_FREQ \ |
240 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 1) | 240 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1) |
241 | 241 | ||
242 | /** | 242 | /** |
243 | * How long until we forget about historic accumulators and thus | 243 | * How long until we forget about historic accumulators and thus |
@@ -245,7 +245,7 @@ | |||
245 | * active connection experiences without an ACK. | 245 | * active connection experiences without an ACK. |
246 | */ | 246 | */ |
247 | #define ACK_CUMMULATOR_TIMEOUT \ | 247 | #define ACK_CUMMULATOR_TIMEOUT \ |
248 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 4) | 248 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
249 | 249 | ||
250 | /** | 250 | /** |
251 | * What is the non-randomized base frequency at which we | 251 | * What is the non-randomized base frequency at which we |
@@ -263,13 +263,13 @@ | |||
263 | * When do we forget an invalid address for sure? | 263 | * When do we forget an invalid address for sure? |
264 | */ | 264 | */ |
265 | #define MAX_ADDRESS_VALID_UNTIL \ | 265 | #define MAX_ADDRESS_VALID_UNTIL \ |
266 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MONTHS, 1) | 266 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1) |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * How long do we consider an address valid if we just checked? | 269 | * How long do we consider an address valid if we just checked? |
270 | */ | 270 | */ |
271 | #define ADDRESS_VALIDATION_LIFETIME \ | 271 | #define ADDRESS_VALIDATION_LIFETIME \ |
272 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 4) | 272 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4) |
273 | 273 | ||
274 | /** | 274 | /** |
275 | * What is the maximum frequency at which we do address validation? | 275 | * What is the maximum frequency at which we do address validation? |
@@ -308,7 +308,8 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
308 | /** | 308 | /** |
309 | * Unique identifier we attach to a message. | 309 | * Unique identifier we attach to a message. |
310 | */ | 310 | */ |
311 | struct MessageUUIDP { | 311 | struct MessageUUIDP |
312 | { | ||
312 | /** | 313 | /** |
313 | * Unique value, generated by incrementing the | 314 | * Unique value, generated by incrementing the |
314 | * `message_uuid_ctr` of `struct Neighbour`. | 315 | * `message_uuid_ctr` of `struct Neighbour`. |
@@ -320,7 +321,8 @@ struct MessageUUIDP { | |||
320 | /** | 321 | /** |
321 | * Unique identifier to map an acknowledgement to a transmission. | 322 | * Unique identifier to map an acknowledgement to a transmission. |
322 | */ | 323 | */ |
323 | struct AcknowledgementUUIDP { | 324 | struct AcknowledgementUUIDP |
325 | { | ||
324 | /** | 326 | /** |
325 | * The UUID value. | 327 | * The UUID value. |
326 | */ | 328 | */ |
@@ -331,7 +333,8 @@ struct AcknowledgementUUIDP { | |||
331 | /** | 333 | /** |
332 | * Type of a nonce used for challenges. | 334 | * Type of a nonce used for challenges. |
333 | */ | 335 | */ |
334 | struct ChallengeNonceP { | 336 | struct ChallengeNonceP |
337 | { | ||
335 | /** | 338 | /** |
336 | * The value of the nonce. Note that this is NOT a hash. | 339 | * The value of the nonce. Note that this is NOT a hash. |
337 | */ | 340 | */ |
@@ -342,7 +345,8 @@ struct ChallengeNonceP { | |||
342 | /** | 345 | /** |
343 | * Outer layer of an encapsulated backchannel message. | 346 | * Outer layer of an encapsulated backchannel message. |
344 | */ | 347 | */ |
345 | struct TransportBackchannelEncapsulationMessage { | 348 | struct TransportBackchannelEncapsulationMessage |
349 | { | ||
346 | /** | 350 | /** |
347 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION. | 351 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION. |
348 | */ | 352 | */ |
@@ -358,7 +362,8 @@ struct TransportBackchannelEncapsulationMessage { | |||
358 | /** | 362 | /** |
359 | * Body by which a peer confirms that it is using an ephemeral key. | 363 | * Body by which a peer confirms that it is using an ephemeral key. |
360 | */ | 364 | */ |
361 | struct EphemeralConfirmationPS { | 365 | struct EphemeralConfirmationPS |
366 | { | ||
362 | /** | 367 | /** |
363 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL | 368 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL |
364 | */ | 369 | */ |
@@ -397,7 +402,8 @@ struct EphemeralConfirmationPS { | |||
397 | * Plaintext of the variable-size payload that is encrypted | 402 | * Plaintext of the variable-size payload that is encrypted |
398 | * within a `struct TransportBackchannelEncapsulationMessage` | 403 | * within a `struct TransportBackchannelEncapsulationMessage` |
399 | */ | 404 | */ |
400 | struct TransportDVBoxPayloadP { | 405 | struct TransportDVBoxPayloadP |
406 | { | ||
401 | /** | 407 | /** |
402 | * Sender's peer identity. | 408 | * Sender's peer identity. |
403 | */ | 409 | */ |
@@ -430,7 +436,8 @@ struct TransportDVBoxPayloadP { | |||
430 | * Outer layer of an encapsulated unfragmented application message sent | 436 | * Outer layer of an encapsulated unfragmented application message sent |
431 | * over an unreliable channel. | 437 | * over an unreliable channel. |
432 | */ | 438 | */ |
433 | struct TransportReliabilityBoxMessage { | 439 | struct TransportReliabilityBoxMessage |
440 | { | ||
434 | /** | 441 | /** |
435 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX | 442 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX |
436 | */ | 443 | */ |
@@ -456,7 +463,8 @@ struct TransportReliabilityBoxMessage { | |||
456 | /** | 463 | /** |
457 | * Acknowledgement payload. | 464 | * Acknowledgement payload. |
458 | */ | 465 | */ |
459 | struct TransportCummulativeAckPayloadP { | 466 | struct TransportCummulativeAckPayloadP |
467 | { | ||
460 | /** | 468 | /** |
461 | * How long was the ACK delayed for generating cummulative ACKs? | 469 | * How long was the ACK delayed for generating cummulative ACKs? |
462 | * Used to calculate the correct network RTT by taking the receipt | 470 | * Used to calculate the correct network RTT by taking the receipt |
@@ -479,7 +487,8 @@ struct TransportCummulativeAckPayloadP { | |||
479 | * so ACKs are identified by a combination of PID of sender and | 487 | * so ACKs are identified by a combination of PID of sender and |
480 | * message UUID, without the queue playing any role! | 488 | * message UUID, without the queue playing any role! |
481 | */ | 489 | */ |
482 | struct TransportReliabilityAckMessage { | 490 | struct TransportReliabilityAckMessage |
491 | { | ||
483 | /** | 492 | /** |
484 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK | 493 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK |
485 | */ | 494 | */ |
@@ -499,7 +508,8 @@ struct TransportReliabilityAckMessage { | |||
499 | /** | 508 | /** |
500 | * Outer layer of an encapsulated fragmented application message. | 509 | * Outer layer of an encapsulated fragmented application message. |
501 | */ | 510 | */ |
502 | struct TransportFragmentBoxMessage { | 511 | struct TransportFragmentBoxMessage |
512 | { | ||
503 | /** | 513 | /** |
504 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT | 514 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT |
505 | */ | 515 | */ |
@@ -549,7 +559,8 @@ struct TransportFragmentBoxMessage { | |||
549 | * potential amplificator will check the @e monotonic_time and only respond | 559 | * potential amplificator will check the @e monotonic_time and only respond |
550 | * (at most) once per message. | 560 | * (at most) once per message. |
551 | */ | 561 | */ |
552 | struct DvInitPS { | 562 | struct DvInitPS |
563 | { | ||
553 | /** | 564 | /** |
554 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR | 565 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR |
555 | */ | 566 | */ |
@@ -592,7 +603,8 @@ struct DvInitPS { | |||
592 | * replay old messages. Thus, passively learned paths should always be | 603 | * replay old messages. Thus, passively learned paths should always be |
593 | * immediately marked as "potentially stale". | 604 | * immediately marked as "potentially stale". |
594 | */ | 605 | */ |
595 | struct DvHopPS { | 606 | struct DvHopPS |
607 | { | ||
596 | /** | 608 | /** |
597 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP | 609 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP |
598 | */ | 610 | */ |
@@ -619,7 +631,8 @@ struct DvHopPS { | |||
619 | * An entry describing a peer on a path in a | 631 | * An entry describing a peer on a path in a |
620 | * `struct TransportDVLearnMessage` message. | 632 | * `struct TransportDVLearnMessage` message. |
621 | */ | 633 | */ |
622 | struct DVPathEntryP { | 634 | struct DVPathEntryP |
635 | { | ||
623 | /** | 636 | /** |
624 | * Identity of a peer on the path. | 637 | * Identity of a peer on the path. |
625 | */ | 638 | */ |
@@ -646,7 +659,8 @@ struct DVPathEntryP { | |||
646 | * zero, peers that can forward to the initator should always try to | 659 | * zero, peers that can forward to the initator should always try to |
647 | * forward to the initiator. | 660 | * forward to the initiator. |
648 | */ | 661 | */ |
649 | struct TransportDVLearnMessage { | 662 | struct TransportDVLearnMessage |
663 | { | ||
650 | /** | 664 | /** |
651 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN | 665 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN |
652 | */ | 666 | */ |
@@ -733,7 +747,8 @@ struct TransportDVLearnMessage { | |||
733 | * the predecessor must be the origin (so this is not really useful | 747 | * the predecessor must be the origin (so this is not really useful |
734 | * for anonymization). | 748 | * for anonymization). |
735 | */ | 749 | */ |
736 | struct TransportDVBoxMessage { | 750 | struct TransportDVBoxMessage |
751 | { | ||
737 | /** | 752 | /** |
738 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX | 753 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX |
739 | */ | 754 | */ |
@@ -791,7 +806,8 @@ struct TransportDVBoxMessage { | |||
791 | * Message send to another peer to validate that it can indeed | 806 | * Message send to another peer to validate that it can indeed |
792 | * receive messages at a particular address. | 807 | * receive messages at a particular address. |
793 | */ | 808 | */ |
794 | struct TransportValidationChallengeMessage { | 809 | struct TransportValidationChallengeMessage |
810 | { | ||
795 | /** | 811 | /** |
796 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE | 812 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE |
797 | */ | 813 | */ |
@@ -819,7 +835,8 @@ struct TransportValidationChallengeMessage { | |||
819 | * Message signed by a peer to confirm that it can indeed | 835 | * Message signed by a peer to confirm that it can indeed |
820 | * receive messages at a particular address. | 836 | * receive messages at a particular address. |
821 | */ | 837 | */ |
822 | struct TransportValidationPS { | 838 | struct TransportValidationPS |
839 | { | ||
823 | /** | 840 | /** |
824 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE | 841 | * Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE |
825 | */ | 842 | */ |
@@ -842,7 +859,8 @@ struct TransportValidationPS { | |||
842 | * Message send to a peer to respond to a | 859 | * Message send to a peer to respond to a |
843 | * #GNUNET_MESSAGE_TYPE_ADDRESS_VALIDATION_CHALLENGE | 860 | * #GNUNET_MESSAGE_TYPE_ADDRESS_VALIDATION_CHALLENGE |
844 | */ | 861 | */ |
845 | struct TransportValidationResponseMessage { | 862 | struct TransportValidationResponseMessage |
863 | { | ||
846 | /** | 864 | /** |
847 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE | 865 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE |
848 | */ | 866 | */ |
@@ -886,7 +904,8 @@ struct TransportValidationResponseMessage { | |||
886 | * send to us, and how much data we already received from the other | 904 | * send to us, and how much data we already received from the other |
887 | * peer. | 905 | * peer. |
888 | */ | 906 | */ |
889 | struct TransportFlowControlMessage { | 907 | struct TransportFlowControlMessage |
908 | { | ||
890 | /** | 909 | /** |
891 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL | 910 | * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL |
892 | */ | 911 | */ |
@@ -942,7 +961,8 @@ GNUNET_NETWORK_STRUCT_END | |||
942 | /** | 961 | /** |
943 | * What type of client is the `struct TransportClient` about? | 962 | * What type of client is the `struct TransportClient` about? |
944 | */ | 963 | */ |
945 | enum ClientType { | 964 | enum ClientType |
965 | { | ||
946 | /** | 966 | /** |
947 | * We do not know yet (client is fresh). | 967 | * We do not know yet (client is fresh). |
948 | */ | 968 | */ |
@@ -974,7 +994,8 @@ enum ClientType { | |||
974 | * Which transmission options are allowable for transmission? | 994 | * Which transmission options are allowable for transmission? |
975 | * Interpreted bit-wise! | 995 | * Interpreted bit-wise! |
976 | */ | 996 | */ |
977 | enum RouteMessageOptions { | 997 | enum RouteMessageOptions |
998 | { | ||
978 | /** | 999 | /** |
979 | * Only confirmed, non-DV direct neighbours. | 1000 | * Only confirmed, non-DV direct neighbours. |
980 | */ | 1001 | */ |
@@ -1007,7 +1028,8 @@ enum RouteMessageOptions { | |||
1007 | /** | 1028 | /** |
1008 | * When did we launch this DV learning activity? | 1029 | * When did we launch this DV learning activity? |
1009 | */ | 1030 | */ |
1010 | struct LearnLaunchEntry { | 1031 | struct LearnLaunchEntry |
1032 | { | ||
1011 | /** | 1033 | /** |
1012 | * Kept (also) in a DLL sorted by launch time. | 1034 | * Kept (also) in a DLL sorted by launch time. |
1013 | */ | 1035 | */ |
@@ -1035,7 +1057,8 @@ struct LearnLaunchEntry { | |||
1035 | * Information we keep per #GOODPUT_AGING_SLOTS about historic | 1057 | * Information we keep per #GOODPUT_AGING_SLOTS about historic |
1036 | * (or current) transmission performance. | 1058 | * (or current) transmission performance. |
1037 | */ | 1059 | */ |
1038 | struct TransmissionHistoryEntry { | 1060 | struct TransmissionHistoryEntry |
1061 | { | ||
1039 | /** | 1062 | /** |
1040 | * Number of bytes actually sent in the interval. | 1063 | * Number of bytes actually sent in the interval. |
1041 | */ | 1064 | */ |
@@ -1052,7 +1075,8 @@ struct TransmissionHistoryEntry { | |||
1052 | /** | 1075 | /** |
1053 | * Performance data for a transmission possibility. | 1076 | * Performance data for a transmission possibility. |
1054 | */ | 1077 | */ |
1055 | struct PerformanceData { | 1078 | struct PerformanceData |
1079 | { | ||
1056 | /** | 1080 | /** |
1057 | * Weighted average for the RTT. | 1081 | * Weighted average for the RTT. |
1058 | */ | 1082 | */ |
@@ -1119,7 +1143,8 @@ struct VirtualLink; | |||
1119 | * Context from #handle_incoming_msg(). Closure for many | 1143 | * Context from #handle_incoming_msg(). Closure for many |
1120 | * message handlers below. | 1144 | * message handlers below. |
1121 | */ | 1145 | */ |
1122 | struct CommunicatorMessageContext { | 1146 | struct CommunicatorMessageContext |
1147 | { | ||
1123 | /** | 1148 | /** |
1124 | * Kept in a DLL of `struct VirtualLink` if waiting for CORE | 1149 | * Kept in a DLL of `struct VirtualLink` if waiting for CORE |
1125 | * flow control to unchoke. | 1150 | * flow control to unchoke. |
@@ -1153,7 +1178,8 @@ struct CommunicatorMessageContext { | |||
1153 | /** | 1178 | /** |
1154 | * Closure for #core_env_sent_cb. | 1179 | * Closure for #core_env_sent_cb. |
1155 | */ | 1180 | */ |
1156 | struct CoreSentContext { | 1181 | struct CoreSentContext |
1182 | { | ||
1157 | /** | 1183 | /** |
1158 | * Kept in a DLL to clear @e vl in case @e vl is lost. | 1184 | * Kept in a DLL to clear @e vl in case @e vl is lost. |
1159 | */ | 1185 | */ |
@@ -1192,7 +1218,8 @@ struct CoreSentContext { | |||
1192 | * data that is per neighbour that is not specific to how the | 1218 | * data that is per neighbour that is not specific to how the |
1193 | * connectivity is established. | 1219 | * connectivity is established. |
1194 | */ | 1220 | */ |
1195 | struct VirtualLink { | 1221 | struct VirtualLink |
1222 | { | ||
1196 | /** | 1223 | /** |
1197 | * Identity of the peer at the other end of the link. | 1224 | * Identity of the peer at the other end of the link. |
1198 | */ | 1225 | */ |
@@ -1390,7 +1417,8 @@ struct VirtualLink { | |||
1390 | /** | 1417 | /** |
1391 | * Data structure kept when we are waiting for an acknowledgement. | 1418 | * Data structure kept when we are waiting for an acknowledgement. |
1392 | */ | 1419 | */ |
1393 | struct PendingAcknowledgement { | 1420 | struct PendingAcknowledgement |
1421 | { | ||
1394 | /** | 1422 | /** |
1395 | * If @e pm is non-NULL, this is the DLL in which this acknowledgement | 1423 | * If @e pm is non-NULL, this is the DLL in which this acknowledgement |
1396 | * is kept in relation to its pending message. | 1424 | * is kept in relation to its pending message. |
@@ -1483,7 +1511,8 @@ struct PendingAcknowledgement { | |||
1483 | /** | 1511 | /** |
1484 | * One possible hop towards a DV target. | 1512 | * One possible hop towards a DV target. |
1485 | */ | 1513 | */ |
1486 | struct DistanceVectorHop { | 1514 | struct DistanceVectorHop |
1515 | { | ||
1487 | /** | 1516 | /** |
1488 | * Kept in a MDLL, sorted by @e timeout. | 1517 | * Kept in a MDLL, sorted by @e timeout. |
1489 | */ | 1518 | */ |
@@ -1564,7 +1593,8 @@ struct DistanceVectorHop { | |||
1564 | * Entry in our #dv_routes table, representing a (set of) distance | 1593 | * Entry in our #dv_routes table, representing a (set of) distance |
1565 | * vector routes to a particular peer. | 1594 | * vector routes to a particular peer. |
1566 | */ | 1595 | */ |
1567 | struct DistanceVector { | 1596 | struct DistanceVector |
1597 | { | ||
1568 | /** | 1598 | /** |
1569 | * To which peer is this a route? | 1599 | * To which peer is this a route? |
1570 | */ | 1600 | */ |
@@ -1628,7 +1658,8 @@ struct DistanceVector { | |||
1628 | * what the communicator can actually provide towards a particular | 1658 | * what the communicator can actually provide towards a particular |
1629 | * peer/target). | 1659 | * peer/target). |
1630 | */ | 1660 | */ |
1631 | struct QueueEntry { | 1661 | struct QueueEntry |
1662 | { | ||
1632 | /** | 1663 | /** |
1633 | * Kept as a DLL. | 1664 | * Kept as a DLL. |
1634 | */ | 1665 | */ |
@@ -1660,7 +1691,8 @@ struct QueueEntry { | |||
1660 | * A queue is a message queue provided by a communicator | 1691 | * A queue is a message queue provided by a communicator |
1661 | * via which we can reach a particular neighbour. | 1692 | * via which we can reach a particular neighbour. |
1662 | */ | 1693 | */ |
1663 | struct Queue { | 1694 | struct Queue |
1695 | { | ||
1664 | /** | 1696 | /** |
1665 | * Kept in a MDLL. | 1697 | * Kept in a MDLL. |
1666 | */ | 1698 | */ |
@@ -1788,7 +1820,8 @@ struct Queue { | |||
1788 | /** | 1820 | /** |
1789 | * Information we keep for a message that we are reassembling. | 1821 | * Information we keep for a message that we are reassembling. |
1790 | */ | 1822 | */ |
1791 | struct ReassemblyContext { | 1823 | struct ReassemblyContext |
1824 | { | ||
1792 | /** | 1825 | /** |
1793 | * Original message ID for of the message that all the fragments | 1826 | * Original message ID for of the message that all the fragments |
1794 | * belong to. | 1827 | * belong to. |
@@ -1846,7 +1879,8 @@ struct ReassemblyContext { | |||
1846 | /** | 1879 | /** |
1847 | * A neighbour that at least one communicator is connected to. | 1880 | * A neighbour that at least one communicator is connected to. |
1848 | */ | 1881 | */ |
1849 | struct Neighbour { | 1882 | struct Neighbour |
1883 | { | ||
1850 | /** | 1884 | /** |
1851 | * Which peer is this about? | 1885 | * Which peer is this about? |
1852 | */ | 1886 | */ |
@@ -1929,7 +1963,8 @@ struct Neighbour { | |||
1929 | * Another peer attempted to talk to us, we should try to establish | 1963 | * Another peer attempted to talk to us, we should try to establish |
1930 | * a connection in the other direction. | 1964 | * a connection in the other direction. |
1931 | */ | 1965 | */ |
1932 | struct IncomingRequest { | 1966 | struct IncomingRequest |
1967 | { | ||
1933 | /** | 1968 | /** |
1934 | * Kept in a DLL. | 1969 | * Kept in a DLL. |
1935 | */ | 1970 | */ |
@@ -1955,7 +1990,8 @@ struct IncomingRequest { | |||
1955 | /** | 1990 | /** |
1956 | * A peer that an application (client) would like us to talk to directly. | 1991 | * A peer that an application (client) would like us to talk to directly. |
1957 | */ | 1992 | */ |
1958 | struct PeerRequest { | 1993 | struct PeerRequest |
1994 | { | ||
1959 | /** | 1995 | /** |
1960 | * Which peer is this about? | 1996 | * Which peer is this about? |
1961 | */ | 1997 | */ |
@@ -1988,7 +2024,8 @@ struct PeerRequest { | |||
1988 | /** | 2024 | /** |
1989 | * Types of different pending messages. | 2025 | * Types of different pending messages. |
1990 | */ | 2026 | */ |
1991 | enum PendingMessageType { | 2027 | enum PendingMessageType |
2028 | { | ||
1992 | /** | 2029 | /** |
1993 | * Ordinary message received from the CORE service. | 2030 | * Ordinary message received from the CORE service. |
1994 | */ | 2031 | */ |
@@ -2037,7 +2074,8 @@ enum PendingMessageType { | |||
2037 | * is never again transmitted (even if it fits below the MTU), and | 2074 | * is never again transmitted (even if it fits below the MTU), and |
2038 | * only (remaining) fragments are sent. | 2075 | * only (remaining) fragments are sent. |
2039 | */ | 2076 | */ |
2040 | struct PendingMessage { | 2077 | struct PendingMessage |
2078 | { | ||
2041 | /** | 2079 | /** |
2042 | * Kept in a MDLL of messages for this @a vl. | 2080 | * Kept in a MDLL of messages for this @a vl. |
2043 | */ | 2081 | */ |
@@ -2176,7 +2214,8 @@ struct PendingMessage { | |||
2176 | /** | 2214 | /** |
2177 | * Acknowledgement payload. | 2215 | * Acknowledgement payload. |
2178 | */ | 2216 | */ |
2179 | struct TransportCummulativeAckPayload { | 2217 | struct TransportCummulativeAckPayload |
2218 | { | ||
2180 | /** | 2219 | /** |
2181 | * When did we receive the message we are ACKing? Used to calculate | 2220 | * When did we receive the message we are ACKing? Used to calculate |
2182 | * the delay we introduced by cummulating ACKs. | 2221 | * the delay we introduced by cummulating ACKs. |
@@ -2194,7 +2233,8 @@ struct TransportCummulativeAckPayload { | |||
2194 | * Data structure in which we track acknowledgements still to | 2233 | * Data structure in which we track acknowledgements still to |
2195 | * be sent to the | 2234 | * be sent to the |
2196 | */ | 2235 | */ |
2197 | struct AcknowledgementCummulator { | 2236 | struct AcknowledgementCummulator |
2237 | { | ||
2198 | /** | 2238 | /** |
2199 | * Target peer for which we are accumulating ACKs here. | 2239 | * Target peer for which we are accumulating ACKs here. |
2200 | */ | 2240 | */ |
@@ -2234,7 +2274,8 @@ struct AcknowledgementCummulator { | |||
2234 | /** | 2274 | /** |
2235 | * One of the addresses of this peer. | 2275 | * One of the addresses of this peer. |
2236 | */ | 2276 | */ |
2237 | struct AddressListEntry { | 2277 | struct AddressListEntry |
2278 | { | ||
2238 | /** | 2279 | /** |
2239 | * Kept in a DLL. | 2280 | * Kept in a DLL. |
2240 | */ | 2281 | */ |
@@ -2286,7 +2327,8 @@ struct AddressListEntry { | |||
2286 | /** | 2327 | /** |
2287 | * Client connected to the transport service. | 2328 | * Client connected to the transport service. |
2288 | */ | 2329 | */ |
2289 | struct TransportClient { | 2330 | struct TransportClient |
2331 | { | ||
2290 | /** | 2332 | /** |
2291 | * Kept in a DLL. | 2333 | * Kept in a DLL. |
2292 | */ | 2334 | */ |
@@ -2312,11 +2354,13 @@ struct TransportClient { | |||
2312 | */ | 2354 | */ |
2313 | enum ClientType type; | 2355 | enum ClientType type; |
2314 | 2356 | ||
2315 | union { | 2357 | union |
2358 | { | ||
2316 | /** | 2359 | /** |
2317 | * Information for @e type #CT_CORE. | 2360 | * Information for @e type #CT_CORE. |
2318 | */ | 2361 | */ |
2319 | struct { | 2362 | struct |
2363 | { | ||
2320 | /** | 2364 | /** |
2321 | * Head of list of messages pending for this client, sorted by | 2365 | * Head of list of messages pending for this client, sorted by |
2322 | * transmission time ("next_attempt" + possibly internal prioritization). | 2366 | * transmission time ("next_attempt" + possibly internal prioritization). |
@@ -2332,7 +2376,8 @@ struct TransportClient { | |||
2332 | /** | 2376 | /** |
2333 | * Information for @e type #CT_MONITOR. | 2377 | * Information for @e type #CT_MONITOR. |
2334 | */ | 2378 | */ |
2335 | struct { | 2379 | struct |
2380 | { | ||
2336 | /** | 2381 | /** |
2337 | * Peer identity to monitor the addresses of. | 2382 | * Peer identity to monitor the addresses of. |
2338 | * Zero to monitor all neighbours. Valid if | 2383 | * Zero to monitor all neighbours. Valid if |
@@ -2350,7 +2395,8 @@ struct TransportClient { | |||
2350 | /** | 2395 | /** |
2351 | * Information for @e type #CT_COMMUNICATOR. | 2396 | * Information for @e type #CT_COMMUNICATOR. |
2352 | */ | 2397 | */ |
2353 | struct { | 2398 | struct |
2399 | { | ||
2354 | /** | 2400 | /** |
2355 | * If @e type is #CT_COMMUNICATOR, this communicator | 2401 | * If @e type is #CT_COMMUNICATOR, this communicator |
2356 | * supports communicating using these addresses. | 2402 | * supports communicating using these addresses. |
@@ -2395,7 +2441,8 @@ struct TransportClient { | |||
2395 | /** | 2441 | /** |
2396 | * Information for @e type #CT_APPLICATION | 2442 | * Information for @e type #CT_APPLICATION |
2397 | */ | 2443 | */ |
2398 | struct { | 2444 | struct |
2445 | { | ||
2399 | /** | 2446 | /** |
2400 | * Map of requests for peers the given client application would like to | 2447 | * Map of requests for peers the given client application would like to |
2401 | * see connections for. Maps from PIDs to `struct PeerRequest`. | 2448 | * see connections for. Maps from PIDs to `struct PeerRequest`. |
@@ -2410,7 +2457,8 @@ struct TransportClient { | |||
2410 | * State we keep for validation activities. Each of these | 2457 | * State we keep for validation activities. Each of these |
2411 | * is both in the #validation_heap and the #validation_map. | 2458 | * is both in the #validation_heap and the #validation_map. |
2412 | */ | 2459 | */ |
2413 | struct ValidationState { | 2460 | struct ValidationState |
2461 | { | ||
2414 | /** | 2462 | /** |
2415 | * For which peer is @a address to be validated (or possibly valid)? | 2463 | * For which peer is @a address to be validated (or possibly valid)? |
2416 | * Serves as key in the #validation_map. | 2464 | * Serves as key in the #validation_map. |
@@ -2520,7 +2568,8 @@ struct ValidationState { | |||
2520 | * material (to avoid repeatedly checking signatures), and to synchronize | 2568 | * material (to avoid repeatedly checking signatures), and to synchronize |
2521 | * monotonic time with the PEERSTORE. | 2569 | * monotonic time with the PEERSTORE. |
2522 | */ | 2570 | */ |
2523 | struct Backtalker { | 2571 | struct Backtalker |
2572 | { | ||
2524 | /** | 2573 | /** |
2525 | * Peer this is about. | 2574 | * Peer this is about. |
2526 | */ | 2575 | */ |
@@ -2743,11 +2792,11 @@ static struct GNUNET_TIME_Absolute hello_mono_time; | |||
2743 | * @return current age of the world | 2792 | * @return current age of the world |
2744 | */ | 2793 | */ |
2745 | static unsigned int | 2794 | static unsigned int |
2746 | get_age() | 2795 | get_age () |
2747 | { | 2796 | { |
2748 | struct GNUNET_TIME_Absolute now; | 2797 | struct GNUNET_TIME_Absolute now; |
2749 | 2798 | ||
2750 | now = GNUNET_TIME_absolute_get(); | 2799 | now = GNUNET_TIME_absolute_get (); |
2751 | return now.abs_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us / 15; | 2800 | return now.abs_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us / 15; |
2752 | } | 2801 | } |
2753 | 2802 | ||
@@ -2758,13 +2807,13 @@ get_age() | |||
2758 | * @param ir data structure to release | 2807 | * @param ir data structure to release |
2759 | */ | 2808 | */ |
2760 | static void | 2809 | static void |
2761 | free_incoming_request(struct IncomingRequest *ir) | 2810 | free_incoming_request (struct IncomingRequest *ir) |
2762 | { | 2811 | { |
2763 | GNUNET_CONTAINER_DLL_remove(ir_head, ir_tail, ir); | 2812 | GNUNET_CONTAINER_DLL_remove (ir_head, ir_tail, ir); |
2764 | GNUNET_assert(ir_total > 0); | 2813 | GNUNET_assert (ir_total > 0); |
2765 | ir_total--; | 2814 | ir_total--; |
2766 | GNUNET_PEERSTORE_watch_cancel(ir->wc); | 2815 | GNUNET_PEERSTORE_watch_cancel (ir->wc); |
2767 | GNUNET_free(ir); | 2816 | GNUNET_free (ir); |
2768 | } | 2817 | } |
2769 | 2818 | ||
2770 | 2819 | ||
@@ -2774,34 +2823,34 @@ free_incoming_request(struct IncomingRequest *ir) | |||
2774 | * @param pa data structure to release | 2823 | * @param pa data structure to release |
2775 | */ | 2824 | */ |
2776 | static void | 2825 | static void |
2777 | free_pending_acknowledgement(struct PendingAcknowledgement *pa) | 2826 | free_pending_acknowledgement (struct PendingAcknowledgement *pa) |
2778 | { | 2827 | { |
2779 | struct Queue *q = pa->queue; | 2828 | struct Queue *q = pa->queue; |
2780 | struct PendingMessage *pm = pa->pm; | 2829 | struct PendingMessage *pm = pa->pm; |
2781 | struct DistanceVectorHop *dvh = pa->dvh; | 2830 | struct DistanceVectorHop *dvh = pa->dvh; |
2782 | 2831 | ||
2783 | GNUNET_CONTAINER_MDLL_remove(pa, pa_head, pa_tail, pa); | 2832 | GNUNET_CONTAINER_MDLL_remove (pa, pa_head, pa_tail, pa); |
2784 | pa_count--; | 2833 | pa_count--; |
2785 | if (NULL != q) | 2834 | if (NULL != q) |
2786 | { | 2835 | { |
2787 | GNUNET_CONTAINER_MDLL_remove(queue, q->pa_head, q->pa_tail, pa); | 2836 | GNUNET_CONTAINER_MDLL_remove (queue, q->pa_head, q->pa_tail, pa); |
2788 | pa->queue = NULL; | 2837 | pa->queue = NULL; |
2789 | } | 2838 | } |
2790 | if (NULL != pm) | 2839 | if (NULL != pm) |
2791 | { | 2840 | { |
2792 | GNUNET_CONTAINER_MDLL_remove(pm, pm->pa_head, pm->pa_tail, pa); | 2841 | GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa); |
2793 | pa->pm = NULL; | 2842 | pa->pm = NULL; |
2794 | } | 2843 | } |
2795 | if (NULL != dvh) | 2844 | if (NULL != dvh) |
2796 | { | 2845 | { |
2797 | GNUNET_CONTAINER_MDLL_remove(dvh, dvh->pa_head, dvh->pa_tail, pa); | 2846 | GNUNET_CONTAINER_MDLL_remove (dvh, dvh->pa_head, dvh->pa_tail, pa); |
2798 | pa->queue = NULL; | 2847 | pa->queue = NULL; |
2799 | } | 2848 | } |
2800 | GNUNET_assert(GNUNET_YES == | 2849 | GNUNET_assert (GNUNET_YES == |
2801 | GNUNET_CONTAINER_multiuuidmap_remove(pending_acks, | 2850 | GNUNET_CONTAINER_multiuuidmap_remove (pending_acks, |
2802 | &pa->ack_uuid.value, | 2851 | &pa->ack_uuid.value, |
2803 | pa)); | 2852 | pa)); |
2804 | GNUNET_free(pa); | 2853 | GNUNET_free (pa); |
2805 | } | 2854 | } |
2806 | 2855 | ||
2807 | 2856 | ||
@@ -2814,23 +2863,23 @@ free_pending_acknowledgement(struct PendingAcknowledgement *pa) | |||
2814 | * @param root root of the tree to free | 2863 | * @param root root of the tree to free |
2815 | */ | 2864 | */ |
2816 | static void | 2865 | static void |
2817 | free_fragment_tree(struct PendingMessage *root) | 2866 | free_fragment_tree (struct PendingMessage *root) |
2818 | { | 2867 | { |
2819 | struct PendingMessage *frag; | 2868 | struct PendingMessage *frag; |
2820 | 2869 | ||
2821 | while (NULL != (frag = root->head_frag)) | 2870 | while (NULL != (frag = root->head_frag)) |
2822 | { | 2871 | { |
2823 | struct PendingAcknowledgement *pa; | 2872 | struct PendingAcknowledgement *pa; |
2824 | 2873 | ||
2825 | free_fragment_tree(frag); | 2874 | free_fragment_tree (frag); |
2826 | while (NULL != (pa = frag->pa_head)) | 2875 | while (NULL != (pa = frag->pa_head)) |
2827 | { | 2876 | { |
2828 | GNUNET_CONTAINER_MDLL_remove(pm, frag->pa_head, frag->pa_tail, pa); | 2877 | GNUNET_CONTAINER_MDLL_remove (pm, frag->pa_head, frag->pa_tail, pa); |
2829 | pa->pm = NULL; | 2878 | pa->pm = NULL; |
2830 | } | ||
2831 | GNUNET_CONTAINER_MDLL_remove(frag, root->head_frag, root->tail_frag, frag); | ||
2832 | GNUNET_free(frag); | ||
2833 | } | 2879 | } |
2880 | GNUNET_CONTAINER_MDLL_remove (frag, root->head_frag, root->tail_frag, frag); | ||
2881 | GNUNET_free (frag); | ||
2882 | } | ||
2834 | } | 2883 | } |
2835 | 2884 | ||
2836 | 2885 | ||
@@ -2842,44 +2891,44 @@ free_fragment_tree(struct PendingMessage *root) | |||
2842 | * @param pm the pending message to free | 2891 | * @param pm the pending message to free |
2843 | */ | 2892 | */ |
2844 | static void | 2893 | static void |
2845 | free_pending_message(struct PendingMessage *pm) | 2894 | free_pending_message (struct PendingMessage *pm) |
2846 | { | 2895 | { |
2847 | struct TransportClient *tc = pm->client; | 2896 | struct TransportClient *tc = pm->client; |
2848 | struct VirtualLink *vl = pm->vl; | 2897 | struct VirtualLink *vl = pm->vl; |
2849 | struct PendingAcknowledgement *pa; | 2898 | struct PendingAcknowledgement *pa; |
2850 | 2899 | ||
2851 | if (NULL != tc) | 2900 | if (NULL != tc) |
2852 | { | 2901 | { |
2853 | GNUNET_CONTAINER_MDLL_remove(client, | 2902 | GNUNET_CONTAINER_MDLL_remove (client, |
2854 | tc->details.core.pending_msg_head, | 2903 | tc->details.core.pending_msg_head, |
2855 | tc->details.core.pending_msg_tail, | 2904 | tc->details.core.pending_msg_tail, |
2856 | pm); | 2905 | pm); |
2857 | } | 2906 | } |
2858 | if (NULL != vl) | 2907 | if (NULL != vl) |
2859 | { | 2908 | { |
2860 | GNUNET_CONTAINER_MDLL_remove(vl, | 2909 | GNUNET_CONTAINER_MDLL_remove (vl, |
2861 | vl->pending_msg_head, | 2910 | vl->pending_msg_head, |
2862 | vl->pending_msg_tail, | 2911 | vl->pending_msg_tail, |
2863 | pm); | 2912 | pm); |
2864 | } | 2913 | } |
2865 | while (NULL != (pa = pm->pa_head)) | 2914 | while (NULL != (pa = pm->pa_head)) |
2866 | { | 2915 | { |
2867 | GNUNET_CONTAINER_MDLL_remove(pm, pm->pa_head, pm->pa_tail, pa); | 2916 | GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa); |
2868 | pa->pm = NULL; | 2917 | pa->pm = NULL; |
2869 | } | 2918 | } |
2870 | 2919 | ||
2871 | free_fragment_tree(pm); | 2920 | free_fragment_tree (pm); |
2872 | if (NULL != pm->qe) | 2921 | if (NULL != pm->qe) |
2873 | { | 2922 | { |
2874 | GNUNET_assert(pm == pm->qe->pm); | 2923 | GNUNET_assert (pm == pm->qe->pm); |
2875 | pm->qe->pm = NULL; | 2924 | pm->qe->pm = NULL; |
2876 | } | 2925 | } |
2877 | if (NULL != pm->bpm) | 2926 | if (NULL != pm->bpm) |
2878 | { | 2927 | { |
2879 | free_fragment_tree(pm->bpm); | 2928 | free_fragment_tree (pm->bpm); |
2880 | GNUNET_free(pm->bpm); | 2929 | GNUNET_free (pm->bpm); |
2881 | } | 2930 | } |
2882 | GNUNET_free(pm); | 2931 | GNUNET_free (pm); |
2883 | } | 2932 | } |
2884 | 2933 | ||
2885 | 2934 | ||
@@ -2889,34 +2938,34 @@ free_pending_message(struct PendingMessage *pm) | |||
2889 | * @param vl link data to free | 2938 | * @param vl link data to free |
2890 | */ | 2939 | */ |
2891 | static void | 2940 | static void |
2892 | free_virtual_link(struct VirtualLink *vl) | 2941 | free_virtual_link (struct VirtualLink *vl) |
2893 | { | 2942 | { |
2894 | struct PendingMessage *pm; | 2943 | struct PendingMessage *pm; |
2895 | struct CoreSentContext *csc; | 2944 | struct CoreSentContext *csc; |
2896 | 2945 | ||
2897 | while (NULL != (pm = vl->pending_msg_head)) | 2946 | while (NULL != (pm = vl->pending_msg_head)) |
2898 | free_pending_message(pm); | 2947 | free_pending_message (pm); |
2899 | GNUNET_assert(GNUNET_YES == | 2948 | GNUNET_assert (GNUNET_YES == |
2900 | GNUNET_CONTAINER_multipeermap_remove(links, &vl->target, vl)); | 2949 | GNUNET_CONTAINER_multipeermap_remove (links, &vl->target, vl)); |
2901 | if (NULL != vl->visibility_task) | 2950 | if (NULL != vl->visibility_task) |
2902 | { | 2951 | { |
2903 | GNUNET_SCHEDULER_cancel(vl->visibility_task); | 2952 | GNUNET_SCHEDULER_cancel (vl->visibility_task); |
2904 | vl->visibility_task = NULL; | 2953 | vl->visibility_task = NULL; |
2905 | } | 2954 | } |
2906 | if (NULL != vl->fc_retransmit_task) | 2955 | if (NULL != vl->fc_retransmit_task) |
2907 | { | 2956 | { |
2908 | GNUNET_SCHEDULER_cancel(vl->fc_retransmit_task); | 2957 | GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task); |
2909 | vl->fc_retransmit_task = NULL; | 2958 | vl->fc_retransmit_task = NULL; |
2910 | } | 2959 | } |
2911 | while (NULL != (csc = vl->csc_head)) | 2960 | while (NULL != (csc = vl->csc_head)) |
2912 | { | 2961 | { |
2913 | GNUNET_CONTAINER_DLL_remove(vl->csc_head, vl->csc_tail, csc); | 2962 | GNUNET_CONTAINER_DLL_remove (vl->csc_head, vl->csc_tail, csc); |
2914 | GNUNET_assert(vl == csc->vl); | 2963 | GNUNET_assert (vl == csc->vl); |
2915 | csc->vl = NULL; | 2964 | csc->vl = NULL; |
2916 | } | 2965 | } |
2917 | GNUNET_break(NULL == vl->n); | 2966 | GNUNET_break (NULL == vl->n); |
2918 | GNUNET_break(NULL == vl->dv); | 2967 | GNUNET_break (NULL == vl->dv); |
2919 | GNUNET_free(vl); | 2968 | GNUNET_free (vl); |
2920 | } | 2969 | } |
2921 | 2970 | ||
2922 | 2971 | ||
@@ -2926,20 +2975,20 @@ free_virtual_link(struct VirtualLink *vl) | |||
2926 | * @param vs validation state to free | 2975 | * @param vs validation state to free |
2927 | */ | 2976 | */ |
2928 | static void | 2977 | static void |
2929 | free_validation_state(struct ValidationState *vs) | 2978 | free_validation_state (struct ValidationState *vs) |
2930 | { | 2979 | { |
2931 | GNUNET_assert( | 2980 | GNUNET_assert ( |
2932 | GNUNET_YES == | 2981 | GNUNET_YES == |
2933 | GNUNET_CONTAINER_multipeermap_remove(validation_map, &vs->pid, vs)); | 2982 | GNUNET_CONTAINER_multipeermap_remove (validation_map, &vs->pid, vs)); |
2934 | GNUNET_CONTAINER_heap_remove_node(vs->hn); | 2983 | GNUNET_CONTAINER_heap_remove_node (vs->hn); |
2935 | vs->hn = NULL; | 2984 | vs->hn = NULL; |
2936 | if (NULL != vs->sc) | 2985 | if (NULL != vs->sc) |
2937 | { | 2986 | { |
2938 | GNUNET_PEERSTORE_store_cancel(vs->sc); | 2987 | GNUNET_PEERSTORE_store_cancel (vs->sc); |
2939 | vs->sc = NULL; | 2988 | vs->sc = NULL; |
2940 | } | 2989 | } |
2941 | GNUNET_free(vs->address); | 2990 | GNUNET_free (vs->address); |
2942 | GNUNET_free(vs); | 2991 | GNUNET_free (vs); |
2943 | } | 2992 | } |
2944 | 2993 | ||
2945 | 2994 | ||
@@ -2950,9 +2999,9 @@ free_validation_state(struct ValidationState *vs) | |||
2950 | * @return NULL if we do not have this peer as a neighbour | 2999 | * @return NULL if we do not have this peer as a neighbour |
2951 | */ | 3000 | */ |
2952 | static struct Neighbour * | 3001 | static struct Neighbour * |
2953 | lookup_neighbour(const struct GNUNET_PeerIdentity *pid) | 3002 | lookup_neighbour (const struct GNUNET_PeerIdentity *pid) |
2954 | { | 3003 | { |
2955 | return GNUNET_CONTAINER_multipeermap_get(neighbours, pid); | 3004 | return GNUNET_CONTAINER_multipeermap_get (neighbours, pid); |
2956 | } | 3005 | } |
2957 | 3006 | ||
2958 | 3007 | ||
@@ -2963,16 +3012,17 @@ lookup_neighbour(const struct GNUNET_PeerIdentity *pid) | |||
2963 | * @return NULL if we do not have this peer as a virtual link | 3012 | * @return NULL if we do not have this peer as a virtual link |
2964 | */ | 3013 | */ |
2965 | static struct VirtualLink * | 3014 | static struct VirtualLink * |
2966 | lookup_virtual_link(const struct GNUNET_PeerIdentity *pid) | 3015 | lookup_virtual_link (const struct GNUNET_PeerIdentity *pid) |
2967 | { | 3016 | { |
2968 | return GNUNET_CONTAINER_multipeermap_get(links, pid); | 3017 | return GNUNET_CONTAINER_multipeermap_get (links, pid); |
2969 | } | 3018 | } |
2970 | 3019 | ||
2971 | 3020 | ||
2972 | /** | 3021 | /** |
2973 | * Details about what to notify monitors about. | 3022 | * Details about what to notify monitors about. |
2974 | */ | 3023 | */ |
2975 | struct MonitorEvent { | 3024 | struct MonitorEvent |
3025 | { | ||
2976 | /** | 3026 | /** |
2977 | * @deprecated To be discussed if we keep these... | 3027 | * @deprecated To be discussed if we keep these... |
2978 | */ | 3028 | */ |
@@ -3011,20 +3061,20 @@ struct MonitorEvent { | |||
3011 | * @param dvh hop to free | 3061 | * @param dvh hop to free |
3012 | */ | 3062 | */ |
3013 | static void | 3063 | static void |
3014 | free_distance_vector_hop(struct DistanceVectorHop *dvh) | 3064 | free_distance_vector_hop (struct DistanceVectorHop *dvh) |
3015 | { | 3065 | { |
3016 | struct Neighbour *n = dvh->next_hop; | 3066 | struct Neighbour *n = dvh->next_hop; |
3017 | struct DistanceVector *dv = dvh->dv; | 3067 | struct DistanceVector *dv = dvh->dv; |
3018 | struct PendingAcknowledgement *pa; | 3068 | struct PendingAcknowledgement *pa; |
3019 | 3069 | ||
3020 | while (NULL != (pa = dvh->pa_head)) | 3070 | while (NULL != (pa = dvh->pa_head)) |
3021 | { | 3071 | { |
3022 | GNUNET_CONTAINER_MDLL_remove(dvh, dvh->pa_head, dvh->pa_tail, pa); | 3072 | GNUNET_CONTAINER_MDLL_remove (dvh, dvh->pa_head, dvh->pa_tail, pa); |
3023 | pa->dvh = NULL; | 3073 | pa->dvh = NULL; |
3024 | } | 3074 | } |
3025 | GNUNET_CONTAINER_MDLL_remove(neighbour, n->dv_head, n->dv_tail, dvh); | 3075 | GNUNET_CONTAINER_MDLL_remove (neighbour, n->dv_head, n->dv_tail, dvh); |
3026 | GNUNET_CONTAINER_MDLL_remove(dv, dv->dv_head, dv->dv_tail, dvh); | 3076 | GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, dvh); |
3027 | GNUNET_free(dvh); | 3077 | GNUNET_free (dvh); |
3028 | } | 3078 | } |
3029 | 3079 | ||
3030 | 3080 | ||
@@ -3035,7 +3085,7 @@ free_distance_vector_hop(struct DistanceVectorHop *dvh) | |||
3035 | * @param cls a `struct VirtualLink` | 3085 | * @param cls a `struct VirtualLink` |
3036 | */ | 3086 | */ |
3037 | static void | 3087 | static void |
3038 | check_link_down(void *cls); | 3088 | check_link_down (void *cls); |
3039 | 3089 | ||
3040 | 3090 | ||
3041 | /** | 3091 | /** |
@@ -3044,22 +3094,22 @@ check_link_down(void *cls); | |||
3044 | * @param pid peer the connection was for | 3094 | * @param pid peer the connection was for |
3045 | */ | 3095 | */ |
3046 | static void | 3096 | static void |
3047 | cores_send_disconnect_info(const struct GNUNET_PeerIdentity *pid) | 3097 | cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid) |
3048 | { | 3098 | { |
3049 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3099 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3050 | "Informing CORE clients about disconnect from %s\n", | 3100 | "Informing CORE clients about disconnect from %s\n", |
3051 | GNUNET_i2s(pid)); | 3101 | GNUNET_i2s (pid)); |
3052 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) | 3102 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
3053 | { | 3103 | { |
3054 | struct GNUNET_MQ_Envelope *env; | 3104 | struct GNUNET_MQ_Envelope *env; |
3055 | struct DisconnectInfoMessage *dim; | 3105 | struct DisconnectInfoMessage *dim; |
3056 | 3106 | ||
3057 | if (CT_CORE != tc->type) | 3107 | if (CT_CORE != tc->type) |
3058 | continue; | 3108 | continue; |
3059 | env = GNUNET_MQ_msg(dim, GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); | 3109 | env = GNUNET_MQ_msg (dim, GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); |
3060 | dim->peer = *pid; | 3110 | dim->peer = *pid; |
3061 | GNUNET_MQ_send(tc->mq, env); | 3111 | GNUNET_MQ_send (tc->mq, env); |
3062 | } | 3112 | } |
3063 | } | 3113 | } |
3064 | 3114 | ||
3065 | 3115 | ||
@@ -3070,43 +3120,43 @@ cores_send_disconnect_info(const struct GNUNET_PeerIdentity *pid) | |||
3070 | * @param dv route to free | 3120 | * @param dv route to free |
3071 | */ | 3121 | */ |
3072 | static void | 3122 | static void |
3073 | free_dv_route(struct DistanceVector *dv) | 3123 | free_dv_route (struct DistanceVector *dv) |
3074 | { | 3124 | { |
3075 | struct DistanceVectorHop *dvh; | 3125 | struct DistanceVectorHop *dvh; |
3076 | 3126 | ||
3077 | while (NULL != (dvh = dv->dv_head)) | 3127 | while (NULL != (dvh = dv->dv_head)) |
3078 | free_distance_vector_hop(dvh); | 3128 | free_distance_vector_hop (dvh); |
3079 | if (NULL == dv->dv_head) | 3129 | if (NULL == dv->dv_head) |
3080 | { | 3130 | { |
3081 | struct VirtualLink *vl; | 3131 | struct VirtualLink *vl; |
3082 | 3132 | ||
3083 | GNUNET_assert( | 3133 | GNUNET_assert ( |
3084 | GNUNET_YES == | 3134 | GNUNET_YES == |
3085 | GNUNET_CONTAINER_multipeermap_remove(dv_routes, &dv->target, dv)); | 3135 | GNUNET_CONTAINER_multipeermap_remove (dv_routes, &dv->target, dv)); |
3086 | if (NULL != (vl = dv->vl)) | 3136 | if (NULL != (vl = dv->vl)) |
3087 | { | 3137 | { |
3088 | GNUNET_assert(dv == vl->dv); | 3138 | GNUNET_assert (dv == vl->dv); |
3089 | vl->dv = NULL; | 3139 | vl->dv = NULL; |
3090 | if (NULL == vl->n) | 3140 | if (NULL == vl->n) |
3091 | { | 3141 | { |
3092 | cores_send_disconnect_info(&dv->target); | 3142 | cores_send_disconnect_info (&dv->target); |
3093 | free_virtual_link(vl); | 3143 | free_virtual_link (vl); |
3094 | } | 3144 | } |
3095 | else | 3145 | else |
3096 | { | 3146 | { |
3097 | GNUNET_SCHEDULER_cancel(vl->visibility_task); | 3147 | GNUNET_SCHEDULER_cancel (vl->visibility_task); |
3098 | vl->visibility_task = GNUNET_SCHEDULER_add_now(&check_link_down, vl); | 3148 | vl->visibility_task = GNUNET_SCHEDULER_add_now (&check_link_down, vl); |
3099 | } | 3149 | } |
3100 | dv->vl = NULL; | 3150 | dv->vl = NULL; |
3101 | } | 3151 | } |
3102 | 3152 | ||
3103 | if (NULL != dv->timeout_task) | 3153 | if (NULL != dv->timeout_task) |
3104 | { | 3154 | { |
3105 | GNUNET_SCHEDULER_cancel(dv->timeout_task); | 3155 | GNUNET_SCHEDULER_cancel (dv->timeout_task); |
3106 | dv->timeout_task = NULL; | 3156 | dv->timeout_task = NULL; |
3107 | } | ||
3108 | GNUNET_free(dv); | ||
3109 | } | 3157 | } |
3158 | GNUNET_free (dv); | ||
3159 | } | ||
3110 | } | 3160 | } |
3111 | 3161 | ||
3112 | 3162 | ||
@@ -3124,30 +3174,30 @@ free_dv_route(struct DistanceVector *dv) | |||
3124 | * @param me detailed information to transmit | 3174 | * @param me detailed information to transmit |
3125 | */ | 3175 | */ |
3126 | static void | 3176 | static void |
3127 | notify_monitor(struct TransportClient *tc, | 3177 | notify_monitor (struct TransportClient *tc, |
3128 | const struct GNUNET_PeerIdentity *peer, | 3178 | const struct GNUNET_PeerIdentity *peer, |
3129 | const char *address, | 3179 | const char *address, |
3130 | enum GNUNET_NetworkType nt, | 3180 | enum GNUNET_NetworkType nt, |
3131 | const struct MonitorEvent *me) | 3181 | const struct MonitorEvent *me) |
3132 | { | 3182 | { |
3133 | struct GNUNET_MQ_Envelope *env; | 3183 | struct GNUNET_MQ_Envelope *env; |
3134 | struct GNUNET_TRANSPORT_MonitorData *md; | 3184 | struct GNUNET_TRANSPORT_MonitorData *md; |
3135 | size_t addr_len = strlen(address) + 1; | 3185 | size_t addr_len = strlen (address) + 1; |
3136 | 3186 | ||
3137 | env = GNUNET_MQ_msg_extra(md, | 3187 | env = GNUNET_MQ_msg_extra (md, |
3138 | addr_len, | 3188 | addr_len, |
3139 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA); | 3189 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA); |
3140 | md->nt = htonl((uint32_t)nt); | 3190 | md->nt = htonl ((uint32_t) nt); |
3141 | md->peer = *peer; | 3191 | md->peer = *peer; |
3142 | md->last_validation = GNUNET_TIME_absolute_hton(me->last_validation); | 3192 | md->last_validation = GNUNET_TIME_absolute_hton (me->last_validation); |
3143 | md->valid_until = GNUNET_TIME_absolute_hton(me->valid_until); | 3193 | md->valid_until = GNUNET_TIME_absolute_hton (me->valid_until); |
3144 | md->next_validation = GNUNET_TIME_absolute_hton(me->next_validation); | 3194 | md->next_validation = GNUNET_TIME_absolute_hton (me->next_validation); |
3145 | md->rtt = GNUNET_TIME_relative_hton(me->rtt); | 3195 | md->rtt = GNUNET_TIME_relative_hton (me->rtt); |
3146 | md->cs = htonl((uint32_t)me->cs); | 3196 | md->cs = htonl ((uint32_t) me->cs); |
3147 | md->num_msg_pending = htonl(me->num_msg_pending); | 3197 | md->num_msg_pending = htonl (me->num_msg_pending); |
3148 | md->num_bytes_pending = htonl(me->num_bytes_pending); | 3198 | md->num_bytes_pending = htonl (me->num_bytes_pending); |
3149 | memcpy(&md[1], address, addr_len); | 3199 | memcpy (&md[1], address, addr_len); |
3150 | GNUNET_MQ_send(tc->mq, env); | 3200 | GNUNET_MQ_send (tc->mq, env); |
3151 | } | 3201 | } |
3152 | 3202 | ||
3153 | 3203 | ||
@@ -3161,22 +3211,22 @@ notify_monitor(struct TransportClient *tc, | |||
3161 | * @param me detailed information to transmit | 3211 | * @param me detailed information to transmit |
3162 | */ | 3212 | */ |
3163 | static void | 3213 | static void |
3164 | notify_monitors(const struct GNUNET_PeerIdentity *peer, | 3214 | notify_monitors (const struct GNUNET_PeerIdentity *peer, |
3165 | const char *address, | 3215 | const char *address, |
3166 | enum GNUNET_NetworkType nt, | 3216 | enum GNUNET_NetworkType nt, |
3167 | const struct MonitorEvent *me) | 3217 | const struct MonitorEvent *me) |
3168 | { | 3218 | { |
3169 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) | 3219 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
3170 | { | 3220 | { |
3171 | if (CT_MONITOR != tc->type) | 3221 | if (CT_MONITOR != tc->type) |
3172 | continue; | 3222 | continue; |
3173 | if (tc->details.monitor.one_shot) | 3223 | if (tc->details.monitor.one_shot) |
3174 | continue; | 3224 | continue; |
3175 | if ((0 != GNUNET_is_zero(&tc->details.monitor.peer)) && | 3225 | if ((0 != GNUNET_is_zero (&tc->details.monitor.peer)) && |
3176 | (0 != GNUNET_memcmp(&tc->details.monitor.peer, peer))) | 3226 | (0 != GNUNET_memcmp (&tc->details.monitor.peer, peer))) |
3177 | continue; | 3227 | continue; |
3178 | notify_monitor(tc, peer, address, nt, me); | 3228 | notify_monitor (tc, peer, address, nt, me); |
3179 | } | 3229 | } |
3180 | } | 3230 | } |
3181 | 3231 | ||
3182 | 3232 | ||
@@ -3190,18 +3240,18 @@ notify_monitors(const struct GNUNET_PeerIdentity *peer, | |||
3190 | * @return our `struct TransportClient` | 3240 | * @return our `struct TransportClient` |
3191 | */ | 3241 | */ |
3192 | static void * | 3242 | static void * |
3193 | client_connect_cb(void *cls, | 3243 | client_connect_cb (void *cls, |
3194 | struct GNUNET_SERVICE_Client *client, | 3244 | struct GNUNET_SERVICE_Client *client, |
3195 | struct GNUNET_MQ_Handle *mq) | 3245 | struct GNUNET_MQ_Handle *mq) |
3196 | { | 3246 | { |
3197 | struct TransportClient *tc; | 3247 | struct TransportClient *tc; |
3198 | 3248 | ||
3199 | (void)cls; | 3249 | (void) cls; |
3200 | tc = GNUNET_new(struct TransportClient); | 3250 | tc = GNUNET_new (struct TransportClient); |
3201 | tc->client = client; | 3251 | tc->client = client; |
3202 | tc->mq = mq; | 3252 | tc->mq = mq; |
3203 | GNUNET_CONTAINER_DLL_insert(clients_head, clients_tail, tc); | 3253 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); |
3204 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc); | 3254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc); |
3205 | return tc; | 3255 | return tc; |
3206 | } | 3256 | } |
3207 | 3257 | ||
@@ -3212,16 +3262,16 @@ client_connect_cb(void *cls, | |||
3212 | * @param rc data structure to free | 3262 | * @param rc data structure to free |
3213 | */ | 3263 | */ |
3214 | static void | 3264 | static void |
3215 | free_reassembly_context(struct ReassemblyContext *rc) | 3265 | free_reassembly_context (struct ReassemblyContext *rc) |
3216 | { | 3266 | { |
3217 | struct Neighbour *n = rc->neighbour; | 3267 | struct Neighbour *n = rc->neighbour; |
3218 | 3268 | ||
3219 | GNUNET_assert(rc == GNUNET_CONTAINER_heap_remove_node(rc->hn)); | 3269 | GNUNET_assert (rc == GNUNET_CONTAINER_heap_remove_node (rc->hn)); |
3220 | GNUNET_assert(GNUNET_OK == | 3270 | GNUNET_assert (GNUNET_OK == |
3221 | GNUNET_CONTAINER_multihashmap32_remove(n->reassembly_map, | 3271 | GNUNET_CONTAINER_multihashmap32_remove (n->reassembly_map, |
3222 | rc->msg_uuid.uuid, | 3272 | rc->msg_uuid.uuid, |
3223 | rc)); | 3273 | rc)); |
3224 | GNUNET_free(rc); | 3274 | GNUNET_free (rc); |
3225 | } | 3275 | } |
3226 | 3276 | ||
3227 | 3277 | ||
@@ -3231,27 +3281,27 @@ free_reassembly_context(struct ReassemblyContext *rc) | |||
3231 | * @param cls a `struct Neighbour` | 3281 | * @param cls a `struct Neighbour` |
3232 | */ | 3282 | */ |
3233 | static void | 3283 | static void |
3234 | reassembly_cleanup_task(void *cls) | 3284 | reassembly_cleanup_task (void *cls) |
3235 | { | 3285 | { |
3236 | struct Neighbour *n = cls; | 3286 | struct Neighbour *n = cls; |
3237 | struct ReassemblyContext *rc; | 3287 | struct ReassemblyContext *rc; |
3238 | 3288 | ||
3239 | n->reassembly_timeout_task = NULL; | 3289 | n->reassembly_timeout_task = NULL; |
3240 | while (NULL != (rc = GNUNET_CONTAINER_heap_peek(n->reassembly_heap))) | 3290 | while (NULL != (rc = GNUNET_CONTAINER_heap_peek (n->reassembly_heap))) |
3291 | { | ||
3292 | if (0 == GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout) | ||
3293 | .rel_value_us) | ||
3241 | { | 3294 | { |
3242 | if (0 == GNUNET_TIME_absolute_get_remaining(rc->reassembly_timeout) | 3295 | free_reassembly_context (rc); |
3243 | .rel_value_us) | 3296 | continue; |
3244 | { | ||
3245 | free_reassembly_context(rc); | ||
3246 | continue; | ||
3247 | } | ||
3248 | GNUNET_assert(NULL == n->reassembly_timeout_task); | ||
3249 | n->reassembly_timeout_task = | ||
3250 | GNUNET_SCHEDULER_add_at(rc->reassembly_timeout, | ||
3251 | &reassembly_cleanup_task, | ||
3252 | n); | ||
3253 | return; | ||
3254 | } | 3297 | } |
3298 | GNUNET_assert (NULL == n->reassembly_timeout_task); | ||
3299 | n->reassembly_timeout_task = | ||
3300 | GNUNET_SCHEDULER_add_at (rc->reassembly_timeout, | ||
3301 | &reassembly_cleanup_task, | ||
3302 | n); | ||
3303 | return; | ||
3304 | } | ||
3255 | } | 3305 | } |
3256 | 3306 | ||
3257 | 3307 | ||
@@ -3264,13 +3314,13 @@ reassembly_cleanup_task(void *cls) | |||
3264 | * @return #GNUNET_OK (continue iteration) | 3314 | * @return #GNUNET_OK (continue iteration) |
3265 | */ | 3315 | */ |
3266 | static int | 3316 | static int |
3267 | free_reassembly_cb(void *cls, uint32_t key, void *value) | 3317 | free_reassembly_cb (void *cls, uint32_t key, void *value) |
3268 | { | 3318 | { |
3269 | struct ReassemblyContext *rc = value; | 3319 | struct ReassemblyContext *rc = value; |
3270 | 3320 | ||
3271 | (void)cls; | 3321 | (void) cls; |
3272 | (void)key; | 3322 | (void) key; |
3273 | free_reassembly_context(rc); | 3323 | free_reassembly_context (rc); |
3274 | return GNUNET_OK; | 3324 | return GNUNET_OK; |
3275 | } | 3325 | } |
3276 | 3326 | ||
@@ -3281,66 +3331,66 @@ free_reassembly_cb(void *cls, uint32_t key, void *value) | |||
3281 | * @param neighbour neighbour entry to free | 3331 | * @param neighbour neighbour entry to free |
3282 | */ | 3332 | */ |
3283 | static void | 3333 | static void |
3284 | free_neighbour(struct Neighbour *neighbour) | 3334 | free_neighbour (struct Neighbour *neighbour) |
3285 | { | 3335 | { |
3286 | struct DistanceVectorHop *dvh; | 3336 | struct DistanceVectorHop *dvh; |
3287 | struct VirtualLink *vl; | 3337 | struct VirtualLink *vl; |
3288 | 3338 | ||
3289 | GNUNET_assert(NULL == neighbour->queue_head); | 3339 | GNUNET_assert (NULL == neighbour->queue_head); |
3290 | GNUNET_assert(GNUNET_YES == | 3340 | GNUNET_assert (GNUNET_YES == |
3291 | GNUNET_CONTAINER_multipeermap_remove(neighbours, | 3341 | GNUNET_CONTAINER_multipeermap_remove (neighbours, |
3292 | &neighbour->pid, | 3342 | &neighbour->pid, |
3293 | neighbour)); | 3343 | neighbour)); |
3294 | if (NULL != neighbour->reassembly_map) | 3344 | if (NULL != neighbour->reassembly_map) |
3295 | { | 3345 | { |
3296 | GNUNET_CONTAINER_multihashmap32_iterate(neighbour->reassembly_map, | 3346 | GNUNET_CONTAINER_multihashmap32_iterate (neighbour->reassembly_map, |
3297 | &free_reassembly_cb, | 3347 | &free_reassembly_cb, |
3298 | NULL); | 3348 | NULL); |
3299 | GNUNET_CONTAINER_multihashmap32_destroy(neighbour->reassembly_map); | 3349 | GNUNET_CONTAINER_multihashmap32_destroy (neighbour->reassembly_map); |
3300 | neighbour->reassembly_map = NULL; | 3350 | neighbour->reassembly_map = NULL; |
3301 | GNUNET_CONTAINER_heap_destroy(neighbour->reassembly_heap); | 3351 | GNUNET_CONTAINER_heap_destroy (neighbour->reassembly_heap); |
3302 | neighbour->reassembly_heap = NULL; | 3352 | neighbour->reassembly_heap = NULL; |
3303 | } | 3353 | } |
3304 | while (NULL != (dvh = neighbour->dv_head)) | 3354 | while (NULL != (dvh = neighbour->dv_head)) |
3305 | { | 3355 | { |
3306 | struct DistanceVector *dv = dvh->dv; | 3356 | struct DistanceVector *dv = dvh->dv; |
3307 | 3357 | ||
3308 | free_distance_vector_hop(dvh); | 3358 | free_distance_vector_hop (dvh); |
3309 | if (NULL == dv->dv_head) | 3359 | if (NULL == dv->dv_head) |
3310 | free_dv_route(dv); | 3360 | free_dv_route (dv); |
3311 | } | 3361 | } |
3312 | if (NULL != neighbour->reassembly_timeout_task) | 3362 | if (NULL != neighbour->reassembly_timeout_task) |
3313 | { | 3363 | { |
3314 | GNUNET_SCHEDULER_cancel(neighbour->reassembly_timeout_task); | 3364 | GNUNET_SCHEDULER_cancel (neighbour->reassembly_timeout_task); |
3315 | neighbour->reassembly_timeout_task = NULL; | 3365 | neighbour->reassembly_timeout_task = NULL; |
3316 | } | 3366 | } |
3317 | if (NULL != neighbour->get) | 3367 | if (NULL != neighbour->get) |
3318 | { | 3368 | { |
3319 | GNUNET_PEERSTORE_iterate_cancel(neighbour->get); | 3369 | GNUNET_PEERSTORE_iterate_cancel (neighbour->get); |
3320 | neighbour->get = NULL; | 3370 | neighbour->get = NULL; |
3321 | } | 3371 | } |
3322 | if (NULL != neighbour->sc) | 3372 | if (NULL != neighbour->sc) |
3373 | { | ||
3374 | GNUNET_PEERSTORE_store_cancel (neighbour->sc); | ||
3375 | neighbour->sc = NULL; | ||
3376 | } | ||
3377 | if (NULL != (vl = neighbour->vl)) | ||
3378 | { | ||
3379 | GNUNET_assert (neighbour == vl->n); | ||
3380 | vl->n = NULL; | ||
3381 | if (NULL == vl->dv) | ||
3323 | { | 3382 | { |
3324 | GNUNET_PEERSTORE_store_cancel(neighbour->sc); | 3383 | cores_send_disconnect_info (&vl->target); |
3325 | neighbour->sc = NULL; | 3384 | free_virtual_link (vl); |
3326 | } | 3385 | } |
3327 | if (NULL != (vl = neighbour->vl)) | 3386 | else |
3328 | { | 3387 | { |
3329 | GNUNET_assert(neighbour == vl->n); | 3388 | GNUNET_SCHEDULER_cancel (vl->visibility_task); |
3330 | vl->n = NULL; | 3389 | vl->visibility_task = GNUNET_SCHEDULER_add_now (&check_link_down, vl); |
3331 | if (NULL == vl->dv) | ||
3332 | { | ||
3333 | cores_send_disconnect_info(&vl->target); | ||
3334 | free_virtual_link(vl); | ||
3335 | } | ||
3336 | else | ||
3337 | { | ||
3338 | GNUNET_SCHEDULER_cancel(vl->visibility_task); | ||
3339 | vl->visibility_task = GNUNET_SCHEDULER_add_now(&check_link_down, vl); | ||
3340 | } | ||
3341 | neighbour->vl = NULL; | ||
3342 | } | 3390 | } |
3343 | GNUNET_free(neighbour); | 3391 | neighbour->vl = NULL; |
3392 | } | ||
3393 | GNUNET_free (neighbour); | ||
3344 | } | 3394 | } |
3345 | 3395 | ||
3346 | 3396 | ||
@@ -3351,16 +3401,16 @@ free_neighbour(struct Neighbour *neighbour) | |||
3351 | * @param pid peer the connection is for | 3401 | * @param pid peer the connection is for |
3352 | */ | 3402 | */ |
3353 | static void | 3403 | static void |
3354 | core_send_connect_info(struct TransportClient *tc, | 3404 | core_send_connect_info (struct TransportClient *tc, |
3355 | const struct GNUNET_PeerIdentity *pid) | 3405 | const struct GNUNET_PeerIdentity *pid) |
3356 | { | 3406 | { |
3357 | struct GNUNET_MQ_Envelope *env; | 3407 | struct GNUNET_MQ_Envelope *env; |
3358 | struct ConnectInfoMessage *cim; | 3408 | struct ConnectInfoMessage *cim; |
3359 | 3409 | ||
3360 | GNUNET_assert(CT_CORE == tc->type); | 3410 | GNUNET_assert (CT_CORE == tc->type); |
3361 | env = GNUNET_MQ_msg(cim, GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 3411 | env = GNUNET_MQ_msg (cim, GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
3362 | cim->id = *pid; | 3412 | cim->id = *pid; |
3363 | GNUNET_MQ_send(tc->mq, env); | 3413 | GNUNET_MQ_send (tc->mq, env); |
3364 | } | 3414 | } |
3365 | 3415 | ||
3366 | 3416 | ||
@@ -3370,17 +3420,17 @@ core_send_connect_info(struct TransportClient *tc, | |||
3370 | * @param pid peer the queue was for | 3420 | * @param pid peer the queue was for |
3371 | */ | 3421 | */ |
3372 | static void | 3422 | static void |
3373 | cores_send_connect_info(const struct GNUNET_PeerIdentity *pid) | 3423 | cores_send_connect_info (const struct GNUNET_PeerIdentity *pid) |
3374 | { | 3424 | { |
3375 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3425 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3376 | "Informing CORE clients about connection to %s\n", | 3426 | "Informing CORE clients about connection to %s\n", |
3377 | GNUNET_i2s(pid)); | 3427 | GNUNET_i2s (pid)); |
3378 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) | 3428 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
3379 | { | 3429 | { |
3380 | if (CT_CORE != tc->type) | 3430 | if (CT_CORE != tc->type) |
3381 | continue; | 3431 | continue; |
3382 | core_send_connect_info(tc, pid); | 3432 | core_send_connect_info (tc, pid); |
3383 | } | 3433 | } |
3384 | } | 3434 | } |
3385 | 3435 | ||
3386 | 3436 | ||
@@ -3392,7 +3442,7 @@ cores_send_connect_info(const struct GNUNET_PeerIdentity *pid) | |||
3392 | * @param cls the `struct Queue` to process transmissions for | 3442 | * @param cls the `struct Queue` to process transmissions for |
3393 | */ | 3443 | */ |
3394 | static void | 3444 | static void |
3395 | transmit_on_queue(void *cls); | 3445 | transmit_on_queue (void *cls); |
3396 | 3446 | ||
3397 | 3447 | ||
3398 | /** | 3448 | /** |
@@ -3403,38 +3453,38 @@ transmit_on_queue(void *cls); | |||
3403 | * @param p task priority to use, if @a queue is scheduled | 3453 | * @param p task priority to use, if @a queue is scheduled |
3404 | */ | 3454 | */ |
3405 | static void | 3455 | static void |
3406 | schedule_transmit_on_queue(struct Queue *queue, | 3456 | schedule_transmit_on_queue (struct Queue *queue, |
3407 | enum GNUNET_SCHEDULER_Priority p) | 3457 | enum GNUNET_SCHEDULER_Priority p) |
3408 | { | 3458 | { |
3409 | if (queue->tc->details.communicator.total_queue_length >= | 3459 | if (queue->tc->details.communicator.total_queue_length >= |
3410 | COMMUNICATOR_TOTAL_QUEUE_LIMIT) | 3460 | COMMUNICATOR_TOTAL_QUEUE_LIMIT) |
3411 | { | 3461 | { |
3412 | GNUNET_STATISTICS_update( | 3462 | GNUNET_STATISTICS_update ( |
3413 | GST_stats, | 3463 | GST_stats, |
3414 | "# Transmission throttled due to communicator queue limit", | 3464 | "# Transmission throttled due to communicator queue limit", |
3415 | 1, | 3465 | 1, |
3416 | GNUNET_NO); | 3466 | GNUNET_NO); |
3417 | queue->idle = GNUNET_NO; | 3467 | queue->idle = GNUNET_NO; |
3418 | return; | 3468 | return; |
3419 | } | 3469 | } |
3420 | if (queue->queue_length >= QUEUE_LENGTH_LIMIT) | 3470 | if (queue->queue_length >= QUEUE_LENGTH_LIMIT) |
3421 | { | 3471 | { |
3422 | GNUNET_STATISTICS_update(GST_stats, | 3472 | GNUNET_STATISTICS_update (GST_stats, |
3423 | "# Transmission throttled due to queue queue limit", | 3473 | "# Transmission throttled due to queue queue limit", |
3424 | 1, | 3474 | 1, |
3425 | GNUNET_NO); | 3475 | GNUNET_NO); |
3426 | queue->idle = GNUNET_NO; | 3476 | queue->idle = GNUNET_NO; |
3427 | return; | 3477 | return; |
3428 | } | 3478 | } |
3429 | /* queue might indeed be ready, schedule it */ | 3479 | /* queue might indeed be ready, schedule it */ |
3430 | if (NULL != queue->transmit_task) | 3480 | if (NULL != queue->transmit_task) |
3431 | GNUNET_SCHEDULER_cancel(queue->transmit_task); | 3481 | GNUNET_SCHEDULER_cancel (queue->transmit_task); |
3432 | queue->transmit_task = | 3482 | queue->transmit_task = |
3433 | GNUNET_SCHEDULER_add_with_priority(p, &transmit_on_queue, queue); | 3483 | GNUNET_SCHEDULER_add_with_priority (p, &transmit_on_queue, queue); |
3434 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3484 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3435 | "Considering transmission on queue `%s' to %s\n", | 3485 | "Considering transmission on queue `%s' to %s\n", |
3436 | queue->address, | 3486 | queue->address, |
3437 | GNUNET_i2s(&queue->neighbour->pid)); | 3487 | GNUNET_i2s (&queue->neighbour->pid)); |
3438 | } | 3488 | } |
3439 | 3489 | ||
3440 | 3490 | ||
@@ -3445,7 +3495,7 @@ schedule_transmit_on_queue(struct Queue *queue, | |||
3445 | * @param cls a `struct VirtualLink` | 3495 | * @param cls a `struct VirtualLink` |
3446 | */ | 3496 | */ |
3447 | static void | 3497 | static void |
3448 | check_link_down(void *cls) | 3498 | check_link_down (void *cls) |
3449 | { | 3499 | { |
3450 | struct VirtualLink *vl = cls; | 3500 | struct VirtualLink *vl = cls; |
3451 | struct DistanceVector *dv = vl->dv; | 3501 | struct DistanceVector *dv = vl->dv; |
@@ -3457,30 +3507,30 @@ check_link_down(void *cls) | |||
3457 | dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS; | 3507 | dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS; |
3458 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | 3508 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; |
3459 | pos = pos->next_dv) | 3509 | pos = pos->next_dv) |
3460 | dvh_timeout = GNUNET_TIME_absolute_max(dvh_timeout, pos->path_valid_until); | 3510 | dvh_timeout = GNUNET_TIME_absolute_max (dvh_timeout, pos->path_valid_until); |
3461 | if (0 == GNUNET_TIME_absolute_get_remaining(dvh_timeout).rel_value_us) | 3511 | if (0 == GNUNET_TIME_absolute_get_remaining (dvh_timeout).rel_value_us) |
3462 | { | 3512 | { |
3463 | vl->dv->vl = NULL; | 3513 | vl->dv->vl = NULL; |
3464 | vl->dv = NULL; | 3514 | vl->dv = NULL; |
3465 | } | 3515 | } |
3466 | q_timeout = GNUNET_TIME_UNIT_ZERO_ABS; | 3516 | q_timeout = GNUNET_TIME_UNIT_ZERO_ABS; |
3467 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) | 3517 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) |
3468 | q_timeout = GNUNET_TIME_absolute_max(q_timeout, q->validated_until); | 3518 | q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until); |
3469 | if (0 == GNUNET_TIME_absolute_get_remaining(q_timeout).rel_value_us) | 3519 | if (0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us) |
3470 | { | 3520 | { |
3471 | vl->n->vl = NULL; | 3521 | vl->n->vl = NULL; |
3472 | vl->n = NULL; | 3522 | vl->n = NULL; |
3473 | } | 3523 | } |
3474 | if ((NULL == vl->n) && (NULL == vl->dv)) | 3524 | if ((NULL == vl->n) && (NULL == vl->dv)) |
3475 | { | 3525 | { |
3476 | cores_send_disconnect_info(&vl->target); | 3526 | cores_send_disconnect_info (&vl->target); |
3477 | free_virtual_link(vl); | 3527 | free_virtual_link (vl); |
3478 | return; | 3528 | return; |
3479 | } | 3529 | } |
3480 | vl->visibility_task = | 3530 | vl->visibility_task = |
3481 | GNUNET_SCHEDULER_add_at(GNUNET_TIME_absolute_max(q_timeout, dvh_timeout), | 3531 | GNUNET_SCHEDULER_add_at (GNUNET_TIME_absolute_max (q_timeout, dvh_timeout), |
3482 | &check_link_down, | 3532 | &check_link_down, |
3483 | vl); | 3533 | vl); |
3484 | } | 3534 | } |
3485 | 3535 | ||
3486 | 3536 | ||
@@ -3490,7 +3540,7 @@ check_link_down(void *cls) | |||
3490 | * @param queue the queue to free | 3540 | * @param queue the queue to free |
3491 | */ | 3541 | */ |
3492 | static void | 3542 | static void |
3493 | free_queue(struct Queue *queue) | 3543 | free_queue (struct Queue *queue) |
3494 | { | 3544 | { |
3495 | struct Neighbour *neighbour = queue->neighbour; | 3545 | struct Neighbour *neighbour = queue->neighbour; |
3496 | struct TransportClient *tc = queue->tc; | 3546 | struct TransportClient *tc = queue->tc; |
@@ -3502,65 +3552,65 @@ free_queue(struct Queue *queue) | |||
3502 | struct VirtualLink *vl; | 3552 | struct VirtualLink *vl; |
3503 | 3553 | ||
3504 | if (NULL != queue->transmit_task) | 3554 | if (NULL != queue->transmit_task) |
3505 | { | 3555 | { |
3506 | GNUNET_SCHEDULER_cancel(queue->transmit_task); | 3556 | GNUNET_SCHEDULER_cancel (queue->transmit_task); |
3507 | queue->transmit_task = NULL; | 3557 | queue->transmit_task = NULL; |
3508 | } | 3558 | } |
3509 | while (NULL != (pa = queue->pa_head)) | 3559 | while (NULL != (pa = queue->pa_head)) |
3510 | { | 3560 | { |
3511 | GNUNET_CONTAINER_MDLL_remove(queue, queue->pa_head, queue->pa_tail, pa); | 3561 | GNUNET_CONTAINER_MDLL_remove (queue, queue->pa_head, queue->pa_tail, pa); |
3512 | pa->queue = NULL; | 3562 | pa->queue = NULL; |
3513 | } | 3563 | } |
3514 | 3564 | ||
3515 | GNUNET_CONTAINER_MDLL_remove(neighbour, | 3565 | GNUNET_CONTAINER_MDLL_remove (neighbour, |
3516 | neighbour->queue_head, | 3566 | neighbour->queue_head, |
3517 | neighbour->queue_tail, | 3567 | neighbour->queue_tail, |
3518 | queue); | 3568 | queue); |
3519 | GNUNET_CONTAINER_MDLL_remove(client, | 3569 | GNUNET_CONTAINER_MDLL_remove (client, |
3520 | tc->details.communicator.queue_head, | 3570 | tc->details.communicator.queue_head, |
3521 | tc->details.communicator.queue_tail, | 3571 | tc->details.communicator.queue_tail, |
3522 | queue); | 3572 | queue); |
3523 | maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >= | 3573 | maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >= |
3524 | tc->details.communicator.total_queue_length); | 3574 | tc->details.communicator.total_queue_length); |
3525 | while (NULL != (qe = queue->queue_head)) | 3575 | while (NULL != (qe = queue->queue_head)) |
3576 | { | ||
3577 | GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe); | ||
3578 | queue->queue_length--; | ||
3579 | tc->details.communicator.total_queue_length--; | ||
3580 | if (NULL != qe->pm) | ||
3526 | { | 3581 | { |
3527 | GNUNET_CONTAINER_DLL_remove(queue->queue_head, queue->queue_tail, qe); | 3582 | GNUNET_assert (qe == qe->pm->qe); |
3528 | queue->queue_length--; | 3583 | qe->pm->qe = NULL; |
3529 | tc->details.communicator.total_queue_length--; | ||
3530 | if (NULL != qe->pm) | ||
3531 | { | ||
3532 | GNUNET_assert(qe == qe->pm->qe); | ||
3533 | qe->pm->qe = NULL; | ||
3534 | } | ||
3535 | GNUNET_free(qe); | ||
3536 | } | 3584 | } |
3537 | GNUNET_assert(0 == queue->queue_length); | 3585 | GNUNET_free (qe); |
3586 | } | ||
3587 | GNUNET_assert (0 == queue->queue_length); | ||
3538 | if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT < | 3588 | if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT < |
3539 | tc->details.communicator.total_queue_length)) | 3589 | tc->details.communicator.total_queue_length)) |
3540 | { | 3590 | { |
3541 | /* Communicator dropped below threshold, resume all _other_ queues */ | 3591 | /* Communicator dropped below threshold, resume all _other_ queues */ |
3542 | GNUNET_STATISTICS_update( | 3592 | GNUNET_STATISTICS_update ( |
3543 | GST_stats, | 3593 | GST_stats, |
3544 | "# Transmission throttled due to communicator queue limit", | 3594 | "# Transmission throttled due to communicator queue limit", |
3545 | -1, | 3595 | -1, |
3546 | GNUNET_NO); | 3596 | GNUNET_NO); |
3547 | for (struct Queue *s = tc->details.communicator.queue_head; NULL != s; | 3597 | for (struct Queue *s = tc->details.communicator.queue_head; NULL != s; |
3548 | s = s->next_client) | 3598 | s = s->next_client) |
3549 | schedule_transmit_on_queue(s, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 3599 | schedule_transmit_on_queue (s, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
3550 | } | 3600 | } |
3551 | notify_monitors(&neighbour->pid, queue->address, queue->nt, &me); | 3601 | notify_monitors (&neighbour->pid, queue->address, queue->nt, &me); |
3552 | GNUNET_free(queue); | 3602 | GNUNET_free (queue); |
3553 | 3603 | ||
3554 | vl = lookup_virtual_link(&neighbour->pid); | 3604 | vl = lookup_virtual_link (&neighbour->pid); |
3555 | if ((NULL != vl) && (neighbour == vl->n)) | 3605 | if ((NULL != vl) && (neighbour == vl->n)) |
3556 | { | 3606 | { |
3557 | GNUNET_SCHEDULER_cancel(vl->visibility_task); | 3607 | GNUNET_SCHEDULER_cancel (vl->visibility_task); |
3558 | check_link_down(vl); | 3608 | check_link_down (vl); |
3559 | } | 3609 | } |
3560 | if (NULL == neighbour->queue_head) | 3610 | if (NULL == neighbour->queue_head) |
3561 | { | 3611 | { |
3562 | free_neighbour(neighbour); | 3612 | free_neighbour (neighbour); |
3563 | } | 3613 | } |
3564 | } | 3614 | } |
3565 | 3615 | ||
3566 | 3616 | ||
@@ -3570,24 +3620,24 @@ free_queue(struct Queue *queue) | |||
3570 | * @param ale address list entry to free | 3620 | * @param ale address list entry to free |
3571 | */ | 3621 | */ |
3572 | static void | 3622 | static void |
3573 | free_address_list_entry(struct AddressListEntry *ale) | 3623 | free_address_list_entry (struct AddressListEntry *ale) |
3574 | { | 3624 | { |
3575 | struct TransportClient *tc = ale->tc; | 3625 | struct TransportClient *tc = ale->tc; |
3576 | 3626 | ||
3577 | GNUNET_CONTAINER_DLL_remove(tc->details.communicator.addr_head, | 3627 | GNUNET_CONTAINER_DLL_remove (tc->details.communicator.addr_head, |
3578 | tc->details.communicator.addr_tail, | 3628 | tc->details.communicator.addr_tail, |
3579 | ale); | 3629 | ale); |
3580 | if (NULL != ale->sc) | 3630 | if (NULL != ale->sc) |
3581 | { | 3631 | { |
3582 | GNUNET_PEERSTORE_store_cancel(ale->sc); | 3632 | GNUNET_PEERSTORE_store_cancel (ale->sc); |
3583 | ale->sc = NULL; | 3633 | ale->sc = NULL; |
3584 | } | 3634 | } |
3585 | if (NULL != ale->st) | 3635 | if (NULL != ale->st) |
3586 | { | 3636 | { |
3587 | GNUNET_SCHEDULER_cancel(ale->st); | 3637 | GNUNET_SCHEDULER_cancel (ale->st); |
3588 | ale->st = NULL; | 3638 | ale->st = NULL; |
3589 | } | 3639 | } |
3590 | GNUNET_free(ale); | 3640 | GNUNET_free (ale); |
3591 | } | 3641 | } |
3592 | 3642 | ||
3593 | 3643 | ||
@@ -3600,20 +3650,20 @@ free_address_list_entry(struct AddressListEntry *ale) | |||
3600 | * @return #GNUNET_YES (always) | 3650 | * @return #GNUNET_YES (always) |
3601 | */ | 3651 | */ |
3602 | static int | 3652 | static int |
3603 | stop_peer_request(void *cls, | 3653 | stop_peer_request (void *cls, |
3604 | const struct GNUNET_PeerIdentity *pid, | 3654 | const struct GNUNET_PeerIdentity *pid, |
3605 | void *value) | 3655 | void *value) |
3606 | { | 3656 | { |
3607 | struct TransportClient *tc = cls; | 3657 | struct TransportClient *tc = cls; |
3608 | struct PeerRequest *pr = value; | 3658 | struct PeerRequest *pr = value; |
3609 | 3659 | ||
3610 | GNUNET_PEERSTORE_watch_cancel(pr->wc); | 3660 | GNUNET_PEERSTORE_watch_cancel (pr->wc); |
3611 | GNUNET_assert( | 3661 | GNUNET_assert ( |
3612 | GNUNET_YES == | 3662 | GNUNET_YES == |
3613 | GNUNET_CONTAINER_multipeermap_remove(tc->details.application.requests, | 3663 | GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests, |
3614 | pid, | 3664 | pid, |
3615 | pr)); | 3665 | pr)); |
3616 | GNUNET_free(pr); | 3666 | GNUNET_free (pr); |
3617 | 3667 | ||
3618 | return GNUNET_OK; | 3668 | return GNUNET_OK; |
3619 | } | 3669 | } |
@@ -3628,60 +3678,60 @@ stop_peer_request(void *cls, | |||
3628 | * @param app_ctx our `struct TransportClient` | 3678 | * @param app_ctx our `struct TransportClient` |
3629 | */ | 3679 | */ |
3630 | static void | 3680 | static void |
3631 | client_disconnect_cb(void *cls, | 3681 | client_disconnect_cb (void *cls, |
3632 | struct GNUNET_SERVICE_Client *client, | 3682 | struct GNUNET_SERVICE_Client *client, |
3633 | void *app_ctx) | 3683 | void *app_ctx) |
3634 | { | 3684 | { |
3635 | struct TransportClient *tc = app_ctx; | 3685 | struct TransportClient *tc = app_ctx; |
3636 | 3686 | ||
3637 | (void)cls; | 3687 | (void) cls; |
3638 | (void)client; | 3688 | (void) client; |
3639 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3689 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3640 | "Client %p disconnected, cleaning up.\n", | 3690 | "Client %p disconnected, cleaning up.\n", |
3641 | tc); | 3691 | tc); |
3642 | GNUNET_CONTAINER_DLL_remove(clients_head, clients_tail, tc); | 3692 | GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc); |
3643 | switch (tc->type) | 3693 | switch (tc->type) |
3644 | { | 3694 | { |
3645 | case CT_NONE: | 3695 | case CT_NONE: |
3646 | break; | 3696 | break; |
3647 | 3697 | ||
3648 | case CT_CORE: { | 3698 | case CT_CORE: { |
3649 | struct PendingMessage *pm; | 3699 | struct PendingMessage *pm; |
3650 | 3700 | ||
3651 | while (NULL != (pm = tc->details.core.pending_msg_head)) | 3701 | while (NULL != (pm = tc->details.core.pending_msg_head)) |
3652 | { | 3702 | { |
3653 | GNUNET_CONTAINER_MDLL_remove(client, | 3703 | GNUNET_CONTAINER_MDLL_remove (client, |
3654 | tc->details.core.pending_msg_head, | 3704 | tc->details.core.pending_msg_head, |
3655 | tc->details.core.pending_msg_tail, | 3705 | tc->details.core.pending_msg_tail, |
3656 | pm); | 3706 | pm); |
3657 | pm->client = NULL; | 3707 | pm->client = NULL; |
3658 | } | 3708 | } |
3659 | } | 3709 | } |
3660 | break; | 3710 | break; |
3661 | 3711 | ||
3662 | case CT_MONITOR: | 3712 | case CT_MONITOR: |
3663 | break; | 3713 | break; |
3664 | 3714 | ||
3665 | case CT_COMMUNICATOR: { | 3715 | case CT_COMMUNICATOR: { |
3666 | struct Queue *q; | 3716 | struct Queue *q; |
3667 | struct AddressListEntry *ale; | 3717 | struct AddressListEntry *ale; |
3668 | 3718 | ||
3669 | while (NULL != (q = tc->details.communicator.queue_head)) | 3719 | while (NULL != (q = tc->details.communicator.queue_head)) |
3670 | free_queue(q); | 3720 | free_queue (q); |
3671 | while (NULL != (ale = tc->details.communicator.addr_head)) | 3721 | while (NULL != (ale = tc->details.communicator.addr_head)) |
3672 | free_address_list_entry(ale); | 3722 | free_address_list_entry (ale); |
3673 | GNUNET_free(tc->details.communicator.address_prefix); | 3723 | GNUNET_free (tc->details.communicator.address_prefix); |
3674 | } | 3724 | } |
3675 | break; | 3725 | break; |
3676 | 3726 | ||
3677 | case CT_APPLICATION: | 3727 | case CT_APPLICATION: |
3678 | GNUNET_CONTAINER_multipeermap_iterate(tc->details.application.requests, | 3728 | GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests, |
3679 | &stop_peer_request, | 3729 | &stop_peer_request, |
3680 | tc); | 3730 | tc); |
3681 | GNUNET_CONTAINER_multipeermap_destroy(tc->details.application.requests); | 3731 | GNUNET_CONTAINER_multipeermap_destroy (tc->details.application.requests); |
3682 | break; | 3732 | break; |
3683 | } | 3733 | } |
3684 | GNUNET_free(tc); | 3734 | GNUNET_free (tc); |
3685 | } | 3735 | } |
3686 | 3736 | ||
3687 | 3737 | ||
@@ -3695,17 +3745,17 @@ client_disconnect_cb(void *cls, | |||
3695 | * @return #GNUNET_OK (continue to iterate) | 3745 | * @return #GNUNET_OK (continue to iterate) |
3696 | */ | 3746 | */ |
3697 | static int | 3747 | static int |
3698 | notify_client_connect_info(void *cls, | 3748 | notify_client_connect_info (void *cls, |
3699 | const struct GNUNET_PeerIdentity *pid, | 3749 | const struct GNUNET_PeerIdentity *pid, |
3700 | void *value) | 3750 | void *value) |
3701 | { | 3751 | { |
3702 | struct TransportClient *tc = cls; | 3752 | struct TransportClient *tc = cls; |
3703 | 3753 | ||
3704 | (void)value; | 3754 | (void) value; |
3705 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3706 | "Telling new CORE client about existing connection to %s\n", | 3756 | "Telling new CORE client about existing connection to %s\n", |
3707 | GNUNET_i2s(pid)); | 3757 | GNUNET_i2s (pid)); |
3708 | core_send_connect_info(tc, pid); | 3758 | core_send_connect_info (tc, pid); |
3709 | return GNUNET_OK; | 3759 | return GNUNET_OK; |
3710 | } | 3760 | } |
3711 | 3761 | ||
@@ -3719,34 +3769,34 @@ notify_client_connect_info(void *cls, | |||
3719 | * @param start the start message that was sent | 3769 | * @param start the start message that was sent |
3720 | */ | 3770 | */ |
3721 | static void | 3771 | static void |
3722 | handle_client_start(void *cls, const struct StartMessage *start) | 3772 | handle_client_start (void *cls, const struct StartMessage *start) |
3723 | { | 3773 | { |
3724 | struct TransportClient *tc = cls; | 3774 | struct TransportClient *tc = cls; |
3725 | uint32_t options; | 3775 | uint32_t options; |
3726 | 3776 | ||
3727 | options = ntohl(start->options); | 3777 | options = ntohl (start->options); |
3728 | if ((0 != (1 & options)) && | 3778 | if ((0 != (1 & options)) && |
3729 | (0 != GNUNET_memcmp(&start->self, &GST_my_identity))) | 3779 | (0 != GNUNET_memcmp (&start->self, &GST_my_identity))) |
3730 | { | 3780 | { |
3731 | /* client thinks this is a different peer, reject */ | 3781 | /* client thinks this is a different peer, reject */ |
3732 | GNUNET_break(0); | 3782 | GNUNET_break (0); |
3733 | GNUNET_SERVICE_client_drop(tc->client); | 3783 | GNUNET_SERVICE_client_drop (tc->client); |
3734 | return; | 3784 | return; |
3735 | } | 3785 | } |
3736 | if (CT_NONE != tc->type) | 3786 | if (CT_NONE != tc->type) |
3737 | { | 3787 | { |
3738 | GNUNET_break(0); | 3788 | GNUNET_break (0); |
3739 | GNUNET_SERVICE_client_drop(tc->client); | 3789 | GNUNET_SERVICE_client_drop (tc->client); |
3740 | return; | 3790 | return; |
3741 | } | 3791 | } |
3742 | tc->type = CT_CORE; | 3792 | tc->type = CT_CORE; |
3743 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3793 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3744 | "New CORE client with PID %s registered\n", | 3794 | "New CORE client with PID %s registered\n", |
3745 | GNUNET_i2s(&start->self)); | 3795 | GNUNET_i2s (&start->self)); |
3746 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, | 3796 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
3747 | ¬ify_client_connect_info, | 3797 | ¬ify_client_connect_info, |
3748 | tc); | 3798 | tc); |
3749 | GNUNET_SERVICE_client_continue(tc->client); | 3799 | GNUNET_SERVICE_client_continue (tc->client); |
3750 | } | 3800 | } |
3751 | 3801 | ||
3752 | 3802 | ||
@@ -3757,29 +3807,29 @@ handle_client_start(void *cls, const struct StartMessage *start) | |||
3757 | * @param obm the send message that was sent | 3807 | * @param obm the send message that was sent |
3758 | */ | 3808 | */ |
3759 | static int | 3809 | static int |
3760 | check_client_send(void *cls, const struct OutboundMessage *obm) | 3810 | check_client_send (void *cls, const struct OutboundMessage *obm) |
3761 | { | 3811 | { |
3762 | struct TransportClient *tc = cls; | 3812 | struct TransportClient *tc = cls; |
3763 | uint16_t size; | 3813 | uint16_t size; |
3764 | const struct GNUNET_MessageHeader *obmm; | 3814 | const struct GNUNET_MessageHeader *obmm; |
3765 | 3815 | ||
3766 | if (CT_CORE != tc->type) | 3816 | if (CT_CORE != tc->type) |
3767 | { | 3817 | { |
3768 | GNUNET_break(0); | 3818 | GNUNET_break (0); |
3769 | return GNUNET_SYSERR; | 3819 | return GNUNET_SYSERR; |
3770 | } | 3820 | } |
3771 | size = ntohs(obm->header.size) - sizeof(struct OutboundMessage); | 3821 | size = ntohs (obm->header.size) - sizeof(struct OutboundMessage); |
3772 | if (size < sizeof(struct GNUNET_MessageHeader)) | 3822 | if (size < sizeof(struct GNUNET_MessageHeader)) |
3773 | { | 3823 | { |
3774 | GNUNET_break(0); | 3824 | GNUNET_break (0); |
3775 | return GNUNET_SYSERR; | 3825 | return GNUNET_SYSERR; |
3776 | } | 3826 | } |
3777 | obmm = (const struct GNUNET_MessageHeader *)&obm[1]; | 3827 | obmm = (const struct GNUNET_MessageHeader *) &obm[1]; |
3778 | if (size != ntohs(obmm->size)) | 3828 | if (size != ntohs (obmm->size)) |
3779 | { | 3829 | { |
3780 | GNUNET_break(0); | 3830 | GNUNET_break (0); |
3781 | return GNUNET_SYSERR; | 3831 | return GNUNET_SYSERR; |
3782 | } | 3832 | } |
3783 | return GNUNET_OK; | 3833 | return GNUNET_OK; |
3784 | } | 3834 | } |
3785 | 3835 | ||
@@ -3792,25 +3842,25 @@ check_client_send(void *cls, const struct OutboundMessage *obm) | |||
3792 | * @param pm handle to the original pending message | 3842 | * @param pm handle to the original pending message |
3793 | */ | 3843 | */ |
3794 | static void | 3844 | static void |
3795 | client_send_response(struct PendingMessage *pm) | 3845 | client_send_response (struct PendingMessage *pm) |
3796 | { | 3846 | { |
3797 | struct TransportClient *tc = pm->client; | 3847 | struct TransportClient *tc = pm->client; |
3798 | struct VirtualLink *vl = pm->vl; | 3848 | struct VirtualLink *vl = pm->vl; |
3799 | 3849 | ||
3800 | if (NULL != tc) | 3850 | if (NULL != tc) |
3801 | { | 3851 | { |
3802 | struct GNUNET_MQ_Envelope *env; | 3852 | struct GNUNET_MQ_Envelope *env; |
3803 | struct SendOkMessage *som; | 3853 | struct SendOkMessage *som; |
3804 | 3854 | ||
3805 | env = GNUNET_MQ_msg(som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); | 3855 | env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); |
3806 | som->peer = vl->target; | 3856 | som->peer = vl->target; |
3807 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3857 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3808 | "Confirming transmission of <%llu> to %s\n", | 3858 | "Confirming transmission of <%llu> to %s\n", |
3809 | pm->logging_uuid, | 3859 | pm->logging_uuid, |
3810 | GNUNET_i2s(&vl->target)); | 3860 | GNUNET_i2s (&vl->target)); |
3811 | GNUNET_MQ_send(tc->mq, env); | 3861 | GNUNET_MQ_send (tc->mq, env); |
3812 | } | 3862 | } |
3813 | free_pending_message(pm); | 3863 | free_pending_message (pm); |
3814 | } | 3864 | } |
3815 | 3865 | ||
3816 | 3866 | ||
@@ -3824,10 +3874,10 @@ client_send_response(struct PendingMessage *pm) | |||
3824 | * @return number of entries set in @a hops_array | 3874 | * @return number of entries set in @a hops_array |
3825 | */ | 3875 | */ |
3826 | static unsigned int | 3876 | static unsigned int |
3827 | pick_random_dv_hops(const struct DistanceVector *dv, | 3877 | pick_random_dv_hops (const struct DistanceVector *dv, |
3828 | enum RouteMessageOptions options, | 3878 | enum RouteMessageOptions options, |
3829 | struct DistanceVectorHop **hops_array, | 3879 | struct DistanceVectorHop **hops_array, |
3830 | unsigned int hops_array_length) | 3880 | unsigned int hops_array_length) |
3831 | { | 3881 | { |
3832 | uint64_t choices[hops_array_length]; | 3882 | uint64_t choices[hops_array_length]; |
3833 | uint64_t num_dv; | 3883 | uint64_t num_dv; |
@@ -3839,56 +3889,56 @@ pick_random_dv_hops(const struct DistanceVector *dv, | |||
3839 | dv_count = 0; | 3889 | dv_count = 0; |
3840 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | 3890 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; |
3841 | pos = pos->next_dv) | 3891 | pos = pos->next_dv) |
3842 | { | 3892 | { |
3843 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) && | 3893 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) && |
3844 | (GNUNET_TIME_absolute_get_remaining(pos->path_valid_until) | 3894 | (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until) |
3845 | .rel_value_us == 0)) | 3895 | .rel_value_us == 0)) |
3846 | continue; /* pos unconfirmed and confirmed required */ | 3896 | continue; /* pos unconfirmed and confirmed required */ |
3847 | num_dv += MAX_DV_HOPS_ALLOWED - pos->distance; | 3897 | num_dv += MAX_DV_HOPS_ALLOWED - pos->distance; |
3848 | dv_count++; | 3898 | dv_count++; |
3849 | } | 3899 | } |
3850 | if (0 == dv_count) | 3900 | if (0 == dv_count) |
3851 | return 0; | 3901 | return 0; |
3852 | if (dv_count <= hops_array_length) | 3902 | if (dv_count <= hops_array_length) |
3853 | { | 3903 | { |
3854 | dv_count = 0; | 3904 | dv_count = 0; |
3855 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | 3905 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; |
3856 | pos = pos->next_dv) | 3906 | pos = pos->next_dv) |
3857 | hops_array[dv_count++] = pos; | 3907 | hops_array[dv_count++] = pos; |
3858 | return dv_count; | 3908 | return dv_count; |
3859 | } | 3909 | } |
3860 | for (unsigned int i = 0; i < hops_array_length; i++) | 3910 | for (unsigned int i = 0; i < hops_array_length; i++) |
3861 | { | 3911 | { |
3862 | int ok = GNUNET_NO; | 3912 | int ok = GNUNET_NO; |
3863 | while (GNUNET_NO == ok) | 3913 | while (GNUNET_NO == ok) |
3914 | { | ||
3915 | choices[i] = | ||
3916 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, num_dv); | ||
3917 | ok = GNUNET_YES; | ||
3918 | for (unsigned int j = 0; j < i; j++) | ||
3919 | if (choices[i] == choices[j]) | ||
3864 | { | 3920 | { |
3865 | choices[i] = | 3921 | ok = GNUNET_NO; |
3866 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, num_dv); | 3922 | break; |
3867 | ok = GNUNET_YES; | ||
3868 | for (unsigned int j = 0; j < i; j++) | ||
3869 | if (choices[i] == choices[j]) | ||
3870 | { | ||
3871 | ok = GNUNET_NO; | ||
3872 | break; | ||
3873 | } | ||
3874 | } | 3923 | } |
3875 | } | 3924 | } |
3925 | } | ||
3876 | dv_count = 0; | 3926 | dv_count = 0; |
3877 | num_dv = 0; | 3927 | num_dv = 0; |
3878 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | 3928 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; |
3879 | pos = pos->next_dv) | 3929 | pos = pos->next_dv) |
3880 | { | 3930 | { |
3881 | uint32_t delta = MAX_DV_HOPS_ALLOWED - pos->distance; | 3931 | uint32_t delta = MAX_DV_HOPS_ALLOWED - pos->distance; |
3882 | 3932 | ||
3883 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) && | 3933 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) && |
3884 | (GNUNET_TIME_absolute_get_remaining(pos->path_valid_until) | 3934 | (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until) |
3885 | .rel_value_us == 0)) | 3935 | .rel_value_us == 0)) |
3886 | continue; /* pos unconfirmed and confirmed required */ | 3936 | continue; /* pos unconfirmed and confirmed required */ |
3887 | for (unsigned int i = 0; i < hops_array_length; i++) | 3937 | for (unsigned int i = 0; i < hops_array_length; i++) |
3888 | if ((num_dv <= choices[i]) && (num_dv + delta > choices[i])) | 3938 | if ((num_dv <= choices[i]) && (num_dv + delta > choices[i])) |
3889 | hops_array[dv_count++] = pos; | 3939 | hops_array[dv_count++] = pos; |
3890 | num_dv += delta; | 3940 | num_dv += delta; |
3891 | } | 3941 | } |
3892 | return dv_count; | 3942 | return dv_count; |
3893 | } | 3943 | } |
3894 | 3944 | ||
@@ -3900,7 +3950,7 @@ pick_random_dv_hops(const struct DistanceVector *dv, | |||
3900 | * @param cam the send message that was sent | 3950 | * @param cam the send message that was sent |
3901 | */ | 3951 | */ |
3902 | static int | 3952 | static int |
3903 | check_communicator_available( | 3953 | check_communicator_available ( |
3904 | void *cls, | 3954 | void *cls, |
3905 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam) | 3955 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam) |
3906 | { | 3956 | { |
@@ -3908,15 +3958,15 @@ check_communicator_available( | |||
3908 | uint16_t size; | 3958 | uint16_t size; |
3909 | 3959 | ||
3910 | if (CT_NONE != tc->type) | 3960 | if (CT_NONE != tc->type) |
3911 | { | 3961 | { |
3912 | GNUNET_break(0); | 3962 | GNUNET_break (0); |
3913 | return GNUNET_SYSERR; | 3963 | return GNUNET_SYSERR; |
3914 | } | 3964 | } |
3915 | tc->type = CT_COMMUNICATOR; | 3965 | tc->type = CT_COMMUNICATOR; |
3916 | size = ntohs(cam->header.size) - sizeof(*cam); | 3966 | size = ntohs (cam->header.size) - sizeof(*cam); |
3917 | if (0 == size) | 3967 | if (0 == size) |
3918 | return GNUNET_OK; /* receive-only communicator */ | 3968 | return GNUNET_OK; /* receive-only communicator */ |
3919 | GNUNET_MQ_check_zero_termination(cam); | 3969 | GNUNET_MQ_check_zero_termination (cam); |
3920 | return GNUNET_OK; | 3970 | return GNUNET_OK; |
3921 | } | 3971 | } |
3922 | 3972 | ||
@@ -3927,22 +3977,22 @@ check_communicator_available( | |||
3927 | * @param cmc context for which we are done handling the message | 3977 | * @param cmc context for which we are done handling the message |
3928 | */ | 3978 | */ |
3929 | static void | 3979 | static void |
3930 | finish_cmc_handling(struct CommunicatorMessageContext *cmc) | 3980 | finish_cmc_handling (struct CommunicatorMessageContext *cmc) |
3931 | { | 3981 | { |
3932 | if (0 != ntohl(cmc->im.fc_on)) | 3982 | if (0 != ntohl (cmc->im.fc_on)) |
3933 | { | 3983 | { |
3934 | /* send ACK when done to communicator for flow control! */ | 3984 | /* send ACK when done to communicator for flow control! */ |
3935 | struct GNUNET_MQ_Envelope *env; | 3985 | struct GNUNET_MQ_Envelope *env; |
3936 | struct GNUNET_TRANSPORT_IncomingMessageAck *ack; | 3986 | struct GNUNET_TRANSPORT_IncomingMessageAck *ack; |
3937 | 3987 | ||
3938 | env = GNUNET_MQ_msg(ack, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK); | 3988 | env = GNUNET_MQ_msg (ack, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK); |
3939 | ack->reserved = htonl(0); | 3989 | ack->reserved = htonl (0); |
3940 | ack->fc_id = cmc->im.fc_id; | 3990 | ack->fc_id = cmc->im.fc_id; |
3941 | ack->sender = cmc->im.sender; | 3991 | ack->sender = cmc->im.sender; |
3942 | GNUNET_MQ_send(cmc->tc->mq, env); | 3992 | GNUNET_MQ_send (cmc->tc->mq, env); |
3943 | } | 3993 | } |
3944 | GNUNET_SERVICE_client_continue(cmc->tc->client); | 3994 | GNUNET_SERVICE_client_continue (cmc->tc->client); |
3945 | GNUNET_free(cmc); | 3995 | GNUNET_free (cmc); |
3946 | } | 3996 | } |
3947 | 3997 | ||
3948 | 3998 | ||
@@ -3956,7 +4006,7 @@ finish_cmc_handling(struct CommunicatorMessageContext *cmc) | |||
3956 | * @param rom the message that was sent | 4006 | * @param rom the message that was sent |
3957 | */ | 4007 | */ |
3958 | static void | 4008 | static void |
3959 | handle_client_recv_ok(void *cls, const struct RecvOkMessage *rom) | 4009 | handle_client_recv_ok (void *cls, const struct RecvOkMessage *rom) |
3960 | { | 4010 | { |
3961 | struct TransportClient *tc = cls; | 4011 | struct TransportClient *tc = cls; |
3962 | struct VirtualLink *vl; | 4012 | struct VirtualLink *vl; |
@@ -3964,31 +4014,31 @@ handle_client_recv_ok(void *cls, const struct RecvOkMessage *rom) | |||
3964 | struct CommunicatorMessageContext *cmc; | 4014 | struct CommunicatorMessageContext *cmc; |
3965 | 4015 | ||
3966 | if (CT_CORE != tc->type) | 4016 | if (CT_CORE != tc->type) |
3967 | { | 4017 | { |
3968 | GNUNET_break(0); | 4018 | GNUNET_break (0); |
3969 | GNUNET_SERVICE_client_drop(tc->client); | 4019 | GNUNET_SERVICE_client_drop (tc->client); |
3970 | return; | 4020 | return; |
3971 | } | 4021 | } |
3972 | vl = lookup_virtual_link(&rom->peer); | 4022 | vl = lookup_virtual_link (&rom->peer); |
3973 | if (NULL == vl) | 4023 | if (NULL == vl) |
3974 | { | 4024 | { |
3975 | GNUNET_STATISTICS_update(GST_stats, | 4025 | GNUNET_STATISTICS_update (GST_stats, |
3976 | "# RECV_OK dropped: virtual link unknown", | 4026 | "# RECV_OK dropped: virtual link unknown", |
3977 | 1, | 4027 | 1, |
3978 | GNUNET_NO); | 4028 | GNUNET_NO); |
3979 | GNUNET_SERVICE_client_continue(tc->client); | 4029 | GNUNET_SERVICE_client_continue (tc->client); |
3980 | return; | 4030 | return; |
3981 | } | 4031 | } |
3982 | delta = ntohl(rom->increase_window_delta); | 4032 | delta = ntohl (rom->increase_window_delta); |
3983 | vl->core_recv_window += delta; | 4033 | vl->core_recv_window += delta; |
3984 | if (vl->core_recv_window <= 0) | 4034 | if (vl->core_recv_window <= 0) |
3985 | return; | 4035 | return; |
3986 | /* resume communicators */ | 4036 | /* resume communicators */ |
3987 | while (NULL != (cmc = vl->cmc_tail)) | 4037 | while (NULL != (cmc = vl->cmc_tail)) |
3988 | { | 4038 | { |
3989 | GNUNET_CONTAINER_DLL_remove(vl->cmc_head, vl->cmc_tail, cmc); | 4039 | GNUNET_CONTAINER_DLL_remove (vl->cmc_head, vl->cmc_tail, cmc); |
3990 | finish_cmc_handling(cmc); | 4040 | finish_cmc_handling (cmc); |
3991 | } | 4041 | } |
3992 | } | 4042 | } |
3993 | 4043 | ||
3994 | 4044 | ||
@@ -3999,28 +4049,28 @@ handle_client_recv_ok(void *cls, const struct RecvOkMessage *rom) | |||
3999 | * @param cam the send message that was sent | 4049 | * @param cam the send message that was sent |
4000 | */ | 4050 | */ |
4001 | static void | 4051 | static void |
4002 | handle_communicator_available( | 4052 | handle_communicator_available ( |
4003 | void *cls, | 4053 | void *cls, |
4004 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam) | 4054 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam) |
4005 | { | 4055 | { |
4006 | struct TransportClient *tc = cls; | 4056 | struct TransportClient *tc = cls; |
4007 | uint16_t size; | 4057 | uint16_t size; |
4008 | 4058 | ||
4009 | size = ntohs(cam->header.size) - sizeof(*cam); | 4059 | size = ntohs (cam->header.size) - sizeof(*cam); |
4010 | if (0 == size) | 4060 | if (0 == size) |
4011 | { | 4061 | { |
4012 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4062 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4013 | "Receive-only communicator connected\n"); | 4063 | "Receive-only communicator connected\n"); |
4014 | return; /* receive-only communicator */ | 4064 | return; /* receive-only communicator */ |
4015 | } | 4065 | } |
4016 | tc->details.communicator.address_prefix = | 4066 | tc->details.communicator.address_prefix = |
4017 | GNUNET_strdup((const char *)&cam[1]); | 4067 | GNUNET_strdup ((const char *) &cam[1]); |
4018 | tc->details.communicator.cc = | 4068 | tc->details.communicator.cc = |
4019 | (enum GNUNET_TRANSPORT_CommunicatorCharacteristics)ntohl(cam->cc); | 4069 | (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc); |
4020 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4070 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4021 | "Communicator with prefix `%s' connected\n", | 4071 | "Communicator with prefix `%s' connected\n", |
4022 | tc->details.communicator.address_prefix); | 4072 | tc->details.communicator.address_prefix); |
4023 | GNUNET_SERVICE_client_continue(tc->client); | 4073 | GNUNET_SERVICE_client_continue (tc->client); |
4024 | } | 4074 | } |
4025 | 4075 | ||
4026 | 4076 | ||
@@ -4032,7 +4082,7 @@ handle_communicator_available( | |||
4032 | * @return #GNUNET_OK if message is well-formed | 4082 | * @return #GNUNET_OK if message is well-formed |
4033 | */ | 4083 | */ |
4034 | static int | 4084 | static int |
4035 | check_communicator_backchannel( | 4085 | check_communicator_backchannel ( |
4036 | void *cls, | 4086 | void *cls, |
4037 | const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb) | 4087 | const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb) |
4038 | { | 4088 | { |
@@ -4041,24 +4091,24 @@ check_communicator_backchannel( | |||
4041 | uint16_t msize; | 4091 | uint16_t msize; |
4042 | uint16_t isize; | 4092 | uint16_t isize; |
4043 | 4093 | ||
4044 | (void)cls; | 4094 | (void) cls; |
4045 | msize = ntohs(cb->header.size) - sizeof(*cb); | 4095 | msize = ntohs (cb->header.size) - sizeof(*cb); |
4046 | inbox = (const struct GNUNET_MessageHeader *)&cb[1]; | 4096 | inbox = (const struct GNUNET_MessageHeader *) &cb[1]; |
4047 | isize = ntohs(inbox->size); | 4097 | isize = ntohs (inbox->size); |
4048 | if (isize >= msize) | 4098 | if (isize >= msize) |
4049 | { | 4099 | { |
4050 | GNUNET_break(0); | 4100 | GNUNET_break (0); |
4051 | return GNUNET_SYSERR; | 4101 | return GNUNET_SYSERR; |
4052 | } | 4102 | } |
4053 | is = (const char *)inbox; | 4103 | is = (const char *) inbox; |
4054 | is += isize; | 4104 | is += isize; |
4055 | msize -= isize; | 4105 | msize -= isize; |
4056 | GNUNET_assert(0 < msize); | 4106 | GNUNET_assert (0 < msize); |
4057 | if ('\0' != is[msize - 1]) | 4107 | if ('\0' != is[msize - 1]) |
4058 | { | 4108 | { |
4059 | GNUNET_break(0); | 4109 | GNUNET_break (0); |
4060 | return GNUNET_SYSERR; | 4110 | return GNUNET_SYSERR; |
4061 | } | 4111 | } |
4062 | return GNUNET_OK; | 4112 | return GNUNET_OK; |
4063 | } | 4113 | } |
4064 | 4114 | ||
@@ -4070,26 +4120,26 @@ check_communicator_backchannel( | |||
4070 | * @param dv[in,out] virtual link to update ephemeral for | 4120 | * @param dv[in,out] virtual link to update ephemeral for |
4071 | */ | 4121 | */ |
4072 | static void | 4122 | static void |
4073 | update_ephemeral(struct DistanceVector *dv) | 4123 | update_ephemeral (struct DistanceVector *dv) |
4074 | { | 4124 | { |
4075 | struct EphemeralConfirmationPS ec; | 4125 | struct EphemeralConfirmationPS ec; |
4076 | 4126 | ||
4077 | if (0 != | 4127 | if (0 != |
4078 | GNUNET_TIME_absolute_get_remaining(dv->ephemeral_validity).rel_value_us) | 4128 | GNUNET_TIME_absolute_get_remaining (dv->ephemeral_validity).rel_value_us) |
4079 | return; | 4129 | return; |
4080 | dv->monotime = GNUNET_TIME_absolute_get_monotonic(GST_cfg); | 4130 | dv->monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg); |
4081 | dv->ephemeral_validity = | 4131 | dv->ephemeral_validity = |
4082 | GNUNET_TIME_absolute_add(dv->monotime, EPHEMERAL_VALIDITY); | 4132 | GNUNET_TIME_absolute_add (dv->monotime, EPHEMERAL_VALIDITY); |
4083 | GNUNET_assert(GNUNET_OK == | 4133 | GNUNET_assert (GNUNET_OK == |
4084 | GNUNET_CRYPTO_ecdhe_key_create2(&dv->private_key)); | 4134 | GNUNET_CRYPTO_ecdhe_key_create2 (&dv->private_key)); |
4085 | GNUNET_CRYPTO_ecdhe_key_get_public(&dv->private_key, &dv->ephemeral_key); | 4135 | GNUNET_CRYPTO_ecdhe_key_get_public (&dv->private_key, &dv->ephemeral_key); |
4086 | ec.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); | 4136 | ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); |
4087 | ec.purpose.size = htonl(sizeof(ec)); | 4137 | ec.purpose.size = htonl (sizeof(ec)); |
4088 | ec.target = dv->target; | 4138 | ec.target = dv->target; |
4089 | ec.ephemeral_key = dv->ephemeral_key; | 4139 | ec.ephemeral_key = dv->ephemeral_key; |
4090 | GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_eddsa_sign(GST_my_private_key, | 4140 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, |
4091 | &ec.purpose, | 4141 | &ec.purpose, |
4092 | &dv->sender_sig)); | 4142 | &dv->sender_sig)); |
4093 | } | 4143 | } |
4094 | 4144 | ||
4095 | 4145 | ||
@@ -4103,45 +4153,45 @@ update_ephemeral(struct DistanceVector *dv) | |||
4103 | * @param payload_size number of bytes in @a payload | 4153 | * @param payload_size number of bytes in @a payload |
4104 | */ | 4154 | */ |
4105 | static void | 4155 | static void |
4106 | queue_send_msg(struct Queue *queue, | 4156 | queue_send_msg (struct Queue *queue, |
4107 | struct PendingMessage *pm, | 4157 | struct PendingMessage *pm, |
4108 | const void *payload, | 4158 | const void *payload, |
4109 | size_t payload_size) | 4159 | size_t payload_size) |
4110 | { | 4160 | { |
4111 | struct Neighbour *n = queue->neighbour; | 4161 | struct Neighbour *n = queue->neighbour; |
4112 | struct GNUNET_TRANSPORT_SendMessageTo *smt; | 4162 | struct GNUNET_TRANSPORT_SendMessageTo *smt; |
4113 | struct GNUNET_MQ_Envelope *env; | 4163 | struct GNUNET_MQ_Envelope *env; |
4114 | 4164 | ||
4115 | queue->idle = GNUNET_NO; | 4165 | queue->idle = GNUNET_NO; |
4116 | GNUNET_log( | 4166 | GNUNET_log ( |
4117 | GNUNET_ERROR_TYPE_DEBUG, | 4167 | GNUNET_ERROR_TYPE_DEBUG, |
4118 | "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n", | 4168 | "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n", |
4119 | (unsigned int)payload_size, | 4169 | (unsigned int) payload_size, |
4120 | (NULL == pm) ? 0 : pm->logging_uuid, | 4170 | (NULL == pm) ? 0 : pm->logging_uuid, |
4121 | (unsigned long long)queue->qid, | 4171 | (unsigned long long) queue->qid, |
4122 | GNUNET_i2s(&queue->neighbour->pid)); | 4172 | GNUNET_i2s (&queue->neighbour->pid)); |
4123 | env = GNUNET_MQ_msg_extra(smt, | 4173 | env = GNUNET_MQ_msg_extra (smt, |
4124 | payload_size, | 4174 | payload_size, |
4125 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); | 4175 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); |
4126 | smt->qid = queue->qid; | 4176 | smt->qid = queue->qid; |
4127 | smt->mid = queue->mid_gen; | 4177 | smt->mid = queue->mid_gen; |
4128 | smt->receiver = n->pid; | 4178 | smt->receiver = n->pid; |
4129 | memcpy(&smt[1], payload, payload_size); | 4179 | memcpy (&smt[1], payload, payload_size); |
4130 | { | 4180 | { |
4131 | /* Pass the env to the communicator of queue for transmission. */ | 4181 | /* Pass the env to the communicator of queue for transmission. */ |
4132 | struct QueueEntry *qe; | 4182 | struct QueueEntry *qe; |
4133 | 4183 | ||
4134 | qe = GNUNET_new(struct QueueEntry); | 4184 | qe = GNUNET_new (struct QueueEntry); |
4135 | qe->mid = queue->mid_gen++; | 4185 | qe->mid = queue->mid_gen++; |
4136 | qe->queue = queue; | 4186 | qe->queue = queue; |
4137 | if (NULL != pm) | 4187 | if (NULL != pm) |
4138 | { | 4188 | { |
4139 | qe->pm = pm; | 4189 | qe->pm = pm; |
4140 | GNUNET_assert(NULL == pm->qe); | 4190 | GNUNET_assert (NULL == pm->qe); |
4141 | pm->qe = qe; | 4191 | pm->qe = qe; |
4142 | } | 4192 | } |
4143 | GNUNET_CONTAINER_DLL_insert(queue->queue_head, queue->queue_tail, qe); | 4193 | GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe); |
4144 | GNUNET_assert(CT_COMMUNICATOR == queue->tc->type); | 4194 | GNUNET_assert (CT_COMMUNICATOR == queue->tc->type); |
4145 | queue->queue_length++; | 4195 | queue->queue_length++; |
4146 | queue->tc->details.communicator.total_queue_length++; | 4196 | queue->tc->details.communicator.total_queue_length++; |
4147 | if (COMMUNICATOR_TOTAL_QUEUE_LIMIT == | 4197 | if (COMMUNICATOR_TOTAL_QUEUE_LIMIT == |
@@ -4149,7 +4199,7 @@ queue_send_msg(struct Queue *queue, | |||
4149 | queue->idle = GNUNET_NO; | 4199 | queue->idle = GNUNET_NO; |
4150 | if (QUEUE_LENGTH_LIMIT == queue->queue_length) | 4200 | if (QUEUE_LENGTH_LIMIT == queue->queue_length) |
4151 | queue->idle = GNUNET_NO; | 4201 | queue->idle = GNUNET_NO; |
4152 | GNUNET_MQ_send(queue->tc->mq, env); | 4202 | GNUNET_MQ_send (queue->tc->mq, env); |
4153 | } | 4203 | } |
4154 | } | 4204 | } |
4155 | 4205 | ||
@@ -4165,9 +4215,9 @@ queue_send_msg(struct Queue *queue, | |||
4165 | * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed | 4215 | * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed |
4166 | */ | 4216 | */ |
4167 | static struct GNUNET_TIME_Relative | 4217 | static struct GNUNET_TIME_Relative |
4168 | route_via_neighbour(const struct Neighbour *n, | 4218 | route_via_neighbour (const struct Neighbour *n, |
4169 | const struct GNUNET_MessageHeader *hdr, | 4219 | const struct GNUNET_MessageHeader *hdr, |
4170 | enum RouteMessageOptions options) | 4220 | enum RouteMessageOptions options) |
4171 | { | 4221 | { |
4172 | struct GNUNET_TIME_Absolute now; | 4222 | struct GNUNET_TIME_Absolute now; |
4173 | unsigned int candidates; | 4223 | unsigned int candidates; |
@@ -4176,7 +4226,7 @@ route_via_neighbour(const struct Neighbour *n, | |||
4176 | struct GNUNET_TIME_Relative rtt; | 4226 | struct GNUNET_TIME_Relative rtt; |
4177 | 4227 | ||
4178 | /* Pick one or two 'random' queues from n (under constraints of options) */ | 4228 | /* Pick one or two 'random' queues from n (under constraints of options) */ |
4179 | now = GNUNET_TIME_absolute_get(); | 4229 | now = GNUNET_TIME_absolute_get (); |
4180 | /* FIXME-OPTIMIZE: give queues 'weights' and pick proportional to | 4230 | /* FIXME-OPTIMIZE: give queues 'weights' and pick proportional to |
4181 | weight in the future; weight could be assigned by observed | 4231 | weight in the future; weight could be assigned by observed |
4182 | bandwidth (note: not sure if we should do this for this type | 4232 | bandwidth (note: not sure if we should do this for this type |
@@ -4184,53 +4234,53 @@ route_via_neighbour(const struct Neighbour *n, | |||
4184 | candidates = 0; | 4234 | candidates = 0; |
4185 | for (struct Queue *pos = n->queue_head; NULL != pos; | 4235 | for (struct Queue *pos = n->queue_head; NULL != pos; |
4186 | pos = pos->next_neighbour) | 4236 | pos = pos->next_neighbour) |
4187 | { | 4237 | { |
4188 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) || | 4238 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) || |
4189 | (pos->validated_until.abs_value_us > now.abs_value_us)) | 4239 | (pos->validated_until.abs_value_us > now.abs_value_us)) |
4190 | candidates++; | 4240 | candidates++; |
4191 | } | 4241 | } |
4192 | if (0 == candidates) | 4242 | if (0 == candidates) |
4193 | { | 4243 | { |
4194 | /* This can happen rarely if the last confirmed queue timed | 4244 | /* This can happen rarely if the last confirmed queue timed |
4195 | out just as we were beginning to process this message. */ | 4245 | out just as we were beginning to process this message. */ |
4196 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 4246 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
4197 | "Could not route message of type %u to %s: no valid queue\n", | 4247 | "Could not route message of type %u to %s: no valid queue\n", |
4198 | ntohs(hdr->type), | 4248 | ntohs (hdr->type), |
4199 | GNUNET_i2s(&n->pid)); | 4249 | GNUNET_i2s (&n->pid)); |
4200 | GNUNET_STATISTICS_update(GST_stats, | 4250 | GNUNET_STATISTICS_update (GST_stats, |
4201 | "# route selection failed (all no valid queue)", | 4251 | "# route selection failed (all no valid queue)", |
4202 | 1, | 4252 | 1, |
4203 | GNUNET_NO); | 4253 | GNUNET_NO); |
4204 | return GNUNET_TIME_UNIT_FOREVER_REL; | 4254 | return GNUNET_TIME_UNIT_FOREVER_REL; |
4205 | } | 4255 | } |
4206 | 4256 | ||
4207 | rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 4257 | rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
4208 | sel1 = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, candidates); | 4258 | sel1 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, candidates); |
4209 | if (0 == (options & RMO_REDUNDANT)) | 4259 | if (0 == (options & RMO_REDUNDANT)) |
4210 | sel2 = candidates; /* picks none! */ | 4260 | sel2 = candidates; /* picks none! */ |
4211 | else | 4261 | else |
4212 | sel2 = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, candidates); | 4262 | sel2 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, candidates); |
4213 | candidates = 0; | 4263 | candidates = 0; |
4214 | for (struct Queue *pos = n->queue_head; NULL != pos; | 4264 | for (struct Queue *pos = n->queue_head; NULL != pos; |
4215 | pos = pos->next_neighbour) | 4265 | pos = pos->next_neighbour) |
4266 | { | ||
4267 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) || | ||
4268 | (pos->validated_until.abs_value_us > now.abs_value_us)) | ||
4216 | { | 4269 | { |
4217 | if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) || | 4270 | if ((sel1 == candidates) || (sel2 == candidates)) |
4218 | (pos->validated_until.abs_value_us > now.abs_value_us)) | 4271 | { |
4219 | { | 4272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4220 | if ((sel1 == candidates) || (sel2 == candidates)) | 4273 | "Routing message of type %u to %s using %s (#%u)\n", |
4221 | { | 4274 | ntohs (hdr->type), |
4222 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4275 | GNUNET_i2s (&n->pid), |
4223 | "Routing message of type %u to %s using %s (#%u)\n", | 4276 | pos->address, |
4224 | ntohs(hdr->type), | 4277 | (sel1 == candidates) ? 1 : 2); |
4225 | GNUNET_i2s(&n->pid), | 4278 | rtt = GNUNET_TIME_relative_min (rtt, pos->pd.aged_rtt); |
4226 | pos->address, | 4279 | queue_send_msg (pos, NULL, hdr, ntohs (hdr->size)); |
4227 | (sel1 == candidates) ? 1 : 2); | 4280 | } |
4228 | rtt = GNUNET_TIME_relative_min(rtt, pos->pd.aged_rtt); | 4281 | candidates++; |
4229 | queue_send_msg(pos, NULL, hdr, ntohs(hdr->size)); | ||
4230 | } | ||
4231 | candidates++; | ||
4232 | } | ||
4233 | } | 4282 | } |
4283 | } | ||
4234 | return rtt; | 4284 | return rtt; |
4235 | } | 4285 | } |
4236 | 4286 | ||
@@ -4238,7 +4288,8 @@ route_via_neighbour(const struct Neighbour *n, | |||
4238 | /** | 4288 | /** |
4239 | * Structure of the key material used to encrypt backchannel messages. | 4289 | * Structure of the key material used to encrypt backchannel messages. |
4240 | */ | 4290 | */ |
4241 | struct DVKeyState { | 4291 | struct DVKeyState |
4292 | { | ||
4242 | /** | 4293 | /** |
4243 | * State of our block cipher. | 4294 | * State of our block cipher. |
4244 | */ | 4295 | */ |
@@ -4247,7 +4298,8 @@ struct DVKeyState { | |||
4247 | /** | 4298 | /** |
4248 | * Actual key material. | 4299 | * Actual key material. |
4249 | */ | 4300 | */ |
4250 | struct { | 4301 | struct |
4302 | { | ||
4251 | /** | 4303 | /** |
4252 | * Key used for HMAC calculations (via #GNUNET_CRYPTO_hmac()). | 4304 | * Key used for HMAC calculations (via #GNUNET_CRYPTO_hmac()). |
4253 | */ | 4305 | */ |
@@ -4275,34 +4327,34 @@ struct DVKeyState { | |||
4275 | * @param key[out] symmetric cipher and HMAC state to generate | 4327 | * @param key[out] symmetric cipher and HMAC state to generate |
4276 | */ | 4328 | */ |
4277 | static void | 4329 | static void |
4278 | dv_setup_key_state_from_km(const struct GNUNET_HashCode *km, | 4330 | dv_setup_key_state_from_km (const struct GNUNET_HashCode *km, |
4279 | const struct GNUNET_ShortHashCode *iv, | 4331 | const struct GNUNET_ShortHashCode *iv, |
4280 | struct DVKeyState *key) | 4332 | struct DVKeyState *key) |
4281 | { | 4333 | { |
4282 | /* must match #dh_key_derive_eph_pub */ | 4334 | /* must match #dh_key_derive_eph_pub */ |
4283 | GNUNET_assert(GNUNET_YES == | 4335 | GNUNET_assert (GNUNET_YES == |
4284 | GNUNET_CRYPTO_kdf(&key->material, | 4336 | GNUNET_CRYPTO_kdf (&key->material, |
4285 | sizeof(key->material), | 4337 | sizeof(key->material), |
4286 | "transport-backchannel-key", | 4338 | "transport-backchannel-key", |
4287 | strlen("transport-backchannel-key"), | 4339 | strlen ("transport-backchannel-key"), |
4288 | &km, | 4340 | &km, |
4289 | sizeof(km), | 4341 | sizeof(km), |
4290 | iv, | 4342 | iv, |
4291 | sizeof(*iv))); | 4343 | sizeof(*iv))); |
4292 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4293 | "Deriving backchannel key based on KM %s and IV %s\n", | 4345 | "Deriving backchannel key based on KM %s and IV %s\n", |
4294 | GNUNET_h2s(km), | 4346 | GNUNET_h2s (km), |
4295 | GNUNET_sh2s(iv)); | 4347 | GNUNET_sh2s (iv)); |
4296 | gcry_cipher_open(&key->cipher, | 4348 | gcry_cipher_open (&key->cipher, |
4297 | GCRY_CIPHER_AES256 /* low level: go for speed */, | 4349 | GCRY_CIPHER_AES256 /* low level: go for speed */, |
4298 | GCRY_CIPHER_MODE_CTR, | 4350 | GCRY_CIPHER_MODE_CTR, |
4299 | 0 /* flags */); | 4351 | 0 /* flags */); |
4300 | gcry_cipher_setkey(key->cipher, | 4352 | gcry_cipher_setkey (key->cipher, |
4301 | &key->material.aes_key, | 4353 | &key->material.aes_key, |
4302 | sizeof(key->material.aes_key)); | 4354 | sizeof(key->material.aes_key)); |
4303 | gcry_cipher_setctr(key->cipher, | 4355 | gcry_cipher_setctr (key->cipher, |
4304 | &key->material.aes_ctr, | 4356 | &key->material.aes_ctr, |
4305 | sizeof(key->material.aes_ctr)); | 4357 | sizeof(key->material.aes_ctr)); |
4306 | } | 4358 | } |
4307 | 4359 | ||
4308 | 4360 | ||
@@ -4316,7 +4368,7 @@ dv_setup_key_state_from_km(const struct GNUNET_HashCode *km, | |||
4316 | * @param key[out] set to the key material | 4368 | * @param key[out] set to the key material |
4317 | */ | 4369 | */ |
4318 | static void | 4370 | static void |
4319 | dh_key_derive_eph_pid( | 4371 | dh_key_derive_eph_pid ( |
4320 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral, | 4372 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral, |
4321 | const struct GNUNET_PeerIdentity *target, | 4373 | const struct GNUNET_PeerIdentity *target, |
4322 | const struct GNUNET_ShortHashCode *iv, | 4374 | const struct GNUNET_ShortHashCode *iv, |
@@ -4324,10 +4376,10 @@ dh_key_derive_eph_pid( | |||
4324 | { | 4376 | { |
4325 | struct GNUNET_HashCode km; | 4377 | struct GNUNET_HashCode km; |
4326 | 4378 | ||
4327 | GNUNET_assert(GNUNET_YES == GNUNET_CRYPTO_ecdh_eddsa(priv_ephemeral, | 4379 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_ecdh_eddsa (priv_ephemeral, |
4328 | &target->public_key, | 4380 | &target->public_key, |
4329 | &km)); | 4381 | &km)); |
4330 | dv_setup_key_state_from_km(&km, iv, key); | 4382 | dv_setup_key_state_from_km (&km, iv, key); |
4331 | } | 4383 | } |
4332 | 4384 | ||
4333 | 4385 | ||
@@ -4341,16 +4393,16 @@ dh_key_derive_eph_pid( | |||
4341 | * @param key[out] set to the key material | 4393 | * @param key[out] set to the key material |
4342 | */ | 4394 | */ |
4343 | static void | 4395 | static void |
4344 | dh_key_derive_eph_pub(const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral, | 4396 | dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral, |
4345 | const struct GNUNET_ShortHashCode *iv, | 4397 | const struct GNUNET_ShortHashCode *iv, |
4346 | struct DVKeyState *key) | 4398 | struct DVKeyState *key) |
4347 | { | 4399 | { |
4348 | struct GNUNET_HashCode km; | 4400 | struct GNUNET_HashCode km; |
4349 | 4401 | ||
4350 | GNUNET_assert(GNUNET_YES == GNUNET_CRYPTO_eddsa_ecdh(GST_my_private_key, | 4402 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_eddsa_ecdh (GST_my_private_key, |
4351 | pub_ephemeral, | 4403 | pub_ephemeral, |
4352 | &km)); | 4404 | &km)); |
4353 | dv_setup_key_state_from_km(&km, iv, key); | 4405 | dv_setup_key_state_from_km (&km, iv, key); |
4354 | } | 4406 | } |
4355 | 4407 | ||
4356 | 4408 | ||
@@ -4364,12 +4416,12 @@ dh_key_derive_eph_pub(const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral, | |||
4364 | * @param data_size number of bytes in @a data | 4416 | * @param data_size number of bytes in @a data |
4365 | */ | 4417 | */ |
4366 | static void | 4418 | static void |
4367 | dv_hmac(const struct DVKeyState *key, | 4419 | dv_hmac (const struct DVKeyState *key, |
4368 | struct GNUNET_HashCode *hmac, | 4420 | struct GNUNET_HashCode *hmac, |
4369 | const void *data, | 4421 | const void *data, |
4370 | size_t data_size) | 4422 | size_t data_size) |
4371 | { | 4423 | { |
4372 | GNUNET_CRYPTO_hmac(&key->material.hmac_key, data, data_size, hmac); | 4424 | GNUNET_CRYPTO_hmac (&key->material.hmac_key, data, data_size, hmac); |
4373 | } | 4425 | } |
4374 | 4426 | ||
4375 | 4427 | ||
@@ -4383,10 +4435,10 @@ dv_hmac(const struct DVKeyState *key, | |||
4383 | * @param in_size number of bytes of input in @a in and available at @a dst | 4435 | * @param in_size number of bytes of input in @a in and available at @a dst |
4384 | */ | 4436 | */ |
4385 | static void | 4437 | static void |
4386 | dv_encrypt(struct DVKeyState *key, const void *in, void *dst, size_t in_size) | 4438 | dv_encrypt (struct DVKeyState *key, const void *in, void *dst, size_t in_size) |
4387 | { | 4439 | { |
4388 | GNUNET_assert(0 == | 4440 | GNUNET_assert (0 == |
4389 | gcry_cipher_encrypt(key->cipher, dst, in_size, in, in_size)); | 4441 | gcry_cipher_encrypt (key->cipher, dst, in_size, in, in_size)); |
4390 | } | 4442 | } |
4391 | 4443 | ||
4392 | 4444 | ||
@@ -4400,13 +4452,13 @@ dv_encrypt(struct DVKeyState *key, const void *in, void *dst, size_t in_size) | |||
4400 | * @param out_size number of bytes of input in @a ciph and available in @a out | 4452 | * @param out_size number of bytes of input in @a ciph and available in @a out |
4401 | */ | 4453 | */ |
4402 | static void | 4454 | static void |
4403 | dv_decrypt(struct DVKeyState *key, | 4455 | dv_decrypt (struct DVKeyState *key, |
4404 | void *out, | 4456 | void *out, |
4405 | const void *ciph, | 4457 | const void *ciph, |
4406 | size_t out_size) | 4458 | size_t out_size) |
4407 | { | 4459 | { |
4408 | GNUNET_assert( | 4460 | GNUNET_assert ( |
4409 | 0 == gcry_cipher_decrypt(key->cipher, out, out_size, ciph, out_size)); | 4461 | 0 == gcry_cipher_decrypt (key->cipher, out, out_size, ciph, out_size)); |
4410 | } | 4462 | } |
4411 | 4463 | ||
4412 | 4464 | ||
@@ -4416,10 +4468,10 @@ dv_decrypt(struct DVKeyState *key, | |||
4416 | * @param key key material to clean up (memory must not be free'd!) | 4468 | * @param key key material to clean up (memory must not be free'd!) |
4417 | */ | 4469 | */ |
4418 | static void | 4470 | static void |
4419 | dv_key_clean(struct DVKeyState *key) | 4471 | dv_key_clean (struct DVKeyState *key) |
4420 | { | 4472 | { |
4421 | gcry_cipher_close(key->cipher); | 4473 | gcry_cipher_close (key->cipher); |
4422 | GNUNET_CRYPTO_zero_keys(&key->material, sizeof(key->material)); | 4474 | GNUNET_CRYPTO_zero_keys (&key->material, sizeof(key->material)); |
4423 | } | 4475 | } |
4424 | 4476 | ||
4425 | 4477 | ||
@@ -4452,92 +4504,92 @@ typedef void (*DVMessageHandler) (void *cls, | |||
4452 | * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed | 4504 | * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed |
4453 | */ | 4505 | */ |
4454 | static struct GNUNET_TIME_Relative | 4506 | static struct GNUNET_TIME_Relative |
4455 | encapsulate_for_dv(struct DistanceVector *dv, | 4507 | encapsulate_for_dv (struct DistanceVector *dv, |
4456 | unsigned int num_dvhs, | 4508 | unsigned int num_dvhs, |
4457 | struct DistanceVectorHop **dvhs, | 4509 | struct DistanceVectorHop **dvhs, |
4458 | const struct GNUNET_MessageHeader *hdr, | 4510 | const struct GNUNET_MessageHeader *hdr, |
4459 | DVMessageHandler use, | 4511 | DVMessageHandler use, |
4460 | void *use_cls, | 4512 | void *use_cls, |
4461 | enum RouteMessageOptions options) | 4513 | enum RouteMessageOptions options) |
4462 | { | 4514 | { |
4463 | struct TransportDVBoxMessage box_hdr; | 4515 | struct TransportDVBoxMessage box_hdr; |
4464 | struct TransportDVBoxPayloadP payload_hdr; | 4516 | struct TransportDVBoxPayloadP payload_hdr; |
4465 | uint16_t enc_body_size = ntohs(hdr->size); | 4517 | uint16_t enc_body_size = ntohs (hdr->size); |
4466 | char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN; | 4518 | char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN; |
4467 | struct TransportDVBoxPayloadP *enc_payload_hdr = | 4519 | struct TransportDVBoxPayloadP *enc_payload_hdr = |
4468 | (struct TransportDVBoxPayloadP *)enc; | 4520 | (struct TransportDVBoxPayloadP *) enc; |
4469 | struct DVKeyState key; | 4521 | struct DVKeyState key; |
4470 | struct GNUNET_TIME_Relative rtt; | 4522 | struct GNUNET_TIME_Relative rtt; |
4471 | 4523 | ||
4472 | /* Encrypt payload */ | 4524 | /* Encrypt payload */ |
4473 | box_hdr.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX); | 4525 | box_hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX); |
4474 | box_hdr.total_hops = htons(0); | 4526 | box_hdr.total_hops = htons (0); |
4475 | update_ephemeral(dv); | 4527 | update_ephemeral (dv); |
4476 | box_hdr.ephemeral_key = dv->ephemeral_key; | 4528 | box_hdr.ephemeral_key = dv->ephemeral_key; |
4477 | payload_hdr.sender_sig = dv->sender_sig; | 4529 | payload_hdr.sender_sig = dv->sender_sig; |
4478 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_NONCE, | 4530 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
4479 | &box_hdr.iv, | 4531 | &box_hdr.iv, |
4480 | sizeof(box_hdr.iv)); | 4532 | sizeof(box_hdr.iv)); |
4481 | dh_key_derive_eph_pid(&dv->private_key, &dv->target, &box_hdr.iv, &key); | 4533 | dh_key_derive_eph_pid (&dv->private_key, &dv->target, &box_hdr.iv, &key); |
4482 | payload_hdr.sender = GST_my_identity; | 4534 | payload_hdr.sender = GST_my_identity; |
4483 | payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton(dv->monotime); | 4535 | payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime); |
4484 | dv_encrypt(&key, &payload_hdr, enc_payload_hdr, sizeof(payload_hdr)); | 4536 | dv_encrypt (&key, &payload_hdr, enc_payload_hdr, sizeof(payload_hdr)); |
4485 | dv_encrypt(&key, | 4537 | dv_encrypt (&key, |
4486 | hdr, | 4538 | hdr, |
4487 | &enc[sizeof(struct TransportDVBoxPayloadP)], | 4539 | &enc[sizeof(struct TransportDVBoxPayloadP)], |
4488 | enc_body_size); | 4540 | enc_body_size); |
4489 | dv_hmac(&key, &box_hdr.hmac, enc, sizeof(enc)); | 4541 | dv_hmac (&key, &box_hdr.hmac, enc, sizeof(enc)); |
4490 | dv_key_clean(&key); | 4542 | dv_key_clean (&key); |
4491 | rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 4543 | rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
4492 | /* For each selected path, take the pre-computed header and body | 4544 | /* For each selected path, take the pre-computed header and body |
4493 | and add the path in the middle of the message; then send it. */ | 4545 | and add the path in the middle of the message; then send it. */ |
4494 | for (unsigned int i = 0; i < num_dvhs; i++) | 4546 | for (unsigned int i = 0; i < num_dvhs; i++) |
4547 | { | ||
4548 | struct DistanceVectorHop *dvh = dvhs[i]; | ||
4549 | unsigned int num_hops = dvh->distance + 1; | ||
4550 | char buf[sizeof(struct TransportDVBoxMessage) | ||
4551 | + sizeof(struct GNUNET_PeerIdentity) * num_hops | ||
4552 | + sizeof(struct TransportDVBoxPayloadP) | ||
4553 | + enc_body_size] GNUNET_ALIGN; | ||
4554 | struct GNUNET_PeerIdentity *dhops; | ||
4555 | |||
4556 | box_hdr.header.size = htons (sizeof(buf)); | ||
4557 | box_hdr.num_hops = htons (num_hops); | ||
4558 | memcpy (buf, &box_hdr, sizeof(box_hdr)); | ||
4559 | dhops = (struct GNUNET_PeerIdentity *) &buf[sizeof(box_hdr)]; | ||
4560 | memcpy (dhops, | ||
4561 | dvh->path, | ||
4562 | dvh->distance * sizeof(struct GNUNET_PeerIdentity)); | ||
4563 | dhops[dvh->distance] = dv->target; | ||
4564 | if (GNUNET_EXTRA_LOGGING > 0) | ||
4495 | { | 4565 | { |
4496 | struct DistanceVectorHop *dvh = dvhs[i]; | 4566 | char *path; |
4497 | unsigned int num_hops = dvh->distance + 1; | 4567 | |
4498 | char buf[sizeof(struct TransportDVBoxMessage) + | 4568 | path = GNUNET_strdup (GNUNET_i2s (&GST_my_identity)); |
4499 | sizeof(struct GNUNET_PeerIdentity) * num_hops + | 4569 | for (unsigned int j = 0; j <= num_hops; j++) |
4500 | sizeof(struct TransportDVBoxPayloadP) + | 4570 | { |
4501 | enc_body_size] GNUNET_ALIGN; | 4571 | char *tmp; |
4502 | struct GNUNET_PeerIdentity *dhops; | 4572 | |
4503 | 4573 | GNUNET_asprintf (&tmp, "%s-%s", path, GNUNET_i2s (&dhops[j])); | |
4504 | box_hdr.header.size = htons(sizeof(buf)); | 4574 | GNUNET_free (path); |
4505 | box_hdr.num_hops = htons(num_hops); | 4575 | path = tmp; |
4506 | memcpy(buf, &box_hdr, sizeof(box_hdr)); | 4576 | } |
4507 | dhops = (struct GNUNET_PeerIdentity *)&buf[sizeof(box_hdr)]; | 4577 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4508 | memcpy(dhops, | 4578 | "Routing message of type %u to %s using DV (#%u/%u) via %s\n", |
4509 | dvh->path, | 4579 | ntohs (hdr->type), |
4510 | dvh->distance * sizeof(struct GNUNET_PeerIdentity)); | 4580 | GNUNET_i2s (&dv->target), |
4511 | dhops[dvh->distance] = dv->target; | 4581 | i + 1, |
4512 | if (GNUNET_EXTRA_LOGGING > 0) | 4582 | num_dvhs + 1, |
4513 | { | 4583 | path); |
4514 | char *path; | 4584 | GNUNET_free (path); |
4515 | 4585 | } | |
4516 | path = GNUNET_strdup(GNUNET_i2s(&GST_my_identity)); | 4586 | rtt = GNUNET_TIME_relative_min (rtt, dvh->pd.aged_rtt); |
4517 | for (unsigned int j = 0; j <= num_hops; j++) | 4587 | memcpy (&dhops[num_hops], enc, sizeof(enc)); |
4518 | { | 4588 | use (use_cls, |
4519 | char *tmp; | 4589 | dvh->next_hop, |
4520 | 4590 | (const struct GNUNET_MessageHeader *) buf, | |
4521 | GNUNET_asprintf(&tmp, "%s-%s", path, GNUNET_i2s(&dhops[j])); | 4591 | options); |
4522 | GNUNET_free(path); | 4592 | } |
4523 | path = tmp; | ||
4524 | } | ||
4525 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
4526 | "Routing message of type %u to %s using DV (#%u/%u) via %s\n", | ||
4527 | ntohs(hdr->type), | ||
4528 | GNUNET_i2s(&dv->target), | ||
4529 | i + 1, | ||
4530 | num_dvhs + 1, | ||
4531 | path); | ||
4532 | GNUNET_free(path); | ||
4533 | } | ||
4534 | rtt = GNUNET_TIME_relative_min(rtt, dvh->pd.aged_rtt); | ||
4535 | memcpy(&dhops[num_hops], enc, sizeof(enc)); | ||
4536 | use(use_cls, | ||
4537 | dvh->next_hop, | ||
4538 | (const struct GNUNET_MessageHeader *)buf, | ||
4539 | options); | ||
4540 | } | ||
4541 | return rtt; | 4593 | return rtt; |
4542 | } | 4594 | } |
4543 | 4595 | ||
@@ -4552,13 +4604,13 @@ encapsulate_for_dv(struct DistanceVector *dv, | |||
4552 | * @param options message options for queue selection | 4604 | * @param options message options for queue selection |
4553 | */ | 4605 | */ |
4554 | static void | 4606 | static void |
4555 | send_dv_to_neighbour(void *cls, | 4607 | send_dv_to_neighbour (void *cls, |
4556 | struct Neighbour *next_hop, | 4608 | struct Neighbour *next_hop, |
4557 | const struct GNUNET_MessageHeader *hdr, | 4609 | const struct GNUNET_MessageHeader *hdr, |
4558 | enum RouteMessageOptions options) | 4610 | enum RouteMessageOptions options) |
4559 | { | 4611 | { |
4560 | (void)cls; | 4612 | (void) cls; |
4561 | (void)route_via_neighbour(next_hop, hdr, options); | 4613 | (void) route_via_neighbour (next_hop, hdr, options); |
4562 | } | 4614 | } |
4563 | 4615 | ||
4564 | 4616 | ||
@@ -4574,9 +4626,9 @@ send_dv_to_neighbour(void *cls, | |||
4574 | * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed | 4626 | * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed |
4575 | */ | 4627 | */ |
4576 | static struct GNUNET_TIME_Relative | 4628 | static struct GNUNET_TIME_Relative |
4577 | route_control_message_without_fc(const struct GNUNET_PeerIdentity *target, | 4629 | route_control_message_without_fc (const struct GNUNET_PeerIdentity *target, |
4578 | const struct GNUNET_MessageHeader *hdr, | 4630 | const struct GNUNET_MessageHeader *hdr, |
4579 | enum RouteMessageOptions options) | 4631 | enum RouteMessageOptions options) |
4580 | { | 4632 | { |
4581 | struct VirtualLink *vl; | 4633 | struct VirtualLink *vl; |
4582 | struct Neighbour *n; | 4634 | struct Neighbour *n; |
@@ -4584,78 +4636,78 @@ route_control_message_without_fc(const struct GNUNET_PeerIdentity *target, | |||
4584 | struct GNUNET_TIME_Relative rtt1; | 4636 | struct GNUNET_TIME_Relative rtt1; |
4585 | struct GNUNET_TIME_Relative rtt2; | 4637 | struct GNUNET_TIME_Relative rtt2; |
4586 | 4638 | ||
4587 | vl = lookup_virtual_link(target); | 4639 | vl = lookup_virtual_link (target); |
4588 | GNUNET_assert(NULL != vl); | 4640 | GNUNET_assert (NULL != vl); |
4589 | n = vl->n; | 4641 | n = vl->n; |
4590 | dv = (0 != (options & RMO_DV_ALLOWED)) ? vl->dv : NULL; | 4642 | dv = (0 != (options & RMO_DV_ALLOWED)) ? vl->dv : NULL; |
4591 | if (0 == (options & RMO_UNCONFIRMED_ALLOWED)) | 4643 | if (0 == (options & RMO_UNCONFIRMED_ALLOWED)) |
4592 | { | 4644 | { |
4593 | /* if confirmed is required, and we do not have anything | 4645 | /* if confirmed is required, and we do not have anything |
4594 | confirmed, drop respective options */ | 4646 | confirmed, drop respective options */ |
4595 | if (NULL == n) | 4647 | if (NULL == n) |
4596 | n = lookup_neighbour(target); | 4648 | n = lookup_neighbour (target); |
4597 | if ((NULL == dv) && (0 != (options & RMO_DV_ALLOWED))) | 4649 | if ((NULL == dv) && (0 != (options & RMO_DV_ALLOWED))) |
4598 | dv = GNUNET_CONTAINER_multipeermap_get(dv_routes, target); | 4650 | dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, target); |
4599 | } | 4651 | } |
4600 | if ((NULL == n) && (NULL == dv)) | 4652 | if ((NULL == n) && (NULL == dv)) |
4601 | { | 4653 | { |
4602 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 4654 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
4603 | "Cannot route message of type %u to %s: no route\n", | 4655 | "Cannot route message of type %u to %s: no route\n", |
4604 | ntohs(hdr->type), | 4656 | ntohs (hdr->type), |
4605 | GNUNET_i2s(target)); | 4657 | GNUNET_i2s (target)); |
4606 | GNUNET_STATISTICS_update(GST_stats, | 4658 | GNUNET_STATISTICS_update (GST_stats, |
4607 | "# Messages dropped in routing: no acceptable method", | 4659 | "# Messages dropped in routing: no acceptable method", |
4608 | 1, | 4660 | 1, |
4609 | GNUNET_NO); | 4661 | GNUNET_NO); |
4610 | return GNUNET_TIME_UNIT_FOREVER_REL; | 4662 | return GNUNET_TIME_UNIT_FOREVER_REL; |
4611 | } | 4663 | } |
4612 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4613 | "Routing message of type %u to %s with options %X\n", | 4665 | "Routing message of type %u to %s with options %X\n", |
4614 | ntohs(hdr->type), | 4666 | ntohs (hdr->type), |
4615 | GNUNET_i2s(target), | 4667 | GNUNET_i2s (target), |
4616 | (unsigned int)options); | 4668 | (unsigned int) options); |
4617 | /* If both dv and n are possible and we must choose: | 4669 | /* If both dv and n are possible and we must choose: |
4618 | flip a coin for the choice between the two; for now 50/50 */ | 4670 | flip a coin for the choice between the two; for now 50/50 */ |
4619 | if ((NULL != n) && (NULL != dv) && (0 == (options & RMO_REDUNDANT))) | 4671 | if ((NULL != n) && (NULL != dv) && (0 == (options & RMO_REDUNDANT))) |
4620 | { | 4672 | { |
4621 | if (0 == GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2)) | 4673 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2)) |
4622 | n = NULL; | 4674 | n = NULL; |
4623 | else | 4675 | else |
4624 | dv = NULL; | 4676 | dv = NULL; |
4625 | } | 4677 | } |
4626 | if ((NULL != n) && (NULL != dv)) | 4678 | if ((NULL != n) && (NULL != dv)) |
4627 | options &= ~RMO_REDUNDANT; /* We will do one DV and one direct, that's | 4679 | options &= ~RMO_REDUNDANT; /* We will do one DV and one direct, that's |
4628 | enough for redunancy, so clear the flag. */ | 4680 | enough for redunancy, so clear the flag. */ |
4629 | rtt1 = GNUNET_TIME_UNIT_FOREVER_REL; | 4681 | rtt1 = GNUNET_TIME_UNIT_FOREVER_REL; |
4630 | rtt2 = GNUNET_TIME_UNIT_FOREVER_REL; | 4682 | rtt2 = GNUNET_TIME_UNIT_FOREVER_REL; |
4631 | if (NULL != n) | 4683 | if (NULL != n) |
4632 | { | 4684 | { |
4633 | rtt1 = route_via_neighbour(n, hdr, options); | 4685 | rtt1 = route_via_neighbour (n, hdr, options); |
4634 | } | 4686 | } |
4635 | if (NULL != dv) | 4687 | if (NULL != dv) |
4636 | { | 4688 | { |
4637 | struct DistanceVectorHop *hops[2]; | 4689 | struct DistanceVectorHop *hops[2]; |
4638 | unsigned int res; | 4690 | unsigned int res; |
4639 | 4691 | ||
4640 | res = pick_random_dv_hops(dv, | 4692 | res = pick_random_dv_hops (dv, |
4641 | options, | 4693 | options, |
4642 | hops, | 4694 | hops, |
4643 | (0 == (options & RMO_REDUNDANT)) ? 1 : 2); | 4695 | (0 == (options & RMO_REDUNDANT)) ? 1 : 2); |
4644 | if (0 == res) | 4696 | if (0 == res) |
4645 | { | 4697 | { |
4646 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 4698 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
4647 | "Failed to route message, could not determine DV path\n"); | 4699 | "Failed to route message, could not determine DV path\n"); |
4648 | return rtt1; | 4700 | return rtt1; |
4649 | } | 4701 | } |
4650 | rtt2 = encapsulate_for_dv(dv, | 4702 | rtt2 = encapsulate_for_dv (dv, |
4651 | res, | 4703 | res, |
4652 | hops, | 4704 | hops, |
4653 | hdr, | 4705 | hdr, |
4654 | &send_dv_to_neighbour, | 4706 | &send_dv_to_neighbour, |
4655 | NULL, | 4707 | NULL, |
4656 | options & (~RMO_REDUNDANT)); | 4708 | options & (~RMO_REDUNDANT)); |
4657 | } | 4709 | } |
4658 | return GNUNET_TIME_relative_min(rtt1, rtt2); | 4710 | return GNUNET_TIME_relative_min (rtt1, rtt2); |
4659 | } | 4711 | } |
4660 | 4712 | ||
4661 | 4713 | ||
@@ -4666,7 +4718,7 @@ route_control_message_without_fc(const struct GNUNET_PeerIdentity *target, | |||
4666 | * @param cls a `struct VirtualLink` to work with | 4718 | * @param cls a `struct VirtualLink` to work with |
4667 | */ | 4719 | */ |
4668 | static void | 4720 | static void |
4669 | consider_sending_fc(void *cls) | 4721 | consider_sending_fc (void *cls) |
4670 | { | 4722 | { |
4671 | struct VirtualLink *vl = cls; | 4723 | struct VirtualLink *vl = cls; |
4672 | struct GNUNET_TIME_Absolute monotime; | 4724 | struct GNUNET_TIME_Absolute monotime; |
@@ -4674,7 +4726,7 @@ consider_sending_fc(void *cls) | |||
4674 | struct GNUNET_TIME_Relative duration; | 4726 | struct GNUNET_TIME_Relative duration; |
4675 | struct GNUNET_TIME_Relative rtt; | 4727 | struct GNUNET_TIME_Relative rtt; |
4676 | 4728 | ||
4677 | duration = GNUNET_TIME_absolute_get_duration(vl->last_fc_transmission); | 4729 | duration = GNUNET_TIME_absolute_get_duration (vl->last_fc_transmission); |
4678 | /* OPTIMIZE-FC-BDP: decide sane criteria on when to do this, instead of doing | 4730 | /* OPTIMIZE-FC-BDP: decide sane criteria on when to do this, instead of doing |
4679 | it always! */ | 4731 | it always! */ |
4680 | /* For example, we should probably ONLY do this if a bit more than | 4732 | /* For example, we should probably ONLY do this if a bit more than |
@@ -4683,41 +4735,41 @@ consider_sending_fc(void *cls) | |||
4683 | need an estimate for the bandwidth-delay-product for the entire | 4735 | need an estimate for the bandwidth-delay-product for the entire |
4684 | VL, as that determines "significantly". We have the delay, but | 4736 | VL, as that determines "significantly". We have the delay, but |
4685 | the bandwidth statistics need to be added for the VL!*/ | 4737 | the bandwidth statistics need to be added for the VL!*/ |
4686 | (void)duration; | 4738 | (void) duration; |
4687 | 4739 | ||
4688 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4740 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4689 | "Sending FC seq %u to %s with new window %llu\n", | 4741 | "Sending FC seq %u to %s with new window %llu\n", |
4690 | (unsigned int)vl->fc_seq_gen, | 4742 | (unsigned int) vl->fc_seq_gen, |
4691 | GNUNET_i2s(&vl->target), | 4743 | GNUNET_i2s (&vl->target), |
4692 | (unsigned long long)vl->incoming_fc_window_size); | 4744 | (unsigned long long) vl->incoming_fc_window_size); |
4693 | monotime = GNUNET_TIME_absolute_get_monotonic(GST_cfg); | 4745 | monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg); |
4694 | vl->last_fc_transmission = monotime; | 4746 | vl->last_fc_transmission = monotime; |
4695 | fc.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL); | 4747 | fc.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL); |
4696 | fc.header.size = htons(sizeof(fc)); | 4748 | fc.header.size = htons (sizeof(fc)); |
4697 | fc.seq = htonl(vl->fc_seq_gen++); | 4749 | fc.seq = htonl (vl->fc_seq_gen++); |
4698 | fc.inbound_window_size = GNUNET_htonll(vl->incoming_fc_window_size); | 4750 | fc.inbound_window_size = GNUNET_htonll (vl->incoming_fc_window_size); |
4699 | fc.outbound_sent = GNUNET_htonll(vl->outbound_fc_window_size_used); | 4751 | fc.outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used); |
4700 | fc.outbound_window_size = GNUNET_htonll(vl->outbound_fc_window_size); | 4752 | fc.outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size); |
4701 | fc.sender_time = GNUNET_TIME_absolute_hton(monotime); | 4753 | fc.sender_time = GNUNET_TIME_absolute_hton (monotime); |
4702 | rtt = route_control_message_without_fc(&vl->target, &fc.header, RMO_NONE); | 4754 | rtt = route_control_message_without_fc (&vl->target, &fc.header, RMO_NONE); |
4703 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us) | 4755 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us) |
4704 | { | 4756 | { |
4705 | rtt = GNUNET_TIME_UNIT_SECONDS; | 4757 | rtt = GNUNET_TIME_UNIT_SECONDS; |
4706 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4758 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4707 | "FC retransmission to %s failed, will retry in %s\n", | 4759 | "FC retransmission to %s failed, will retry in %s\n", |
4708 | GNUNET_i2s(&vl->target), | 4760 | GNUNET_i2s (&vl->target), |
4709 | GNUNET_STRINGS_relative_time_to_string(rtt, GNUNET_YES)); | 4761 | GNUNET_STRINGS_relative_time_to_string (rtt, GNUNET_YES)); |
4710 | vl->last_fc_rtt = GNUNET_TIME_UNIT_ZERO; | 4762 | vl->last_fc_rtt = GNUNET_TIME_UNIT_ZERO; |
4711 | } | 4763 | } |
4712 | else | 4764 | else |
4713 | { | 4765 | { |
4714 | /* OPTIMIZE-FC-BDP: rtt is not ideal, we can do better! */ | 4766 | /* OPTIMIZE-FC-BDP: rtt is not ideal, we can do better! */ |
4715 | vl->last_fc_rtt = rtt; | 4767 | vl->last_fc_rtt = rtt; |
4716 | } | 4768 | } |
4717 | if (NULL != vl->fc_retransmit_task) | 4769 | if (NULL != vl->fc_retransmit_task) |
4718 | GNUNET_SCHEDULER_cancel(vl->fc_retransmit_task); | 4770 | GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task); |
4719 | vl->fc_retransmit_task = | 4771 | vl->fc_retransmit_task = |
4720 | GNUNET_SCHEDULER_add_delayed(rtt, &consider_sending_fc, vl); | 4772 | GNUNET_SCHEDULER_add_delayed (rtt, &consider_sending_fc, vl); |
4721 | } | 4773 | } |
4722 | 4774 | ||
4723 | 4775 | ||
@@ -4738,7 +4790,7 @@ consider_sending_fc(void *cls) | |||
4738 | * @param vl virtual link where we should check for transmission | 4790 | * @param vl virtual link where we should check for transmission |
4739 | */ | 4791 | */ |
4740 | static void | 4792 | static void |
4741 | check_vl_transmission(struct VirtualLink *vl) | 4793 | check_vl_transmission (struct VirtualLink *vl) |
4742 | { | 4794 | { |
4743 | struct Neighbour *n = vl->n; | 4795 | struct Neighbour *n = vl->n; |
4744 | struct DistanceVector *dv = vl->dv; | 4796 | struct DistanceVector *dv = vl->dv; |
@@ -4750,57 +4802,57 @@ check_vl_transmission(struct VirtualLink *vl) | |||
4750 | elig = GNUNET_NO; | 4802 | elig = GNUNET_NO; |
4751 | for (struct PendingMessage *pm = vl->pending_msg_head; NULL != pm; | 4803 | for (struct PendingMessage *pm = vl->pending_msg_head; NULL != pm; |
4752 | pm = pm->next_vl) | 4804 | pm = pm->next_vl) |
4753 | { | 4805 | { |
4754 | if (NULL != pm->qe) | 4806 | if (NULL != pm->qe) |
4755 | continue; /* not eligible, is in a queue! */ | 4807 | continue; /* not eligible, is in a queue! */ |
4756 | if (pm->bytes_msg + vl->outbound_fc_window_size_used > | 4808 | if (pm->bytes_msg + vl->outbound_fc_window_size_used > |
4757 | vl->outbound_fc_window_size) | 4809 | vl->outbound_fc_window_size) |
4758 | { | 4810 | { |
4759 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4760 | "Stalled transmision on VL %s due to flow control: %llu < %llu\n", | 4812 | "Stalled transmision on VL %s due to flow control: %llu < %llu\n", |
4761 | GNUNET_i2s(&vl->target), | 4813 | GNUNET_i2s (&vl->target), |
4762 | (unsigned long long)vl->outbound_fc_window_size, | 4814 | (unsigned long long) vl->outbound_fc_window_size, |
4763 | (unsigned long long)(pm->bytes_msg + | 4815 | (unsigned long long) (pm->bytes_msg |
4764 | vl->outbound_fc_window_size_used)); | 4816 | + vl->outbound_fc_window_size_used)); |
4765 | consider_sending_fc(vl); | 4817 | consider_sending_fc (vl); |
4766 | return; /* We have a message, but flow control says "nope" */ | 4818 | return; /* We have a message, but flow control says "nope" */ |
4767 | } | 4819 | } |
4768 | elig = GNUNET_YES; | 4820 | elig = GNUNET_YES; |
4769 | break; | 4821 | break; |
4770 | } | 4822 | } |
4771 | if (GNUNET_NO == elig) | 4823 | if (GNUNET_NO == elig) |
4772 | return; | 4824 | return; |
4773 | 4825 | ||
4774 | /* Notify queues at direct neighbours that we are interested */ | 4826 | /* Notify queues at direct neighbours that we are interested */ |
4775 | now = GNUNET_TIME_absolute_get(); | 4827 | now = GNUNET_TIME_absolute_get (); |
4776 | if (NULL != n) | 4828 | if (NULL != n) |
4829 | { | ||
4830 | for (struct Queue *queue = n->queue_head; NULL != queue; | ||
4831 | queue = queue->next_neighbour) | ||
4832 | if ((GNUNET_YES == queue->idle) && | ||
4833 | (queue->validated_until.abs_value_us > now.abs_value_us)) | ||
4834 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | ||
4835 | } | ||
4836 | /* Notify queues via DV that we are interested */ | ||
4837 | if (NULL != dv) | ||
4838 | { | ||
4839 | /* Do DV with lower scheduler priority, which effectively means that | ||
4840 | IF a neighbour exists and is available, we prefer it. */ | ||
4841 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | ||
4842 | pos = pos->next_dv) | ||
4777 | { | 4843 | { |
4778 | for (struct Queue *queue = n->queue_head; NULL != queue; | 4844 | struct Neighbour *nh = pos->next_hop; |
4845 | |||
4846 | if (pos->path_valid_until.abs_value_us <= now.abs_value_us) | ||
4847 | continue; /* skip this one: path not validated */ | ||
4848 | for (struct Queue *queue = nh->queue_head; NULL != queue; | ||
4779 | queue = queue->next_neighbour) | 4849 | queue = queue->next_neighbour) |
4780 | if ((GNUNET_YES == queue->idle) && | 4850 | if ((GNUNET_YES == queue->idle) && |
4781 | (queue->validated_until.abs_value_us > now.abs_value_us)) | 4851 | (queue->validated_until.abs_value_us > now.abs_value_us)) |
4782 | schedule_transmit_on_queue(queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 4852 | schedule_transmit_on_queue (queue, |
4783 | } | 4853 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND); |
4784 | /* Notify queues via DV that we are interested */ | ||
4785 | if (NULL != dv) | ||
4786 | { | ||
4787 | /* Do DV with lower scheduler priority, which effectively means that | ||
4788 | IF a neighbour exists and is available, we prefer it. */ | ||
4789 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | ||
4790 | pos = pos->next_dv) | ||
4791 | { | ||
4792 | struct Neighbour *nh = pos->next_hop; | ||
4793 | |||
4794 | if (pos->path_valid_until.abs_value_us <= now.abs_value_us) | ||
4795 | continue; /* skip this one: path not validated */ | ||
4796 | for (struct Queue *queue = nh->queue_head; NULL != queue; | ||
4797 | queue = queue->next_neighbour) | ||
4798 | if ((GNUNET_YES == queue->idle) && | ||
4799 | (queue->validated_until.abs_value_us > now.abs_value_us)) | ||
4800 | schedule_transmit_on_queue(queue, | ||
4801 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND); | ||
4802 | } | ||
4803 | } | 4854 | } |
4855 | } | ||
4804 | } | 4856 | } |
4805 | 4857 | ||
4806 | 4858 | ||
@@ -4811,7 +4863,7 @@ check_vl_transmission(struct VirtualLink *vl) | |||
4811 | * @param obm the send message that was sent | 4863 | * @param obm the send message that was sent |
4812 | */ | 4864 | */ |
4813 | static void | 4865 | static void |
4814 | handle_client_send(void *cls, const struct OutboundMessage *obm) | 4866 | handle_client_send (void *cls, const struct OutboundMessage *obm) |
4815 | { | 4867 | { |
4816 | struct TransportClient *tc = cls; | 4868 | struct TransportClient *tc = cls; |
4817 | struct PendingMessage *pm; | 4869 | struct PendingMessage *pm; |
@@ -4820,46 +4872,46 @@ handle_client_send(void *cls, const struct OutboundMessage *obm) | |||
4820 | struct VirtualLink *vl; | 4872 | struct VirtualLink *vl; |
4821 | enum GNUNET_MQ_PriorityPreferences pp; | 4873 | enum GNUNET_MQ_PriorityPreferences pp; |
4822 | 4874 | ||
4823 | GNUNET_assert(CT_CORE == tc->type); | 4875 | GNUNET_assert (CT_CORE == tc->type); |
4824 | obmm = (const struct GNUNET_MessageHeader *)&obm[1]; | 4876 | obmm = (const struct GNUNET_MessageHeader *) &obm[1]; |
4825 | bytes_msg = ntohs(obmm->size); | 4877 | bytes_msg = ntohs (obmm->size); |
4826 | pp = (enum GNUNET_MQ_PriorityPreferences)ntohl(obm->priority); | 4878 | pp = (enum GNUNET_MQ_PriorityPreferences) ntohl (obm->priority); |
4827 | vl = lookup_virtual_link(&obm->peer); | 4879 | vl = lookup_virtual_link (&obm->peer); |
4828 | if (NULL == vl) | 4880 | if (NULL == vl) |
4829 | { | 4881 | { |
4830 | /* Failure: don't have this peer as a neighbour (anymore). | 4882 | /* Failure: don't have this peer as a neighbour (anymore). |
4831 | Might have gone down asynchronously, so this is NOT | 4883 | Might have gone down asynchronously, so this is NOT |
4832 | a protocol violation by CORE. Still count the event, | 4884 | a protocol violation by CORE. Still count the event, |
4833 | as this should be rare. */ | 4885 | as this should be rare. */ |
4834 | GNUNET_SERVICE_client_continue(tc->client); | 4886 | GNUNET_SERVICE_client_continue (tc->client); |
4835 | GNUNET_STATISTICS_update(GST_stats, | 4887 | GNUNET_STATISTICS_update (GST_stats, |
4836 | "# messages dropped (neighbour unknown)", | 4888 | "# messages dropped (neighbour unknown)", |
4837 | 1, | 4889 | 1, |
4838 | GNUNET_NO); | 4890 | GNUNET_NO); |
4839 | return; | 4891 | return; |
4840 | } | 4892 | } |
4841 | 4893 | ||
4842 | pm = GNUNET_malloc(sizeof(struct PendingMessage) + bytes_msg); | 4894 | pm = GNUNET_malloc (sizeof(struct PendingMessage) + bytes_msg); |
4843 | pm->logging_uuid = logging_uuid_gen++; | 4895 | pm->logging_uuid = logging_uuid_gen++; |
4844 | pm->prefs = pp; | 4896 | pm->prefs = pp; |
4845 | pm->client = tc; | 4897 | pm->client = tc; |
4846 | pm->vl = vl; | 4898 | pm->vl = vl; |
4847 | pm->bytes_msg = bytes_msg; | 4899 | pm->bytes_msg = bytes_msg; |
4848 | memcpy(&pm[1], obmm, bytes_msg); | 4900 | memcpy (&pm[1], obmm, bytes_msg); |
4849 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4901 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4850 | "Sending %u bytes as <%llu> to %s\n", | 4902 | "Sending %u bytes as <%llu> to %s\n", |
4851 | bytes_msg, | 4903 | bytes_msg, |
4852 | pm->logging_uuid, | 4904 | pm->logging_uuid, |
4853 | GNUNET_i2s(&obm->peer)); | 4905 | GNUNET_i2s (&obm->peer)); |
4854 | GNUNET_CONTAINER_MDLL_insert(client, | 4906 | GNUNET_CONTAINER_MDLL_insert (client, |
4855 | tc->details.core.pending_msg_head, | 4907 | tc->details.core.pending_msg_head, |
4856 | tc->details.core.pending_msg_tail, | 4908 | tc->details.core.pending_msg_tail, |
4857 | pm); | 4909 | pm); |
4858 | GNUNET_CONTAINER_MDLL_insert(vl, | 4910 | GNUNET_CONTAINER_MDLL_insert (vl, |
4859 | vl->pending_msg_head, | 4911 | vl->pending_msg_head, |
4860 | vl->pending_msg_tail, | 4912 | vl->pending_msg_tail, |
4861 | pm); | 4913 | pm); |
4862 | check_vl_transmission(vl); | 4914 | check_vl_transmission (vl); |
4863 | } | 4915 | } |
4864 | 4916 | ||
4865 | 4917 | ||
@@ -4873,39 +4925,40 @@ handle_client_send(void *cls, const struct OutboundMessage *obm) | |||
4873 | * @param cb the send message that was sent | 4925 | * @param cb the send message that was sent |
4874 | */ | 4926 | */ |
4875 | static void | 4927 | static void |
4876 | handle_communicator_backchannel( | 4928 | handle_communicator_backchannel ( |
4877 | void *cls, | 4929 | void *cls, |
4878 | const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb) | 4930 | const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb) |
4879 | { | 4931 | { |
4880 | struct TransportClient *tc = cls; | 4932 | struct TransportClient *tc = cls; |
4881 | const struct GNUNET_MessageHeader *inbox = | 4933 | const struct GNUNET_MessageHeader *inbox = |
4882 | (const struct GNUNET_MessageHeader *)&cb[1]; | 4934 | (const struct GNUNET_MessageHeader *) &cb[1]; |
4883 | uint16_t isize = ntohs(inbox->size); | 4935 | uint16_t isize = ntohs (inbox->size); |
4884 | const char *is = ((const char *)&cb[1]) + isize; | 4936 | const char *is = ((const char *) &cb[1]) + isize; |
4885 | char | 4937 | char |
4886 | mbuf[isize + | 4938 | mbuf[isize |
4887 | sizeof(struct TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN; | 4939 | + sizeof(struct |
4940 | TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN; | ||
4888 | struct TransportBackchannelEncapsulationMessage *be = | 4941 | struct TransportBackchannelEncapsulationMessage *be = |
4889 | (struct TransportBackchannelEncapsulationMessage *)mbuf; | 4942 | (struct TransportBackchannelEncapsulationMessage *) mbuf; |
4890 | 4943 | ||
4891 | /* 0-termination of 'is' was checked already in | 4944 | /* 0-termination of 'is' was checked already in |
4892 | #check_communicator_backchannel() */ | 4945 | #check_communicator_backchannel() */ |
4893 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4946 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4894 | "Preparing backchannel transmission to %s:%s of type %u\n", | 4947 | "Preparing backchannel transmission to %s:%s of type %u\n", |
4895 | GNUNET_i2s(&cb->pid), | 4948 | GNUNET_i2s (&cb->pid), |
4896 | is, | 4949 | is, |
4897 | ntohs(inbox->size)); | 4950 | ntohs (inbox->size)); |
4898 | /* encapsulate and encrypt message */ | 4951 | /* encapsulate and encrypt message */ |
4899 | be->header.type = | 4952 | be->header.type = |
4900 | htons(GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION); | 4953 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION); |
4901 | be->header.size = htons(sizeof(mbuf)); | 4954 | be->header.size = htons (sizeof(mbuf)); |
4902 | memcpy(&be[1], inbox, isize); | 4955 | memcpy (&be[1], inbox, isize); |
4903 | memcpy(&mbuf[sizeof(struct TransportBackchannelEncapsulationMessage) + | 4956 | memcpy (&mbuf[sizeof(struct TransportBackchannelEncapsulationMessage) |
4904 | isize], | 4957 | + isize], |
4905 | is, | 4958 | is, |
4906 | strlen(is) + 1); | 4959 | strlen (is) + 1); |
4907 | route_control_message_without_fc(&cb->pid, &be->header, RMO_DV_ALLOWED); | 4960 | route_control_message_without_fc (&cb->pid, &be->header, RMO_DV_ALLOWED); |
4908 | GNUNET_SERVICE_client_continue(tc->client); | 4961 | GNUNET_SERVICE_client_continue (tc->client); |
4909 | } | 4962 | } |
4910 | 4963 | ||
4911 | 4964 | ||
@@ -4917,17 +4970,17 @@ handle_communicator_backchannel( | |||
4917 | * @return #GNUNET_OK if message is well-formed | 4970 | * @return #GNUNET_OK if message is well-formed |
4918 | */ | 4971 | */ |
4919 | static int | 4972 | static int |
4920 | check_add_address(void *cls, | 4973 | check_add_address (void *cls, |
4921 | const struct GNUNET_TRANSPORT_AddAddressMessage *aam) | 4974 | const struct GNUNET_TRANSPORT_AddAddressMessage *aam) |
4922 | { | 4975 | { |
4923 | struct TransportClient *tc = cls; | 4976 | struct TransportClient *tc = cls; |
4924 | 4977 | ||
4925 | if (CT_COMMUNICATOR != tc->type) | 4978 | if (CT_COMMUNICATOR != tc->type) |
4926 | { | 4979 | { |
4927 | GNUNET_break(0); | 4980 | GNUNET_break (0); |
4928 | return GNUNET_SYSERR; | 4981 | return GNUNET_SYSERR; |
4929 | } | 4982 | } |
4930 | GNUNET_MQ_check_zero_termination(aam); | 4983 | GNUNET_MQ_check_zero_termination (aam); |
4931 | return GNUNET_OK; | 4984 | return GNUNET_OK; |
4932 | } | 4985 | } |
4933 | 4986 | ||
@@ -4938,7 +4991,7 @@ check_add_address(void *cls, | |||
4938 | * @param cls an `struct AddressListEntry *` | 4991 | * @param cls an `struct AddressListEntry *` |
4939 | */ | 4992 | */ |
4940 | static void | 4993 | static void |
4941 | store_pi(void *cls); | 4994 | store_pi (void *cls); |
4942 | 4995 | ||
4943 | 4996 | ||
4944 | /** | 4997 | /** |
@@ -4948,26 +5001,26 @@ store_pi(void *cls); | |||
4948 | * @param success #GNUNET_YES if peerstore was successful | 5001 | * @param success #GNUNET_YES if peerstore was successful |
4949 | */ | 5002 | */ |
4950 | static void | 5003 | static void |
4951 | peerstore_store_own_cb(void *cls, int success) | 5004 | peerstore_store_own_cb (void *cls, int success) |
4952 | { | 5005 | { |
4953 | struct AddressListEntry *ale = cls; | 5006 | struct AddressListEntry *ale = cls; |
4954 | 5007 | ||
4955 | ale->sc = NULL; | 5008 | ale->sc = NULL; |
4956 | if (GNUNET_YES != success) | 5009 | if (GNUNET_YES != success) |
4957 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 5010 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
4958 | "Failed to store our own address `%s' in peerstore!\n", | 5011 | "Failed to store our own address `%s' in peerstore!\n", |
4959 | ale->address); | 5012 | ale->address); |
4960 | else | 5013 | else |
4961 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4962 | "Successfully stored our own address `%s' in peerstore!\n", | 5015 | "Successfully stored our own address `%s' in peerstore!\n", |
4963 | ale->address); | 5016 | ale->address); |
4964 | /* refresh period is 1/4 of expiration time, that should be plenty | 5017 | /* refresh period is 1/4 of expiration time, that should be plenty |
4965 | without being excessive. */ | 5018 | without being excessive. */ |
4966 | ale->st = | 5019 | ale->st = |
4967 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_divide(ale->expiration, | 5020 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (ale->expiration, |
4968 | 4ULL), | 5021 | 4ULL), |
4969 | &store_pi, | 5022 | &store_pi, |
4970 | ale); | 5023 | ale); |
4971 | } | 5024 | } |
4972 | 5025 | ||
4973 | 5026 | ||
@@ -4977,7 +5030,7 @@ peerstore_store_own_cb(void *cls, int success) | |||
4977 | * @param cls an `struct AddressListEntry *` | 5030 | * @param cls an `struct AddressListEntry *` |
4978 | */ | 5031 | */ |
4979 | static void | 5032 | static void |
4980 | store_pi(void *cls) | 5033 | store_pi (void *cls) |
4981 | { | 5034 | { |
4982 | struct AddressListEntry *ale = cls; | 5035 | struct AddressListEntry *ale = cls; |
4983 | void *addr; | 5036 | void *addr; |
@@ -4985,36 +5038,36 @@ store_pi(void *cls) | |||
4985 | struct GNUNET_TIME_Absolute expiration; | 5038 | struct GNUNET_TIME_Absolute expiration; |
4986 | 5039 | ||
4987 | ale->st = NULL; | 5040 | ale->st = NULL; |
4988 | expiration = GNUNET_TIME_relative_to_absolute(ale->expiration); | 5041 | expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); |
4989 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5042 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4990 | "Storing our address `%s' in peerstore until %s!\n", | 5043 | "Storing our address `%s' in peerstore until %s!\n", |
4991 | ale->address, | 5044 | ale->address, |
4992 | GNUNET_STRINGS_absolute_time_to_string(expiration)); | 5045 | GNUNET_STRINGS_absolute_time_to_string (expiration)); |
4993 | GNUNET_HELLO_sign_address(ale->address, | 5046 | GNUNET_HELLO_sign_address (ale->address, |
4994 | ale->nt, | 5047 | ale->nt, |
4995 | hello_mono_time, | 5048 | hello_mono_time, |
4996 | GST_my_private_key, | 5049 | GST_my_private_key, |
4997 | &addr, | 5050 | &addr, |
4998 | &addr_len); | 5051 | &addr_len); |
4999 | ale->sc = GNUNET_PEERSTORE_store(peerstore, | 5052 | ale->sc = GNUNET_PEERSTORE_store (peerstore, |
5000 | "transport", | 5053 | "transport", |
5001 | &GST_my_identity, | 5054 | &GST_my_identity, |
5002 | GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, | 5055 | GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, |
5003 | addr, | 5056 | addr, |
5004 | addr_len, | 5057 | addr_len, |
5005 | expiration, | 5058 | expiration, |
5006 | GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, | 5059 | GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, |
5007 | &peerstore_store_own_cb, | 5060 | &peerstore_store_own_cb, |
5008 | ale); | 5061 | ale); |
5009 | GNUNET_free(addr); | 5062 | GNUNET_free (addr); |
5010 | if (NULL == ale->sc) | 5063 | if (NULL == ale->sc) |
5011 | { | 5064 | { |
5012 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 5065 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
5013 | "Failed to store our address `%s' with peerstore\n", | 5066 | "Failed to store our address `%s' with peerstore\n", |
5014 | ale->address); | 5067 | ale->address); |
5015 | ale->st = | 5068 | ale->st = |
5016 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &store_pi, ale); | 5069 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &store_pi, ale); |
5017 | } | 5070 | } |
5018 | } | 5071 | } |
5019 | 5072 | ||
5020 | 5073 | ||
@@ -5025,30 +5078,30 @@ store_pi(void *cls) | |||
5025 | * @param aam the send message that was sent | 5078 | * @param aam the send message that was sent |
5026 | */ | 5079 | */ |
5027 | static void | 5080 | static void |
5028 | handle_add_address(void *cls, | 5081 | handle_add_address (void *cls, |
5029 | const struct GNUNET_TRANSPORT_AddAddressMessage *aam) | 5082 | const struct GNUNET_TRANSPORT_AddAddressMessage *aam) |
5030 | { | 5083 | { |
5031 | struct TransportClient *tc = cls; | 5084 | struct TransportClient *tc = cls; |
5032 | struct AddressListEntry *ale; | 5085 | struct AddressListEntry *ale; |
5033 | size_t slen; | 5086 | size_t slen; |
5034 | 5087 | ||
5035 | /* 0-termination of &aam[1] was checked in #check_add_address */ | 5088 | /* 0-termination of &aam[1] was checked in #check_add_address */ |
5036 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5089 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5037 | "Communicator added address `%s'!\n", | 5090 | "Communicator added address `%s'!\n", |
5038 | (const char *)&aam[1]); | 5091 | (const char *) &aam[1]); |
5039 | slen = ntohs(aam->header.size) - sizeof(*aam); | 5092 | slen = ntohs (aam->header.size) - sizeof(*aam); |
5040 | ale = GNUNET_malloc(sizeof(struct AddressListEntry) + slen); | 5093 | ale = GNUNET_malloc (sizeof(struct AddressListEntry) + slen); |
5041 | ale->tc = tc; | 5094 | ale->tc = tc; |
5042 | ale->address = (const char *)&ale[1]; | 5095 | ale->address = (const char *) &ale[1]; |
5043 | ale->expiration = GNUNET_TIME_relative_ntoh(aam->expiration); | 5096 | ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration); |
5044 | ale->aid = aam->aid; | 5097 | ale->aid = aam->aid; |
5045 | ale->nt = (enum GNUNET_NetworkType)ntohl(aam->nt); | 5098 | ale->nt = (enum GNUNET_NetworkType) ntohl (aam->nt); |
5046 | memcpy(&ale[1], &aam[1], slen); | 5099 | memcpy (&ale[1], &aam[1], slen); |
5047 | GNUNET_CONTAINER_DLL_insert(tc->details.communicator.addr_head, | 5100 | GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head, |
5048 | tc->details.communicator.addr_tail, | 5101 | tc->details.communicator.addr_tail, |
5049 | ale); | 5102 | ale); |
5050 | ale->st = GNUNET_SCHEDULER_add_now(&store_pi, ale); | 5103 | ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale); |
5051 | GNUNET_SERVICE_client_continue(tc->client); | 5104 | GNUNET_SERVICE_client_continue (tc->client); |
5052 | } | 5105 | } |
5053 | 5106 | ||
5054 | 5107 | ||
@@ -5059,34 +5112,34 @@ handle_add_address(void *cls, | |||
5059 | * @param dam the send message that was sent | 5112 | * @param dam the send message that was sent |
5060 | */ | 5113 | */ |
5061 | static void | 5114 | static void |
5062 | handle_del_address(void *cls, | 5115 | handle_del_address (void *cls, |
5063 | const struct GNUNET_TRANSPORT_DelAddressMessage *dam) | 5116 | const struct GNUNET_TRANSPORT_DelAddressMessage *dam) |
5064 | { | 5117 | { |
5065 | struct TransportClient *tc = cls; | 5118 | struct TransportClient *tc = cls; |
5066 | struct AddressListEntry *alen; | 5119 | struct AddressListEntry *alen; |
5067 | 5120 | ||
5068 | if (CT_COMMUNICATOR != tc->type) | 5121 | if (CT_COMMUNICATOR != tc->type) |
5069 | { | 5122 | { |
5070 | GNUNET_break(0); | 5123 | GNUNET_break (0); |
5071 | GNUNET_SERVICE_client_drop(tc->client); | 5124 | GNUNET_SERVICE_client_drop (tc->client); |
5072 | return; | 5125 | return; |
5073 | } | 5126 | } |
5074 | for (struct AddressListEntry *ale = tc->details.communicator.addr_head; | 5127 | for (struct AddressListEntry *ale = tc->details.communicator.addr_head; |
5075 | NULL != ale; | 5128 | NULL != ale; |
5076 | ale = alen) | 5129 | ale = alen) |
5077 | { | 5130 | { |
5078 | alen = ale->next; | 5131 | alen = ale->next; |
5079 | if (dam->aid != ale->aid) | 5132 | if (dam->aid != ale->aid) |
5080 | continue; | 5133 | continue; |
5081 | GNUNET_assert(ale->tc == tc); | 5134 | GNUNET_assert (ale->tc == tc); |
5082 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5083 | "Communicator deleted address `%s'!\n", | 5136 | "Communicator deleted address `%s'!\n", |
5084 | ale->address); | 5137 | ale->address); |
5085 | free_address_list_entry(ale); | 5138 | free_address_list_entry (ale); |
5086 | GNUNET_SERVICE_client_continue(tc->client); | 5139 | GNUNET_SERVICE_client_continue (tc->client); |
5087 | } | 5140 | } |
5088 | GNUNET_break(0); | 5141 | GNUNET_break (0); |
5089 | GNUNET_SERVICE_client_drop(tc->client); | 5142 | GNUNET_SERVICE_client_drop (tc->client); |
5090 | } | 5143 | } |
5091 | 5144 | ||
5092 | 5145 | ||
@@ -5098,8 +5151,8 @@ handle_del_address(void *cls, | |||
5098 | * @param msg message to demultiplex | 5151 | * @param msg message to demultiplex |
5099 | */ | 5152 | */ |
5100 | static void | 5153 | static void |
5101 | demultiplex_with_cmc(struct CommunicatorMessageContext *cmc, | 5154 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, |
5102 | const struct GNUNET_MessageHeader *msg); | 5155 | const struct GNUNET_MessageHeader *msg); |
5103 | 5156 | ||
5104 | 5157 | ||
5105 | /** | 5158 | /** |
@@ -5110,23 +5163,23 @@ demultiplex_with_cmc(struct CommunicatorMessageContext *cmc, | |||
5110 | * @param cls a `struct CoreSentContext` | 5163 | * @param cls a `struct CoreSentContext` |
5111 | */ | 5164 | */ |
5112 | static void | 5165 | static void |
5113 | core_env_sent_cb(void *cls) | 5166 | core_env_sent_cb (void *cls) |
5114 | { | 5167 | { |
5115 | struct CoreSentContext *ctx = cls; | 5168 | struct CoreSentContext *ctx = cls; |
5116 | struct VirtualLink *vl = ctx->vl; | 5169 | struct VirtualLink *vl = ctx->vl; |
5117 | 5170 | ||
5118 | if (NULL == vl) | 5171 | if (NULL == vl) |
5119 | { | 5172 | { |
5120 | /* lost the link in the meantime, ignore */ | 5173 | /* lost the link in the meantime, ignore */ |
5121 | GNUNET_free(ctx); | 5174 | GNUNET_free (ctx); |
5122 | return; | 5175 | return; |
5123 | } | 5176 | } |
5124 | GNUNET_CONTAINER_DLL_remove(vl->csc_head, vl->csc_tail, ctx); | 5177 | GNUNET_CONTAINER_DLL_remove (vl->csc_head, vl->csc_tail, ctx); |
5125 | GNUNET_assert(vl->incoming_fc_window_size_ram >= ctx->size); | 5178 | GNUNET_assert (vl->incoming_fc_window_size_ram >= ctx->size); |
5126 | vl->incoming_fc_window_size_ram -= ctx->size; | 5179 | vl->incoming_fc_window_size_ram -= ctx->size; |
5127 | vl->incoming_fc_window_size_used += ctx->isize; | 5180 | vl->incoming_fc_window_size_used += ctx->isize; |
5128 | consider_sending_fc(vl); | 5181 | consider_sending_fc (vl); |
5129 | GNUNET_free(ctx); | 5182 | GNUNET_free (ctx); |
5130 | } | 5183 | } |
5131 | 5184 | ||
5132 | 5185 | ||
@@ -5139,109 +5192,109 @@ core_env_sent_cb(void *cls) | |||
5139 | * @param mh the message that was received | 5192 | * @param mh the message that was received |
5140 | */ | 5193 | */ |
5141 | static void | 5194 | static void |
5142 | handle_raw_message(void *cls, const struct GNUNET_MessageHeader *mh) | 5195 | handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) |
5143 | { | 5196 | { |
5144 | struct CommunicatorMessageContext *cmc = cls; | 5197 | struct CommunicatorMessageContext *cmc = cls; |
5145 | struct VirtualLink *vl; | 5198 | struct VirtualLink *vl; |
5146 | uint16_t size = ntohs(mh->size); | 5199 | uint16_t size = ntohs (mh->size); |
5147 | int have_core; | 5200 | int have_core; |
5148 | 5201 | ||
5149 | if ((size > UINT16_MAX - sizeof(struct InboundMessage)) || | 5202 | if ((size > UINT16_MAX - sizeof(struct InboundMessage)) || |
5150 | (size < sizeof(struct GNUNET_MessageHeader))) | 5203 | (size < sizeof(struct GNUNET_MessageHeader))) |
5151 | { | 5204 | { |
5152 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; | 5205 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; |
5153 | 5206 | ||
5154 | GNUNET_break(0); | 5207 | GNUNET_break (0); |
5155 | finish_cmc_handling(cmc); | 5208 | finish_cmc_handling (cmc); |
5156 | GNUNET_SERVICE_client_drop(client); | 5209 | GNUNET_SERVICE_client_drop (client); |
5157 | return; | 5210 | return; |
5158 | } | 5211 | } |
5159 | vl = lookup_virtual_link(&cmc->im.sender); | 5212 | vl = lookup_virtual_link (&cmc->im.sender); |
5160 | if (NULL == vl) | 5213 | if (NULL == vl) |
5161 | { | 5214 | { |
5162 | /* FIXME: sender is giving us messages for CORE but we don't have | 5215 | /* FIXME: sender is giving us messages for CORE but we don't have |
5163 | the link up yet! I *suspect* this can happen right now (i.e. | 5216 | the link up yet! I *suspect* this can happen right now (i.e. |
5164 | sender has verified us, but we didn't verify sender), but if | 5217 | sender has verified us, but we didn't verify sender), but if |
5165 | we pass this on, CORE would be confused (link down, messages | 5218 | we pass this on, CORE would be confused (link down, messages |
5166 | arrive). We should investigate more if this happens often, | 5219 | arrive). We should investigate more if this happens often, |
5167 | or in a persistent manner, and possibly do "something" about | 5220 | or in a persistent manner, and possibly do "something" about |
5168 | it. Thus logging as error for now. */ | 5221 | it. Thus logging as error for now. */ |
5169 | GNUNET_break_op(0); | 5222 | GNUNET_break_op (0); |
5170 | GNUNET_STATISTICS_update(GST_stats, | 5223 | GNUNET_STATISTICS_update (GST_stats, |
5171 | "# CORE messages droped (virtual link still down)", | 5224 | "# CORE messages droped (virtual link still down)", |
5172 | 1, | 5225 | 1, |
5173 | GNUNET_NO); | 5226 | GNUNET_NO); |
5174 | 5227 | ||
5175 | finish_cmc_handling(cmc); | 5228 | finish_cmc_handling (cmc); |
5176 | return; | 5229 | return; |
5177 | } | 5230 | } |
5178 | if (vl->incoming_fc_window_size_ram > UINT_MAX - size) | 5231 | if (vl->incoming_fc_window_size_ram > UINT_MAX - size) |
5179 | { | 5232 | { |
5180 | GNUNET_STATISTICS_update(GST_stats, | 5233 | GNUNET_STATISTICS_update (GST_stats, |
5181 | "# CORE messages droped (FC arithmetic overflow)", | 5234 | "# CORE messages droped (FC arithmetic overflow)", |
5182 | 1, | 5235 | 1, |
5183 | GNUNET_NO); | 5236 | GNUNET_NO); |
5184 | 5237 | ||
5185 | finish_cmc_handling(cmc); | 5238 | finish_cmc_handling (cmc); |
5186 | return; | 5239 | return; |
5187 | } | 5240 | } |
5188 | if (vl->incoming_fc_window_size_ram + size > vl->available_fc_window_size) | 5241 | if (vl->incoming_fc_window_size_ram + size > vl->available_fc_window_size) |
5189 | { | 5242 | { |
5190 | GNUNET_STATISTICS_update(GST_stats, | 5243 | GNUNET_STATISTICS_update (GST_stats, |
5191 | "# CORE messages droped (FC window overflow)", | 5244 | "# CORE messages droped (FC window overflow)", |
5192 | 1, | 5245 | 1, |
5193 | GNUNET_NO); | 5246 | GNUNET_NO); |
5194 | finish_cmc_handling(cmc); | 5247 | finish_cmc_handling (cmc); |
5195 | return; | 5248 | return; |
5196 | } | 5249 | } |
5197 | 5250 | ||
5198 | /* Forward to all CORE clients */ | 5251 | /* Forward to all CORE clients */ |
5199 | have_core = GNUNET_NO; | 5252 | have_core = GNUNET_NO; |
5200 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) | 5253 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
5201 | { | 5254 | { |
5202 | struct GNUNET_MQ_Envelope *env; | 5255 | struct GNUNET_MQ_Envelope *env; |
5203 | struct InboundMessage *im; | 5256 | struct InboundMessage *im; |
5204 | struct CoreSentContext *ctx; | 5257 | struct CoreSentContext *ctx; |
5205 | 5258 | ||
5206 | if (CT_CORE != tc->type) | 5259 | if (CT_CORE != tc->type) |
5207 | continue; | 5260 | continue; |
5208 | vl->incoming_fc_window_size_ram += size; | 5261 | vl->incoming_fc_window_size_ram += size; |
5209 | env = GNUNET_MQ_msg_extra(im, size, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); | 5262 | env = GNUNET_MQ_msg_extra (im, size, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); |
5210 | ctx = GNUNET_new(struct CoreSentContext); | 5263 | ctx = GNUNET_new (struct CoreSentContext); |
5211 | ctx->vl = vl; | 5264 | ctx->vl = vl; |
5212 | ctx->size = size; | 5265 | ctx->size = size; |
5213 | ctx->isize = (GNUNET_NO == have_core) ? size : 0; | 5266 | ctx->isize = (GNUNET_NO == have_core) ? size : 0; |
5214 | have_core = GNUNET_YES; | 5267 | have_core = GNUNET_YES; |
5215 | GNUNET_CONTAINER_DLL_insert(vl->csc_head, vl->csc_tail, ctx); | 5268 | GNUNET_CONTAINER_DLL_insert (vl->csc_head, vl->csc_tail, ctx); |
5216 | GNUNET_MQ_notify_sent(env, &core_env_sent_cb, ctx); | 5269 | GNUNET_MQ_notify_sent (env, &core_env_sent_cb, ctx); |
5217 | im->peer = cmc->im.sender; | 5270 | im->peer = cmc->im.sender; |
5218 | memcpy(&im[1], mh, size); | 5271 | memcpy (&im[1], mh, size); |
5219 | GNUNET_MQ_send(tc->mq, env); | 5272 | GNUNET_MQ_send (tc->mq, env); |
5220 | vl->core_recv_window--; | 5273 | vl->core_recv_window--; |
5221 | } | 5274 | } |
5222 | if (GNUNET_NO == have_core) | 5275 | if (GNUNET_NO == have_core) |
5223 | { | 5276 | { |
5224 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 5277 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
5225 | "Dropped message to CORE: no CORE client connected!\n"); | 5278 | "Dropped message to CORE: no CORE client connected!\n"); |
5226 | /* Nevertheless, count window as used, as it is from the | 5279 | /* Nevertheless, count window as used, as it is from the |
5227 | perspective of the other peer! */ | 5280 | perspective of the other peer! */ |
5228 | vl->incoming_fc_window_size_used += size; | 5281 | vl->incoming_fc_window_size_used += size; |
5229 | /* TODO-M1 */ | 5282 | /* TODO-M1 */ |
5230 | finish_cmc_handling(cmc); | 5283 | finish_cmc_handling (cmc); |
5231 | return; | 5284 | return; |
5232 | } | 5285 | } |
5233 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5234 | "Delivered message from %s of type %u to CORE\n", | 5287 | "Delivered message from %s of type %u to CORE\n", |
5235 | GNUNET_i2s(&cmc->im.sender), | 5288 | GNUNET_i2s (&cmc->im.sender), |
5236 | ntohs(mh->type)); | 5289 | ntohs (mh->type)); |
5237 | if (vl->core_recv_window > 0) | 5290 | if (vl->core_recv_window > 0) |
5238 | { | 5291 | { |
5239 | finish_cmc_handling(cmc); | 5292 | finish_cmc_handling (cmc); |
5240 | return; | 5293 | return; |
5241 | } | 5294 | } |
5242 | /* Wait with calling #finish_cmc_handling(cmc) until the message | 5295 | /* Wait with calling #finish_cmc_handling(cmc) until the message |
5243 | was processed by CORE MQs (for CORE flow control)! */ | 5296 | was processed by CORE MQs (for CORE flow control)! */ |
5244 | GNUNET_CONTAINER_DLL_insert(vl->cmc_head, vl->cmc_tail, cmc); | 5297 | GNUNET_CONTAINER_DLL_insert (vl->cmc_head, vl->cmc_tail, cmc); |
5245 | } | 5298 | } |
5246 | 5299 | ||
5247 | 5300 | ||
@@ -5253,27 +5306,27 @@ handle_raw_message(void *cls, const struct GNUNET_MessageHeader *mh) | |||
5253 | * @return #GNUNET_YES if message is well-formed | 5306 | * @return #GNUNET_YES if message is well-formed |
5254 | */ | 5307 | */ |
5255 | static int | 5308 | static int |
5256 | check_fragment_box(void *cls, const struct TransportFragmentBoxMessage *fb) | 5309 | check_fragment_box (void *cls, const struct TransportFragmentBoxMessage *fb) |
5257 | { | 5310 | { |
5258 | uint16_t size = ntohs(fb->header.size); | 5311 | uint16_t size = ntohs (fb->header.size); |
5259 | uint16_t bsize = size - sizeof(*fb); | 5312 | uint16_t bsize = size - sizeof(*fb); |
5260 | 5313 | ||
5261 | (void)cls; | 5314 | (void) cls; |
5262 | if (0 == bsize) | 5315 | if (0 == bsize) |
5263 | { | 5316 | { |
5264 | GNUNET_break_op(0); | 5317 | GNUNET_break_op (0); |
5265 | return GNUNET_SYSERR; | 5318 | return GNUNET_SYSERR; |
5266 | } | 5319 | } |
5267 | if (bsize + ntohs(fb->frag_off) > ntohs(fb->msg_size)) | 5320 | if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) |
5268 | { | 5321 | { |
5269 | GNUNET_break_op(0); | 5322 | GNUNET_break_op (0); |
5270 | return GNUNET_SYSERR; | 5323 | return GNUNET_SYSERR; |
5271 | } | 5324 | } |
5272 | if (ntohs(fb->frag_off) >= ntohs(fb->msg_size)) | 5325 | if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) |
5273 | { | 5326 | { |
5274 | GNUNET_break_op(0); | 5327 | GNUNET_break_op (0); |
5275 | return GNUNET_SYSERR; | 5328 | return GNUNET_SYSERR; |
5276 | } | 5329 | } |
5277 | return GNUNET_YES; | 5330 | return GNUNET_YES; |
5278 | } | 5331 | } |
5279 | 5332 | ||
@@ -5284,16 +5337,16 @@ check_fragment_box(void *cls, const struct TransportFragmentBoxMessage *fb) | |||
5284 | * @param cls a `struct AcknowledgementCummulator *` | 5337 | * @param cls a `struct AcknowledgementCummulator *` |
5285 | */ | 5338 | */ |
5286 | static void | 5339 | static void |
5287 | destroy_ack_cummulator(void *cls) | 5340 | destroy_ack_cummulator (void *cls) |
5288 | { | 5341 | { |
5289 | struct AcknowledgementCummulator *ac = cls; | 5342 | struct AcknowledgementCummulator *ac = cls; |
5290 | 5343 | ||
5291 | ac->task = NULL; | 5344 | ac->task = NULL; |
5292 | GNUNET_assert(0 == ac->num_acks); | 5345 | GNUNET_assert (0 == ac->num_acks); |
5293 | GNUNET_assert( | 5346 | GNUNET_assert ( |
5294 | GNUNET_YES == | 5347 | GNUNET_YES == |
5295 | GNUNET_CONTAINER_multipeermap_remove(ack_cummulators, &ac->target, ac)); | 5348 | GNUNET_CONTAINER_multipeermap_remove (ack_cummulators, &ac->target, ac)); |
5296 | GNUNET_free(ac); | 5349 | GNUNET_free (ac); |
5297 | } | 5350 | } |
5298 | 5351 | ||
5299 | 5352 | ||
@@ -5303,39 +5356,39 @@ destroy_ack_cummulator(void *cls) | |||
5303 | * @param cls a `struct AcknowledgementCummulator *` | 5356 | * @param cls a `struct AcknowledgementCummulator *` |
5304 | */ | 5357 | */ |
5305 | static void | 5358 | static void |
5306 | transmit_cummulative_ack_cb(void *cls) | 5359 | transmit_cummulative_ack_cb (void *cls) |
5307 | { | 5360 | { |
5308 | struct AcknowledgementCummulator *ac = cls; | 5361 | struct AcknowledgementCummulator *ac = cls; |
5309 | char buf[sizeof(struct TransportReliabilityAckMessage) + | 5362 | char buf[sizeof(struct TransportReliabilityAckMessage) |
5310 | ac->ack_counter * | 5363 | + ac->ack_counter |
5311 | sizeof(struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN; | 5364 | * sizeof(struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN; |
5312 | struct TransportReliabilityAckMessage *ack = | 5365 | struct TransportReliabilityAckMessage *ack = |
5313 | (struct TransportReliabilityAckMessage *)buf; | 5366 | (struct TransportReliabilityAckMessage *) buf; |
5314 | struct TransportCummulativeAckPayloadP *ap; | 5367 | struct TransportCummulativeAckPayloadP *ap; |
5315 | 5368 | ||
5316 | ac->task = NULL; | 5369 | ac->task = NULL; |
5317 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5318 | "Sending ACK with %u components to %s\n", | 5371 | "Sending ACK with %u components to %s\n", |
5319 | ac->ack_counter, | 5372 | ac->ack_counter, |
5320 | GNUNET_i2s(&ac->target)); | 5373 | GNUNET_i2s (&ac->target)); |
5321 | GNUNET_assert(0 < ac->ack_counter); | 5374 | GNUNET_assert (0 < ac->ack_counter); |
5322 | ack->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); | 5375 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); |
5323 | ack->header.size = | 5376 | ack->header.size = |
5324 | htons(sizeof(*ack) + | 5377 | htons (sizeof(*ack) |
5325 | ac->ack_counter * sizeof(struct TransportCummulativeAckPayloadP)); | 5378 | + ac->ack_counter * sizeof(struct TransportCummulativeAckPayloadP)); |
5326 | ack->ack_counter = htonl(ac->ack_counter++); | 5379 | ack->ack_counter = htonl (ac->ack_counter++); |
5327 | ap = (struct TransportCummulativeAckPayloadP *)&ack[1]; | 5380 | ap = (struct TransportCummulativeAckPayloadP *) &ack[1]; |
5328 | for (unsigned int i = 0; i < ac->ack_counter; i++) | 5381 | for (unsigned int i = 0; i < ac->ack_counter; i++) |
5329 | { | 5382 | { |
5330 | ap[i].ack_uuid = ac->ack_uuids[i].ack_uuid; | 5383 | ap[i].ack_uuid = ac->ack_uuids[i].ack_uuid; |
5331 | ap[i].ack_delay = GNUNET_TIME_relative_hton( | 5384 | ap[i].ack_delay = GNUNET_TIME_relative_hton ( |
5332 | GNUNET_TIME_absolute_get_duration(ac->ack_uuids[i].receive_time)); | 5385 | GNUNET_TIME_absolute_get_duration (ac->ack_uuids[i].receive_time)); |
5333 | } | 5386 | } |
5334 | route_control_message_without_fc(&ac->target, &ack->header, RMO_DV_ALLOWED); | 5387 | route_control_message_without_fc (&ac->target, &ack->header, RMO_DV_ALLOWED); |
5335 | ac->num_acks = 0; | 5388 | ac->num_acks = 0; |
5336 | ac->task = GNUNET_SCHEDULER_add_delayed(ACK_CUMMULATOR_TIMEOUT, | 5389 | ac->task = GNUNET_SCHEDULER_add_delayed (ACK_CUMMULATOR_TIMEOUT, |
5337 | &destroy_ack_cummulator, | 5390 | &destroy_ack_cummulator, |
5338 | ac); | 5391 | ac); |
5339 | } | 5392 | } |
5340 | 5393 | ||
5341 | 5394 | ||
@@ -5348,55 +5401,56 @@ transmit_cummulative_ack_cb(void *cls) | |||
5348 | * @param max_delay how long can the ACK wait | 5401 | * @param max_delay how long can the ACK wait |
5349 | */ | 5402 | */ |
5350 | static void | 5403 | static void |
5351 | cummulative_ack(const struct GNUNET_PeerIdentity *pid, | 5404 | cummulative_ack (const struct GNUNET_PeerIdentity *pid, |
5352 | const struct AcknowledgementUUIDP *ack_uuid, | 5405 | const struct AcknowledgementUUIDP *ack_uuid, |
5353 | struct GNUNET_TIME_Absolute max_delay) | 5406 | struct GNUNET_TIME_Absolute max_delay) |
5354 | { | 5407 | { |
5355 | struct AcknowledgementCummulator *ac; | 5408 | struct AcknowledgementCummulator *ac; |
5356 | 5409 | ||
5357 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5358 | "Scheduling ACK %s for transmission to %s\n", | 5411 | "Scheduling ACK %s for transmission to %s\n", |
5359 | GNUNET_uuid2s(&ack_uuid->value), | 5412 | GNUNET_uuid2s (&ack_uuid->value), |
5360 | GNUNET_i2s(pid)); | 5413 | GNUNET_i2s (pid)); |
5361 | ac = GNUNET_CONTAINER_multipeermap_get(ack_cummulators, pid); | 5414 | ac = GNUNET_CONTAINER_multipeermap_get (ack_cummulators, pid); |
5362 | if (NULL == ac) | 5415 | if (NULL == ac) |
5363 | { | 5416 | { |
5364 | ac = GNUNET_new(struct AcknowledgementCummulator); | 5417 | ac = GNUNET_new (struct AcknowledgementCummulator); |
5365 | ac->target = *pid; | 5418 | ac->target = *pid; |
5366 | ac->min_transmission_time = max_delay; | 5419 | ac->min_transmission_time = max_delay; |
5367 | GNUNET_assert(GNUNET_YES == | 5420 | GNUNET_assert (GNUNET_YES == |
5368 | GNUNET_CONTAINER_multipeermap_put( | 5421 | GNUNET_CONTAINER_multipeermap_put ( |
5369 | ack_cummulators, | 5422 | ack_cummulators, |
5370 | &ac->target, | 5423 | &ac->target, |
5371 | ac, | 5424 | ac, |
5372 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 5425 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
5373 | } | 5426 | } |
5374 | else | 5427 | else |
5428 | { | ||
5429 | if (MAX_CUMMULATIVE_ACKS == ac->num_acks) | ||
5375 | { | 5430 | { |
5376 | if (MAX_CUMMULATIVE_ACKS == ac->num_acks) | 5431 | /* must run immediately, ack buffer full! */ |
5377 | { | 5432 | GNUNET_SCHEDULER_cancel (ac->task); |
5378 | /* must run immediately, ack buffer full! */ | 5433 | transmit_cummulative_ack_cb (ac); |
5379 | GNUNET_SCHEDULER_cancel(ac->task); | ||
5380 | transmit_cummulative_ack_cb(ac); | ||
5381 | } | ||
5382 | GNUNET_SCHEDULER_cancel(ac->task); | ||
5383 | ac->min_transmission_time = | ||
5384 | GNUNET_TIME_absolute_min(ac->min_transmission_time, max_delay); | ||
5385 | } | 5434 | } |
5386 | GNUNET_assert(ac->num_acks < MAX_CUMMULATIVE_ACKS); | 5435 | GNUNET_SCHEDULER_cancel (ac->task); |
5387 | ac->ack_uuids[ac->num_acks].receive_time = GNUNET_TIME_absolute_get(); | 5436 | ac->min_transmission_time = |
5437 | GNUNET_TIME_absolute_min (ac->min_transmission_time, max_delay); | ||
5438 | } | ||
5439 | GNUNET_assert (ac->num_acks < MAX_CUMMULATIVE_ACKS); | ||
5440 | ac->ack_uuids[ac->num_acks].receive_time = GNUNET_TIME_absolute_get (); | ||
5388 | ac->ack_uuids[ac->num_acks].ack_uuid = *ack_uuid; | 5441 | ac->ack_uuids[ac->num_acks].ack_uuid = *ack_uuid; |
5389 | ac->num_acks++; | 5442 | ac->num_acks++; |
5390 | ac->task = GNUNET_SCHEDULER_add_at(ac->min_transmission_time, | 5443 | ac->task = GNUNET_SCHEDULER_add_at (ac->min_transmission_time, |
5391 | &transmit_cummulative_ack_cb, | 5444 | &transmit_cummulative_ack_cb, |
5392 | ac); | 5445 | ac); |
5393 | } | 5446 | } |
5394 | 5447 | ||
5395 | 5448 | ||
5396 | /** | 5449 | /** |
5397 | * Closure for #find_by_message_uuid. | 5450 | * Closure for #find_by_message_uuid. |
5398 | */ | 5451 | */ |
5399 | struct FindByMessageUuidContext { | 5452 | struct FindByMessageUuidContext |
5453 | { | ||
5400 | /** | 5454 | /** |
5401 | * UUID to look for. | 5455 | * UUID to look for. |
5402 | */ | 5456 | */ |
@@ -5419,17 +5473,17 @@ struct FindByMessageUuidContext { | |||
5419 | * @return #GNUNET_YES if not found, #GNUNET_NO if found | 5473 | * @return #GNUNET_YES if not found, #GNUNET_NO if found |
5420 | */ | 5474 | */ |
5421 | static int | 5475 | static int |
5422 | find_by_message_uuid(void *cls, uint32_t key, void *value) | 5476 | find_by_message_uuid (void *cls, uint32_t key, void *value) |
5423 | { | 5477 | { |
5424 | struct FindByMessageUuidContext *fc = cls; | 5478 | struct FindByMessageUuidContext *fc = cls; |
5425 | struct ReassemblyContext *rc = value; | 5479 | struct ReassemblyContext *rc = value; |
5426 | 5480 | ||
5427 | (void)key; | 5481 | (void) key; |
5428 | if (0 == GNUNET_memcmp(&fc->message_uuid, &rc->msg_uuid)) | 5482 | if (0 == GNUNET_memcmp (&fc->message_uuid, &rc->msg_uuid)) |
5429 | { | 5483 | { |
5430 | fc->rc = rc; | 5484 | fc->rc = rc; |
5431 | return GNUNET_NO; | 5485 | return GNUNET_NO; |
5432 | } | 5486 | } |
5433 | return GNUNET_YES; | 5487 | return GNUNET_YES; |
5434 | } | 5488 | } |
5435 | 5489 | ||
@@ -5442,7 +5496,7 @@ find_by_message_uuid(void *cls, uint32_t key, void *value) | |||
5442 | * @param fb the message that was received | 5496 | * @param fb the message that was received |
5443 | */ | 5497 | */ |
5444 | static void | 5498 | static void |
5445 | handle_fragment_box(void *cls, const struct TransportFragmentBoxMessage *fb) | 5499 | handle_fragment_box (void *cls, const struct TransportFragmentBoxMessage *fb) |
5446 | { | 5500 | { |
5447 | struct CommunicatorMessageContext *cmc = cls; | 5501 | struct CommunicatorMessageContext *cmc = cls; |
5448 | struct Neighbour *n; | 5502 | struct Neighbour *n; |
@@ -5455,142 +5509,142 @@ handle_fragment_box(void *cls, const struct TransportFragmentBoxMessage *fb) | |||
5455 | struct GNUNET_TIME_Relative cdelay; | 5509 | struct GNUNET_TIME_Relative cdelay; |
5456 | struct FindByMessageUuidContext fc; | 5510 | struct FindByMessageUuidContext fc; |
5457 | 5511 | ||
5458 | n = lookup_neighbour(&cmc->im.sender); | 5512 | n = lookup_neighbour (&cmc->im.sender); |
5459 | if (NULL == n) | 5513 | if (NULL == n) |
5460 | { | 5514 | { |
5461 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; | 5515 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; |
5462 | 5516 | ||
5463 | GNUNET_break(0); | 5517 | GNUNET_break (0); |
5464 | finish_cmc_handling(cmc); | 5518 | finish_cmc_handling (cmc); |
5465 | GNUNET_SERVICE_client_drop(client); | 5519 | GNUNET_SERVICE_client_drop (client); |
5466 | return; | 5520 | return; |
5467 | } | 5521 | } |
5468 | if (NULL == n->reassembly_map) | 5522 | if (NULL == n->reassembly_map) |
5469 | { | 5523 | { |
5470 | n->reassembly_map = GNUNET_CONTAINER_multihashmap32_create(8); | 5524 | n->reassembly_map = GNUNET_CONTAINER_multihashmap32_create (8); |
5471 | n->reassembly_heap = | 5525 | n->reassembly_heap = |
5472 | GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); | 5526 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
5473 | n->reassembly_timeout_task = | 5527 | n->reassembly_timeout_task = |
5474 | GNUNET_SCHEDULER_add_delayed(REASSEMBLY_EXPIRATION, | 5528 | GNUNET_SCHEDULER_add_delayed (REASSEMBLY_EXPIRATION, |
5475 | &reassembly_cleanup_task, | 5529 | &reassembly_cleanup_task, |
5476 | n); | 5530 | n); |
5477 | } | 5531 | } |
5478 | msize = ntohs(fb->msg_size); | 5532 | msize = ntohs (fb->msg_size); |
5479 | fc.message_uuid = fb->msg_uuid; | 5533 | fc.message_uuid = fb->msg_uuid; |
5480 | fc.rc = NULL; | 5534 | fc.rc = NULL; |
5481 | (void)GNUNET_CONTAINER_multihashmap32_get_multiple(n->reassembly_map, | 5535 | (void) GNUNET_CONTAINER_multihashmap32_get_multiple (n->reassembly_map, |
5482 | fb->msg_uuid.uuid, | 5536 | fb->msg_uuid.uuid, |
5483 | &find_by_message_uuid, | 5537 | &find_by_message_uuid, |
5484 | &fc); | 5538 | &fc); |
5485 | if (NULL == (rc = fc.rc)) | 5539 | if (NULL == (rc = fc.rc)) |
5486 | { | 5540 | { |
5487 | rc = GNUNET_malloc(sizeof(*rc) + msize + /* reassembly payload buffer */ | 5541 | rc = GNUNET_malloc (sizeof(*rc) + msize /* reassembly payload buffer */ |
5488 | (msize + 7) / 8 * sizeof(uint8_t) /* bitfield */); | 5542 | + (msize + 7) / 8 * sizeof(uint8_t) /* bitfield */); |
5489 | rc->msg_uuid = fb->msg_uuid; | 5543 | rc->msg_uuid = fb->msg_uuid; |
5490 | rc->neighbour = n; | 5544 | rc->neighbour = n; |
5491 | rc->msg_size = msize; | 5545 | rc->msg_size = msize; |
5492 | rc->reassembly_timeout = | 5546 | rc->reassembly_timeout = |
5493 | GNUNET_TIME_relative_to_absolute(REASSEMBLY_EXPIRATION); | 5547 | GNUNET_TIME_relative_to_absolute (REASSEMBLY_EXPIRATION); |
5494 | rc->last_frag = GNUNET_TIME_absolute_get(); | 5548 | rc->last_frag = GNUNET_TIME_absolute_get (); |
5495 | rc->hn = GNUNET_CONTAINER_heap_insert(n->reassembly_heap, | 5549 | rc->hn = GNUNET_CONTAINER_heap_insert (n->reassembly_heap, |
5496 | rc, | 5550 | rc, |
5497 | rc->reassembly_timeout.abs_value_us); | 5551 | rc->reassembly_timeout.abs_value_us); |
5498 | GNUNET_assert(GNUNET_OK == | 5552 | GNUNET_assert (GNUNET_OK == |
5499 | GNUNET_CONTAINER_multihashmap32_put( | 5553 | GNUNET_CONTAINER_multihashmap32_put ( |
5500 | n->reassembly_map, | 5554 | n->reassembly_map, |
5501 | rc->msg_uuid.uuid, | 5555 | rc->msg_uuid.uuid, |
5502 | rc, | 5556 | rc, |
5503 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 5557 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
5504 | target = (char *)&rc[1]; | 5558 | target = (char *) &rc[1]; |
5505 | rc->bitfield = (uint8_t *)(target + rc->msg_size); | 5559 | rc->bitfield = (uint8_t *) (target + rc->msg_size); |
5506 | rc->msg_missing = rc->msg_size; | 5560 | rc->msg_missing = rc->msg_size; |
5507 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5508 | "Received fragment at offset %u/%u from %s for NEW message %u\n", | 5562 | "Received fragment at offset %u/%u from %s for NEW message %u\n", |
5509 | ntohs(fb->frag_off), | 5563 | ntohs (fb->frag_off), |
5510 | msize, | 5564 | msize, |
5511 | GNUNET_i2s(&cmc->im.sender), | 5565 | GNUNET_i2s (&cmc->im.sender), |
5512 | (unsigned int)fb->msg_uuid.uuid); | 5566 | (unsigned int) fb->msg_uuid.uuid); |
5513 | } | 5567 | } |
5514 | else | 5568 | else |
5515 | { | 5569 | { |
5516 | target = (char *)&rc[1]; | 5570 | target = (char *) &rc[1]; |
5517 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5571 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5518 | "Received fragment at offset %u/%u from %s for message %u\n", | 5572 | "Received fragment at offset %u/%u from %s for message %u\n", |
5519 | ntohs(fb->frag_off), | 5573 | ntohs (fb->frag_off), |
5520 | msize, | 5574 | msize, |
5521 | GNUNET_i2s(&cmc->im.sender), | 5575 | GNUNET_i2s (&cmc->im.sender), |
5522 | (unsigned int)fb->msg_uuid.uuid); | 5576 | (unsigned int) fb->msg_uuid.uuid); |
5523 | } | 5577 | } |
5524 | if (msize != rc->msg_size) | 5578 | if (msize != rc->msg_size) |
5525 | { | 5579 | { |
5526 | GNUNET_break(0); | 5580 | GNUNET_break (0); |
5527 | finish_cmc_handling(cmc); | 5581 | finish_cmc_handling (cmc); |
5528 | return; | 5582 | return; |
5529 | } | 5583 | } |
5530 | 5584 | ||
5531 | /* reassemble */ | 5585 | /* reassemble */ |
5532 | fsize = ntohs(fb->header.size) - sizeof(*fb); | 5586 | fsize = ntohs (fb->header.size) - sizeof(*fb); |
5533 | if (0 == fsize) | 5587 | if (0 == fsize) |
5534 | { | 5588 | { |
5535 | GNUNET_break(0); | 5589 | GNUNET_break (0); |
5536 | finish_cmc_handling(cmc); | 5590 | finish_cmc_handling (cmc); |
5537 | return; | 5591 | return; |
5538 | } | 5592 | } |
5539 | frag_off = ntohs(fb->frag_off); | 5593 | frag_off = ntohs (fb->frag_off); |
5540 | if (frag_off + fsize > msize) | 5594 | if (frag_off + fsize > msize) |
5541 | { | 5595 | { |
5542 | /* Fragment (plus fragment size) exceeds message size! */ | 5596 | /* Fragment (plus fragment size) exceeds message size! */ |
5543 | GNUNET_break_op(0); | 5597 | GNUNET_break_op (0); |
5544 | finish_cmc_handling(cmc); | 5598 | finish_cmc_handling (cmc); |
5545 | return; | 5599 | return; |
5546 | } | 5600 | } |
5547 | memcpy(&target[frag_off], &fb[1], fsize); | 5601 | memcpy (&target[frag_off], &fb[1], fsize); |
5548 | /* update bitfield and msg_missing */ | 5602 | /* update bitfield and msg_missing */ |
5549 | for (unsigned int i = frag_off; i < frag_off + fsize; i++) | 5603 | for (unsigned int i = frag_off; i < frag_off + fsize; i++) |
5604 | { | ||
5605 | if (0 == (rc->bitfield[i / 8] & (1 << (i % 8)))) | ||
5550 | { | 5606 | { |
5551 | if (0 == (rc->bitfield[i / 8] & (1 << (i % 8)))) | 5607 | rc->bitfield[i / 8] |= (1 << (i % 8)); |
5552 | { | 5608 | rc->msg_missing--; |
5553 | rc->bitfield[i / 8] |= (1 << (i % 8)); | ||
5554 | rc->msg_missing--; | ||
5555 | } | ||
5556 | } | 5609 | } |
5610 | } | ||
5557 | 5611 | ||
5558 | /* Compute cummulative ACK */ | 5612 | /* Compute cummulative ACK */ |
5559 | cdelay = GNUNET_TIME_absolute_get_duration(rc->last_frag); | 5613 | cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); |
5560 | cdelay = GNUNET_TIME_relative_multiply(cdelay, rc->msg_missing / fsize); | 5614 | cdelay = GNUNET_TIME_relative_multiply (cdelay, rc->msg_missing / fsize); |
5561 | if (0 == rc->msg_missing) | 5615 | if (0 == rc->msg_missing) |
5562 | cdelay = GNUNET_TIME_UNIT_ZERO; | 5616 | cdelay = GNUNET_TIME_UNIT_ZERO; |
5563 | cummulative_ack(&cmc->im.sender, | 5617 | cummulative_ack (&cmc->im.sender, |
5564 | &fb->ack_uuid, | 5618 | &fb->ack_uuid, |
5565 | GNUNET_TIME_relative_to_absolute(cdelay)); | 5619 | GNUNET_TIME_relative_to_absolute (cdelay)); |
5566 | rc->last_frag = GNUNET_TIME_absolute_get(); | 5620 | rc->last_frag = GNUNET_TIME_absolute_get (); |
5567 | /* is reassembly complete? */ | 5621 | /* is reassembly complete? */ |
5568 | if (0 != rc->msg_missing) | 5622 | if (0 != rc->msg_missing) |
5569 | { | 5623 | { |
5570 | finish_cmc_handling(cmc); | 5624 | finish_cmc_handling (cmc); |
5571 | return; | 5625 | return; |
5572 | } | 5626 | } |
5573 | /* reassembly is complete, verify result */ | 5627 | /* reassembly is complete, verify result */ |
5574 | msg = (const struct GNUNET_MessageHeader *)&rc[1]; | 5628 | msg = (const struct GNUNET_MessageHeader *) &rc[1]; |
5575 | if (ntohs(msg->size) != rc->msg_size) | 5629 | if (ntohs (msg->size) != rc->msg_size) |
5576 | { | 5630 | { |
5577 | GNUNET_break(0); | 5631 | GNUNET_break (0); |
5578 | free_reassembly_context(rc); | 5632 | free_reassembly_context (rc); |
5579 | finish_cmc_handling(cmc); | 5633 | finish_cmc_handling (cmc); |
5580 | return; | 5634 | return; |
5581 | } | 5635 | } |
5582 | /* successful reassembly */ | 5636 | /* successful reassembly */ |
5583 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5584 | "Fragment reassembly complete for message %u\n", | 5638 | "Fragment reassembly complete for message %u\n", |
5585 | (unsigned int)fb->msg_uuid.uuid); | 5639 | (unsigned int) fb->msg_uuid.uuid); |
5586 | /* FIXME: check that the resulting msg is NOT a | 5640 | /* FIXME: check that the resulting msg is NOT a |
5587 | DV Box or Reliability Box, as that is NOT allowed! */ | 5641 | DV Box or Reliability Box, as that is NOT allowed! */ |
5588 | demultiplex_with_cmc(cmc, msg); | 5642 | demultiplex_with_cmc (cmc, msg); |
5589 | /* FIXME-OPTIMIZE: really free here? Might be bad if fragments are still | 5643 | /* FIXME-OPTIMIZE: really free here? Might be bad if fragments are still |
5590 | en-route and we forget that we finished this reassembly immediately! | 5644 | en-route and we forget that we finished this reassembly immediately! |
5591 | -> keep around until timeout? | 5645 | -> keep around until timeout? |
5592 | -> shorten timeout based on ACK? */ | 5646 | -> shorten timeout based on ACK? */ |
5593 | free_reassembly_context(rc); | 5647 | free_reassembly_context (rc); |
5594 | } | 5648 | } |
5595 | 5649 | ||
5596 | 5650 | ||
@@ -5602,11 +5656,11 @@ handle_fragment_box(void *cls, const struct TransportFragmentBoxMessage *fb) | |||
5602 | * @return #GNUNET_YES if message is well-formed | 5656 | * @return #GNUNET_YES if message is well-formed |
5603 | */ | 5657 | */ |
5604 | static int | 5658 | static int |
5605 | check_reliability_box(void *cls, | 5659 | check_reliability_box (void *cls, |
5606 | const struct TransportReliabilityBoxMessage *rb) | 5660 | const struct TransportReliabilityBoxMessage *rb) |
5607 | { | 5661 | { |
5608 | (void)cls; | 5662 | (void) cls; |
5609 | GNUNET_MQ_check_boxed_message(rb); | 5663 | GNUNET_MQ_check_boxed_message (rb); |
5610 | return GNUNET_YES; | 5664 | return GNUNET_YES; |
5611 | } | 5665 | } |
5612 | 5666 | ||
@@ -5619,34 +5673,34 @@ check_reliability_box(void *cls, | |||
5619 | * @param rb the message that was received | 5673 | * @param rb the message that was received |
5620 | */ | 5674 | */ |
5621 | static void | 5675 | static void |
5622 | handle_reliability_box(void *cls, | 5676 | handle_reliability_box (void *cls, |
5623 | const struct TransportReliabilityBoxMessage *rb) | 5677 | const struct TransportReliabilityBoxMessage *rb) |
5624 | { | 5678 | { |
5625 | struct CommunicatorMessageContext *cmc = cls; | 5679 | struct CommunicatorMessageContext *cmc = cls; |
5626 | const struct GNUNET_MessageHeader *inbox = | 5680 | const struct GNUNET_MessageHeader *inbox = |
5627 | (const struct GNUNET_MessageHeader *)&rb[1]; | 5681 | (const struct GNUNET_MessageHeader *) &rb[1]; |
5628 | struct GNUNET_TIME_Relative rtt; | 5682 | struct GNUNET_TIME_Relative rtt; |
5629 | 5683 | ||
5630 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5684 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5631 | "Received reliability box from %s with UUID %s of type %u\n", | 5685 | "Received reliability box from %s with UUID %s of type %u\n", |
5632 | GNUNET_i2s(&cmc->im.sender), | 5686 | GNUNET_i2s (&cmc->im.sender), |
5633 | GNUNET_uuid2s(&rb->ack_uuid.value), | 5687 | GNUNET_uuid2s (&rb->ack_uuid.value), |
5634 | (unsigned int)ntohs(inbox->type)); | 5688 | (unsigned int) ntohs (inbox->type)); |
5635 | rtt = GNUNET_TIME_UNIT_SECONDS; /* FIXME: should base this on "RTT", but we | 5689 | rtt = GNUNET_TIME_UNIT_SECONDS; /* FIXME: should base this on "RTT", but we |
5636 | do not really have an RTT for the | 5690 | do not really have an RTT for the |
5637 | * incoming* queue (should we have | 5691 | * incoming* queue (should we have |
5638 | the sender add it to the rb message?) */ | 5692 | the sender add it to the rb message?) */ |
5639 | cummulative_ack( | 5693 | cummulative_ack ( |
5640 | &cmc->im.sender, | 5694 | &cmc->im.sender, |
5641 | &rb->ack_uuid, | 5695 | &rb->ack_uuid, |
5642 | (0 == ntohl(rb->ack_countdown)) | 5696 | (0 == ntohl (rb->ack_countdown)) |
5643 | ? GNUNET_TIME_UNIT_ZERO_ABS | 5697 | ? GNUNET_TIME_UNIT_ZERO_ABS |
5644 | : GNUNET_TIME_relative_to_absolute( | 5698 | : GNUNET_TIME_relative_to_absolute ( |
5645 | GNUNET_TIME_relative_divide(rtt, 8 /* FIXME: magic constant */))); | 5699 | GNUNET_TIME_relative_divide (rtt, 8 /* FIXME: magic constant */))); |
5646 | /* continue with inner message */ | 5700 | /* continue with inner message */ |
5647 | /* FIXME: check that inbox is NOT a DV Box, fragment or another | 5701 | /* FIXME: check that inbox is NOT a DV Box, fragment or another |
5648 | reliability box (not allowed!) */ | 5702 | reliability box (not allowed!) */ |
5649 | demultiplex_with_cmc(cmc, inbox); | 5703 | demultiplex_with_cmc (cmc, inbox); |
5650 | } | 5704 | } |
5651 | 5705 | ||
5652 | 5706 | ||
@@ -5659,20 +5713,20 @@ handle_reliability_box(void *cls, | |||
5659 | * @param age current age | 5713 | * @param age current age |
5660 | */ | 5714 | */ |
5661 | static void | 5715 | static void |
5662 | update_pd_age(struct PerformanceData *pd, unsigned int age) | 5716 | update_pd_age (struct PerformanceData *pd, unsigned int age) |
5663 | { | 5717 | { |
5664 | unsigned int sage; | 5718 | unsigned int sage; |
5665 | 5719 | ||
5666 | if (age == pd->last_age) | 5720 | if (age == pd->last_age) |
5667 | return; /* nothing to do */ | 5721 | return; /* nothing to do */ |
5668 | sage = GNUNET_MAX(pd->last_age, age - 2 * GOODPUT_AGING_SLOTS); | 5722 | sage = GNUNET_MAX (pd->last_age, age - 2 * GOODPUT_AGING_SLOTS); |
5669 | for (unsigned int i = sage; i <= age - GOODPUT_AGING_SLOTS; i++) | 5723 | for (unsigned int i = sage; i <= age - GOODPUT_AGING_SLOTS; i++) |
5670 | { | 5724 | { |
5671 | struct TransmissionHistoryEntry *the = &pd->the[i % GOODPUT_AGING_SLOTS]; | 5725 | struct TransmissionHistoryEntry *the = &pd->the[i % GOODPUT_AGING_SLOTS]; |
5672 | 5726 | ||
5673 | the->bytes_sent = 0; | 5727 | the->bytes_sent = 0; |
5674 | the->bytes_received = 0; | 5728 | the->bytes_received = 0; |
5675 | } | 5729 | } |
5676 | pd->last_age = age; | 5730 | pd->last_age = age; |
5677 | } | 5731 | } |
5678 | 5732 | ||
@@ -5686,20 +5740,20 @@ update_pd_age(struct PerformanceData *pd, unsigned int age) | |||
5686 | * @param bytes_transmitted_ok number of bytes receiver confirmed as received | 5740 | * @param bytes_transmitted_ok number of bytes receiver confirmed as received |
5687 | */ | 5741 | */ |
5688 | static void | 5742 | static void |
5689 | update_performance_data(struct PerformanceData *pd, | 5743 | update_performance_data (struct PerformanceData *pd, |
5690 | struct GNUNET_TIME_Relative rtt, | 5744 | struct GNUNET_TIME_Relative rtt, |
5691 | uint16_t bytes_transmitted_ok) | 5745 | uint16_t bytes_transmitted_ok) |
5692 | { | 5746 | { |
5693 | uint64_t nval = rtt.rel_value_us; | 5747 | uint64_t nval = rtt.rel_value_us; |
5694 | uint64_t oval = pd->aged_rtt.rel_value_us; | 5748 | uint64_t oval = pd->aged_rtt.rel_value_us; |
5695 | unsigned int age = get_age(); | 5749 | unsigned int age = get_age (); |
5696 | struct TransmissionHistoryEntry *the = &pd->the[age % GOODPUT_AGING_SLOTS]; | 5750 | struct TransmissionHistoryEntry *the = &pd->the[age % GOODPUT_AGING_SLOTS]; |
5697 | 5751 | ||
5698 | if (oval == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) | 5752 | if (oval == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) |
5699 | pd->aged_rtt = rtt; | 5753 | pd->aged_rtt = rtt; |
5700 | else | 5754 | else |
5701 | pd->aged_rtt.rel_value_us = (nval + 7 * oval) / 8; | 5755 | pd->aged_rtt.rel_value_us = (nval + 7 * oval) / 8; |
5702 | update_pd_age(pd, age); | 5756 | update_pd_age (pd, age); |
5703 | the->bytes_received += bytes_transmitted_ok; | 5757 | the->bytes_received += bytes_transmitted_ok; |
5704 | } | 5758 | } |
5705 | 5759 | ||
@@ -5712,11 +5766,11 @@ update_performance_data(struct PerformanceData *pd, | |||
5712 | * @param bytes_transmitted_ok number of bytes successfully transmitted | 5766 | * @param bytes_transmitted_ok number of bytes successfully transmitted |
5713 | */ | 5767 | */ |
5714 | static void | 5768 | static void |
5715 | update_queue_performance(struct Queue *q, | 5769 | update_queue_performance (struct Queue *q, |
5716 | struct GNUNET_TIME_Relative rtt, | 5770 | struct GNUNET_TIME_Relative rtt, |
5717 | uint16_t bytes_transmitted_ok) | 5771 | uint16_t bytes_transmitted_ok) |
5718 | { | 5772 | { |
5719 | update_performance_data(&q->pd, rtt, bytes_transmitted_ok); | 5773 | update_performance_data (&q->pd, rtt, bytes_transmitted_ok); |
5720 | } | 5774 | } |
5721 | 5775 | ||
5722 | 5776 | ||
@@ -5728,11 +5782,11 @@ update_queue_performance(struct Queue *q, | |||
5728 | * @param bytes_transmitted_ok number of bytes successfully transmitted | 5782 | * @param bytes_transmitted_ok number of bytes successfully transmitted |
5729 | */ | 5783 | */ |
5730 | static void | 5784 | static void |
5731 | update_dvh_performance(struct DistanceVectorHop *dvh, | 5785 | update_dvh_performance (struct DistanceVectorHop *dvh, |
5732 | struct GNUNET_TIME_Relative rtt, | 5786 | struct GNUNET_TIME_Relative rtt, |
5733 | uint16_t bytes_transmitted_ok) | 5787 | uint16_t bytes_transmitted_ok) |
5734 | { | 5788 | { |
5735 | update_performance_data(&dvh->pd, rtt, bytes_transmitted_ok); | 5789 | update_performance_data (&dvh->pd, rtt, bytes_transmitted_ok); |
5736 | } | 5790 | } |
5737 | 5791 | ||
5738 | 5792 | ||
@@ -5744,47 +5798,47 @@ update_dvh_performance(struct DistanceVectorHop *dvh, | |||
5744 | * @param pm pending message that was transmitted | 5798 | * @param pm pending message that was transmitted |
5745 | */ | 5799 | */ |
5746 | static void | 5800 | static void |
5747 | completed_pending_message(struct PendingMessage *pm) | 5801 | completed_pending_message (struct PendingMessage *pm) |
5748 | { | 5802 | { |
5749 | struct PendingMessage *pos; | 5803 | struct PendingMessage *pos; |
5750 | 5804 | ||
5751 | switch (pm->pmt) | 5805 | switch (pm->pmt) |
5752 | { | 5806 | { |
5753 | case PMT_CORE: | 5807 | case PMT_CORE: |
5754 | case PMT_RELIABILITY_BOX: | 5808 | case PMT_RELIABILITY_BOX: |
5755 | /* Full message sent, we are done */ | 5809 | /* Full message sent, we are done */ |
5756 | client_send_response(pm); | 5810 | client_send_response (pm); |
5757 | return; | 5811 | return; |
5758 | 5812 | ||
5759 | case PMT_FRAGMENT_BOX: | 5813 | case PMT_FRAGMENT_BOX: |
5760 | /* Fragment sent over reliabile channel */ | 5814 | /* Fragment sent over reliabile channel */ |
5761 | free_fragment_tree(pm); | 5815 | free_fragment_tree (pm); |
5816 | pos = pm->frag_parent; | ||
5817 | GNUNET_CONTAINER_MDLL_remove (frag, pos->head_frag, pos->tail_frag, pm); | ||
5818 | GNUNET_free (pm); | ||
5819 | /* check if subtree is done */ | ||
5820 | while ((NULL == pos->head_frag) && (pos->frag_off == pos->bytes_msg) && | ||
5821 | (pos != pm)) | ||
5822 | { | ||
5823 | pm = pos; | ||
5762 | pos = pm->frag_parent; | 5824 | pos = pm->frag_parent; |
5763 | GNUNET_CONTAINER_MDLL_remove(frag, pos->head_frag, pos->tail_frag, pm); | 5825 | GNUNET_CONTAINER_MDLL_remove (frag, pos->head_frag, pos->tail_frag, pm); |
5764 | GNUNET_free(pm); | 5826 | GNUNET_free (pm); |
5765 | /* check if subtree is done */ | 5827 | } |
5766 | while ((NULL == pos->head_frag) && (pos->frag_off == pos->bytes_msg) && | ||
5767 | (pos != pm)) | ||
5768 | { | ||
5769 | pm = pos; | ||
5770 | pos = pm->frag_parent; | ||
5771 | GNUNET_CONTAINER_MDLL_remove(frag, pos->head_frag, pos->tail_frag, pm); | ||
5772 | GNUNET_free(pm); | ||
5773 | } | ||
5774 | 5828 | ||
5775 | /* Was this the last applicable fragmment? */ | 5829 | /* Was this the last applicable fragmment? */ |
5776 | if ((NULL == pos->head_frag) && (NULL == pos->frag_parent) && | 5830 | if ((NULL == pos->head_frag) && (NULL == pos->frag_parent) && |
5777 | (pos->frag_off == pos->bytes_msg)) | 5831 | (pos->frag_off == pos->bytes_msg)) |
5778 | client_send_response(pos); | 5832 | client_send_response (pos); |
5779 | return; | 5833 | return; |
5780 | 5834 | ||
5781 | case PMT_DV_BOX: | 5835 | case PMT_DV_BOX: |
5782 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 5836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5783 | "Completed transmission of message %llu (DV Box)\n", | 5837 | "Completed transmission of message %llu (DV Box)\n", |
5784 | pm->logging_uuid); | 5838 | pm->logging_uuid); |
5785 | free_pending_message(pm); | 5839 | free_pending_message (pm); |
5786 | return; | 5840 | return; |
5787 | } | 5841 | } |
5788 | } | 5842 | } |
5789 | 5843 | ||
5790 | 5844 | ||
@@ -5796,23 +5850,23 @@ completed_pending_message(struct PendingMessage *pm) | |||
5796 | * other peer | 5850 | * other peer |
5797 | */ | 5851 | */ |
5798 | static void | 5852 | static void |
5799 | handle_acknowledged(struct PendingAcknowledgement *pa, | 5853 | handle_acknowledged (struct PendingAcknowledgement *pa, |
5800 | struct GNUNET_TIME_Relative ack_delay) | 5854 | struct GNUNET_TIME_Relative ack_delay) |
5801 | { | 5855 | { |
5802 | struct GNUNET_TIME_Relative delay; | 5856 | struct GNUNET_TIME_Relative delay; |
5803 | 5857 | ||
5804 | delay = GNUNET_TIME_absolute_get_duration(pa->transmission_time); | 5858 | delay = GNUNET_TIME_absolute_get_duration (pa->transmission_time); |
5805 | if (delay.rel_value_us > ack_delay.rel_value_us) | 5859 | if (delay.rel_value_us > ack_delay.rel_value_us) |
5806 | delay = GNUNET_TIME_UNIT_ZERO; | 5860 | delay = GNUNET_TIME_UNIT_ZERO; |
5807 | else | 5861 | else |
5808 | delay = GNUNET_TIME_relative_subtract(delay, ack_delay); | 5862 | delay = GNUNET_TIME_relative_subtract (delay, ack_delay); |
5809 | if (NULL != pa->queue) | 5863 | if (NULL != pa->queue) |
5810 | update_queue_performance(pa->queue, delay, pa->message_size); | 5864 | update_queue_performance (pa->queue, delay, pa->message_size); |
5811 | if (NULL != pa->dvh) | 5865 | if (NULL != pa->dvh) |
5812 | update_dvh_performance(pa->dvh, delay, pa->message_size); | 5866 | update_dvh_performance (pa->dvh, delay, pa->message_size); |
5813 | if (NULL != pa->pm) | 5867 | if (NULL != pa->pm) |
5814 | completed_pending_message(pa->pm); | 5868 | completed_pending_message (pa->pm); |
5815 | free_pending_acknowledgement(pa); | 5869 | free_pending_acknowledgement (pa); |
5816 | } | 5870 | } |
5817 | 5871 | ||
5818 | 5872 | ||
@@ -5824,25 +5878,25 @@ handle_acknowledged(struct PendingAcknowledgement *pa, | |||
5824 | * @return #GNUNET_Ok if @a ra is well-formed | 5878 | * @return #GNUNET_Ok if @a ra is well-formed |
5825 | */ | 5879 | */ |
5826 | static int | 5880 | static int |
5827 | check_reliability_ack(void *cls, | 5881 | check_reliability_ack (void *cls, |
5828 | const struct TransportReliabilityAckMessage *ra) | 5882 | const struct TransportReliabilityAckMessage *ra) |
5829 | { | 5883 | { |
5830 | unsigned int n_acks; | 5884 | unsigned int n_acks; |
5831 | 5885 | ||
5832 | (void)cls; | 5886 | (void) cls; |
5833 | n_acks = (ntohs(ra->header.size) - sizeof(*ra)) / | 5887 | n_acks = (ntohs (ra->header.size) - sizeof(*ra)) |
5834 | sizeof(struct TransportCummulativeAckPayloadP); | 5888 | / sizeof(struct TransportCummulativeAckPayloadP); |
5835 | if (0 == n_acks) | 5889 | if (0 == n_acks) |
5836 | { | 5890 | { |
5837 | GNUNET_break_op(0); | 5891 | GNUNET_break_op (0); |
5838 | return GNUNET_SYSERR; | 5892 | return GNUNET_SYSERR; |
5839 | } | 5893 | } |
5840 | if ((ntohs(ra->header.size) - sizeof(*ra)) != | 5894 | if ((ntohs (ra->header.size) - sizeof(*ra)) != |
5841 | n_acks * sizeof(struct TransportCummulativeAckPayloadP)) | 5895 | n_acks * sizeof(struct TransportCummulativeAckPayloadP)) |
5842 | { | 5896 | { |
5843 | GNUNET_break_op(0); | 5897 | GNUNET_break_op (0); |
5844 | return GNUNET_SYSERR; | 5898 | return GNUNET_SYSERR; |
5845 | } | 5899 | } |
5846 | return GNUNET_OK; | 5900 | return GNUNET_OK; |
5847 | } | 5901 | } |
5848 | 5902 | ||
@@ -5855,46 +5909,46 @@ check_reliability_ack(void *cls, | |||
5855 | * @param ra the message that was received | 5909 | * @param ra the message that was received |
5856 | */ | 5910 | */ |
5857 | static void | 5911 | static void |
5858 | handle_reliability_ack(void *cls, | 5912 | handle_reliability_ack (void *cls, |
5859 | const struct TransportReliabilityAckMessage *ra) | 5913 | const struct TransportReliabilityAckMessage *ra) |
5860 | { | 5914 | { |
5861 | struct CommunicatorMessageContext *cmc = cls; | 5915 | struct CommunicatorMessageContext *cmc = cls; |
5862 | const struct TransportCummulativeAckPayloadP *ack; | 5916 | const struct TransportCummulativeAckPayloadP *ack; |
5863 | unsigned int n_acks; | 5917 | unsigned int n_acks; |
5864 | uint32_t ack_counter; | 5918 | uint32_t ack_counter; |
5865 | 5919 | ||
5866 | n_acks = (ntohs(ra->header.size) - sizeof(*ra)) / | 5920 | n_acks = (ntohs (ra->header.size) - sizeof(*ra)) |
5867 | sizeof(struct TransportCummulativeAckPayloadP); | 5921 | / sizeof(struct TransportCummulativeAckPayloadP); |
5868 | ack = (const struct TransportCummulativeAckPayloadP *)&ra[1]; | 5922 | ack = (const struct TransportCummulativeAckPayloadP *) &ra[1]; |
5869 | for (unsigned int i = 0; i < n_acks; i++) | 5923 | for (unsigned int i = 0; i < n_acks; i++) |
5870 | { | 5924 | { |
5871 | struct PendingAcknowledgement *pa = | 5925 | struct PendingAcknowledgement *pa = |
5872 | GNUNET_CONTAINER_multiuuidmap_get(pending_acks, &ack[i].ack_uuid.value); | 5926 | GNUNET_CONTAINER_multiuuidmap_get (pending_acks, &ack[i].ack_uuid.value); |
5873 | if (NULL == pa) | 5927 | if (NULL == pa) |
5874 | { | 5928 | { |
5875 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 5929 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
5876 | "Received ACK from %s with UUID %s which is unknown to us!\n", | 5930 | "Received ACK from %s with UUID %s which is unknown to us!\n", |
5877 | GNUNET_i2s(&cmc->im.sender), | 5931 | GNUNET_i2s (&cmc->im.sender), |
5878 | GNUNET_uuid2s(&ack[i].ack_uuid.value)); | 5932 | GNUNET_uuid2s (&ack[i].ack_uuid.value)); |
5879 | GNUNET_STATISTICS_update( | 5933 | GNUNET_STATISTICS_update ( |
5880 | GST_stats, | 5934 | GST_stats, |
5881 | "# FRAGMENT_ACKS dropped, no matching pending message", | 5935 | "# FRAGMENT_ACKS dropped, no matching pending message", |
5882 | 1, | 5936 | 1, |
5883 | GNUNET_NO); | 5937 | GNUNET_NO); |
5884 | continue; | 5938 | continue; |
5885 | } | ||
5886 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
5887 | "Received ACK from %s with UUID %s\n", | ||
5888 | GNUNET_i2s(&cmc->im.sender), | ||
5889 | GNUNET_uuid2s(&ack[i].ack_uuid.value)); | ||
5890 | handle_acknowledged(pa, GNUNET_TIME_relative_ntoh(ack[i].ack_delay)); | ||
5891 | } | 5939 | } |
5940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
5941 | "Received ACK from %s with UUID %s\n", | ||
5942 | GNUNET_i2s (&cmc->im.sender), | ||
5943 | GNUNET_uuid2s (&ack[i].ack_uuid.value)); | ||
5944 | handle_acknowledged (pa, GNUNET_TIME_relative_ntoh (ack[i].ack_delay)); | ||
5945 | } | ||
5892 | 5946 | ||
5893 | ack_counter = htonl(ra->ack_counter); | 5947 | ack_counter = htonl (ra->ack_counter); |
5894 | (void)ack_counter; /* silence compiler warning for now */ | 5948 | (void) ack_counter; /* silence compiler warning for now */ |
5895 | // FIXME-OPTIMIZE: track ACK losses based on ack_counter somewhere! | 5949 | // FIXME-OPTIMIZE: track ACK losses based on ack_counter somewhere! |
5896 | // (DV and/or Neighbour?) | 5950 | // (DV and/or Neighbour?) |
5897 | finish_cmc_handling(cmc); | 5951 | finish_cmc_handling (cmc); |
5898 | } | 5952 | } |
5899 | 5953 | ||
5900 | 5954 | ||
@@ -5906,30 +5960,30 @@ handle_reliability_ack(void *cls, | |||
5906 | * @return #GNUNET_YES if message is well-formed | 5960 | * @return #GNUNET_YES if message is well-formed |
5907 | */ | 5961 | */ |
5908 | static int | 5962 | static int |
5909 | check_backchannel_encapsulation( | 5963 | check_backchannel_encapsulation ( |
5910 | void *cls, | 5964 | void *cls, |
5911 | const struct TransportBackchannelEncapsulationMessage *be) | 5965 | const struct TransportBackchannelEncapsulationMessage *be) |
5912 | { | 5966 | { |
5913 | uint16_t size = ntohs(be->header.size) - sizeof(*be); | 5967 | uint16_t size = ntohs (be->header.size) - sizeof(*be); |
5914 | const struct GNUNET_MessageHeader *inbox = | 5968 | const struct GNUNET_MessageHeader *inbox = |
5915 | (const struct GNUNET_MessageHeader *)&be[1]; | 5969 | (const struct GNUNET_MessageHeader *) &be[1]; |
5916 | const char *is; | 5970 | const char *is; |
5917 | uint16_t isize; | 5971 | uint16_t isize; |
5918 | 5972 | ||
5919 | (void)cls; | 5973 | (void) cls; |
5920 | if (ntohs(inbox->size) >= size) | 5974 | if (ntohs (inbox->size) >= size) |
5921 | { | 5975 | { |
5922 | GNUNET_break_op(0); | 5976 | GNUNET_break_op (0); |
5923 | return GNUNET_SYSERR; | 5977 | return GNUNET_SYSERR; |
5924 | } | 5978 | } |
5925 | isize = ntohs(inbox->size); | 5979 | isize = ntohs (inbox->size); |
5926 | is = ((const char *)inbox) + isize; | 5980 | is = ((const char *) inbox) + isize; |
5927 | size -= isize; | 5981 | size -= isize; |
5928 | if ('\0' != is[size - 1]) | 5982 | if ('\0' != is[size - 1]) |
5929 | { | 5983 | { |
5930 | GNUNET_break_op(0); | 5984 | GNUNET_break_op (0); |
5931 | return GNUNET_SYSERR; | 5985 | return GNUNET_SYSERR; |
5932 | } | 5986 | } |
5933 | return GNUNET_YES; | 5987 | return GNUNET_YES; |
5934 | } | 5988 | } |
5935 | 5989 | ||
@@ -5943,7 +5997,7 @@ check_backchannel_encapsulation( | |||
5943 | * @param be the message that was received | 5997 | * @param be the message that was received |
5944 | */ | 5998 | */ |
5945 | static void | 5999 | static void |
5946 | handle_backchannel_encapsulation( | 6000 | handle_backchannel_encapsulation ( |
5947 | void *cls, | 6001 | void *cls, |
5948 | const struct TransportBackchannelEncapsulationMessage *be) | 6002 | const struct TransportBackchannelEncapsulationMessage *be) |
5949 | { | 6003 | { |
@@ -5952,41 +6006,41 @@ handle_backchannel_encapsulation( | |||
5952 | struct GNUNET_MQ_Envelope *env; | 6006 | struct GNUNET_MQ_Envelope *env; |
5953 | struct TransportClient *tc; | 6007 | struct TransportClient *tc; |
5954 | const struct GNUNET_MessageHeader *inbox = | 6008 | const struct GNUNET_MessageHeader *inbox = |
5955 | (const struct GNUNET_MessageHeader *)&be[1]; | 6009 | (const struct GNUNET_MessageHeader *) &be[1]; |
5956 | uint16_t isize = ntohs(inbox->size); | 6010 | uint16_t isize = ntohs (inbox->size); |
5957 | const char *target_communicator = ((const char *)inbox) + isize; | 6011 | const char *target_communicator = ((const char *) inbox) + isize; |
5958 | 6012 | ||
5959 | /* Find client providing this communicator */ | 6013 | /* Find client providing this communicator */ |
5960 | for (tc = clients_head; NULL != tc; tc = tc->next) | 6014 | for (tc = clients_head; NULL != tc; tc = tc->next) |
5961 | if ((CT_COMMUNICATOR == tc->type) && | 6015 | if ((CT_COMMUNICATOR == tc->type) && |
5962 | (0 == | 6016 | (0 == |
5963 | strcmp(tc->details.communicator.address_prefix, target_communicator))) | 6017 | strcmp (tc->details.communicator.address_prefix, target_communicator))) |
5964 | break; | 6018 | break; |
5965 | if (NULL == tc) | 6019 | if (NULL == tc) |
5966 | { | 6020 | { |
5967 | char *stastr; | 6021 | char *stastr; |
5968 | 6022 | ||
5969 | GNUNET_asprintf( | 6023 | GNUNET_asprintf ( |
5970 | &stastr, | 6024 | &stastr, |
5971 | "# Backchannel message dropped: target communicator `%s' unknown", | 6025 | "# Backchannel message dropped: target communicator `%s' unknown", |
5972 | target_communicator); | 6026 | target_communicator); |
5973 | GNUNET_STATISTICS_update(GST_stats, stastr, 1, GNUNET_NO); | 6027 | GNUNET_STATISTICS_update (GST_stats, stastr, 1, GNUNET_NO); |
5974 | GNUNET_free(stastr); | 6028 | GNUNET_free (stastr); |
5975 | return; | 6029 | return; |
5976 | } | 6030 | } |
5977 | /* Finally, deliver backchannel message to communicator */ | 6031 | /* Finally, deliver backchannel message to communicator */ |
5978 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6032 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5979 | "Delivering backchannel message from %s of type %u to %s\n", | 6033 | "Delivering backchannel message from %s of type %u to %s\n", |
5980 | GNUNET_i2s(&cmc->im.sender), | 6034 | GNUNET_i2s (&cmc->im.sender), |
5981 | ntohs(inbox->type), | 6035 | ntohs (inbox->type), |
5982 | target_communicator); | 6036 | target_communicator); |
5983 | env = GNUNET_MQ_msg_extra( | 6037 | env = GNUNET_MQ_msg_extra ( |
5984 | cbi, | 6038 | cbi, |
5985 | isize, | 6039 | isize, |
5986 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING); | 6040 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING); |
5987 | cbi->pid = cmc->im.sender; | 6041 | cbi->pid = cmc->im.sender; |
5988 | memcpy(&cbi[1], inbox, isize); | 6042 | memcpy (&cbi[1], inbox, isize); |
5989 | GNUNET_MQ_send(tc->mq, env); | 6043 | GNUNET_MQ_send (tc->mq, env); |
5990 | } | 6044 | } |
5991 | 6045 | ||
5992 | 6046 | ||
@@ -6000,26 +6054,26 @@ handle_backchannel_encapsulation( | |||
6000 | * @param cls a `struct DistanceVector` | 6054 | * @param cls a `struct DistanceVector` |
6001 | */ | 6055 | */ |
6002 | static void | 6056 | static void |
6003 | path_cleanup_cb(void *cls) | 6057 | path_cleanup_cb (void *cls) |
6004 | { | 6058 | { |
6005 | struct DistanceVector *dv = cls; | 6059 | struct DistanceVector *dv = cls; |
6006 | struct DistanceVectorHop *pos; | 6060 | struct DistanceVectorHop *pos; |
6007 | 6061 | ||
6008 | dv->timeout_task = NULL; | 6062 | dv->timeout_task = NULL; |
6009 | while (NULL != (pos = dv->dv_head)) | 6063 | while (NULL != (pos = dv->dv_head)) |
6010 | { | 6064 | { |
6011 | GNUNET_assert(dv == pos->dv); | 6065 | GNUNET_assert (dv == pos->dv); |
6012 | if (GNUNET_TIME_absolute_get_remaining(pos->timeout).rel_value_us > 0) | 6066 | if (GNUNET_TIME_absolute_get_remaining (pos->timeout).rel_value_us > 0) |
6013 | break; | 6067 | break; |
6014 | free_distance_vector_hop(pos); | 6068 | free_distance_vector_hop (pos); |
6015 | } | 6069 | } |
6016 | if (NULL == pos) | 6070 | if (NULL == pos) |
6017 | { | 6071 | { |
6018 | free_dv_route(dv); | 6072 | free_dv_route (dv); |
6019 | return; | 6073 | return; |
6020 | } | 6074 | } |
6021 | dv->timeout_task = | 6075 | dv->timeout_task = |
6022 | GNUNET_SCHEDULER_add_at(pos->timeout, &path_cleanup_cb, dv); | 6076 | GNUNET_SCHEDULER_add_at (pos->timeout, &path_cleanup_cb, dv); |
6023 | } | 6077 | } |
6024 | 6078 | ||
6025 | 6079 | ||
@@ -6031,44 +6085,44 @@ path_cleanup_cb(void *cls) | |||
6031 | * @param hop a path to some peer that is the reason for activation | 6085 | * @param hop a path to some peer that is the reason for activation |
6032 | */ | 6086 | */ |
6033 | static void | 6087 | static void |
6034 | activate_core_visible_dv_path(struct DistanceVectorHop *hop) | 6088 | activate_core_visible_dv_path (struct DistanceVectorHop *hop) |
6035 | { | 6089 | { |
6036 | struct DistanceVector *dv = hop->dv; | 6090 | struct DistanceVector *dv = hop->dv; |
6037 | struct VirtualLink *vl; | 6091 | struct VirtualLink *vl; |
6038 | 6092 | ||
6039 | vl = lookup_virtual_link(&dv->target); | 6093 | vl = lookup_virtual_link (&dv->target); |
6040 | if (NULL != vl) | 6094 | if (NULL != vl) |
6041 | { | 6095 | { |
6042 | /* Link was already up, remember dv is also now available and we are done */ | 6096 | /* Link was already up, remember dv is also now available and we are done */ |
6043 | vl->dv = dv; | 6097 | vl->dv = dv; |
6044 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6098 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6045 | "Virtual link to %s could now also use DV!\n", | 6099 | "Virtual link to %s could now also use DV!\n", |
6046 | GNUNET_i2s(&dv->target)); | 6100 | GNUNET_i2s (&dv->target)); |
6047 | return; | 6101 | return; |
6048 | } | 6102 | } |
6049 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6050 | "Creating new virtual link to %s using DV!\n", | 6104 | "Creating new virtual link to %s using DV!\n", |
6051 | GNUNET_i2s(&dv->target)); | 6105 | GNUNET_i2s (&dv->target)); |
6052 | vl = GNUNET_new(struct VirtualLink); | 6106 | vl = GNUNET_new (struct VirtualLink); |
6053 | vl->message_uuid_ctr = | 6107 | vl->message_uuid_ctr = |
6054 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | 6108 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); |
6055 | vl->target = dv->target; | 6109 | vl->target = dv->target; |
6056 | vl->dv = dv; | 6110 | vl->dv = dv; |
6057 | dv->vl = vl; | 6111 | dv->vl = vl; |
6058 | vl->core_recv_window = RECV_WINDOW_SIZE; | 6112 | vl->core_recv_window = RECV_WINDOW_SIZE; |
6059 | vl->available_fc_window_size = DEFAULT_WINDOW_SIZE; | 6113 | vl->available_fc_window_size = DEFAULT_WINDOW_SIZE; |
6060 | vl->visibility_task = | 6114 | vl->visibility_task = |
6061 | GNUNET_SCHEDULER_add_at(hop->path_valid_until, &check_link_down, vl); | 6115 | GNUNET_SCHEDULER_add_at (hop->path_valid_until, &check_link_down, vl); |
6062 | GNUNET_break(GNUNET_YES == | 6116 | GNUNET_break (GNUNET_YES == |
6063 | GNUNET_CONTAINER_multipeermap_put( | 6117 | GNUNET_CONTAINER_multipeermap_put ( |
6064 | links, | 6118 | links, |
6065 | &vl->target, | 6119 | &vl->target, |
6066 | vl, | 6120 | vl, |
6067 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 6121 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
6068 | consider_sending_fc(vl); | 6122 | consider_sending_fc (vl); |
6069 | /* We lacked a confirmed connection to the target | 6123 | /* We lacked a confirmed connection to the target |
6070 | before, so tell CORE about it (finally!) */ | 6124 | before, so tell CORE about it (finally!) */ |
6071 | cores_send_connect_info(&dv->target); | 6125 | cores_send_connect_info (&dv->target); |
6072 | } | 6126 | } |
6073 | 6127 | ||
6074 | 6128 | ||
@@ -6098,10 +6152,10 @@ activate_core_visible_dv_path(struct DistanceVectorHop *hop) | |||
6098 | * or path[i+1] is a direct neighbour for i>0) | 6152 | * or path[i+1] is a direct neighbour for i>0) |
6099 | */ | 6153 | */ |
6100 | static int | 6154 | static int |
6101 | learn_dv_path(const struct GNUNET_PeerIdentity *path, | 6155 | learn_dv_path (const struct GNUNET_PeerIdentity *path, |
6102 | unsigned int path_len, | 6156 | unsigned int path_len, |
6103 | struct GNUNET_TIME_Relative network_latency, | 6157 | struct GNUNET_TIME_Relative network_latency, |
6104 | struct GNUNET_TIME_Absolute path_valid_until) | 6158 | struct GNUNET_TIME_Absolute path_valid_until) |
6105 | { | 6159 | { |
6106 | struct DistanceVectorHop *hop; | 6160 | struct DistanceVectorHop *hop; |
6107 | struct DistanceVector *dv; | 6161 | struct DistanceVector *dv; |
@@ -6109,143 +6163,143 @@ learn_dv_path(const struct GNUNET_PeerIdentity *path, | |||
6109 | unsigned int shorter_distance; | 6163 | unsigned int shorter_distance; |
6110 | 6164 | ||
6111 | if (path_len < 3) | 6165 | if (path_len < 3) |
6112 | { | 6166 | { |
6113 | /* what a boring path! not allowed! */ | 6167 | /* what a boring path! not allowed! */ |
6114 | GNUNET_break(0); | 6168 | GNUNET_break (0); |
6115 | return GNUNET_SYSERR; | 6169 | return GNUNET_SYSERR; |
6116 | } | 6170 | } |
6117 | GNUNET_assert(0 == GNUNET_memcmp(&GST_my_identity, &path[0])); | 6171 | GNUNET_assert (0 == GNUNET_memcmp (&GST_my_identity, &path[0])); |
6118 | next_hop = lookup_neighbour(&path[1]); | 6172 | next_hop = lookup_neighbour (&path[1]); |
6119 | if (NULL == next_hop) | 6173 | if (NULL == next_hop) |
6120 | { | 6174 | { |
6121 | /* next hop must be a neighbour, otherwise this whole thing is useless! */ | 6175 | /* next hop must be a neighbour, otherwise this whole thing is useless! */ |
6122 | GNUNET_break(0); | 6176 | GNUNET_break (0); |
6177 | return GNUNET_SYSERR; | ||
6178 | } | ||
6179 | for (unsigned int i = 2; i < path_len; i++) | ||
6180 | if (NULL != lookup_neighbour (&path[i])) | ||
6181 | { | ||
6182 | /* Useless path: we have a direct connection to some hop | ||
6183 | in the middle of the path, so this one is not even | ||
6184 | terribly useful for redundancy */ | ||
6185 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
6186 | "Path of %u hops useless: directly link to hop %u (%s)\n", | ||
6187 | path_len, | ||
6188 | i, | ||
6189 | GNUNET_i2s (&path[i])); | ||
6190 | GNUNET_STATISTICS_update (GST_stats, | ||
6191 | "# Useless DV path ignored: hop is neighbour", | ||
6192 | 1, | ||
6193 | GNUNET_NO); | ||
6123 | return GNUNET_SYSERR; | 6194 | return GNUNET_SYSERR; |
6124 | } | 6195 | } |
6125 | for (unsigned int i = 2; i < path_len; i++) | 6196 | dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &path[path_len - 1]); |
6126 | if (NULL != lookup_neighbour(&path[i])) | ||
6127 | { | ||
6128 | /* Useless path: we have a direct connection to some hop | ||
6129 | in the middle of the path, so this one is not even | ||
6130 | terribly useful for redundancy */ | ||
6131 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
6132 | "Path of %u hops useless: directly link to hop %u (%s)\n", | ||
6133 | path_len, | ||
6134 | i, | ||
6135 | GNUNET_i2s(&path[i])); | ||
6136 | GNUNET_STATISTICS_update(GST_stats, | ||
6137 | "# Useless DV path ignored: hop is neighbour", | ||
6138 | 1, | ||
6139 | GNUNET_NO); | ||
6140 | return GNUNET_SYSERR; | ||
6141 | } | ||
6142 | dv = GNUNET_CONTAINER_multipeermap_get(dv_routes, &path[path_len - 1]); | ||
6143 | if (NULL == dv) | 6197 | if (NULL == dv) |
6144 | { | 6198 | { |
6145 | dv = GNUNET_new(struct DistanceVector); | 6199 | dv = GNUNET_new (struct DistanceVector); |
6146 | dv->target = path[path_len - 1]; | 6200 | dv->target = path[path_len - 1]; |
6147 | dv->timeout_task = GNUNET_SCHEDULER_add_delayed(DV_PATH_VALIDITY_TIMEOUT, | 6201 | dv->timeout_task = GNUNET_SCHEDULER_add_delayed (DV_PATH_VALIDITY_TIMEOUT, |
6148 | &path_cleanup_cb, | 6202 | &path_cleanup_cb, |
6149 | dv); | 6203 | dv); |
6150 | GNUNET_assert(GNUNET_OK == | 6204 | GNUNET_assert (GNUNET_OK == |
6151 | GNUNET_CONTAINER_multipeermap_put( | 6205 | GNUNET_CONTAINER_multipeermap_put ( |
6152 | dv_routes, | 6206 | dv_routes, |
6153 | &dv->target, | 6207 | &dv->target, |
6154 | dv, | 6208 | dv, |
6155 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 6209 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
6156 | } | 6210 | } |
6157 | /* Check if we have this path already! */ | 6211 | /* Check if we have this path already! */ |
6158 | shorter_distance = 0; | 6212 | shorter_distance = 0; |
6159 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; | 6213 | for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; |
6160 | pos = pos->next_dv) | 6214 | pos = pos->next_dv) |
6215 | { | ||
6216 | if (pos->distance < path_len - 2) | ||
6217 | shorter_distance++; | ||
6218 | /* Note that the distances in 'pos' excludes us (path[0]) and | ||
6219 | the next_hop (path[1]), so we need to subtract two | ||
6220 | and check next_hop explicitly */ | ||
6221 | if ((pos->distance == path_len - 2) && (pos->next_hop == next_hop)) | ||
6161 | { | 6222 | { |
6162 | if (pos->distance < path_len - 2) | 6223 | int match = GNUNET_YES; |
6163 | shorter_distance++; | 6224 | |
6164 | /* Note that the distances in 'pos' excludes us (path[0]) and | 6225 | for (unsigned int i = 0; i < pos->distance; i++) |
6165 | the next_hop (path[1]), so we need to subtract two | 6226 | { |
6166 | and check next_hop explicitly */ | 6227 | if (0 != GNUNET_memcmp (&pos->path[i], &path[i + 2])) |
6167 | if ((pos->distance == path_len - 2) && (pos->next_hop == next_hop)) | 6228 | { |
6229 | match = GNUNET_NO; | ||
6230 | break; | ||
6231 | } | ||
6232 | } | ||
6233 | if (GNUNET_YES == match) | ||
6234 | { | ||
6235 | struct GNUNET_TIME_Relative last_timeout; | ||
6236 | |||
6237 | /* Re-discovered known path, update timeout */ | ||
6238 | GNUNET_STATISTICS_update (GST_stats, | ||
6239 | "# Known DV path refreshed", | ||
6240 | 1, | ||
6241 | GNUNET_NO); | ||
6242 | last_timeout = GNUNET_TIME_absolute_get_remaining (pos->timeout); | ||
6243 | pos->timeout = | ||
6244 | GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT); | ||
6245 | pos->path_valid_until = | ||
6246 | GNUNET_TIME_absolute_max (pos->path_valid_until, path_valid_until); | ||
6247 | GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, pos); | ||
6248 | GNUNET_CONTAINER_MDLL_insert (dv, dv->dv_head, dv->dv_tail, pos); | ||
6249 | if (0 < | ||
6250 | GNUNET_TIME_absolute_get_remaining (path_valid_until).rel_value_us) | ||
6251 | activate_core_visible_dv_path (pos); | ||
6252 | if (last_timeout.rel_value_us < | ||
6253 | GNUNET_TIME_relative_subtract (DV_PATH_VALIDITY_TIMEOUT, | ||
6254 | DV_PATH_DISCOVERY_FREQUENCY) | ||
6255 | .rel_value_us) | ||
6168 | { | 6256 | { |
6169 | int match = GNUNET_YES; | 6257 | /* Some peer send DV learn messages too often, we are learning |
6170 | 6258 | the same path faster than it would be useful; do not forward! */ | |
6171 | for (unsigned int i = 0; i < pos->distance; i++) | 6259 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
6172 | { | 6260 | "Rediscovered path too quickly, not forwarding further\n"); |
6173 | if (0 != GNUNET_memcmp(&pos->path[i], &path[i + 2])) | 6261 | return GNUNET_NO; |
6174 | { | ||
6175 | match = GNUNET_NO; | ||
6176 | break; | ||
6177 | } | ||
6178 | } | ||
6179 | if (GNUNET_YES == match) | ||
6180 | { | ||
6181 | struct GNUNET_TIME_Relative last_timeout; | ||
6182 | |||
6183 | /* Re-discovered known path, update timeout */ | ||
6184 | GNUNET_STATISTICS_update(GST_stats, | ||
6185 | "# Known DV path refreshed", | ||
6186 | 1, | ||
6187 | GNUNET_NO); | ||
6188 | last_timeout = GNUNET_TIME_absolute_get_remaining(pos->timeout); | ||
6189 | pos->timeout = | ||
6190 | GNUNET_TIME_relative_to_absolute(DV_PATH_VALIDITY_TIMEOUT); | ||
6191 | pos->path_valid_until = | ||
6192 | GNUNET_TIME_absolute_max(pos->path_valid_until, path_valid_until); | ||
6193 | GNUNET_CONTAINER_MDLL_remove(dv, dv->dv_head, dv->dv_tail, pos); | ||
6194 | GNUNET_CONTAINER_MDLL_insert(dv, dv->dv_head, dv->dv_tail, pos); | ||
6195 | if (0 < | ||
6196 | GNUNET_TIME_absolute_get_remaining(path_valid_until).rel_value_us) | ||
6197 | activate_core_visible_dv_path(pos); | ||
6198 | if (last_timeout.rel_value_us < | ||
6199 | GNUNET_TIME_relative_subtract(DV_PATH_VALIDITY_TIMEOUT, | ||
6200 | DV_PATH_DISCOVERY_FREQUENCY) | ||
6201 | .rel_value_us) | ||
6202 | { | ||
6203 | /* Some peer send DV learn messages too often, we are learning | ||
6204 | the same path faster than it would be useful; do not forward! */ | ||
6205 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
6206 | "Rediscovered path too quickly, not forwarding further\n"); | ||
6207 | return GNUNET_NO; | ||
6208 | } | ||
6209 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
6210 | "Refreshed known path to %s, forwarding further\n", | ||
6211 | GNUNET_i2s(&dv->target)); | ||
6212 | return GNUNET_YES; | ||
6213 | } | ||
6214 | } | 6262 | } |
6263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
6264 | "Refreshed known path to %s, forwarding further\n", | ||
6265 | GNUNET_i2s (&dv->target)); | ||
6266 | return GNUNET_YES; | ||
6267 | } | ||
6215 | } | 6268 | } |
6269 | } | ||
6216 | /* Count how many shorter paths we have (incl. direct | 6270 | /* Count how many shorter paths we have (incl. direct |
6217 | neighbours) before simply giving up on this one! */ | 6271 | neighbours) before simply giving up on this one! */ |
6218 | if (shorter_distance >= MAX_DV_PATHS_TO_TARGET) | 6272 | if (shorter_distance >= MAX_DV_PATHS_TO_TARGET) |
6219 | { | 6273 | { |
6220 | /* We have a shorter path already! */ | 6274 | /* We have a shorter path already! */ |
6221 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6275 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6222 | "Have many shorter DV paths %s, not forwarding further\n", | 6276 | "Have many shorter DV paths %s, not forwarding further\n", |
6223 | GNUNET_i2s(&dv->target)); | 6277 | GNUNET_i2s (&dv->target)); |
6224 | return GNUNET_NO; | 6278 | return GNUNET_NO; |
6225 | } | 6279 | } |
6226 | /* create new DV path entry */ | 6280 | /* create new DV path entry */ |
6227 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6228 | "Discovered new DV path to %s\n", | 6282 | "Discovered new DV path to %s\n", |
6229 | GNUNET_i2s(&dv->target)); | 6283 | GNUNET_i2s (&dv->target)); |
6230 | hop = GNUNET_malloc(sizeof(struct DistanceVectorHop) + | 6284 | hop = GNUNET_malloc (sizeof(struct DistanceVectorHop) |
6231 | sizeof(struct GNUNET_PeerIdentity) * (path_len - 2)); | 6285 | + sizeof(struct GNUNET_PeerIdentity) * (path_len - 2)); |
6232 | hop->next_hop = next_hop; | 6286 | hop->next_hop = next_hop; |
6233 | hop->dv = dv; | 6287 | hop->dv = dv; |
6234 | hop->path = (const struct GNUNET_PeerIdentity *)&hop[1]; | 6288 | hop->path = (const struct GNUNET_PeerIdentity *) &hop[1]; |
6235 | memcpy(&hop[1], | 6289 | memcpy (&hop[1], |
6236 | &path[2], | 6290 | &path[2], |
6237 | sizeof(struct GNUNET_PeerIdentity) * (path_len - 2)); | 6291 | sizeof(struct GNUNET_PeerIdentity) * (path_len - 2)); |
6238 | hop->timeout = GNUNET_TIME_relative_to_absolute(DV_PATH_VALIDITY_TIMEOUT); | 6292 | hop->timeout = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT); |
6239 | hop->path_valid_until = path_valid_until; | 6293 | hop->path_valid_until = path_valid_until; |
6240 | hop->distance = path_len - 2; | 6294 | hop->distance = path_len - 2; |
6241 | hop->pd.aged_rtt = network_latency; | 6295 | hop->pd.aged_rtt = network_latency; |
6242 | GNUNET_CONTAINER_MDLL_insert(dv, dv->dv_head, dv->dv_tail, hop); | 6296 | GNUNET_CONTAINER_MDLL_insert (dv, dv->dv_head, dv->dv_tail, hop); |
6243 | GNUNET_CONTAINER_MDLL_insert(neighbour, | 6297 | GNUNET_CONTAINER_MDLL_insert (neighbour, |
6244 | next_hop->dv_head, | 6298 | next_hop->dv_head, |
6245 | next_hop->dv_tail, | 6299 | next_hop->dv_tail, |
6246 | hop); | 6300 | hop); |
6247 | if (0 < GNUNET_TIME_absolute_get_remaining(path_valid_until).rel_value_us) | 6301 | if (0 < GNUNET_TIME_absolute_get_remaining (path_valid_until).rel_value_us) |
6248 | activate_core_visible_dv_path(hop); | 6302 | activate_core_visible_dv_path (hop); |
6249 | return GNUNET_YES; | 6303 | return GNUNET_YES; |
6250 | } | 6304 | } |
6251 | 6305 | ||
@@ -6258,36 +6312,36 @@ learn_dv_path(const struct GNUNET_PeerIdentity *path, | |||
6258 | * @return #GNUNET_YES if message is well-formed | 6312 | * @return #GNUNET_YES if message is well-formed |
6259 | */ | 6313 | */ |
6260 | static int | 6314 | static int |
6261 | check_dv_learn(void *cls, const struct TransportDVLearnMessage *dvl) | 6315 | check_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl) |
6262 | { | 6316 | { |
6263 | uint16_t size = ntohs(dvl->header.size); | 6317 | uint16_t size = ntohs (dvl->header.size); |
6264 | uint16_t num_hops = ntohs(dvl->num_hops); | 6318 | uint16_t num_hops = ntohs (dvl->num_hops); |
6265 | const struct DVPathEntryP *hops = (const struct DVPathEntryP *)&dvl[1]; | 6319 | const struct DVPathEntryP *hops = (const struct DVPathEntryP *) &dvl[1]; |
6266 | 6320 | ||
6267 | (void)cls; | 6321 | (void) cls; |
6268 | if (size != sizeof(*dvl) + num_hops * sizeof(struct DVPathEntryP)) | 6322 | if (size != sizeof(*dvl) + num_hops * sizeof(struct DVPathEntryP)) |
6269 | { | 6323 | { |
6270 | GNUNET_break_op(0); | 6324 | GNUNET_break_op (0); |
6271 | return GNUNET_SYSERR; | 6325 | return GNUNET_SYSERR; |
6272 | } | 6326 | } |
6273 | if (num_hops > MAX_DV_HOPS_ALLOWED) | 6327 | if (num_hops > MAX_DV_HOPS_ALLOWED) |
6328 | { | ||
6329 | GNUNET_break_op (0); | ||
6330 | return GNUNET_SYSERR; | ||
6331 | } | ||
6332 | for (unsigned int i = 0; i < num_hops; i++) | ||
6333 | { | ||
6334 | if (0 == GNUNET_memcmp (&dvl->initiator, &hops[i].hop)) | ||
6274 | { | 6335 | { |
6275 | GNUNET_break_op(0); | 6336 | GNUNET_break_op (0); |
6276 | return GNUNET_SYSERR; | 6337 | return GNUNET_SYSERR; |
6277 | } | 6338 | } |
6278 | for (unsigned int i = 0; i < num_hops; i++) | 6339 | if (0 == GNUNET_memcmp (&GST_my_identity, &hops[i].hop)) |
6279 | { | 6340 | { |
6280 | if (0 == GNUNET_memcmp(&dvl->initiator, &hops[i].hop)) | 6341 | GNUNET_break_op (0); |
6281 | { | 6342 | return GNUNET_SYSERR; |
6282 | GNUNET_break_op(0); | ||
6283 | return GNUNET_SYSERR; | ||
6284 | } | ||
6285 | if (0 == GNUNET_memcmp(&GST_my_identity, &hops[i].hop)) | ||
6286 | { | ||
6287 | GNUNET_break_op(0); | ||
6288 | return GNUNET_SYSERR; | ||
6289 | } | ||
6290 | } | 6343 | } |
6344 | } | ||
6291 | return GNUNET_YES; | 6345 | return GNUNET_YES; |
6292 | } | 6346 | } |
6293 | 6347 | ||
@@ -6304,56 +6358,56 @@ check_dv_learn(void *cls, const struct TransportDVLearnMessage *dvl) | |||
6304 | * delay | 6358 | * delay |
6305 | */ | 6359 | */ |
6306 | static void | 6360 | static void |
6307 | forward_dv_learn(const struct GNUNET_PeerIdentity *next_hop, | 6361 | forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop, |
6308 | const struct TransportDVLearnMessage *msg, | 6362 | const struct TransportDVLearnMessage *msg, |
6309 | uint16_t bi_history, | 6363 | uint16_t bi_history, |
6310 | uint16_t nhops, | 6364 | uint16_t nhops, |
6311 | const struct DVPathEntryP *hops, | 6365 | const struct DVPathEntryP *hops, |
6312 | struct GNUNET_TIME_Absolute in_time) | 6366 | struct GNUNET_TIME_Absolute in_time) |
6313 | { | 6367 | { |
6314 | struct DVPathEntryP *dhops; | 6368 | struct DVPathEntryP *dhops; |
6315 | char buf[sizeof(struct TransportDVLearnMessage) + | 6369 | char buf[sizeof(struct TransportDVLearnMessage) |
6316 | (nhops + 1) * sizeof(struct DVPathEntryP)] GNUNET_ALIGN; | 6370 | + (nhops + 1) * sizeof(struct DVPathEntryP)] GNUNET_ALIGN; |
6317 | struct TransportDVLearnMessage *fwd = (struct TransportDVLearnMessage *)buf; | 6371 | struct TransportDVLearnMessage *fwd = (struct TransportDVLearnMessage *) buf; |
6318 | struct GNUNET_TIME_Relative nnd; | 6372 | struct GNUNET_TIME_Relative nnd; |
6319 | 6373 | ||
6320 | /* compute message for forwarding */ | 6374 | /* compute message for forwarding */ |
6321 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6322 | "Forwarding DV learn message originating from %s to %s\n", | 6376 | "Forwarding DV learn message originating from %s to %s\n", |
6323 | GNUNET_i2s(&msg->initiator), | 6377 | GNUNET_i2s (&msg->initiator), |
6324 | GNUNET_i2s2(next_hop)); | 6378 | GNUNET_i2s2 (next_hop)); |
6325 | GNUNET_assert(nhops < MAX_DV_HOPS_ALLOWED); | 6379 | GNUNET_assert (nhops < MAX_DV_HOPS_ALLOWED); |
6326 | fwd->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN); | 6380 | fwd->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN); |
6327 | fwd->header.size = htons(sizeof(struct TransportDVLearnMessage) + | 6381 | fwd->header.size = htons (sizeof(struct TransportDVLearnMessage) |
6328 | (nhops + 1) * sizeof(struct DVPathEntryP)); | 6382 | + (nhops + 1) * sizeof(struct DVPathEntryP)); |
6329 | fwd->num_hops = htons(nhops + 1); | 6383 | fwd->num_hops = htons (nhops + 1); |
6330 | fwd->bidirectional = htons(bi_history); | 6384 | fwd->bidirectional = htons (bi_history); |
6331 | nnd = GNUNET_TIME_relative_add(GNUNET_TIME_absolute_get_duration(in_time), | 6385 | nnd = GNUNET_TIME_relative_add (GNUNET_TIME_absolute_get_duration (in_time), |
6332 | GNUNET_TIME_relative_ntoh( | 6386 | GNUNET_TIME_relative_ntoh ( |
6333 | msg->non_network_delay)); | 6387 | msg->non_network_delay)); |
6334 | fwd->non_network_delay = GNUNET_TIME_relative_hton(nnd); | 6388 | fwd->non_network_delay = GNUNET_TIME_relative_hton (nnd); |
6335 | fwd->init_sig = msg->init_sig; | 6389 | fwd->init_sig = msg->init_sig; |
6336 | fwd->initiator = msg->initiator; | 6390 | fwd->initiator = msg->initiator; |
6337 | fwd->challenge = msg->challenge; | 6391 | fwd->challenge = msg->challenge; |
6338 | dhops = (struct DVPathEntryP *)&fwd[1]; | 6392 | dhops = (struct DVPathEntryP *) &fwd[1]; |
6339 | GNUNET_memcpy(dhops, hops, sizeof(struct DVPathEntryP) * nhops); | 6393 | GNUNET_memcpy (dhops, hops, sizeof(struct DVPathEntryP) * nhops); |
6340 | dhops[nhops].hop = GST_my_identity; | 6394 | dhops[nhops].hop = GST_my_identity; |
6341 | { | 6395 | { |
6342 | struct DvHopPS dhp = { .purpose.purpose = | 6396 | struct DvHopPS dhp = { .purpose.purpose = |
6343 | htonl(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), | 6397 | htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), |
6344 | .purpose.size = htonl(sizeof(dhp)), | 6398 | .purpose.size = htonl (sizeof(dhp)), |
6345 | .pred = dhops[nhops - 1].hop, | 6399 | .pred = dhops[nhops - 1].hop, |
6346 | .succ = *next_hop, | 6400 | .succ = *next_hop, |
6347 | .challenge = msg->challenge }; | 6401 | .challenge = msg->challenge }; |
6348 | 6402 | ||
6349 | GNUNET_assert(GNUNET_OK == | 6403 | GNUNET_assert (GNUNET_OK == |
6350 | GNUNET_CRYPTO_eddsa_sign(GST_my_private_key, | 6404 | GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, |
6351 | &dhp.purpose, | 6405 | &dhp.purpose, |
6352 | &dhops[nhops].hop_sig)); | 6406 | &dhops[nhops].hop_sig)); |
6353 | } | 6407 | } |
6354 | route_control_message_without_fc(next_hop, | 6408 | route_control_message_without_fc (next_hop, |
6355 | &fwd->header, | 6409 | &fwd->header, |
6356 | RMO_UNCONFIRMED_ALLOWED); | 6410 | RMO_UNCONFIRMED_ALLOWED); |
6357 | } | 6411 | } |
6358 | 6412 | ||
6359 | 6413 | ||
@@ -6367,28 +6421,28 @@ forward_dv_learn(const struct GNUNET_PeerIdentity *next_hop, | |||
6367 | * @return #GNUNET_OK if the signature is valid | 6421 | * @return #GNUNET_OK if the signature is valid |
6368 | */ | 6422 | */ |
6369 | static int | 6423 | static int |
6370 | validate_dv_initiator_signature( | 6424 | validate_dv_initiator_signature ( |
6371 | struct GNUNET_TIME_AbsoluteNBO sender_monotonic_time, | 6425 | struct GNUNET_TIME_AbsoluteNBO sender_monotonic_time, |
6372 | const struct GNUNET_PeerIdentity *init, | 6426 | const struct GNUNET_PeerIdentity *init, |
6373 | const struct ChallengeNonceP *challenge, | 6427 | const struct ChallengeNonceP *challenge, |
6374 | const struct GNUNET_CRYPTO_EddsaSignature *init_sig) | 6428 | const struct GNUNET_CRYPTO_EddsaSignature *init_sig) |
6375 | { | 6429 | { |
6376 | struct DvInitPS ip = { .purpose.purpose = htonl( | 6430 | struct DvInitPS ip = { .purpose.purpose = htonl ( |
6377 | GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR), | 6431 | GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR), |
6378 | .purpose.size = htonl(sizeof(ip)), | 6432 | .purpose.size = htonl (sizeof(ip)), |
6379 | .monotonic_time = sender_monotonic_time, | 6433 | .monotonic_time = sender_monotonic_time, |
6380 | .challenge = *challenge }; | 6434 | .challenge = *challenge }; |
6381 | 6435 | ||
6382 | if ( | 6436 | if ( |
6383 | GNUNET_OK != | 6437 | GNUNET_OK != |
6384 | GNUNET_CRYPTO_eddsa_verify(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR, | 6438 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR, |
6385 | &ip.purpose, | 6439 | &ip.purpose, |
6386 | init_sig, | 6440 | init_sig, |
6387 | &init->public_key)) | 6441 | &init->public_key)) |
6388 | { | 6442 | { |
6389 | GNUNET_break_op(0); | 6443 | GNUNET_break_op (0); |
6390 | return GNUNET_SYSERR; | 6444 | return GNUNET_SYSERR; |
6391 | } | 6445 | } |
6392 | return GNUNET_OK; | 6446 | return GNUNET_OK; |
6393 | } | 6447 | } |
6394 | 6448 | ||
@@ -6396,7 +6450,8 @@ validate_dv_initiator_signature( | |||
6396 | /** | 6450 | /** |
6397 | * Closure for #dv_neighbour_selection and #dv_neighbour_transmission. | 6451 | * Closure for #dv_neighbour_selection and #dv_neighbour_transmission. |
6398 | */ | 6452 | */ |
6399 | struct NeighbourSelectionContext { | 6453 | struct NeighbourSelectionContext |
6454 | { | ||
6400 | /** | 6455 | /** |
6401 | * Original message we received. | 6456 | * Original message we received. |
6402 | */ | 6457 | */ |
@@ -6448,17 +6503,17 @@ struct NeighbourSelectionContext { | |||
6448 | * @return #GNUNET_YES (always) | 6503 | * @return #GNUNET_YES (always) |
6449 | */ | 6504 | */ |
6450 | static int | 6505 | static int |
6451 | dv_neighbour_selection(void *cls, | 6506 | dv_neighbour_selection (void *cls, |
6452 | const struct GNUNET_PeerIdentity *pid, | 6507 | const struct GNUNET_PeerIdentity *pid, |
6453 | void *value) | 6508 | void *value) |
6454 | { | 6509 | { |
6455 | struct NeighbourSelectionContext *nsc = cls; | 6510 | struct NeighbourSelectionContext *nsc = cls; |
6456 | 6511 | ||
6457 | (void)value; | 6512 | (void) value; |
6458 | if (0 == GNUNET_memcmp(pid, &nsc->dvl->initiator)) | 6513 | if (0 == GNUNET_memcmp (pid, &nsc->dvl->initiator)) |
6459 | return GNUNET_YES; /* skip initiator */ | 6514 | return GNUNET_YES; /* skip initiator */ |
6460 | for (unsigned int i = 0; i < nsc->nhops; i++) | 6515 | for (unsigned int i = 0; i < nsc->nhops; i++) |
6461 | if (0 == GNUNET_memcmp(pid, &nsc->hops[i].hop)) | 6516 | if (0 == GNUNET_memcmp (pid, &nsc->hops[i].hop)) |
6462 | return GNUNET_YES; | 6517 | return GNUNET_YES; |
6463 | /* skip peers on path */ | 6518 | /* skip peers on path */ |
6464 | nsc->num_eligible++; | 6519 | nsc->num_eligible++; |
@@ -6477,32 +6532,32 @@ dv_neighbour_selection(void *cls, | |||
6477 | * @return #GNUNET_YES (always) | 6532 | * @return #GNUNET_YES (always) |
6478 | */ | 6533 | */ |
6479 | static int | 6534 | static int |
6480 | dv_neighbour_transmission(void *cls, | 6535 | dv_neighbour_transmission (void *cls, |
6481 | const struct GNUNET_PeerIdentity *pid, | 6536 | const struct GNUNET_PeerIdentity *pid, |
6482 | void *value) | 6537 | void *value) |
6483 | { | 6538 | { |
6484 | struct NeighbourSelectionContext *nsc = cls; | 6539 | struct NeighbourSelectionContext *nsc = cls; |
6485 | 6540 | ||
6486 | (void)value; | 6541 | (void) value; |
6487 | if (0 == GNUNET_memcmp(pid, &nsc->dvl->initiator)) | 6542 | if (0 == GNUNET_memcmp (pid, &nsc->dvl->initiator)) |
6488 | return GNUNET_YES; /* skip initiator */ | 6543 | return GNUNET_YES; /* skip initiator */ |
6489 | for (unsigned int i = 0; i < nsc->nhops; i++) | 6544 | for (unsigned int i = 0; i < nsc->nhops; i++) |
6490 | if (0 == GNUNET_memcmp(pid, &nsc->hops[i].hop)) | 6545 | if (0 == GNUNET_memcmp (pid, &nsc->hops[i].hop)) |
6491 | return GNUNET_YES; | 6546 | return GNUNET_YES; |
6492 | /* skip peers on path */ | 6547 | /* skip peers on path */ |
6493 | for (unsigned int i = 0; i < nsc->num_selections; i++) | 6548 | for (unsigned int i = 0; i < nsc->num_selections; i++) |
6494 | { | 6549 | { |
6495 | if (nsc->selections[i] == nsc->num_eligible) | 6550 | if (nsc->selections[i] == nsc->num_eligible) |
6496 | { | 6551 | { |
6497 | forward_dv_learn(pid, | 6552 | forward_dv_learn (pid, |
6498 | nsc->dvl, | 6553 | nsc->dvl, |
6499 | nsc->bi_history, | 6554 | nsc->bi_history, |
6500 | nsc->nhops, | 6555 | nsc->nhops, |
6501 | nsc->hops, | 6556 | nsc->hops, |
6502 | nsc->in_time); | 6557 | nsc->in_time); |
6503 | break; | 6558 | break; |
6504 | } | ||
6505 | } | 6559 | } |
6560 | } | ||
6506 | nsc->num_eligible++; | 6561 | nsc->num_eligible++; |
6507 | return GNUNET_YES; | 6562 | return GNUNET_YES; |
6508 | } | 6563 | } |
@@ -6552,42 +6607,42 @@ dv_neighbour_transmission(void *cls, | |||
6552 | * theory forward to | 6607 | * theory forward to |
6553 | */ | 6608 | */ |
6554 | static unsigned int | 6609 | static unsigned int |
6555 | calculate_fork_degree(unsigned int hops_taken, | 6610 | calculate_fork_degree (unsigned int hops_taken, |
6556 | unsigned int neighbour_count, | 6611 | unsigned int neighbour_count, |
6557 | unsigned int eligible_count) | 6612 | unsigned int eligible_count) |
6558 | { | 6613 | { |
6559 | double target_total = 50.0; /* FIXME: use LOG(NSE)? */ | 6614 | double target_total = 50.0; /* FIXME: use LOG(NSE)? */ |
6560 | double eligible_ratio = | 6615 | double eligible_ratio = |
6561 | ((double)eligible_count) / ((double)neighbour_count); | 6616 | ((double) eligible_count) / ((double) neighbour_count); |
6562 | double boost_factor = eligible_ratio * eligible_ratio; | 6617 | double boost_factor = eligible_ratio * eligible_ratio; |
6563 | unsigned int rnd; | 6618 | unsigned int rnd; |
6564 | double left; | 6619 | double left; |
6565 | 6620 | ||
6566 | if (hops_taken >= 64) | 6621 | if (hops_taken >= 64) |
6567 | { | 6622 | { |
6568 | GNUNET_break(0); | 6623 | GNUNET_break (0); |
6569 | return 0; /* precaution given bitshift below */ | 6624 | return 0; /* precaution given bitshift below */ |
6570 | } | 6625 | } |
6571 | for (unsigned int i = 1; i < hops_taken; i++) | 6626 | for (unsigned int i = 1; i < hops_taken; i++) |
6572 | { | 6627 | { |
6573 | /* For each hop, subtract the expected number of targets | 6628 | /* For each hop, subtract the expected number of targets |
6574 | reached at distance d (so what remains divided by 2^d) */ | 6629 | reached at distance d (so what remains divided by 2^d) */ |
6575 | target_total -= (target_total * boost_factor / (1LLU << i)); | 6630 | target_total -= (target_total * boost_factor / (1LLU << i)); |
6576 | } | 6631 | } |
6577 | rnd = | 6632 | rnd = |
6578 | (unsigned int)floor(target_total * boost_factor / (1LLU << hops_taken)); | 6633 | (unsigned int) floor (target_total * boost_factor / (1LLU << hops_taken)); |
6579 | /* round up or down probabilistically depending on how close we were | 6634 | /* round up or down probabilistically depending on how close we were |
6580 | when floor()ing to rnd */ | 6635 | when floor()ing to rnd */ |
6581 | left = target_total - (double)rnd; | 6636 | left = target_total - (double) rnd; |
6582 | if (UINT32_MAX * left > | 6637 | if (UINT32_MAX * left > |
6583 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)) | 6638 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)) |
6584 | rnd++; /* round up */ | 6639 | rnd++; /* round up */ |
6585 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6640 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6586 | "Forwarding DV learn message of %u hops %u(/%u/%u) times\n", | 6641 | "Forwarding DV learn message of %u hops %u(/%u/%u) times\n", |
6587 | hops_taken, | 6642 | hops_taken, |
6588 | rnd, | 6643 | rnd, |
6589 | eligible_count, | 6644 | eligible_count, |
6590 | neighbour_count); | 6645 | neighbour_count); |
6591 | return rnd; | 6646 | return rnd; |
6592 | } | 6647 | } |
6593 | 6648 | ||
@@ -6599,14 +6654,14 @@ calculate_fork_degree(unsigned int hops_taken, | |||
6599 | * @param success #GNUNET_YES if peerstore was successful | 6654 | * @param success #GNUNET_YES if peerstore was successful |
6600 | */ | 6655 | */ |
6601 | static void | 6656 | static void |
6602 | neighbour_store_dvmono_cb(void *cls, int success) | 6657 | neighbour_store_dvmono_cb (void *cls, int success) |
6603 | { | 6658 | { |
6604 | struct Neighbour *n = cls; | 6659 | struct Neighbour *n = cls; |
6605 | 6660 | ||
6606 | n->sc = NULL; | 6661 | n->sc = NULL; |
6607 | if (GNUNET_YES != success) | 6662 | if (GNUNET_YES != success) |
6608 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 6663 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
6609 | "Failed to store other peer's monotonic time in peerstore!\n"); | 6664 | "Failed to store other peer's monotonic time in peerstore!\n"); |
6610 | } | 6665 | } |
6611 | 6666 | ||
6612 | 6667 | ||
@@ -6618,7 +6673,7 @@ neighbour_store_dvmono_cb(void *cls, int success) | |||
6618 | * @param dvl the message that was received | 6673 | * @param dvl the message that was received |
6619 | */ | 6674 | */ |
6620 | static void | 6675 | static void |
6621 | handle_dv_learn(void *cls, const struct TransportDVLearnMessage *dvl) | 6676 | handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl) |
6622 | { | 6677 | { |
6623 | struct CommunicatorMessageContext *cmc = cls; | 6678 | struct CommunicatorMessageContext *cmc = cls; |
6624 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc; | 6679 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc; |
@@ -6631,287 +6686,287 @@ handle_dv_learn(void *cls, const struct TransportDVLearnMessage *dvl) | |||
6631 | struct GNUNET_TIME_Absolute in_time; | 6686 | struct GNUNET_TIME_Absolute in_time; |
6632 | struct Neighbour *n; | 6687 | struct Neighbour *n; |
6633 | 6688 | ||
6634 | nhops = ntohs(dvl->bidirectional); /* 0 = sender is initiator */ | 6689 | nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */ |
6635 | bi_history = ntohs(dvl->bidirectional); | 6690 | bi_history = ntohs (dvl->bidirectional); |
6636 | hops = (const struct DVPathEntryP *)&dvl[1]; | 6691 | hops = (const struct DVPathEntryP *) &dvl[1]; |
6637 | if (0 == nhops) | 6692 | if (0 == nhops) |
6693 | { | ||
6694 | /* sanity check */ | ||
6695 | if (0 != GNUNET_memcmp (&dvl->initiator, &cmc->im.sender)) | ||
6638 | { | 6696 | { |
6639 | /* sanity check */ | 6697 | GNUNET_break (0); |
6640 | if (0 != GNUNET_memcmp(&dvl->initiator, &cmc->im.sender)) | 6698 | finish_cmc_handling (cmc); |
6641 | { | 6699 | return; |
6642 | GNUNET_break(0); | ||
6643 | finish_cmc_handling(cmc); | ||
6644 | return; | ||
6645 | } | ||
6646 | } | 6700 | } |
6701 | } | ||
6647 | else | 6702 | else |
6703 | { | ||
6704 | /* sanity check */ | ||
6705 | if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender)) | ||
6648 | { | 6706 | { |
6649 | /* sanity check */ | 6707 | GNUNET_break (0); |
6650 | if (0 != GNUNET_memcmp(&hops[nhops - 1].hop, &cmc->im.sender)) | 6708 | finish_cmc_handling (cmc); |
6651 | { | 6709 | return; |
6652 | GNUNET_break(0); | ||
6653 | finish_cmc_handling(cmc); | ||
6654 | return; | ||
6655 | } | ||
6656 | } | 6710 | } |
6711 | } | ||
6657 | 6712 | ||
6658 | GNUNET_assert(CT_COMMUNICATOR == cmc->tc->type); | 6713 | GNUNET_assert (CT_COMMUNICATOR == cmc->tc->type); |
6659 | cc = cmc->tc->details.communicator.cc; | 6714 | cc = cmc->tc->details.communicator.cc; |
6660 | bi_hop = (GNUNET_TRANSPORT_CC_RELIABLE == | 6715 | bi_hop = (GNUNET_TRANSPORT_CC_RELIABLE == |
6661 | cc); // FIXME: add bi-directional flag to cc? | 6716 | cc); // FIXME: add bi-directional flag to cc? |
6662 | in_time = GNUNET_TIME_absolute_get(); | 6717 | in_time = GNUNET_TIME_absolute_get (); |
6663 | 6718 | ||
6664 | /* continue communicator here, everything else can happen asynchronous! */ | 6719 | /* continue communicator here, everything else can happen asynchronous! */ |
6665 | finish_cmc_handling(cmc); | 6720 | finish_cmc_handling (cmc); |
6666 | 6721 | ||
6667 | n = lookup_neighbour(&dvl->initiator); | 6722 | n = lookup_neighbour (&dvl->initiator); |
6668 | if (NULL != n) | 6723 | if (NULL != n) |
6724 | { | ||
6725 | if ((n->dv_monotime_available == GNUNET_YES) && | ||
6726 | (GNUNET_TIME_absolute_ntoh (dvl->monotonic_time).abs_value_us < | ||
6727 | n->last_dv_learn_monotime.abs_value_us)) | ||
6728 | { | ||
6729 | GNUNET_STATISTICS_update (GST_stats, | ||
6730 | "# DV learn discarded due to time travel", | ||
6731 | 1, | ||
6732 | GNUNET_NO); | ||
6733 | return; | ||
6734 | } | ||
6735 | if (GNUNET_OK != validate_dv_initiator_signature (dvl->monotonic_time, | ||
6736 | &dvl->initiator, | ||
6737 | &dvl->challenge, | ||
6738 | &dvl->init_sig)) | ||
6669 | { | 6739 | { |
6670 | if ((n->dv_monotime_available == GNUNET_YES) && | 6740 | GNUNET_break_op (0); |
6671 | (GNUNET_TIME_absolute_ntoh(dvl->monotonic_time).abs_value_us < | 6741 | return; |
6672 | n->last_dv_learn_monotime.abs_value_us)) | 6742 | } |
6673 | { | 6743 | n->last_dv_learn_monotime = GNUNET_TIME_absolute_ntoh (dvl->monotonic_time); |
6674 | GNUNET_STATISTICS_update(GST_stats, | 6744 | if (GNUNET_YES == n->dv_monotime_available) |
6675 | "# DV learn discarded due to time travel", | 6745 | { |
6676 | 1, | 6746 | if (NULL != n->sc) |
6677 | GNUNET_NO); | 6747 | GNUNET_PEERSTORE_store_cancel (n->sc); |
6678 | return; | 6748 | n->sc = |
6679 | } | 6749 | GNUNET_PEERSTORE_store (peerstore, |
6680 | if (GNUNET_OK != validate_dv_initiator_signature(dvl->monotonic_time, | 6750 | "transport", |
6681 | &dvl->initiator, | 6751 | &dvl->initiator, |
6682 | &dvl->challenge, | 6752 | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME, |
6683 | &dvl->init_sig)) | 6753 | &dvl->monotonic_time, |
6684 | { | 6754 | sizeof(dvl->monotonic_time), |
6685 | GNUNET_break_op(0); | 6755 | GNUNET_TIME_UNIT_FOREVER_ABS, |
6686 | return; | 6756 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
6687 | } | 6757 | &neighbour_store_dvmono_cb, |
6688 | n->last_dv_learn_monotime = GNUNET_TIME_absolute_ntoh(dvl->monotonic_time); | 6758 | n); |
6689 | if (GNUNET_YES == n->dv_monotime_available) | ||
6690 | { | ||
6691 | if (NULL != n->sc) | ||
6692 | GNUNET_PEERSTORE_store_cancel(n->sc); | ||
6693 | n->sc = | ||
6694 | GNUNET_PEERSTORE_store(peerstore, | ||
6695 | "transport", | ||
6696 | &dvl->initiator, | ||
6697 | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME, | ||
6698 | &dvl->monotonic_time, | ||
6699 | sizeof(dvl->monotonic_time), | ||
6700 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
6701 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | ||
6702 | &neighbour_store_dvmono_cb, | ||
6703 | n); | ||
6704 | } | ||
6705 | } | 6759 | } |
6760 | } | ||
6706 | /* OPTIMIZE-FIXME: asynchronously (!) verify signatures!, | 6761 | /* OPTIMIZE-FIXME: asynchronously (!) verify signatures!, |
6707 | If signature verification load too high, implement random drop strategy */ | 6762 | If signature verification load too high, implement random drop strategy */ |
6708 | for (unsigned int i = 0; i < nhops; i++) | 6763 | for (unsigned int i = 0; i < nhops; i++) |
6709 | { | 6764 | { |
6710 | struct DvHopPS dhp = { .purpose.purpose = | 6765 | struct DvHopPS dhp = { .purpose.purpose = |
6711 | htonl(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), | 6766 | htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), |
6712 | .purpose.size = htonl(sizeof(dhp)), | 6767 | .purpose.size = htonl (sizeof(dhp)), |
6713 | .pred = (0 == i) ? dvl->initiator : hops[i - 1].hop, | 6768 | .pred = (0 == i) ? dvl->initiator : hops[i - 1].hop, |
6714 | .succ = (nhops == i + 1) ? GST_my_identity | 6769 | .succ = (nhops == i + 1) ? GST_my_identity |
6715 | : hops[i + 1].hop, | 6770 | : hops[i + 1].hop, |
6716 | .challenge = dvl->challenge }; | 6771 | .challenge = dvl->challenge }; |
6717 | 6772 | ||
6718 | if (GNUNET_OK != | 6773 | if (GNUNET_OK != |
6719 | GNUNET_CRYPTO_eddsa_verify(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP, | 6774 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP, |
6720 | &dhp.purpose, | 6775 | &dhp.purpose, |
6721 | &hops[i].hop_sig, | 6776 | &hops[i].hop_sig, |
6722 | &hops[i].hop.public_key)) | 6777 | &hops[i].hop.public_key)) |
6723 | { | 6778 | { |
6724 | GNUNET_break_op(0); | 6779 | GNUNET_break_op (0); |
6725 | return; | 6780 | return; |
6726 | } | ||
6727 | } | 6781 | } |
6782 | } | ||
6728 | 6783 | ||
6729 | if (GNUNET_EXTRA_LOGGING > 0) | 6784 | if (GNUNET_EXTRA_LOGGING > 0) |
6730 | { | 6785 | { |
6731 | char *path; | 6786 | char *path; |
6732 | 6787 | ||
6733 | path = GNUNET_strdup(GNUNET_i2s(&dvl->initiator)); | 6788 | path = GNUNET_strdup (GNUNET_i2s (&dvl->initiator)); |
6734 | for (unsigned int i = 0; i < nhops; i++) | 6789 | for (unsigned int i = 0; i < nhops; i++) |
6735 | { | 6790 | { |
6736 | char *tmp; | 6791 | char *tmp; |
6737 | 6792 | ||
6738 | GNUNET_asprintf(&tmp, | 6793 | GNUNET_asprintf (&tmp, |
6739 | "%s%s%s", | 6794 | "%s%s%s", |
6740 | path, | 6795 | path, |
6741 | (bi_history & (1 << (nhops - i))) ? "<->" : "-->", | 6796 | (bi_history & (1 << (nhops - i))) ? "<->" : "-->", |
6742 | GNUNET_i2s(&hops[i].hop)); | 6797 | GNUNET_i2s (&hops[i].hop)); |
6743 | GNUNET_free(path); | 6798 | GNUNET_free (path); |
6744 | path = tmp; | 6799 | path = tmp; |
6745 | } | 6800 | } |
6746 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6801 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6747 | "Received DVInit via %s%s%s\n", | 6802 | "Received DVInit via %s%s%s\n", |
6748 | path, | 6803 | path, |
6749 | bi_hop ? "<->" : "-->", | 6804 | bi_hop ? "<->" : "-->", |
6750 | GNUNET_i2s(&GST_my_identity)); | 6805 | GNUNET_i2s (&GST_my_identity)); |
6751 | GNUNET_free(path); | 6806 | GNUNET_free (path); |
6752 | } | 6807 | } |
6753 | 6808 | ||
6754 | do_fwd = GNUNET_YES; | 6809 | do_fwd = GNUNET_YES; |
6755 | if (0 == GNUNET_memcmp(&GST_my_identity, &dvl->initiator)) | 6810 | if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator)) |
6756 | { | 6811 | { |
6757 | struct GNUNET_PeerIdentity path[nhops + 1]; | 6812 | struct GNUNET_PeerIdentity path[nhops + 1]; |
6758 | struct GNUNET_TIME_Relative host_latency_sum; | 6813 | struct GNUNET_TIME_Relative host_latency_sum; |
6759 | struct GNUNET_TIME_Relative latency; | 6814 | struct GNUNET_TIME_Relative latency; |
6760 | struct GNUNET_TIME_Relative network_latency; | 6815 | struct GNUNET_TIME_Relative network_latency; |
6761 | 6816 | ||
6762 | /* We initiated this, learn the forward path! */ | 6817 | /* We initiated this, learn the forward path! */ |
6763 | path[0] = GST_my_identity; | 6818 | path[0] = GST_my_identity; |
6764 | path[1] = hops[0].hop; | 6819 | path[1] = hops[0].hop; |
6765 | host_latency_sum = GNUNET_TIME_relative_ntoh(dvl->non_network_delay); | 6820 | host_latency_sum = GNUNET_TIME_relative_ntoh (dvl->non_network_delay); |
6766 | 6821 | ||
6767 | // Need also something to lookup initiation time | 6822 | // Need also something to lookup initiation time |
6768 | // to compute RTT! -> add RTT argument here? | 6823 | // to compute RTT! -> add RTT argument here? |
6769 | latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly | 6824 | latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly |
6770 | // (based on dvl->challenge, we can identify time of origin!) | 6825 | // (based on dvl->challenge, we can identify time of origin!) |
6771 | 6826 | ||
6772 | network_latency = GNUNET_TIME_relative_subtract(latency, host_latency_sum); | 6827 | network_latency = GNUNET_TIME_relative_subtract (latency, host_latency_sum); |
6773 | /* assumption: latency on all links is the same */ | 6828 | /* assumption: latency on all links is the same */ |
6774 | network_latency = GNUNET_TIME_relative_divide(network_latency, nhops); | 6829 | network_latency = GNUNET_TIME_relative_divide (network_latency, nhops); |
6775 | 6830 | ||
6776 | for (unsigned int i = 2; i <= nhops; i++) | 6831 | for (unsigned int i = 2; i <= nhops; i++) |
6777 | { | 6832 | { |
6778 | struct GNUNET_TIME_Relative ilat; | 6833 | struct GNUNET_TIME_Relative ilat; |
6779 | 6834 | ||
6780 | /* assumption: linear latency increase per hop */ | 6835 | /* assumption: linear latency increase per hop */ |
6781 | ilat = GNUNET_TIME_relative_multiply(network_latency, i); | 6836 | ilat = GNUNET_TIME_relative_multiply (network_latency, i); |
6782 | path[i] = hops[i - 1].hop; | 6837 | path[i] = hops[i - 1].hop; |
6783 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6784 | "Learned path with %u hops to %s with latency %s\n", | 6839 | "Learned path with %u hops to %s with latency %s\n", |
6840 | i, | ||
6841 | GNUNET_i2s (&path[i]), | ||
6842 | GNUNET_STRINGS_relative_time_to_string (ilat, GNUNET_YES)); | ||
6843 | learn_dv_path (path, | ||
6785 | i, | 6844 | i, |
6786 | GNUNET_i2s(&path[i]), | 6845 | ilat, |
6787 | GNUNET_STRINGS_relative_time_to_string(ilat, GNUNET_YES)); | 6846 | GNUNET_TIME_relative_to_absolute ( |
6788 | learn_dv_path(path, | 6847 | ADDRESS_VALIDATION_LIFETIME)); |
6789 | i, | ||
6790 | ilat, | ||
6791 | GNUNET_TIME_relative_to_absolute( | ||
6792 | ADDRESS_VALIDATION_LIFETIME)); | ||
6793 | } | ||
6794 | /* as we initiated, do not forward again (would be circular!) */ | ||
6795 | do_fwd = GNUNET_NO; | ||
6796 | return; | ||
6797 | } | 6848 | } |
6849 | /* as we initiated, do not forward again (would be circular!) */ | ||
6850 | do_fwd = GNUNET_NO; | ||
6851 | return; | ||
6852 | } | ||
6798 | if (bi_hop) | 6853 | if (bi_hop) |
6854 | { | ||
6855 | /* last hop was bi-directional, we could learn something here! */ | ||
6856 | struct GNUNET_PeerIdentity path[nhops + 2]; | ||
6857 | |||
6858 | path[0] = GST_my_identity; | ||
6859 | path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */ | ||
6860 | for (unsigned int i = 0; i < nhops; i++) | ||
6799 | { | 6861 | { |
6800 | /* last hop was bi-directional, we could learn something here! */ | 6862 | int iret; |
6801 | struct GNUNET_PeerIdentity path[nhops + 2]; | ||
6802 | 6863 | ||
6803 | path[0] = GST_my_identity; | 6864 | if (0 == (bi_history & (1 << i))) |
6804 | path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */ | 6865 | break; /* i-th hop not bi-directional, stop learning! */ |
6805 | for (unsigned int i = 0; i < nhops; i++) | 6866 | if (i == nhops - 1) |
6806 | { | 6867 | { |
6807 | int iret; | 6868 | path[i + 2] = dvl->initiator; |
6808 | 6869 | } | |
6809 | if (0 == (bi_history & (1 << i))) | 6870 | else |
6810 | break; /* i-th hop not bi-directional, stop learning! */ | 6871 | { |
6811 | if (i == nhops - 1) | 6872 | path[i + 2] = hops[nhops - i - 2].hop; |
6812 | { | 6873 | } |
6813 | path[i + 2] = dvl->initiator; | 6874 | |
6814 | } | 6875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6815 | else | 6876 | "Learned inverse path with %u hops to %s\n", |
6816 | { | 6877 | i + 1, |
6817 | path[i + 2] = hops[nhops - i - 2].hop; | 6878 | GNUNET_i2s (&path[i + 2])); |
6818 | } | 6879 | iret = learn_dv_path (path, |
6819 | 6880 | i + 2, | |
6820 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6881 | GNUNET_TIME_UNIT_FOREVER_REL, |
6821 | "Learned inverse path with %u hops to %s\n", | 6882 | GNUNET_TIME_UNIT_ZERO_ABS); |
6822 | i + 1, | 6883 | if (GNUNET_SYSERR == iret) |
6823 | GNUNET_i2s(&path[i + 2])); | 6884 | { |
6824 | iret = learn_dv_path(path, | 6885 | /* path invalid or too long to be interesting for US, thus should also |
6825 | i + 2, | 6886 | not be interesting to our neighbours, cut path when forwarding to |
6826 | GNUNET_TIME_UNIT_FOREVER_REL, | 6887 | 'i' hops, except of course for the one that goes back to the |
6827 | GNUNET_TIME_UNIT_ZERO_ABS); | 6888 | initiator */ |
6828 | if (GNUNET_SYSERR == iret) | 6889 | GNUNET_STATISTICS_update (GST_stats, |
6829 | { | 6890 | "# DV learn not forwarded due invalidity of path", |
6830 | /* path invalid or too long to be interesting for US, thus should also | 6891 | 1, |
6831 | not be interesting to our neighbours, cut path when forwarding to | 6892 | GNUNET_NO); |
6832 | 'i' hops, except of course for the one that goes back to the | 6893 | do_fwd = GNUNET_NO; |
6833 | initiator */ | 6894 | break; |
6834 | GNUNET_STATISTICS_update(GST_stats, | 6895 | } |
6835 | "# DV learn not forwarded due invalidity of path", | 6896 | if ((GNUNET_NO == iret) && (nhops == i + 1)) |
6836 | 1, | 6897 | { |
6837 | GNUNET_NO); | 6898 | /* we have better paths, and this is the longest target, |
6838 | do_fwd = GNUNET_NO; | 6899 | so there cannot be anything interesting later */ |
6839 | break; | 6900 | GNUNET_STATISTICS_update (GST_stats, |
6840 | } | 6901 | "# DV learn not forwarded, got better paths", |
6841 | if ((GNUNET_NO == iret) && (nhops == i + 1)) | 6902 | 1, |
6842 | { | 6903 | GNUNET_NO); |
6843 | /* we have better paths, and this is the longest target, | 6904 | do_fwd = GNUNET_NO; |
6844 | so there cannot be anything interesting later */ | 6905 | break; |
6845 | GNUNET_STATISTICS_update(GST_stats, | 6906 | } |
6846 | "# DV learn not forwarded, got better paths", | ||
6847 | 1, | ||
6848 | GNUNET_NO); | ||
6849 | do_fwd = GNUNET_NO; | ||
6850 | break; | ||
6851 | } | ||
6852 | } | ||
6853 | } | 6907 | } |
6908 | } | ||
6854 | 6909 | ||
6855 | if (MAX_DV_HOPS_ALLOWED == nhops) | 6910 | if (MAX_DV_HOPS_ALLOWED == nhops) |
6856 | { | 6911 | { |
6857 | /* At limit, we're out of here! */ | 6912 | /* At limit, we're out of here! */ |
6858 | finish_cmc_handling(cmc); | 6913 | finish_cmc_handling (cmc); |
6859 | return; | 6914 | return; |
6860 | } | 6915 | } |
6861 | 6916 | ||
6862 | /* Forward to initiator, if path non-trivial and possible */ | 6917 | /* Forward to initiator, if path non-trivial and possible */ |
6863 | bi_history = (bi_history << 1) | (bi_hop ? 1 : 0); | 6918 | bi_history = (bi_history << 1) | (bi_hop ? 1 : 0); |
6864 | did_initiator = GNUNET_NO; | 6919 | did_initiator = GNUNET_NO; |
6865 | if ((1 < nhops) && | 6920 | if ((1 < nhops) && |
6866 | (GNUNET_YES == | 6921 | (GNUNET_YES == |
6867 | GNUNET_CONTAINER_multipeermap_contains(neighbours, &dvl->initiator))) | 6922 | GNUNET_CONTAINER_multipeermap_contains (neighbours, &dvl->initiator))) |
6868 | { | 6923 | { |
6869 | /* send back to origin! */ | 6924 | /* send back to origin! */ |
6870 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6925 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6871 | "Sending DVL back to initiator %s\n", | 6926 | "Sending DVL back to initiator %s\n", |
6872 | GNUNET_i2s(&dvl->initiator)); | 6927 | GNUNET_i2s (&dvl->initiator)); |
6873 | forward_dv_learn(&dvl->initiator, dvl, bi_history, nhops, hops, in_time); | 6928 | forward_dv_learn (&dvl->initiator, dvl, bi_history, nhops, hops, in_time); |
6874 | did_initiator = GNUNET_YES; | 6929 | did_initiator = GNUNET_YES; |
6875 | } | 6930 | } |
6876 | /* We forward under two conditions: either we still learned something | 6931 | /* We forward under two conditions: either we still learned something |
6877 | ourselves (do_fwd), or the path was darn short and thus the initiator is | 6932 | ourselves (do_fwd), or the path was darn short and thus the initiator is |
6878 | likely to still be very interested in this (and we did NOT already | 6933 | likely to still be very interested in this (and we did NOT already |
6879 | send it back to the initiator) */ | 6934 | send it back to the initiator) */ |
6880 | if ((do_fwd) || ((nhops < MIN_DV_PATH_LENGTH_FOR_INITIATOR) && | 6935 | if ((do_fwd) || ((nhops < MIN_DV_PATH_LENGTH_FOR_INITIATOR) && |
6881 | (GNUNET_NO == did_initiator))) | 6936 | (GNUNET_NO == did_initiator))) |
6882 | { | 6937 | { |
6883 | /* Pick random neighbours that are not yet on the path */ | 6938 | /* Pick random neighbours that are not yet on the path */ |
6884 | struct NeighbourSelectionContext nsc; | 6939 | struct NeighbourSelectionContext nsc; |
6885 | unsigned int n_cnt; | 6940 | unsigned int n_cnt; |
6886 | 6941 | ||
6887 | n_cnt = GNUNET_CONTAINER_multipeermap_size(neighbours); | 6942 | n_cnt = GNUNET_CONTAINER_multipeermap_size (neighbours); |
6888 | nsc.nhops = nhops; | 6943 | nsc.nhops = nhops; |
6889 | nsc.dvl = dvl; | 6944 | nsc.dvl = dvl; |
6890 | nsc.bi_history = bi_history; | 6945 | nsc.bi_history = bi_history; |
6891 | nsc.hops = hops; | 6946 | nsc.hops = hops; |
6892 | nsc.in_time = in_time; | 6947 | nsc.in_time = in_time; |
6893 | nsc.num_eligible = 0; | 6948 | nsc.num_eligible = 0; |
6894 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, | 6949 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
6895 | &dv_neighbour_selection, | 6950 | &dv_neighbour_selection, |
6896 | &nsc); | 6951 | &nsc); |
6897 | if (0 == nsc.num_eligible) | 6952 | if (0 == nsc.num_eligible) |
6898 | return; /* done here, cannot forward to anyone else */ | 6953 | return; /* done here, cannot forward to anyone else */ |
6899 | nsc.num_selections = calculate_fork_degree(nhops, n_cnt, nsc.num_eligible); | 6954 | nsc.num_selections = calculate_fork_degree (nhops, n_cnt, nsc.num_eligible); |
6900 | nsc.num_selections = | 6955 | nsc.num_selections = |
6901 | GNUNET_MIN(MAX_DV_DISCOVERY_SELECTION, nsc.num_selections); | 6956 | GNUNET_MIN (MAX_DV_DISCOVERY_SELECTION, nsc.num_selections); |
6902 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 6957 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6903 | "Forwarding DVL to %u other peers\n", | 6958 | "Forwarding DVL to %u other peers\n", |
6904 | nsc.num_selections); | 6959 | nsc.num_selections); |
6905 | for (unsigned int i = 0; i < nsc.num_selections; i++) | 6960 | for (unsigned int i = 0; i < nsc.num_selections; i++) |
6906 | nsc.selections[i] = | 6961 | nsc.selections[i] = |
6907 | (nsc.num_selections == n_cnt) | 6962 | (nsc.num_selections == n_cnt) |
6908 | ? i /* all were selected, avoid collisions by chance */ | 6963 | ? i /* all were selected, avoid collisions by chance */ |
6909 | : GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, n_cnt); | 6964 | : GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, n_cnt); |
6910 | nsc.num_eligible = 0; | 6965 | nsc.num_eligible = 0; |
6911 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, | 6966 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
6912 | &dv_neighbour_transmission, | 6967 | &dv_neighbour_transmission, |
6913 | &nsc); | 6968 | &nsc); |
6914 | } | 6969 | } |
6915 | } | 6970 | } |
6916 | 6971 | ||
6917 | 6972 | ||
@@ -6923,27 +6978,27 @@ handle_dv_learn(void *cls, const struct TransportDVLearnMessage *dvl) | |||
6923 | * @return #GNUNET_YES if message is well-formed | 6978 | * @return #GNUNET_YES if message is well-formed |
6924 | */ | 6979 | */ |
6925 | static int | 6980 | static int |
6926 | check_dv_box(void *cls, const struct TransportDVBoxMessage *dvb) | 6981 | check_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) |
6927 | { | 6982 | { |
6928 | uint16_t size = ntohs(dvb->header.size); | 6983 | uint16_t size = ntohs (dvb->header.size); |
6929 | uint16_t num_hops = ntohs(dvb->num_hops); | 6984 | uint16_t num_hops = ntohs (dvb->num_hops); |
6930 | const struct GNUNET_PeerIdentity *hops = | 6985 | const struct GNUNET_PeerIdentity *hops = |
6931 | (const struct GNUNET_PeerIdentity *)&dvb[1]; | 6986 | (const struct GNUNET_PeerIdentity *) &dvb[1]; |
6932 | 6987 | ||
6933 | (void)cls; | 6988 | (void) cls; |
6934 | if (size < sizeof(*dvb) + num_hops * sizeof(struct GNUNET_PeerIdentity) + | 6989 | if (size < sizeof(*dvb) + num_hops * sizeof(struct GNUNET_PeerIdentity) |
6935 | sizeof(struct GNUNET_MessageHeader)) | 6990 | + sizeof(struct GNUNET_MessageHeader)) |
6991 | { | ||
6992 | GNUNET_break_op (0); | ||
6993 | return GNUNET_SYSERR; | ||
6994 | } | ||
6995 | /* This peer must not be on the path */ | ||
6996 | for (unsigned int i = 0; i < num_hops; i++) | ||
6997 | if (0 == GNUNET_memcmp (&hops[i], &GST_my_identity)) | ||
6936 | { | 6998 | { |
6937 | GNUNET_break_op(0); | 6999 | GNUNET_break_op (0); |
6938 | return GNUNET_SYSERR; | 7000 | return GNUNET_SYSERR; |
6939 | } | 7001 | } |
6940 | /* This peer must not be on the path */ | ||
6941 | for (unsigned int i = 0; i < num_hops; i++) | ||
6942 | if (0 == GNUNET_memcmp(&hops[i], &GST_my_identity)) | ||
6943 | { | ||
6944 | GNUNET_break_op(0); | ||
6945 | return GNUNET_SYSERR; | ||
6946 | } | ||
6947 | return GNUNET_YES; | 7002 | return GNUNET_YES; |
6948 | } | 7003 | } |
6949 | 7004 | ||
@@ -6961,13 +7016,13 @@ check_dv_box(void *cls, const struct TransportDVBoxMessage *dvb) | |||
6961 | * @param payload_size number of bytes in @a payload | 7016 | * @param payload_size number of bytes in @a payload |
6962 | */ | 7017 | */ |
6963 | static void | 7018 | static void |
6964 | forward_dv_box(struct Neighbour *next_hop, | 7019 | forward_dv_box (struct Neighbour *next_hop, |
6965 | const struct TransportDVBoxMessage *hdr, | 7020 | const struct TransportDVBoxMessage *hdr, |
6966 | uint16_t total_hops, | 7021 | uint16_t total_hops, |
6967 | uint16_t num_hops, | 7022 | uint16_t num_hops, |
6968 | const struct GNUNET_PeerIdentity *hops, | 7023 | const struct GNUNET_PeerIdentity *hops, |
6969 | const void *enc_payload, | 7024 | const void *enc_payload, |
6970 | uint16_t enc_payload_size) | 7025 | uint16_t enc_payload_size) |
6971 | { | 7026 | { |
6972 | struct VirtualLink *vl = next_hop->vl; | 7027 | struct VirtualLink *vl = next_hop->vl; |
6973 | struct PendingMessage *pm; | 7028 | struct PendingMessage *pm; |
@@ -6975,33 +7030,33 @@ forward_dv_box(struct Neighbour *next_hop, | |||
6975 | char *buf; | 7030 | char *buf; |
6976 | struct GNUNET_PeerIdentity *dhops; | 7031 | struct GNUNET_PeerIdentity *dhops; |
6977 | 7032 | ||
6978 | GNUNET_assert(NULL != vl); | 7033 | GNUNET_assert (NULL != vl); |
6979 | msg_size = sizeof(struct TransportDVBoxMessage) + | 7034 | msg_size = sizeof(struct TransportDVBoxMessage) |
6980 | num_hops * sizeof(struct GNUNET_PeerIdentity) + enc_payload_size; | 7035 | + num_hops * sizeof(struct GNUNET_PeerIdentity) + enc_payload_size; |
6981 | pm = GNUNET_malloc(sizeof(struct PendingMessage) + msg_size); | 7036 | pm = GNUNET_malloc (sizeof(struct PendingMessage) + msg_size); |
6982 | pm->pmt = PMT_DV_BOX; | 7037 | pm->pmt = PMT_DV_BOX; |
6983 | pm->vl = vl; | 7038 | pm->vl = vl; |
6984 | pm->timeout = GNUNET_TIME_relative_to_absolute(DV_FORWARD_TIMEOUT); | 7039 | pm->timeout = GNUNET_TIME_relative_to_absolute (DV_FORWARD_TIMEOUT); |
6985 | pm->logging_uuid = logging_uuid_gen++; | 7040 | pm->logging_uuid = logging_uuid_gen++; |
6986 | pm->prefs = GNUNET_MQ_PRIO_BACKGROUND; | 7041 | pm->prefs = GNUNET_MQ_PRIO_BACKGROUND; |
6987 | pm->bytes_msg = msg_size; | 7042 | pm->bytes_msg = msg_size; |
6988 | buf = (char *)&pm[1]; | 7043 | buf = (char *) &pm[1]; |
6989 | memcpy(buf, hdr, sizeof(*hdr)); | 7044 | memcpy (buf, hdr, sizeof(*hdr)); |
6990 | dhops = | 7045 | dhops = |
6991 | (struct GNUNET_PeerIdentity *)&buf[sizeof(struct TransportDVBoxMessage)]; | 7046 | (struct GNUNET_PeerIdentity *) &buf[sizeof(struct TransportDVBoxMessage)]; |
6992 | memcpy(dhops, hops, num_hops * sizeof(struct GNUNET_PeerIdentity)); | 7047 | memcpy (dhops, hops, num_hops * sizeof(struct GNUNET_PeerIdentity)); |
6993 | memcpy(&dhops[num_hops], enc_payload, enc_payload_size); | 7048 | memcpy (&dhops[num_hops], enc_payload, enc_payload_size); |
6994 | GNUNET_CONTAINER_MDLL_insert(vl, | 7049 | GNUNET_CONTAINER_MDLL_insert (vl, |
6995 | vl->pending_msg_head, | 7050 | vl->pending_msg_head, |
6996 | vl->pending_msg_tail, | 7051 | vl->pending_msg_tail, |
6997 | pm); | 7052 | pm); |
6998 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7053 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6999 | "Created pending message %llu for DV Box with next hop %s (%u/%u)\n", | 7054 | "Created pending message %llu for DV Box with next hop %s (%u/%u)\n", |
7000 | pm->logging_uuid, | 7055 | pm->logging_uuid, |
7001 | GNUNET_i2s(&next_hop->pid), | 7056 | GNUNET_i2s (&next_hop->pid), |
7002 | (unsigned int)num_hops, | 7057 | (unsigned int) num_hops, |
7003 | (unsigned int)total_hops); | 7058 | (unsigned int) total_hops); |
7004 | check_vl_transmission(vl); | 7059 | check_vl_transmission (vl); |
7005 | } | 7060 | } |
7006 | 7061 | ||
7007 | 7062 | ||
@@ -7011,30 +7066,30 @@ forward_dv_box(struct Neighbour *next_hop, | |||
7011 | * @param b data structure to release | 7066 | * @param b data structure to release |
7012 | */ | 7067 | */ |
7013 | static void | 7068 | static void |
7014 | free_backtalker(struct Backtalker *b) | 7069 | free_backtalker (struct Backtalker *b) |
7015 | { | 7070 | { |
7016 | if (NULL != b->get) | 7071 | if (NULL != b->get) |
7017 | { | 7072 | { |
7018 | GNUNET_PEERSTORE_iterate_cancel(b->get); | 7073 | GNUNET_PEERSTORE_iterate_cancel (b->get); |
7019 | b->get = NULL; | 7074 | b->get = NULL; |
7020 | GNUNET_assert(NULL != b->cmc); | 7075 | GNUNET_assert (NULL != b->cmc); |
7021 | finish_cmc_handling(b->cmc); | 7076 | finish_cmc_handling (b->cmc); |
7022 | b->cmc = NULL; | 7077 | b->cmc = NULL; |
7023 | } | 7078 | } |
7024 | if (NULL != b->task) | 7079 | if (NULL != b->task) |
7025 | { | 7080 | { |
7026 | GNUNET_SCHEDULER_cancel(b->task); | 7081 | GNUNET_SCHEDULER_cancel (b->task); |
7027 | b->task = NULL; | 7082 | b->task = NULL; |
7028 | } | 7083 | } |
7029 | if (NULL != b->sc) | 7084 | if (NULL != b->sc) |
7030 | { | 7085 | { |
7031 | GNUNET_PEERSTORE_store_cancel(b->sc); | 7086 | GNUNET_PEERSTORE_store_cancel (b->sc); |
7032 | b->sc = NULL; | 7087 | b->sc = NULL; |
7033 | } | 7088 | } |
7034 | GNUNET_assert( | 7089 | GNUNET_assert ( |
7035 | GNUNET_YES == | 7090 | GNUNET_YES == |
7036 | GNUNET_CONTAINER_multipeermap_remove(backtalkers, &b->pid, b)); | 7091 | GNUNET_CONTAINER_multipeermap_remove (backtalkers, &b->pid, b)); |
7037 | GNUNET_free(b); | 7092 | GNUNET_free (b); |
7038 | } | 7093 | } |
7039 | 7094 | ||
7040 | 7095 | ||
@@ -7047,15 +7102,15 @@ free_backtalker(struct Backtalker *b) | |||
7047 | * @return #GNUNET_OK (always) | 7102 | * @return #GNUNET_OK (always) |
7048 | */ | 7103 | */ |
7049 | static int | 7104 | static int |
7050 | free_backtalker_cb(void *cls, | 7105 | free_backtalker_cb (void *cls, |
7051 | const struct GNUNET_PeerIdentity *pid, | 7106 | const struct GNUNET_PeerIdentity *pid, |
7052 | void *value) | 7107 | void *value) |
7053 | { | 7108 | { |
7054 | struct Backtalker *b = value; | 7109 | struct Backtalker *b = value; |
7055 | 7110 | ||
7056 | (void)cls; | 7111 | (void) cls; |
7057 | (void)pid; | 7112 | (void) pid; |
7058 | free_backtalker(b); | 7113 | free_backtalker (b); |
7059 | return GNUNET_OK; | 7114 | return GNUNET_OK; |
7060 | } | 7115 | } |
7061 | 7116 | ||
@@ -7066,18 +7121,18 @@ free_backtalker_cb(void *cls, | |||
7066 | * @param cls a `struct Backtalker` | 7121 | * @param cls a `struct Backtalker` |
7067 | */ | 7122 | */ |
7068 | static void | 7123 | static void |
7069 | backtalker_timeout_cb(void *cls) | 7124 | backtalker_timeout_cb (void *cls) |
7070 | { | 7125 | { |
7071 | struct Backtalker *b = cls; | 7126 | struct Backtalker *b = cls; |
7072 | 7127 | ||
7073 | b->task = NULL; | 7128 | b->task = NULL; |
7074 | if (0 != GNUNET_TIME_absolute_get_remaining(b->timeout).rel_value_us) | 7129 | if (0 != GNUNET_TIME_absolute_get_remaining (b->timeout).rel_value_us) |
7075 | { | 7130 | { |
7076 | b->task = GNUNET_SCHEDULER_add_at(b->timeout, &backtalker_timeout_cb, b); | 7131 | b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); |
7077 | return; | 7132 | return; |
7078 | } | 7133 | } |
7079 | GNUNET_assert(NULL == b->sc); | 7134 | GNUNET_assert (NULL == b->sc); |
7080 | free_backtalker(b); | 7135 | free_backtalker (b); |
7081 | } | 7136 | } |
7082 | 7137 | ||
7083 | 7138 | ||
@@ -7090,52 +7145,52 @@ backtalker_timeout_cb(void *cls) | |||
7090 | * @param emsg error message | 7145 | * @param emsg error message |
7091 | */ | 7146 | */ |
7092 | static void | 7147 | static void |
7093 | backtalker_monotime_cb(void *cls, | 7148 | backtalker_monotime_cb (void *cls, |
7094 | const struct GNUNET_PEERSTORE_Record *record, | 7149 | const struct GNUNET_PEERSTORE_Record *record, |
7095 | const char *emsg) | 7150 | const char *emsg) |
7096 | { | 7151 | { |
7097 | struct Backtalker *b = cls; | 7152 | struct Backtalker *b = cls; |
7098 | struct GNUNET_TIME_AbsoluteNBO *mtbe; | 7153 | struct GNUNET_TIME_AbsoluteNBO *mtbe; |
7099 | struct GNUNET_TIME_Absolute mt; | 7154 | struct GNUNET_TIME_Absolute mt; |
7100 | 7155 | ||
7101 | (void)emsg; | 7156 | (void) emsg; |
7102 | if (NULL == record) | 7157 | if (NULL == record) |
7103 | { | 7158 | { |
7104 | /* we're done with #backtalker_monotime_cb() invocations, | 7159 | /* we're done with #backtalker_monotime_cb() invocations, |
7105 | continue normal processing */ | 7160 | continue normal processing */ |
7106 | b->get = NULL; | 7161 | b->get = NULL; |
7107 | GNUNET_assert(NULL != b->cmc); | 7162 | GNUNET_assert (NULL != b->cmc); |
7108 | if (0 != b->body_size) | 7163 | if (0 != b->body_size) |
7109 | demultiplex_with_cmc(b->cmc, | 7164 | demultiplex_with_cmc (b->cmc, |
7110 | (const struct GNUNET_MessageHeader *)&b[1]); | 7165 | (const struct GNUNET_MessageHeader *) &b[1]); |
7111 | else | 7166 | else |
7112 | finish_cmc_handling(b->cmc); | 7167 | finish_cmc_handling (b->cmc); |
7113 | b->cmc = NULL; | 7168 | b->cmc = NULL; |
7114 | return; | 7169 | return; |
7115 | } | 7170 | } |
7116 | if (sizeof(*mtbe) != record->value_size) | 7171 | if (sizeof(*mtbe) != record->value_size) |
7117 | { | 7172 | { |
7118 | GNUNET_break(0); | 7173 | GNUNET_break (0); |
7119 | return; | 7174 | return; |
7120 | } | 7175 | } |
7121 | mtbe = record->value; | 7176 | mtbe = record->value; |
7122 | mt = GNUNET_TIME_absolute_ntoh(*mtbe); | 7177 | mt = GNUNET_TIME_absolute_ntoh (*mtbe); |
7123 | if (mt.abs_value_us > b->monotonic_time.abs_value_us) | 7178 | if (mt.abs_value_us > b->monotonic_time.abs_value_us) |
7124 | { | 7179 | { |
7125 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7126 | "Backtalker message from %s dropped, monotime in the past\n", | 7181 | "Backtalker message from %s dropped, monotime in the past\n", |
7127 | GNUNET_i2s(&b->pid)); | 7182 | GNUNET_i2s (&b->pid)); |
7128 | GNUNET_STATISTICS_update( | 7183 | GNUNET_STATISTICS_update ( |
7129 | GST_stats, | 7184 | GST_stats, |
7130 | "# Backchannel messages dropped: monotonic time not increasing", | 7185 | "# Backchannel messages dropped: monotonic time not increasing", |
7131 | 1, | 7186 | 1, |
7132 | GNUNET_NO); | 7187 | GNUNET_NO); |
7133 | b->monotonic_time = mt; | 7188 | b->monotonic_time = mt; |
7134 | /* Setting body_size to 0 prevents call to #forward_backchannel_payload() | 7189 | /* Setting body_size to 0 prevents call to #forward_backchannel_payload() |
7135 | */ | 7190 | */ |
7136 | b->body_size = 0; | 7191 | b->body_size = 0; |
7137 | return; | 7192 | return; |
7138 | } | 7193 | } |
7139 | } | 7194 | } |
7140 | 7195 | ||
7141 | 7196 | ||
@@ -7147,17 +7202,17 @@ backtalker_monotime_cb(void *cls, | |||
7147 | * @param success #GNUNET_OK on success | 7202 | * @param success #GNUNET_OK on success |
7148 | */ | 7203 | */ |
7149 | static void | 7204 | static void |
7150 | backtalker_monotime_store_cb(void *cls, int success) | 7205 | backtalker_monotime_store_cb (void *cls, int success) |
7151 | { | 7206 | { |
7152 | struct Backtalker *b = cls; | 7207 | struct Backtalker *b = cls; |
7153 | 7208 | ||
7154 | if (GNUNET_OK != success) | 7209 | if (GNUNET_OK != success) |
7155 | { | 7210 | { |
7156 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 7211 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
7157 | "Failed to store backtalker's monotonic time in PEERSTORE!\n"); | 7212 | "Failed to store backtalker's monotonic time in PEERSTORE!\n"); |
7158 | } | 7213 | } |
7159 | b->sc = NULL; | 7214 | b->sc = NULL; |
7160 | b->task = GNUNET_SCHEDULER_add_at(b->timeout, &backtalker_timeout_cb, b); | 7215 | b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); |
7161 | } | 7216 | } |
7162 | 7217 | ||
7163 | 7218 | ||
@@ -7167,32 +7222,32 @@ backtalker_monotime_store_cb(void *cls, int success) | |||
7167 | * @param b a backtalker with updated monotonic time | 7222 | * @param b a backtalker with updated monotonic time |
7168 | */ | 7223 | */ |
7169 | static void | 7224 | static void |
7170 | update_backtalker_monotime(struct Backtalker *b) | 7225 | update_backtalker_monotime (struct Backtalker *b) |
7171 | { | 7226 | { |
7172 | struct GNUNET_TIME_AbsoluteNBO mtbe; | 7227 | struct GNUNET_TIME_AbsoluteNBO mtbe; |
7173 | 7228 | ||
7174 | if (NULL != b->sc) | 7229 | if (NULL != b->sc) |
7175 | { | 7230 | { |
7176 | GNUNET_PEERSTORE_store_cancel(b->sc); | 7231 | GNUNET_PEERSTORE_store_cancel (b->sc); |
7177 | b->sc = NULL; | 7232 | b->sc = NULL; |
7178 | } | 7233 | } |
7179 | else | 7234 | else |
7180 | { | 7235 | { |
7181 | GNUNET_SCHEDULER_cancel(b->task); | 7236 | GNUNET_SCHEDULER_cancel (b->task); |
7182 | b->task = NULL; | 7237 | b->task = NULL; |
7183 | } | 7238 | } |
7184 | mtbe = GNUNET_TIME_absolute_hton(b->monotonic_time); | 7239 | mtbe = GNUNET_TIME_absolute_hton (b->monotonic_time); |
7185 | b->sc = | 7240 | b->sc = |
7186 | GNUNET_PEERSTORE_store(peerstore, | 7241 | GNUNET_PEERSTORE_store (peerstore, |
7187 | "transport", | 7242 | "transport", |
7188 | &b->pid, | 7243 | &b->pid, |
7189 | GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME, | 7244 | GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME, |
7190 | &mtbe, | 7245 | &mtbe, |
7191 | sizeof(mtbe), | 7246 | sizeof(mtbe), |
7192 | GNUNET_TIME_UNIT_FOREVER_ABS, | 7247 | GNUNET_TIME_UNIT_FOREVER_ABS, |
7193 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 7248 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
7194 | &backtalker_monotime_store_cb, | 7249 | &backtalker_monotime_store_cb, |
7195 | b); | 7250 | b); |
7196 | } | 7251 | } |
7197 | 7252 | ||
7198 | 7253 | ||
@@ -7204,14 +7259,14 @@ update_backtalker_monotime(struct Backtalker *b) | |||
7204 | * @param dvb the message that was received | 7259 | * @param dvb the message that was received |
7205 | */ | 7260 | */ |
7206 | static void | 7261 | static void |
7207 | handle_dv_box(void *cls, const struct TransportDVBoxMessage *dvb) | 7262 | handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb) |
7208 | { | 7263 | { |
7209 | struct CommunicatorMessageContext *cmc = cls; | 7264 | struct CommunicatorMessageContext *cmc = cls; |
7210 | uint16_t size = ntohs(dvb->header.size) - sizeof(*dvb); | 7265 | uint16_t size = ntohs (dvb->header.size) - sizeof(*dvb); |
7211 | uint16_t num_hops = ntohs(dvb->num_hops); | 7266 | uint16_t num_hops = ntohs (dvb->num_hops); |
7212 | const struct GNUNET_PeerIdentity *hops = | 7267 | const struct GNUNET_PeerIdentity *hops = |
7213 | (const struct GNUNET_PeerIdentity *)&dvb[1]; | 7268 | (const struct GNUNET_PeerIdentity *) &dvb[1]; |
7214 | const char *enc_payload = (const char *)&hops[num_hops]; | 7269 | const char *enc_payload = (const char *) &hops[num_hops]; |
7215 | uint16_t enc_payload_size = | 7270 | uint16_t enc_payload_size = |
7216 | size - (num_hops * sizeof(struct GNUNET_PeerIdentity)); | 7271 | size - (num_hops * sizeof(struct GNUNET_PeerIdentity)); |
7217 | struct DVKeyState key; | 7272 | struct DVKeyState key; |
@@ -7220,89 +7275,89 @@ handle_dv_box(void *cls, const struct TransportDVBoxMessage *dvb) | |||
7220 | size_t hdr_len; | 7275 | size_t hdr_len; |
7221 | 7276 | ||
7222 | if (GNUNET_EXTRA_LOGGING > 0) | 7277 | if (GNUNET_EXTRA_LOGGING > 0) |
7223 | { | 7278 | { |
7224 | char *path; | 7279 | char *path; |
7225 | 7280 | ||
7226 | path = GNUNET_strdup(GNUNET_i2s(&GST_my_identity)); | 7281 | path = GNUNET_strdup (GNUNET_i2s (&GST_my_identity)); |
7227 | for (unsigned int i = 0; i < num_hops; i++) | 7282 | for (unsigned int i = 0; i < num_hops; i++) |
7228 | { | 7283 | { |
7229 | char *tmp; | 7284 | char *tmp; |
7230 | 7285 | ||
7231 | GNUNET_asprintf(&tmp, "%s->%s", path, GNUNET_i2s(&hops[i])); | 7286 | GNUNET_asprintf (&tmp, "%s->%s", path, GNUNET_i2s (&hops[i])); |
7232 | GNUNET_free(path); | 7287 | GNUNET_free (path); |
7233 | path = tmp; | 7288 | path = tmp; |
7234 | } | ||
7235 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
7236 | "Received DVBox with remainig path %s\n", | ||
7237 | path); | ||
7238 | GNUNET_free(path); | ||
7239 | } | 7289 | } |
7290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
7291 | "Received DVBox with remainig path %s\n", | ||
7292 | path); | ||
7293 | GNUNET_free (path); | ||
7294 | } | ||
7240 | 7295 | ||
7241 | if (num_hops > 0) | 7296 | if (num_hops > 0) |
7297 | { | ||
7298 | /* We're trying from the end of the hops array, as we may be | ||
7299 | able to find a shortcut unknown to the origin that way */ | ||
7300 | for (int i = num_hops - 1; i >= 0; i--) | ||
7242 | { | 7301 | { |
7243 | /* We're trying from the end of the hops array, as we may be | 7302 | struct Neighbour *n; |
7244 | able to find a shortcut unknown to the origin that way */ | 7303 | |
7245 | for (int i = num_hops - 1; i >= 0; i--) | 7304 | if (0 == GNUNET_memcmp (&hops[i], &GST_my_identity)) |
7246 | { | 7305 | { |
7247 | struct Neighbour *n; | 7306 | GNUNET_break_op (0); |
7248 | 7307 | finish_cmc_handling (cmc); | |
7249 | if (0 == GNUNET_memcmp(&hops[i], &GST_my_identity)) | 7308 | return; |
7250 | { | 7309 | } |
7251 | GNUNET_break_op(0); | 7310 | n = lookup_neighbour (&hops[i]); |
7252 | finish_cmc_handling(cmc); | 7311 | if (NULL == n) |
7253 | return; | 7312 | continue; |
7254 | } | 7313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7255 | n = lookup_neighbour(&hops[i]); | 7314 | "Skipping %u/%u hops ahead while routing DV Box\n", |
7256 | if (NULL == n) | 7315 | i, |
7257 | continue; | 7316 | num_hops); |
7258 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7317 | forward_dv_box (n, |
7259 | "Skipping %u/%u hops ahead while routing DV Box\n", | 7318 | dvb, |
7260 | i, | 7319 | ntohs (dvb->total_hops) + 1, |
7261 | num_hops); | 7320 | num_hops - i - 1, /* number of hops left */ |
7262 | forward_dv_box(n, | 7321 | &hops[i + 1], /* remaining hops */ |
7263 | dvb, | 7322 | enc_payload, |
7264 | ntohs(dvb->total_hops) + 1, | 7323 | enc_payload_size); |
7265 | num_hops - i - 1, /* number of hops left */ | 7324 | GNUNET_STATISTICS_update (GST_stats, |
7266 | &hops[i + 1], /* remaining hops */ | 7325 | "# DV hops skipped routing boxes", |
7267 | enc_payload, | 7326 | i, |
7268 | enc_payload_size); | 7327 | GNUNET_NO); |
7269 | GNUNET_STATISTICS_update(GST_stats, | 7328 | GNUNET_STATISTICS_update (GST_stats, |
7270 | "# DV hops skipped routing boxes", | 7329 | "# DV boxes routed (total)", |
7271 | i, | 7330 | 1, |
7272 | GNUNET_NO); | 7331 | GNUNET_NO); |
7273 | GNUNET_STATISTICS_update(GST_stats, | 7332 | finish_cmc_handling (cmc); |
7274 | "# DV boxes routed (total)", | ||
7275 | 1, | ||
7276 | GNUNET_NO); | ||
7277 | finish_cmc_handling(cmc); | ||
7278 | return; | ||
7279 | } | ||
7280 | /* Woopsie, next hop not in neighbours, drop! */ | ||
7281 | GNUNET_STATISTICS_update(GST_stats, | ||
7282 | "# DV Boxes dropped: next hop unknown", | ||
7283 | 1, | ||
7284 | GNUNET_NO); | ||
7285 | finish_cmc_handling(cmc); | ||
7286 | return; | 7333 | return; |
7287 | } | 7334 | } |
7335 | /* Woopsie, next hop not in neighbours, drop! */ | ||
7336 | GNUNET_STATISTICS_update (GST_stats, | ||
7337 | "# DV Boxes dropped: next hop unknown", | ||
7338 | 1, | ||
7339 | GNUNET_NO); | ||
7340 | finish_cmc_handling (cmc); | ||
7341 | return; | ||
7342 | } | ||
7288 | /* We are the target. Unbox and handle message. */ | 7343 | /* We are the target. Unbox and handle message. */ |
7289 | GNUNET_STATISTICS_update(GST_stats, | 7344 | GNUNET_STATISTICS_update (GST_stats, |
7290 | "# DV boxes opened (ultimate target)", | 7345 | "# DV boxes opened (ultimate target)", |
7291 | 1, | 7346 | 1, |
7292 | GNUNET_NO); | 7347 | GNUNET_NO); |
7293 | cmc->total_hops = ntohs(dvb->total_hops); | 7348 | cmc->total_hops = ntohs (dvb->total_hops); |
7294 | 7349 | ||
7295 | dh_key_derive_eph_pub(&dvb->ephemeral_key, &dvb->iv, &key); | 7350 | dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, &key); |
7296 | hdr = (const char *)&dvb[1]; | 7351 | hdr = (const char *) &dvb[1]; |
7297 | hdr_len = ntohs(dvb->header.size) - sizeof(*dvb); | 7352 | hdr_len = ntohs (dvb->header.size) - sizeof(*dvb); |
7298 | dv_hmac(&key, &hmac, hdr, hdr_len); | 7353 | dv_hmac (&key, &hmac, hdr, hdr_len); |
7299 | if (0 != GNUNET_memcmp(&hmac, &dvb->hmac)) | 7354 | if (0 != GNUNET_memcmp (&hmac, &dvb->hmac)) |
7300 | { | 7355 | { |
7301 | /* HMAC missmatch, disard! */ | 7356 | /* HMAC missmatch, disard! */ |
7302 | GNUNET_break_op(0); | 7357 | GNUNET_break_op (0); |
7303 | finish_cmc_handling(cmc); | 7358 | finish_cmc_handling (cmc); |
7304 | return; | 7359 | return; |
7305 | } | 7360 | } |
7306 | /* begin actual decryption */ | 7361 | /* begin actual decryption */ |
7307 | { | 7362 | { |
7308 | struct Backtalker *b; | 7363 | struct Backtalker *b; |
@@ -7310,117 +7365,118 @@ handle_dv_box(void *cls, const struct TransportDVBoxMessage *dvb) | |||
7310 | struct TransportDVBoxPayloadP ppay; | 7365 | struct TransportDVBoxPayloadP ppay; |
7311 | char body[hdr_len - sizeof(ppay)] GNUNET_ALIGN; | 7366 | char body[hdr_len - sizeof(ppay)] GNUNET_ALIGN; |
7312 | const struct GNUNET_MessageHeader *mh = | 7367 | const struct GNUNET_MessageHeader *mh = |
7313 | (const struct GNUNET_MessageHeader *)body; | 7368 | (const struct GNUNET_MessageHeader *) body; |
7314 | 7369 | ||
7315 | GNUNET_assert(hdr_len >= | 7370 | GNUNET_assert (hdr_len >= |
7316 | sizeof(ppay) + sizeof(struct GNUNET_MessageHeader)); | 7371 | sizeof(ppay) + sizeof(struct GNUNET_MessageHeader)); |
7317 | dv_decrypt(&key, &ppay, hdr, sizeof(ppay)); | 7372 | dv_decrypt (&key, &ppay, hdr, sizeof(ppay)); |
7318 | dv_decrypt(&key, &body, &hdr[sizeof(ppay)], hdr_len - sizeof(ppay)); | 7373 | dv_decrypt (&key, &body, &hdr[sizeof(ppay)], hdr_len - sizeof(ppay)); |
7319 | dv_key_clean(&key); | 7374 | dv_key_clean (&key); |
7320 | if (ntohs(mh->size) != sizeof(body)) | 7375 | if (ntohs (mh->size) != sizeof(body)) |
7321 | { | 7376 | { |
7322 | GNUNET_break_op(0); | 7377 | GNUNET_break_op (0); |
7323 | finish_cmc_handling(cmc); | 7378 | finish_cmc_handling (cmc); |
7324 | return; | 7379 | return; |
7325 | } | 7380 | } |
7326 | /* need to prevent box-in-a-box (and DV_LEARN) so check inbox type! */ | 7381 | /* need to prevent box-in-a-box (and DV_LEARN) so check inbox type! */ |
7327 | switch (ntohs(mh->type)) | 7382 | switch (ntohs (mh->type)) |
7328 | { | 7383 | { |
7329 | case GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX: | 7384 | case GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX: |
7330 | GNUNET_break_op(0); | 7385 | GNUNET_break_op (0); |
7331 | finish_cmc_handling(cmc); | 7386 | finish_cmc_handling (cmc); |
7332 | return; | 7387 | return; |
7333 | 7388 | ||
7334 | case GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN: | 7389 | case GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN: |
7335 | GNUNET_break_op(0); | 7390 | GNUNET_break_op (0); |
7336 | finish_cmc_handling(cmc); | 7391 | finish_cmc_handling (cmc); |
7337 | return; | 7392 | return; |
7338 | 7393 | ||
7339 | default: | 7394 | default: |
7340 | /* permitted, continue */ | 7395 | /* permitted, continue */ |
7341 | break; | 7396 | break; |
7342 | } | 7397 | } |
7343 | monotime = GNUNET_TIME_absolute_ntoh(ppay.monotonic_time); | 7398 | monotime = GNUNET_TIME_absolute_ntoh (ppay.monotonic_time); |
7344 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7345 | "Decrypted backtalk from %s\n", | 7400 | "Decrypted backtalk from %s\n", |
7346 | GNUNET_i2s(&ppay.sender)); | 7401 | GNUNET_i2s (&ppay.sender)); |
7347 | b = GNUNET_CONTAINER_multipeermap_get(backtalkers, &ppay.sender); | 7402 | b = GNUNET_CONTAINER_multipeermap_get (backtalkers, &ppay.sender); |
7348 | if ((NULL != b) && (monotime.abs_value_us < b->monotonic_time.abs_value_us)) | 7403 | if ((NULL != b) && (monotime.abs_value_us < b->monotonic_time.abs_value_us)) |
7349 | { | 7404 | { |
7350 | GNUNET_STATISTICS_update( | 7405 | GNUNET_STATISTICS_update ( |
7351 | GST_stats, | 7406 | GST_stats, |
7352 | "# Backchannel messages dropped: monotonic time not increasing", | 7407 | "# Backchannel messages dropped: monotonic time not increasing", |
7353 | 1, | 7408 | 1, |
7354 | GNUNET_NO); | 7409 | GNUNET_NO); |
7355 | finish_cmc_handling(cmc); | 7410 | finish_cmc_handling (cmc); |
7356 | return; | 7411 | return; |
7357 | } | 7412 | } |
7358 | if ((NULL == b) || | 7413 | if ((NULL == b) || |
7359 | (0 != GNUNET_memcmp(&b->last_ephemeral, &dvb->ephemeral_key))) | 7414 | (0 != GNUNET_memcmp (&b->last_ephemeral, &dvb->ephemeral_key))) |
7415 | { | ||
7416 | /* Check signature */ | ||
7417 | struct EphemeralConfirmationPS ec; | ||
7418 | |||
7419 | ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); | ||
7420 | ec.purpose.size = htonl (sizeof(ec)); | ||
7421 | ec.target = GST_my_identity; | ||
7422 | ec.ephemeral_key = dvb->ephemeral_key; | ||
7423 | if ( | ||
7424 | GNUNET_OK != | ||
7425 | GNUNET_CRYPTO_eddsa_verify ( | ||
7426 | GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL, | ||
7427 | &ec.purpose, | ||
7428 | &ppay.sender_sig, | ||
7429 | &ppay.sender.public_key)) | ||
7360 | { | 7430 | { |
7361 | /* Check signature */ | 7431 | /* Signature invalid, disard! */ |
7362 | struct EphemeralConfirmationPS ec; | 7432 | GNUNET_break_op (0); |
7363 | 7433 | finish_cmc_handling (cmc); | |
7364 | ec.purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL); | 7434 | return; |
7365 | ec.purpose.size = htonl(sizeof(ec)); | ||
7366 | ec.target = GST_my_identity; | ||
7367 | ec.ephemeral_key = dvb->ephemeral_key; | ||
7368 | if ( | ||
7369 | GNUNET_OK != | ||
7370 | GNUNET_CRYPTO_eddsa_verify(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL, | ||
7371 | &ec.purpose, | ||
7372 | &ppay.sender_sig, | ||
7373 | &ppay.sender.public_key)) | ||
7374 | { | ||
7375 | /* Signature invalid, disard! */ | ||
7376 | GNUNET_break_op(0); | ||
7377 | finish_cmc_handling(cmc); | ||
7378 | return; | ||
7379 | } | ||
7380 | } | 7435 | } |
7436 | } | ||
7381 | /* Update sender, we now know the real origin! */ | 7437 | /* Update sender, we now know the real origin! */ |
7382 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7383 | "DVBox received for me from %s via %s\n", | 7439 | "DVBox received for me from %s via %s\n", |
7384 | GNUNET_i2s2(&ppay.sender), | 7440 | GNUNET_i2s2 (&ppay.sender), |
7385 | GNUNET_i2s(&cmc->im.sender)); | 7441 | GNUNET_i2s (&cmc->im.sender)); |
7386 | cmc->im.sender = ppay.sender; | 7442 | cmc->im.sender = ppay.sender; |
7387 | 7443 | ||
7388 | if (NULL != b) | 7444 | if (NULL != b) |
7389 | { | 7445 | { |
7390 | /* update key cache and mono time */ | 7446 | /* update key cache and mono time */ |
7391 | b->last_ephemeral = dvb->ephemeral_key; | 7447 | b->last_ephemeral = dvb->ephemeral_key; |
7392 | b->monotonic_time = monotime; | 7448 | b->monotonic_time = monotime; |
7393 | update_backtalker_monotime(b); | 7449 | update_backtalker_monotime (b); |
7394 | b->timeout = | 7450 | b->timeout = |
7395 | GNUNET_TIME_relative_to_absolute(BACKCHANNEL_INACTIVITY_TIMEOUT); | 7451 | GNUNET_TIME_relative_to_absolute (BACKCHANNEL_INACTIVITY_TIMEOUT); |
7396 | 7452 | ||
7397 | demultiplex_with_cmc(cmc, mh); | 7453 | demultiplex_with_cmc (cmc, mh); |
7398 | return; | 7454 | return; |
7399 | } | 7455 | } |
7400 | /* setup data structure to cache signature AND check | 7456 | /* setup data structure to cache signature AND check |
7401 | monotonic time with PEERSTORE before forwarding backchannel payload */ | 7457 | monotonic time with PEERSTORE before forwarding backchannel payload */ |
7402 | b = GNUNET_malloc(sizeof(struct Backtalker) + sizeof(body)); | 7458 | b = GNUNET_malloc (sizeof(struct Backtalker) + sizeof(body)); |
7403 | b->pid = ppay.sender; | 7459 | b->pid = ppay.sender; |
7404 | b->body_size = sizeof(body); | 7460 | b->body_size = sizeof(body); |
7405 | memcpy(&b[1], body, sizeof(body)); | 7461 | memcpy (&b[1], body, sizeof(body)); |
7406 | GNUNET_assert(GNUNET_YES == | 7462 | GNUNET_assert (GNUNET_YES == |
7407 | GNUNET_CONTAINER_multipeermap_put( | 7463 | GNUNET_CONTAINER_multipeermap_put ( |
7408 | backtalkers, | 7464 | backtalkers, |
7409 | &b->pid, | 7465 | &b->pid, |
7410 | b, | 7466 | b, |
7411 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 7467 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
7412 | b->monotonic_time = monotime; /* NOTE: to be checked still! */ | 7468 | b->monotonic_time = monotime; /* NOTE: to be checked still! */ |
7413 | b->cmc = cmc; | 7469 | b->cmc = cmc; |
7414 | b->timeout = | 7470 | b->timeout = |
7415 | GNUNET_TIME_relative_to_absolute(BACKCHANNEL_INACTIVITY_TIMEOUT); | 7471 | GNUNET_TIME_relative_to_absolute (BACKCHANNEL_INACTIVITY_TIMEOUT); |
7416 | b->task = GNUNET_SCHEDULER_add_at(b->timeout, &backtalker_timeout_cb, b); | 7472 | b->task = GNUNET_SCHEDULER_add_at (b->timeout, &backtalker_timeout_cb, b); |
7417 | b->get = | 7473 | b->get = |
7418 | GNUNET_PEERSTORE_iterate(peerstore, | 7474 | GNUNET_PEERSTORE_iterate (peerstore, |
7419 | "transport", | 7475 | "transport", |
7420 | &b->pid, | 7476 | &b->pid, |
7421 | GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME, | 7477 | GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME, |
7422 | &backtalker_monotime_cb, | 7478 | &backtalker_monotime_cb, |
7423 | b); | 7479 | b); |
7424 | } /* end actual decryption */ | 7480 | } /* end actual decryption */ |
7425 | } | 7481 | } |
7426 | 7482 | ||
@@ -7433,17 +7489,17 @@ handle_dv_box(void *cls, const struct TransportDVBoxMessage *dvb) | |||
7433 | * @return #GNUNET_YES if message is well-formed | 7489 | * @return #GNUNET_YES if message is well-formed |
7434 | */ | 7490 | */ |
7435 | static int | 7491 | static int |
7436 | check_incoming_msg(void *cls, | 7492 | check_incoming_msg (void *cls, |
7437 | const struct GNUNET_TRANSPORT_IncomingMessage *im) | 7493 | const struct GNUNET_TRANSPORT_IncomingMessage *im) |
7438 | { | 7494 | { |
7439 | struct TransportClient *tc = cls; | 7495 | struct TransportClient *tc = cls; |
7440 | 7496 | ||
7441 | if (CT_COMMUNICATOR != tc->type) | 7497 | if (CT_COMMUNICATOR != tc->type) |
7442 | { | 7498 | { |
7443 | GNUNET_break(0); | 7499 | GNUNET_break (0); |
7444 | return GNUNET_SYSERR; | 7500 | return GNUNET_SYSERR; |
7445 | } | 7501 | } |
7446 | GNUNET_MQ_check_boxed_message(im); | 7502 | GNUNET_MQ_check_boxed_message (im); |
7447 | return GNUNET_OK; | 7503 | return GNUNET_OK; |
7448 | } | 7504 | } |
7449 | 7505 | ||
@@ -7451,7 +7507,8 @@ check_incoming_msg(void *cls, | |||
7451 | /** | 7507 | /** |
7452 | * Closure for #check_known_address. | 7508 | * Closure for #check_known_address. |
7453 | */ | 7509 | */ |
7454 | struct CheckKnownAddressContext { | 7510 | struct CheckKnownAddressContext |
7511 | { | ||
7455 | /** | 7512 | /** |
7456 | * Set to the address we are looking for. | 7513 | * Set to the address we are looking for. |
7457 | */ | 7514 | */ |
@@ -7474,15 +7531,15 @@ struct CheckKnownAddressContext { | |||
7474 | * @return #GNUNET_OK if not matching, #GNUNET_NO if match found | 7531 | * @return #GNUNET_OK if not matching, #GNUNET_NO if match found |
7475 | */ | 7532 | */ |
7476 | static int | 7533 | static int |
7477 | check_known_address(void *cls, | 7534 | check_known_address (void *cls, |
7478 | const struct GNUNET_PeerIdentity *pid, | 7535 | const struct GNUNET_PeerIdentity *pid, |
7479 | void *value) | 7536 | void *value) |
7480 | { | 7537 | { |
7481 | struct CheckKnownAddressContext *ckac = cls; | 7538 | struct CheckKnownAddressContext *ckac = cls; |
7482 | struct ValidationState *vs = value; | 7539 | struct ValidationState *vs = value; |
7483 | 7540 | ||
7484 | (void)pid; | 7541 | (void) pid; |
7485 | if (0 != strcmp(vs->address, ckac->address)) | 7542 | if (0 != strcmp (vs->address, ckac->address)) |
7486 | return GNUNET_OK; | 7543 | return GNUNET_OK; |
7487 | ckac->vs = vs; | 7544 | ckac->vs = vs; |
7488 | return GNUNET_NO; | 7545 | return GNUNET_NO; |
@@ -7495,7 +7552,7 @@ check_known_address(void *cls, | |||
7495 | * @param cls NULL | 7552 | * @param cls NULL |
7496 | */ | 7553 | */ |
7497 | static void | 7554 | static void |
7498 | validation_start_cb(void *cls); | 7555 | validation_start_cb (void *cls); |
7499 | 7556 | ||
7500 | 7557 | ||
7501 | /** | 7558 | /** |
@@ -7506,8 +7563,8 @@ validation_start_cb(void *cls); | |||
7506 | * @param new_time new time for revalidation | 7563 | * @param new_time new time for revalidation |
7507 | */ | 7564 | */ |
7508 | static void | 7565 | static void |
7509 | update_next_challenge_time(struct ValidationState *vs, | 7566 | update_next_challenge_time (struct ValidationState *vs, |
7510 | struct GNUNET_TIME_Absolute new_time) | 7567 | struct GNUNET_TIME_Absolute new_time) |
7511 | { | 7568 | { |
7512 | struct GNUNET_TIME_Relative delta; | 7569 | struct GNUNET_TIME_Relative delta; |
7513 | 7570 | ||
@@ -7516,21 +7573,21 @@ update_next_challenge_time(struct ValidationState *vs, | |||
7516 | vs->next_challenge = new_time; | 7573 | vs->next_challenge = new_time; |
7517 | if (NULL == vs->hn) | 7574 | if (NULL == vs->hn) |
7518 | vs->hn = | 7575 | vs->hn = |
7519 | GNUNET_CONTAINER_heap_insert(validation_heap, vs, new_time.abs_value_us); | 7576 | GNUNET_CONTAINER_heap_insert (validation_heap, vs, new_time.abs_value_us); |
7520 | else | 7577 | else |
7521 | GNUNET_CONTAINER_heap_update_cost(vs->hn, new_time.abs_value_us); | 7578 | GNUNET_CONTAINER_heap_update_cost (vs->hn, new_time.abs_value_us); |
7522 | if ((vs != GNUNET_CONTAINER_heap_peek(validation_heap)) && | 7579 | if ((vs != GNUNET_CONTAINER_heap_peek (validation_heap)) && |
7523 | (NULL != validation_task)) | 7580 | (NULL != validation_task)) |
7524 | return; | 7581 | return; |
7525 | if (NULL != validation_task) | 7582 | if (NULL != validation_task) |
7526 | GNUNET_SCHEDULER_cancel(validation_task); | 7583 | GNUNET_SCHEDULER_cancel (validation_task); |
7527 | /* randomize a bit */ | 7584 | /* randomize a bit */ |
7528 | delta.rel_value_us = | 7585 | delta.rel_value_us = |
7529 | GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, | 7586 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
7530 | MIN_DELAY_ADDRESS_VALIDATION.rel_value_us); | 7587 | MIN_DELAY_ADDRESS_VALIDATION.rel_value_us); |
7531 | new_time = GNUNET_TIME_absolute_add(new_time, delta); | 7588 | new_time = GNUNET_TIME_absolute_add (new_time, delta); |
7532 | validation_task = | 7589 | validation_task = |
7533 | GNUNET_SCHEDULER_add_at(new_time, &validation_start_cb, NULL); | 7590 | GNUNET_SCHEDULER_add_at (new_time, &validation_start_cb, NULL); |
7534 | } | 7591 | } |
7535 | 7592 | ||
7536 | 7593 | ||
@@ -7541,57 +7598,58 @@ update_next_challenge_time(struct ValidationState *vs, | |||
7541 | * @param address an address to reach @a pid (presumably) | 7598 | * @param address an address to reach @a pid (presumably) |
7542 | */ | 7599 | */ |
7543 | static void | 7600 | static void |
7544 | start_address_validation(const struct GNUNET_PeerIdentity *pid, | 7601 | start_address_validation (const struct GNUNET_PeerIdentity *pid, |
7545 | const char *address) | 7602 | const char *address) |
7546 | { | 7603 | { |
7547 | struct GNUNET_TIME_Absolute now; | 7604 | struct GNUNET_TIME_Absolute now; |
7548 | struct ValidationState *vs; | 7605 | struct ValidationState *vs; |
7549 | struct CheckKnownAddressContext ckac = { .address = address, .vs = NULL }; | 7606 | struct CheckKnownAddressContext ckac = { .address = address, .vs = NULL }; |
7550 | 7607 | ||
7551 | (void)GNUNET_CONTAINER_multipeermap_get_multiple(validation_map, | 7608 | (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, |
7552 | pid, | 7609 | pid, |
7553 | &check_known_address, | 7610 | &check_known_address, |
7554 | &ckac); | 7611 | &ckac); |
7555 | if (NULL != (vs = ckac.vs)) | 7612 | if (NULL != (vs = ckac.vs)) |
7556 | { | 7613 | { |
7557 | /* if 'vs' is not currently valid, we need to speed up retrying the | 7614 | /* if 'vs' is not currently valid, we need to speed up retrying the |
7558 | * validation */ | 7615 | * validation */ |
7559 | if (vs->validated_until.abs_value_us < vs->next_challenge.abs_value_us) | 7616 | if (vs->validated_until.abs_value_us < vs->next_challenge.abs_value_us) |
7560 | { | 7617 | { |
7561 | /* reduce backoff as we got a fresh advertisement */ | 7618 | /* reduce backoff as we got a fresh advertisement */ |
7562 | vs->challenge_backoff = | 7619 | vs->challenge_backoff = |
7563 | GNUNET_TIME_relative_min(FAST_VALIDATION_CHALLENGE_FREQ, | 7620 | GNUNET_TIME_relative_min (FAST_VALIDATION_CHALLENGE_FREQ, |
7564 | GNUNET_TIME_relative_divide(vs->challenge_backoff, | 7621 | GNUNET_TIME_relative_divide ( |
7565 | 2)); | 7622 | vs->challenge_backoff, |
7566 | update_next_challenge_time(vs, | 7623 | 2)); |
7567 | GNUNET_TIME_relative_to_absolute( | 7624 | update_next_challenge_time (vs, |
7568 | vs->challenge_backoff)); | 7625 | GNUNET_TIME_relative_to_absolute ( |
7569 | } | 7626 | vs->challenge_backoff)); |
7570 | return; | ||
7571 | } | 7627 | } |
7572 | now = GNUNET_TIME_absolute_get(); | 7628 | return; |
7573 | vs = GNUNET_new(struct ValidationState); | 7629 | } |
7630 | now = GNUNET_TIME_absolute_get (); | ||
7631 | vs = GNUNET_new (struct ValidationState); | ||
7574 | vs->pid = *pid; | 7632 | vs->pid = *pid; |
7575 | vs->valid_until = | 7633 | vs->valid_until = |
7576 | GNUNET_TIME_relative_to_absolute(ADDRESS_VALIDATION_LIFETIME); | 7634 | GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME); |
7577 | vs->first_challenge_use = now; | 7635 | vs->first_challenge_use = now; |
7578 | vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 7636 | vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
7579 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_NONCE, | 7637 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
7580 | &vs->challenge, | 7638 | &vs->challenge, |
7581 | sizeof(vs->challenge)); | 7639 | sizeof(vs->challenge)); |
7582 | vs->address = GNUNET_strdup(address); | 7640 | vs->address = GNUNET_strdup (address); |
7583 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7641 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7584 | "Starting address validation `%s' of peer %s using challenge %s\n", | 7642 | "Starting address validation `%s' of peer %s using challenge %s\n", |
7585 | address, | 7643 | address, |
7586 | GNUNET_i2s(pid), | 7644 | GNUNET_i2s (pid), |
7587 | GNUNET_sh2s(&vs->challenge.value)); | 7645 | GNUNET_sh2s (&vs->challenge.value)); |
7588 | GNUNET_assert(GNUNET_YES == | 7646 | GNUNET_assert (GNUNET_YES == |
7589 | GNUNET_CONTAINER_multipeermap_put( | 7647 | GNUNET_CONTAINER_multipeermap_put ( |
7590 | validation_map, | 7648 | validation_map, |
7591 | &vs->pid, | 7649 | &vs->pid, |
7592 | vs, | 7650 | vs, |
7593 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 7651 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
7594 | update_next_challenge_time(vs, now); | 7652 | update_next_challenge_time (vs, now); |
7595 | } | 7653 | } |
7596 | 7654 | ||
7597 | 7655 | ||
@@ -7603,27 +7661,27 @@ start_address_validation(const struct GNUNET_PeerIdentity *pid, | |||
7603 | * @param emsg error message, or NULL if no errors | 7661 | * @param emsg error message, or NULL if no errors |
7604 | */ | 7662 | */ |
7605 | static void | 7663 | static void |
7606 | handle_hello_for_incoming(void *cls, | 7664 | handle_hello_for_incoming (void *cls, |
7607 | const struct GNUNET_PEERSTORE_Record *record, | 7665 | const struct GNUNET_PEERSTORE_Record *record, |
7608 | const char *emsg) | 7666 | const char *emsg) |
7609 | { | 7667 | { |
7610 | struct IncomingRequest *ir = cls; | 7668 | struct IncomingRequest *ir = cls; |
7611 | const char *val; | 7669 | const char *val; |
7612 | 7670 | ||
7613 | if (NULL != emsg) | 7671 | if (NULL != emsg) |
7614 | { | 7672 | { |
7615 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 7673 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
7616 | "Got failure from PEERSTORE: %s\n", | 7674 | "Got failure from PEERSTORE: %s\n", |
7617 | emsg); | 7675 | emsg); |
7618 | return; | 7676 | return; |
7619 | } | 7677 | } |
7620 | val = record->value; | 7678 | val = record->value; |
7621 | if ((0 == record->value_size) || ('\0' != val[record->value_size - 1])) | 7679 | if ((0 == record->value_size) || ('\0' != val[record->value_size - 1])) |
7622 | { | 7680 | { |
7623 | GNUNET_break(0); | 7681 | GNUNET_break (0); |
7624 | return; | 7682 | return; |
7625 | } | 7683 | } |
7626 | start_address_validation(&ir->pid, (const char *)record->value); | 7684 | start_address_validation (&ir->pid, (const char *) record->value); |
7627 | } | 7685 | } |
7628 | 7686 | ||
7629 | 7687 | ||
@@ -7636,7 +7694,7 @@ handle_hello_for_incoming(void *cls, | |||
7636 | * @param tvc the message that was received | 7694 | * @param tvc the message that was received |
7637 | */ | 7695 | */ |
7638 | static void | 7696 | static void |
7639 | handle_validation_challenge( | 7697 | handle_validation_challenge ( |
7640 | void *cls, | 7698 | void *cls, |
7641 | const struct TransportValidationChallengeMessage *tvc) | 7699 | const struct TransportValidationChallengeMessage *tvc) |
7642 | { | 7700 | { |
@@ -7650,44 +7708,44 @@ handle_validation_challenge( | |||
7650 | 7708 | ||
7651 | /* DV-routed messages are not allowed for validation challenges */ | 7709 | /* DV-routed messages are not allowed for validation challenges */ |
7652 | if (cmc->total_hops > 0) | 7710 | if (cmc->total_hops > 0) |
7653 | { | 7711 | { |
7654 | GNUNET_break_op(0); | 7712 | GNUNET_break_op (0); |
7655 | finish_cmc_handling(cmc); | 7713 | finish_cmc_handling (cmc); |
7656 | return; | 7714 | return; |
7657 | } | 7715 | } |
7658 | validity_duration = cmc->im.expected_address_validity; | 7716 | validity_duration = cmc->im.expected_address_validity; |
7659 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7660 | "Received address validation challenge %s\n", | 7718 | "Received address validation challenge %s\n", |
7661 | GNUNET_sh2s(&tvc->challenge.value)); | 7719 | GNUNET_sh2s (&tvc->challenge.value)); |
7662 | /* If we have a virtual link, we use this mechanism to signal the | 7720 | /* If we have a virtual link, we use this mechanism to signal the |
7663 | size of the flow control window, and to allow the sender | 7721 | size of the flow control window, and to allow the sender |
7664 | to ask for increases. If for us the virtual link is still down, | 7722 | to ask for increases. If for us the virtual link is still down, |
7665 | we will always give a window size of zero. */ | 7723 | we will always give a window size of zero. */ |
7666 | tvr.header.type = | 7724 | tvr.header.type = |
7667 | htons(GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE); | 7725 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE); |
7668 | tvr.header.size = htons(sizeof(tvr)); | 7726 | tvr.header.size = htons (sizeof(tvr)); |
7669 | tvr.reserved = htonl(0); | 7727 | tvr.reserved = htonl (0); |
7670 | tvr.challenge = tvc->challenge; | 7728 | tvr.challenge = tvc->challenge; |
7671 | tvr.origin_time = tvc->sender_time; | 7729 | tvr.origin_time = tvc->sender_time; |
7672 | tvr.validity_duration = validity_duration; | 7730 | tvr.validity_duration = validity_duration; |
7673 | { | 7731 | { |
7674 | /* create signature */ | 7732 | /* create signature */ |
7675 | struct TransportValidationPS tvp = | 7733 | struct TransportValidationPS tvp = |
7676 | { .purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE), | 7734 | { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE), |
7677 | .purpose.size = htonl(sizeof(tvp)), | 7735 | .purpose.size = htonl (sizeof(tvp)), |
7678 | .validity_duration = validity_duration, | 7736 | .validity_duration = validity_duration, |
7679 | .challenge = tvc->challenge }; | 7737 | .challenge = tvc->challenge }; |
7680 | 7738 | ||
7681 | GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_eddsa_sign(GST_my_private_key, | 7739 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, |
7682 | &tvp.purpose, | 7740 | &tvp.purpose, |
7683 | &tvr.signature)); | 7741 | &tvr.signature)); |
7684 | } | 7742 | } |
7685 | route_control_message_without_fc(&cmc->im.sender, | 7743 | route_control_message_without_fc (&cmc->im.sender, |
7686 | &tvr.header, | 7744 | &tvr.header, |
7687 | RMO_ANYTHING_GOES | RMO_REDUNDANT); | 7745 | RMO_ANYTHING_GOES | RMO_REDUNDANT); |
7688 | sender = cmc->im.sender; | 7746 | sender = cmc->im.sender; |
7689 | finish_cmc_handling(cmc); | 7747 | finish_cmc_handling (cmc); |
7690 | vl = lookup_virtual_link(&sender); | 7748 | vl = lookup_virtual_link (&sender); |
7691 | if (NULL != vl) | 7749 | if (NULL != vl) |
7692 | return; | 7750 | return; |
7693 | 7751 | ||
@@ -7696,36 +7754,37 @@ handle_validation_challenge( | |||
7696 | CORE), so we must try to bring the link up! */ | 7754 | CORE), so we must try to bring the link up! */ |
7697 | 7755 | ||
7698 | /* (1) Check existing queues, if any, we may be lucky! */ | 7756 | /* (1) Check existing queues, if any, we may be lucky! */ |
7699 | n = lookup_neighbour(&sender); | 7757 | n = lookup_neighbour (&sender); |
7700 | if (NULL != n) | 7758 | if (NULL != n) |
7701 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) | 7759 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) |
7702 | start_address_validation(&sender, q->address); | 7760 | start_address_validation (&sender, q->address); |
7703 | /* (2) Also try to see if we have addresses in PEERSTORE for this peer | 7761 | /* (2) Also try to see if we have addresses in PEERSTORE for this peer |
7704 | we could use */ | 7762 | we could use */ |
7705 | for (ir = ir_head; NULL != ir; ir = ir->next) | 7763 | for (ir = ir_head; NULL != ir; ir = ir->next) |
7706 | if (0 == GNUNET_memcmp(&ir->pid, &sender)) | 7764 | if (0 == GNUNET_memcmp (&ir->pid, &sender)) |
7707 | return; | 7765 | return; |
7708 | /* we are already trying */ | 7766 | /* we are already trying */ |
7709 | ir = GNUNET_new(struct IncomingRequest); | 7767 | ir = GNUNET_new (struct IncomingRequest); |
7710 | ir->pid = sender; | 7768 | ir->pid = sender; |
7711 | GNUNET_CONTAINER_DLL_insert(ir_head, ir_tail, ir); | 7769 | GNUNET_CONTAINER_DLL_insert (ir_head, ir_tail, ir); |
7712 | ir->wc = GNUNET_PEERSTORE_watch(peerstore, | 7770 | ir->wc = GNUNET_PEERSTORE_watch (peerstore, |
7713 | "transport", | 7771 | "transport", |
7714 | &ir->pid, | 7772 | &ir->pid, |
7715 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, | 7773 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, |
7716 | &handle_hello_for_incoming, | 7774 | &handle_hello_for_incoming, |
7717 | ir); | 7775 | ir); |
7718 | ir_total++; | 7776 | ir_total++; |
7719 | /* Bound attempts we do in parallel here, might otherwise get excessive */ | 7777 | /* Bound attempts we do in parallel here, might otherwise get excessive */ |
7720 | while (ir_total > MAX_INCOMING_REQUEST) | 7778 | while (ir_total > MAX_INCOMING_REQUEST) |
7721 | free_incoming_request(ir_head); | 7779 | free_incoming_request (ir_head); |
7722 | } | 7780 | } |
7723 | 7781 | ||
7724 | 7782 | ||
7725 | /** | 7783 | /** |
7726 | * Closure for #check_known_challenge. | 7784 | * Closure for #check_known_challenge. |
7727 | */ | 7785 | */ |
7728 | struct CheckKnownChallengeContext { | 7786 | struct CheckKnownChallengeContext |
7787 | { | ||
7729 | /** | 7788 | /** |
7730 | * Set to the challenge we are looking for. | 7789 | * Set to the challenge we are looking for. |
7731 | */ | 7790 | */ |
@@ -7748,15 +7807,15 @@ struct CheckKnownChallengeContext { | |||
7748 | * @return #GNUNET_OK if not matching, #GNUNET_NO if match found | 7807 | * @return #GNUNET_OK if not matching, #GNUNET_NO if match found |
7749 | */ | 7808 | */ |
7750 | static int | 7809 | static int |
7751 | check_known_challenge(void *cls, | 7810 | check_known_challenge (void *cls, |
7752 | const struct GNUNET_PeerIdentity *pid, | 7811 | const struct GNUNET_PeerIdentity *pid, |
7753 | void *value) | 7812 | void *value) |
7754 | { | 7813 | { |
7755 | struct CheckKnownChallengeContext *ckac = cls; | 7814 | struct CheckKnownChallengeContext *ckac = cls; |
7756 | struct ValidationState *vs = value; | 7815 | struct ValidationState *vs = value; |
7757 | 7816 | ||
7758 | (void)pid; | 7817 | (void) pid; |
7759 | if (0 != GNUNET_memcmp(&vs->challenge, ckac->challenge)) | 7818 | if (0 != GNUNET_memcmp (&vs->challenge, ckac->challenge)) |
7760 | return GNUNET_OK; | 7819 | return GNUNET_OK; |
7761 | ckac->vs = vs; | 7820 | ckac->vs = vs; |
7762 | return GNUNET_NO; | 7821 | return GNUNET_NO; |
@@ -7771,17 +7830,17 @@ check_known_challenge(void *cls, | |||
7771 | * @param success #GNUNET_YES on success | 7830 | * @param success #GNUNET_YES on success |
7772 | */ | 7831 | */ |
7773 | static void | 7832 | static void |
7774 | peerstore_store_validation_cb(void *cls, int success) | 7833 | peerstore_store_validation_cb (void *cls, int success) |
7775 | { | 7834 | { |
7776 | struct ValidationState *vs = cls; | 7835 | struct ValidationState *vs = cls; |
7777 | 7836 | ||
7778 | vs->sc = NULL; | 7837 | vs->sc = NULL; |
7779 | if (GNUNET_YES == success) | 7838 | if (GNUNET_YES == success) |
7780 | return; | 7839 | return; |
7781 | GNUNET_STATISTICS_update(GST_stats, | 7840 | GNUNET_STATISTICS_update (GST_stats, |
7782 | "# Peerstore failed to store foreign address", | 7841 | "# Peerstore failed to store foreign address", |
7783 | 1, | 7842 | 1, |
7784 | GNUNET_NO); | 7843 | GNUNET_NO); |
7785 | } | 7844 | } |
7786 | 7845 | ||
7787 | 7846 | ||
@@ -7793,19 +7852,19 @@ peerstore_store_validation_cb(void *cls, int success) | |||
7793 | * @return NULL if no such queue exists | 7852 | * @return NULL if no such queue exists |
7794 | */ | 7853 | */ |
7795 | static struct Queue * | 7854 | static struct Queue * |
7796 | find_queue(const struct GNUNET_PeerIdentity *pid, const char *address) | 7855 | find_queue (const struct GNUNET_PeerIdentity *pid, const char *address) |
7797 | { | 7856 | { |
7798 | struct Neighbour *n; | 7857 | struct Neighbour *n; |
7799 | 7858 | ||
7800 | n = lookup_neighbour(pid); | 7859 | n = lookup_neighbour (pid); |
7801 | if (NULL == n) | 7860 | if (NULL == n) |
7802 | return NULL; | 7861 | return NULL; |
7803 | for (struct Queue *pos = n->queue_head; NULL != pos; | 7862 | for (struct Queue *pos = n->queue_head; NULL != pos; |
7804 | pos = pos->next_neighbour) | 7863 | pos = pos->next_neighbour) |
7805 | { | 7864 | { |
7806 | if (0 == strcmp(pos->address, address)) | 7865 | if (0 == strcmp (pos->address, address)) |
7807 | return pos; | 7866 | return pos; |
7808 | } | 7867 | } |
7809 | return NULL; | 7868 | return NULL; |
7810 | } | 7869 | } |
7811 | 7870 | ||
@@ -7819,7 +7878,7 @@ find_queue(const struct GNUNET_PeerIdentity *pid, const char *address) | |||
7819 | * @param tvr the message that was received | 7878 | * @param tvr the message that was received |
7820 | */ | 7879 | */ |
7821 | static void | 7880 | static void |
7822 | handle_validation_response( | 7881 | handle_validation_response ( |
7823 | void *cls, | 7882 | void *cls, |
7824 | const struct TransportValidationResponseMessage *tvr) | 7883 | const struct TransportValidationResponseMessage *tvr) |
7825 | { | 7884 | { |
@@ -7833,147 +7892,147 @@ handle_validation_response( | |||
7833 | struct VirtualLink *vl; | 7892 | struct VirtualLink *vl; |
7834 | 7893 | ||
7835 | /* check this is one of our challenges */ | 7894 | /* check this is one of our challenges */ |
7836 | (void)GNUNET_CONTAINER_multipeermap_get_multiple(validation_map, | 7895 | (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, |
7837 | &cmc->im.sender, | 7896 | &cmc->im.sender, |
7838 | &check_known_challenge, | 7897 | &check_known_challenge, |
7839 | &ckac); | 7898 | &ckac); |
7840 | if (NULL == (vs = ckac.vs)) | 7899 | if (NULL == (vs = ckac.vs)) |
7841 | { | 7900 | { |
7842 | /* This can happen simply if we 'forgot' the challenge by now, | 7901 | /* This can happen simply if we 'forgot' the challenge by now, |
7843 | i.e. because we received the validation response twice */ | 7902 | i.e. because we received the validation response twice */ |
7844 | GNUNET_STATISTICS_update(GST_stats, | 7903 | GNUNET_STATISTICS_update (GST_stats, |
7845 | "# Validations dropped, challenge unknown", | 7904 | "# Validations dropped, challenge unknown", |
7846 | 1, | 7905 | 1, |
7847 | GNUNET_NO); | 7906 | GNUNET_NO); |
7848 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7907 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7849 | "Validation response %s dropped, challenge unknown\n", | 7908 | "Validation response %s dropped, challenge unknown\n", |
7850 | GNUNET_sh2s(&tvr->challenge.value)); | 7909 | GNUNET_sh2s (&tvr->challenge.value)); |
7851 | finish_cmc_handling(cmc); | 7910 | finish_cmc_handling (cmc); |
7852 | return; | 7911 | return; |
7853 | } | 7912 | } |
7854 | 7913 | ||
7855 | /* sanity check on origin time */ | 7914 | /* sanity check on origin time */ |
7856 | origin_time = GNUNET_TIME_absolute_ntoh(tvr->origin_time); | 7915 | origin_time = GNUNET_TIME_absolute_ntoh (tvr->origin_time); |
7857 | if ((origin_time.abs_value_us < vs->first_challenge_use.abs_value_us) || | 7916 | if ((origin_time.abs_value_us < vs->first_challenge_use.abs_value_us) || |
7858 | (origin_time.abs_value_us > vs->last_challenge_use.abs_value_us)) | 7917 | (origin_time.abs_value_us > vs->last_challenge_use.abs_value_us)) |
7859 | { | 7918 | { |
7860 | GNUNET_break_op(0); | 7919 | GNUNET_break_op (0); |
7861 | finish_cmc_handling(cmc); | 7920 | finish_cmc_handling (cmc); |
7862 | return; | 7921 | return; |
7863 | } | 7922 | } |
7864 | 7923 | ||
7865 | { | 7924 | { |
7866 | /* check signature */ | 7925 | /* check signature */ |
7867 | struct TransportValidationPS tvp = | 7926 | struct TransportValidationPS tvp = |
7868 | { .purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE), | 7927 | { .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE), |
7869 | .purpose.size = htonl(sizeof(tvp)), | 7928 | .purpose.size = htonl (sizeof(tvp)), |
7870 | .validity_duration = tvr->validity_duration, | 7929 | .validity_duration = tvr->validity_duration, |
7871 | .challenge = tvr->challenge }; | 7930 | .challenge = tvr->challenge }; |
7872 | 7931 | ||
7873 | if ( | 7932 | if ( |
7874 | GNUNET_OK != | 7933 | GNUNET_OK != |
7875 | GNUNET_CRYPTO_eddsa_verify(GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE, | 7934 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE, |
7876 | &tvp.purpose, | 7935 | &tvp.purpose, |
7877 | &tvr->signature, | 7936 | &tvr->signature, |
7878 | &cmc->im.sender.public_key)) | 7937 | &cmc->im.sender.public_key)) |
7879 | { | 7938 | { |
7880 | GNUNET_break_op(0); | 7939 | GNUNET_break_op (0); |
7881 | finish_cmc_handling(cmc); | 7940 | finish_cmc_handling (cmc); |
7882 | return; | 7941 | return; |
7883 | } | 7942 | } |
7884 | } | 7943 | } |
7885 | 7944 | ||
7886 | /* validity is capped by our willingness to keep track of the | 7945 | /* validity is capped by our willingness to keep track of the |
7887 | validation entry and the maximum the other peer allows */ | 7946 | validation entry and the maximum the other peer allows */ |
7888 | vs->valid_until = GNUNET_TIME_relative_to_absolute( | 7947 | vs->valid_until = GNUNET_TIME_relative_to_absolute ( |
7889 | GNUNET_TIME_relative_min(GNUNET_TIME_relative_ntoh( | 7948 | GNUNET_TIME_relative_min (GNUNET_TIME_relative_ntoh ( |
7890 | tvr->validity_duration), | 7949 | tvr->validity_duration), |
7891 | MAX_ADDRESS_VALID_UNTIL)); | 7950 | MAX_ADDRESS_VALID_UNTIL)); |
7892 | vs->validated_until = | 7951 | vs->validated_until = |
7893 | GNUNET_TIME_absolute_min(vs->valid_until, | 7952 | GNUNET_TIME_absolute_min (vs->valid_until, |
7894 | GNUNET_TIME_relative_to_absolute( | 7953 | GNUNET_TIME_relative_to_absolute ( |
7895 | ADDRESS_VALIDATION_LIFETIME)); | 7954 | ADDRESS_VALIDATION_LIFETIME)); |
7896 | vs->validation_rtt = GNUNET_TIME_absolute_get_duration(origin_time); | 7955 | vs->validation_rtt = GNUNET_TIME_absolute_get_duration (origin_time); |
7897 | vs->challenge_backoff = GNUNET_TIME_UNIT_ZERO; | 7956 | vs->challenge_backoff = GNUNET_TIME_UNIT_ZERO; |
7898 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_NONCE, | 7957 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
7899 | &vs->challenge, | 7958 | &vs->challenge, |
7900 | sizeof(vs->challenge)); | 7959 | sizeof(vs->challenge)); |
7901 | vs->first_challenge_use = GNUNET_TIME_absolute_subtract( | 7960 | vs->first_challenge_use = GNUNET_TIME_absolute_subtract ( |
7902 | vs->validated_until, | 7961 | vs->validated_until, |
7903 | GNUNET_TIME_relative_multiply(vs->validation_rtt, | 7962 | GNUNET_TIME_relative_multiply (vs->validation_rtt, |
7904 | VALIDATION_RTT_BUFFER_FACTOR)); | 7963 | VALIDATION_RTT_BUFFER_FACTOR)); |
7905 | vs->last_challenge_use = | 7964 | vs->last_challenge_use = |
7906 | GNUNET_TIME_UNIT_ZERO_ABS; /* challenge was not yet used */ | 7965 | GNUNET_TIME_UNIT_ZERO_ABS; /* challenge was not yet used */ |
7907 | update_next_challenge_time(vs, vs->first_challenge_use); | 7966 | update_next_challenge_time (vs, vs->first_challenge_use); |
7908 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 7967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7909 | "Validation response %s accepted, address valid until %s\n", | 7968 | "Validation response %s accepted, address valid until %s\n", |
7910 | GNUNET_sh2s(&tvr->challenge.value), | 7969 | GNUNET_sh2s (&tvr->challenge.value), |
7911 | GNUNET_STRINGS_absolute_time_to_string(vs->valid_until)); | 7970 | GNUNET_STRINGS_absolute_time_to_string (vs->valid_until)); |
7912 | vs->sc = GNUNET_PEERSTORE_store(peerstore, | 7971 | vs->sc = GNUNET_PEERSTORE_store (peerstore, |
7913 | "transport", | 7972 | "transport", |
7914 | &cmc->im.sender, | 7973 | &cmc->im.sender, |
7915 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, | 7974 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, |
7916 | vs->address, | 7975 | vs->address, |
7917 | strlen(vs->address) + 1, | 7976 | strlen (vs->address) + 1, |
7918 | vs->valid_until, | 7977 | vs->valid_until, |
7919 | GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, | 7978 | GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, |
7920 | &peerstore_store_validation_cb, | 7979 | &peerstore_store_validation_cb, |
7921 | vs); | 7980 | vs); |
7922 | finish_cmc_handling(cmc); | 7981 | finish_cmc_handling (cmc); |
7923 | 7982 | ||
7924 | /* Finally, we now possibly have a confirmed (!) working queue, | 7983 | /* Finally, we now possibly have a confirmed (!) working queue, |
7925 | update queue status (if queue still is around) */ | 7984 | update queue status (if queue still is around) */ |
7926 | q = find_queue(&vs->pid, vs->address); | 7985 | q = find_queue (&vs->pid, vs->address); |
7927 | if (NULL == q) | 7986 | if (NULL == q) |
7928 | { | 7987 | { |
7929 | GNUNET_STATISTICS_update(GST_stats, | 7988 | GNUNET_STATISTICS_update (GST_stats, |
7930 | "# Queues lost at time of successful validation", | 7989 | "# Queues lost at time of successful validation", |
7931 | 1, | 7990 | 1, |
7932 | GNUNET_NO); | 7991 | GNUNET_NO); |
7933 | return; | 7992 | return; |
7934 | } | 7993 | } |
7935 | q->validated_until = vs->validated_until; | 7994 | q->validated_until = vs->validated_until; |
7936 | q->pd.aged_rtt = vs->validation_rtt; | 7995 | q->pd.aged_rtt = vs->validation_rtt; |
7937 | n = q->neighbour; | 7996 | n = q->neighbour; |
7938 | vl = lookup_virtual_link(&vs->pid); | 7997 | vl = lookup_virtual_link (&vs->pid); |
7939 | if (NULL != vl) | 7998 | if (NULL != vl) |
7999 | { | ||
8000 | /* Link was already up, remember n is also now available and we are done */ | ||
8001 | if (NULL == vl->n) | ||
7940 | { | 8002 | { |
7941 | /* Link was already up, remember n is also now available and we are done */ | 8003 | vl->n = n; |
7942 | if (NULL == vl->n) | 8004 | n->vl = vl; |
7943 | { | 8005 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7944 | vl->n = n; | 8006 | "Virtual link to %s could now also direct neighbour!\n", |
7945 | n->vl = vl; | 8007 | GNUNET_i2s (&vs->pid)); |
7946 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
7947 | "Virtual link to %s could now also direct neighbour!\n", | ||
7948 | GNUNET_i2s(&vs->pid)); | ||
7949 | } | ||
7950 | else | ||
7951 | { | ||
7952 | GNUNET_assert(n == vl->n); | ||
7953 | } | ||
7954 | return; | ||
7955 | } | 8008 | } |
7956 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8009 | else |
7957 | "Creating new virtual link to %s using direct neighbour!\n", | 8010 | { |
7958 | GNUNET_i2s(&vs->pid)); | 8011 | GNUNET_assert (n == vl->n); |
7959 | vl = GNUNET_new(struct VirtualLink); | 8012 | } |
8013 | return; | ||
8014 | } | ||
8015 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
8016 | "Creating new virtual link to %s using direct neighbour!\n", | ||
8017 | GNUNET_i2s (&vs->pid)); | ||
8018 | vl = GNUNET_new (struct VirtualLink); | ||
7960 | vl->target = n->pid; | 8019 | vl->target = n->pid; |
7961 | vl->n = n; | 8020 | vl->n = n; |
7962 | n->vl = vl; | 8021 | n->vl = vl; |
7963 | vl->core_recv_window = RECV_WINDOW_SIZE; | 8022 | vl->core_recv_window = RECV_WINDOW_SIZE; |
7964 | vl->available_fc_window_size = DEFAULT_WINDOW_SIZE; | 8023 | vl->available_fc_window_size = DEFAULT_WINDOW_SIZE; |
7965 | vl->visibility_task = | 8024 | vl->visibility_task = |
7966 | GNUNET_SCHEDULER_add_at(q->validated_until, &check_link_down, vl); | 8025 | GNUNET_SCHEDULER_add_at (q->validated_until, &check_link_down, vl); |
7967 | GNUNET_break(GNUNET_YES == | 8026 | GNUNET_break (GNUNET_YES == |
7968 | GNUNET_CONTAINER_multipeermap_put( | 8027 | GNUNET_CONTAINER_multipeermap_put ( |
7969 | links, | 8028 | links, |
7970 | &vl->target, | 8029 | &vl->target, |
7971 | vl, | 8030 | vl, |
7972 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 8031 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
7973 | consider_sending_fc(vl); | 8032 | consider_sending_fc (vl); |
7974 | /* We lacked a confirmed connection to the target | 8033 | /* We lacked a confirmed connection to the target |
7975 | before, so tell CORE about it (finally!) */ | 8034 | before, so tell CORE about it (finally!) */ |
7976 | cores_send_connect_info(&n->pid); | 8035 | cores_send_connect_info (&n->pid); |
7977 | } | 8036 | } |
7978 | 8037 | ||
7979 | 8038 | ||
@@ -7983,19 +8042,19 @@ handle_validation_response( | |||
7983 | * @param im the send message that was received | 8042 | * @param im the send message that was received |
7984 | */ | 8043 | */ |
7985 | static void | 8044 | static void |
7986 | handle_incoming_msg(void *cls, | 8045 | handle_incoming_msg (void *cls, |
7987 | const struct GNUNET_TRANSPORT_IncomingMessage *im) | 8046 | const struct GNUNET_TRANSPORT_IncomingMessage *im) |
7988 | { | 8047 | { |
7989 | struct TransportClient *tc = cls; | 8048 | struct TransportClient *tc = cls; |
7990 | struct CommunicatorMessageContext *cmc = | 8049 | struct CommunicatorMessageContext *cmc = |
7991 | GNUNET_new(struct CommunicatorMessageContext); | 8050 | GNUNET_new (struct CommunicatorMessageContext); |
7992 | 8051 | ||
7993 | cmc->tc = tc; | 8052 | cmc->tc = tc; |
7994 | cmc->im = *im; | 8053 | cmc->im = *im; |
7995 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8054 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
7996 | "Received message via communicator from peer %s\n", | 8055 | "Received message via communicator from peer %s\n", |
7997 | GNUNET_i2s(&im->sender)); | 8056 | GNUNET_i2s (&im->sender)); |
7998 | demultiplex_with_cmc(cmc, (const struct GNUNET_MessageHeader *)&im[1]); | 8057 | demultiplex_with_cmc (cmc, (const struct GNUNET_MessageHeader *) &im[1]); |
7999 | } | 8058 | } |
8000 | 8059 | ||
8001 | 8060 | ||
@@ -8008,7 +8067,7 @@ handle_incoming_msg(void *cls, | |||
8008 | * @param fc the message that was received | 8067 | * @param fc the message that was received |
8009 | */ | 8068 | */ |
8010 | static void | 8069 | static void |
8011 | handle_flow_control(void *cls, const struct TransportFlowControlMessage *fc) | 8070 | handle_flow_control (void *cls, const struct TransportFlowControlMessage *fc) |
8012 | { | 8071 | { |
8013 | struct CommunicatorMessageContext *cmc = cls; | 8072 | struct CommunicatorMessageContext *cmc = cls; |
8014 | struct VirtualLink *vl; | 8073 | struct VirtualLink *vl; |
@@ -8017,70 +8076,70 @@ handle_flow_control(void *cls, const struct TransportFlowControlMessage *fc) | |||
8017 | uint64_t os; | 8076 | uint64_t os; |
8018 | uint64_t wnd; | 8077 | uint64_t wnd; |
8019 | 8078 | ||
8020 | vl = lookup_virtual_link(&cmc->im.sender); | 8079 | vl = lookup_virtual_link (&cmc->im.sender); |
8021 | if (NULL == vl) | 8080 | if (NULL == vl) |
8022 | { | 8081 | { |
8023 | GNUNET_STATISTICS_update(GST_stats, | 8082 | GNUNET_STATISTICS_update (GST_stats, |
8024 | "# FC dropped: virtual link unknown", | 8083 | "# FC dropped: virtual link unknown", |
8025 | 1, | 8084 | 1, |
8026 | GNUNET_NO); | 8085 | GNUNET_NO); |
8027 | finish_cmc_handling(cmc); | 8086 | finish_cmc_handling (cmc); |
8028 | return; | 8087 | return; |
8029 | } | 8088 | } |
8030 | st = GNUNET_TIME_absolute_ntoh(fc->sender_time); | 8089 | st = GNUNET_TIME_absolute_ntoh (fc->sender_time); |
8031 | if (st.abs_value_us < vl->last_fc_timestamp.abs_value_us) | 8090 | if (st.abs_value_us < vl->last_fc_timestamp.abs_value_us) |
8032 | { | 8091 | { |
8033 | /* out of order, drop */ | 8092 | /* out of order, drop */ |
8034 | GNUNET_STATISTICS_update(GST_stats, | 8093 | GNUNET_STATISTICS_update (GST_stats, |
8035 | "# FC dropped: message out of order", | 8094 | "# FC dropped: message out of order", |
8036 | 1, | 8095 | 1, |
8037 | GNUNET_NO); | 8096 | GNUNET_NO); |
8038 | finish_cmc_handling(cmc); | 8097 | finish_cmc_handling (cmc); |
8039 | return; | 8098 | return; |
8040 | } | 8099 | } |
8041 | seq = ntohl(fc->seq); | 8100 | seq = ntohl (fc->seq); |
8042 | if (seq < vl->last_fc_seq) | 8101 | if (seq < vl->last_fc_seq) |
8043 | { | 8102 | { |
8044 | /* Wrap-around/reset of other peer; start all counters from zero */ | 8103 | /* Wrap-around/reset of other peer; start all counters from zero */ |
8045 | vl->outbound_fc_window_size_used = 0; | 8104 | vl->outbound_fc_window_size_used = 0; |
8046 | } | 8105 | } |
8047 | vl->last_fc_seq = seq; | 8106 | vl->last_fc_seq = seq; |
8048 | vl->last_fc_timestamp = st; | 8107 | vl->last_fc_timestamp = st; |
8049 | vl->outbound_fc_window_size = GNUNET_ntohll(fc->inbound_window_size); | 8108 | vl->outbound_fc_window_size = GNUNET_ntohll (fc->inbound_window_size); |
8050 | os = GNUNET_ntohll(fc->outbound_sent); | 8109 | os = GNUNET_ntohll (fc->outbound_sent); |
8051 | vl->incoming_fc_window_size_loss = | 8110 | vl->incoming_fc_window_size_loss = |
8052 | (int64_t)(os - vl->incoming_fc_window_size_used); | 8111 | (int64_t) (os - vl->incoming_fc_window_size_used); |
8053 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8054 | "Received FC from %s, seq %u, new window %llu (loss at %lld)\n", | 8113 | "Received FC from %s, seq %u, new window %llu (loss at %lld)\n", |
8055 | GNUNET_i2s(&vl->target), | 8114 | GNUNET_i2s (&vl->target), |
8056 | (unsigned int)seq, | 8115 | (unsigned int) seq, |
8057 | (unsigned long long)vl->outbound_fc_window_size, | 8116 | (unsigned long long) vl->outbound_fc_window_size, |
8058 | (long long)vl->incoming_fc_window_size_loss); | 8117 | (long long) vl->incoming_fc_window_size_loss); |
8059 | wnd = GNUNET_ntohll(fc->outbound_window_size); | 8118 | wnd = GNUNET_ntohll (fc->outbound_window_size); |
8060 | if ((wnd < vl->incoming_fc_window_size) || | 8119 | if ((wnd < vl->incoming_fc_window_size) || |
8061 | (vl->last_outbound_window_size_received != wnd) || | 8120 | (vl->last_outbound_window_size_received != wnd) || |
8062 | (0 == GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX) % | 8121 | (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX) |
8063 | FC_NO_CHANGE_REPLY_PROBABILITY)) | 8122 | % FC_NO_CHANGE_REPLY_PROBABILITY)) |
8064 | { | 8123 | { |
8065 | /* Consider re-sending our FC message, as clearly the | 8124 | /* Consider re-sending our FC message, as clearly the |
8066 | other peer's idea of the window is not up-to-date */ | 8125 | other peer's idea of the window is not up-to-date */ |
8067 | consider_sending_fc(vl); | 8126 | consider_sending_fc (vl); |
8068 | } | 8127 | } |
8069 | if ((wnd == vl->incoming_fc_window_size) && | 8128 | if ((wnd == vl->incoming_fc_window_size) && |
8070 | (vl->last_outbound_window_size_received == wnd) && | 8129 | (vl->last_outbound_window_size_received == wnd) && |
8071 | (NULL != vl->fc_retransmit_task)) | 8130 | (NULL != vl->fc_retransmit_task)) |
8072 | { | 8131 | { |
8073 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8074 | "Stopping FC retransmission to %s: peer is current at window %llu\n", | 8133 | "Stopping FC retransmission to %s: peer is current at window %llu\n", |
8075 | GNUNET_i2s(&vl->target), | 8134 | GNUNET_i2s (&vl->target), |
8076 | (unsigned long long)wnd); | 8135 | (unsigned long long) wnd); |
8077 | GNUNET_SCHEDULER_cancel(vl->fc_retransmit_task); | 8136 | GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task); |
8078 | vl->fc_retransmit_task = NULL; | 8137 | vl->fc_retransmit_task = NULL; |
8079 | } | 8138 | } |
8080 | vl->last_outbound_window_size_received = wnd; | 8139 | vl->last_outbound_window_size_received = wnd; |
8081 | /* FC window likely increased, check transmission possibilities! */ | 8140 | /* FC window likely increased, check transmission possibilities! */ |
8082 | check_vl_transmission(vl); | 8141 | check_vl_transmission (vl); |
8083 | finish_cmc_handling(cmc); | 8142 | finish_cmc_handling (cmc); |
8084 | } | 8143 | } |
8085 | 8144 | ||
8086 | 8145 | ||
@@ -8092,68 +8151,68 @@ handle_flow_control(void *cls, const struct TransportFlowControlMessage *fc) | |||
8092 | * @param msg message to demultiplex | 8151 | * @param msg message to demultiplex |
8093 | */ | 8152 | */ |
8094 | static void | 8153 | static void |
8095 | demultiplex_with_cmc(struct CommunicatorMessageContext *cmc, | 8154 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, |
8096 | const struct GNUNET_MessageHeader *msg) | 8155 | const struct GNUNET_MessageHeader *msg) |
8097 | { | 8156 | { |
8098 | struct GNUNET_MQ_MessageHandler handlers[] = | 8157 | struct GNUNET_MQ_MessageHandler handlers[] = |
8099 | { GNUNET_MQ_hd_var_size(fragment_box, | 8158 | { GNUNET_MQ_hd_var_size (fragment_box, |
8100 | GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT, | 8159 | GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT, |
8101 | struct TransportFragmentBoxMessage, | 8160 | struct TransportFragmentBoxMessage, |
8102 | &cmc), | 8161 | &cmc), |
8103 | GNUNET_MQ_hd_var_size(reliability_box, | 8162 | GNUNET_MQ_hd_var_size (reliability_box, |
8104 | GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX, | 8163 | GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX, |
8105 | struct TransportReliabilityBoxMessage, | 8164 | struct TransportReliabilityBoxMessage, |
8106 | &cmc), | 8165 | &cmc), |
8107 | GNUNET_MQ_hd_var_size(reliability_ack, | 8166 | GNUNET_MQ_hd_var_size (reliability_ack, |
8108 | GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK, | 8167 | GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK, |
8109 | struct TransportReliabilityAckMessage, | 8168 | struct TransportReliabilityAckMessage, |
8110 | &cmc), | 8169 | &cmc), |
8111 | GNUNET_MQ_hd_var_size(backchannel_encapsulation, | 8170 | GNUNET_MQ_hd_var_size (backchannel_encapsulation, |
8112 | GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION, | 8171 | GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION, |
8113 | struct TransportBackchannelEncapsulationMessage, | 8172 | struct TransportBackchannelEncapsulationMessage, |
8114 | &cmc), | 8173 | &cmc), |
8115 | GNUNET_MQ_hd_var_size(dv_learn, | 8174 | GNUNET_MQ_hd_var_size (dv_learn, |
8116 | GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN, | 8175 | GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN, |
8117 | struct TransportDVLearnMessage, | 8176 | struct TransportDVLearnMessage, |
8118 | &cmc), | 8177 | &cmc), |
8119 | GNUNET_MQ_hd_var_size(dv_box, | 8178 | GNUNET_MQ_hd_var_size (dv_box, |
8120 | GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX, | 8179 | GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX, |
8121 | struct TransportDVBoxMessage, | 8180 | struct TransportDVBoxMessage, |
8122 | &cmc), | 8181 | &cmc), |
8123 | GNUNET_MQ_hd_fixed_size( | 8182 | GNUNET_MQ_hd_fixed_size ( |
8124 | validation_challenge, | 8183 | validation_challenge, |
8125 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE, | 8184 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE, |
8126 | struct TransportValidationChallengeMessage, | 8185 | struct TransportValidationChallengeMessage, |
8127 | &cmc), | 8186 | &cmc), |
8128 | GNUNET_MQ_hd_fixed_size(flow_control, | 8187 | GNUNET_MQ_hd_fixed_size (flow_control, |
8129 | GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL, | 8188 | GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL, |
8130 | struct TransportFlowControlMessage, | 8189 | struct TransportFlowControlMessage, |
8131 | &cmc), | 8190 | &cmc), |
8132 | GNUNET_MQ_hd_fixed_size( | 8191 | GNUNET_MQ_hd_fixed_size ( |
8133 | validation_response, | 8192 | validation_response, |
8134 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE, | 8193 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE, |
8135 | struct TransportValidationResponseMessage, | 8194 | struct TransportValidationResponseMessage, |
8136 | &cmc), | 8195 | &cmc), |
8137 | GNUNET_MQ_handler_end() }; | 8196 | GNUNET_MQ_handler_end () }; |
8138 | int ret; | 8197 | int ret; |
8139 | 8198 | ||
8140 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8141 | "Handling message of type %u with %u bytes\n", | 8200 | "Handling message of type %u with %u bytes\n", |
8142 | (unsigned int)ntohs(msg->type), | 8201 | (unsigned int) ntohs (msg->type), |
8143 | (unsigned int)ntohs(msg->size)); | 8202 | (unsigned int) ntohs (msg->size)); |
8144 | ret = GNUNET_MQ_handle_message(handlers, msg); | 8203 | ret = GNUNET_MQ_handle_message (handlers, msg); |
8145 | if (GNUNET_SYSERR == ret) | 8204 | if (GNUNET_SYSERR == ret) |
8146 | { | 8205 | { |
8147 | GNUNET_break(0); | 8206 | GNUNET_break (0); |
8148 | GNUNET_SERVICE_client_drop(cmc->tc->client); | 8207 | GNUNET_SERVICE_client_drop (cmc->tc->client); |
8149 | GNUNET_free(cmc); | 8208 | GNUNET_free (cmc); |
8150 | return; | 8209 | return; |
8151 | } | 8210 | } |
8152 | if (GNUNET_NO == ret) | 8211 | if (GNUNET_NO == ret) |
8153 | { | 8212 | { |
8154 | /* unencapsulated 'raw' message */ | 8213 | /* unencapsulated 'raw' message */ |
8155 | handle_raw_message(&cmc, msg); | 8214 | handle_raw_message (&cmc, msg); |
8156 | } | 8215 | } |
8157 | } | 8216 | } |
8158 | 8217 | ||
8159 | 8218 | ||
@@ -8164,17 +8223,17 @@ demultiplex_with_cmc(struct CommunicatorMessageContext *cmc, | |||
8164 | * @param aqm the send message that was sent | 8223 | * @param aqm the send message that was sent |
8165 | */ | 8224 | */ |
8166 | static int | 8225 | static int |
8167 | check_add_queue_message(void *cls, | 8226 | check_add_queue_message (void *cls, |
8168 | const struct GNUNET_TRANSPORT_AddQueueMessage *aqm) | 8227 | const struct GNUNET_TRANSPORT_AddQueueMessage *aqm) |
8169 | { | 8228 | { |
8170 | struct TransportClient *tc = cls; | 8229 | struct TransportClient *tc = cls; |
8171 | 8230 | ||
8172 | if (CT_COMMUNICATOR != tc->type) | 8231 | if (CT_COMMUNICATOR != tc->type) |
8173 | { | 8232 | { |
8174 | GNUNET_break(0); | 8233 | GNUNET_break (0); |
8175 | return GNUNET_SYSERR; | 8234 | return GNUNET_SYSERR; |
8176 | } | 8235 | } |
8177 | GNUNET_MQ_check_zero_termination(aqm); | 8236 | GNUNET_MQ_check_zero_termination (aqm); |
8178 | return GNUNET_OK; | 8237 | return GNUNET_OK; |
8179 | } | 8238 | } |
8180 | 8239 | ||
@@ -8185,7 +8244,7 @@ check_add_queue_message(void *cls, | |||
8185 | * @param pm pending message to generate UUID for. | 8244 | * @param pm pending message to generate UUID for. |
8186 | */ | 8245 | */ |
8187 | static void | 8246 | static void |
8188 | set_pending_message_uuid(struct PendingMessage *pm) | 8247 | set_pending_message_uuid (struct PendingMessage *pm) |
8189 | { | 8248 | { |
8190 | if (pm->msg_uuid_set) | 8249 | if (pm->msg_uuid_set) |
8191 | return; | 8250 | return; |
@@ -8203,37 +8262,37 @@ set_pending_message_uuid(struct PendingMessage *pm) | |||
8203 | * @return corresponding fresh pending acknowledgement | 8262 | * @return corresponding fresh pending acknowledgement |
8204 | */ | 8263 | */ |
8205 | static struct PendingAcknowledgement * | 8264 | static struct PendingAcknowledgement * |
8206 | prepare_pending_acknowledgement(struct Queue *queue, | 8265 | prepare_pending_acknowledgement (struct Queue *queue, |
8207 | struct DistanceVectorHop *dvh, | 8266 | struct DistanceVectorHop *dvh, |
8208 | struct PendingMessage *pm) | 8267 | struct PendingMessage *pm) |
8209 | { | 8268 | { |
8210 | struct PendingAcknowledgement *pa; | 8269 | struct PendingAcknowledgement *pa; |
8211 | 8270 | ||
8212 | pa = GNUNET_new(struct PendingAcknowledgement); | 8271 | pa = GNUNET_new (struct PendingAcknowledgement); |
8213 | pa->queue = queue; | 8272 | pa->queue = queue; |
8214 | pa->dvh = dvh; | 8273 | pa->dvh = dvh; |
8215 | pa->pm = pm; | 8274 | pa->pm = pm; |
8216 | do | 8275 | do |
8217 | { | 8276 | { |
8218 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_NONCE, | 8277 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
8219 | &pa->ack_uuid, | 8278 | &pa->ack_uuid, |
8220 | sizeof(pa->ack_uuid)); | 8279 | sizeof(pa->ack_uuid)); |
8221 | } | 8280 | } |
8222 | while (GNUNET_YES != GNUNET_CONTAINER_multiuuidmap_put( | 8281 | while (GNUNET_YES != GNUNET_CONTAINER_multiuuidmap_put ( |
8223 | pending_acks, | 8282 | pending_acks, |
8224 | &pa->ack_uuid.value, | 8283 | &pa->ack_uuid.value, |
8225 | pa, | 8284 | pa, |
8226 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 8285 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
8227 | GNUNET_CONTAINER_MDLL_insert(queue, queue->pa_head, queue->pa_tail, pa); | 8286 | GNUNET_CONTAINER_MDLL_insert (queue, queue->pa_head, queue->pa_tail, pa); |
8228 | GNUNET_CONTAINER_MDLL_insert(pm, pm->pa_head, pm->pa_tail, pa); | 8287 | GNUNET_CONTAINER_MDLL_insert (pm, pm->pa_head, pm->pa_tail, pa); |
8229 | if (NULL != dvh) | 8288 | if (NULL != dvh) |
8230 | GNUNET_CONTAINER_MDLL_insert(dvh, dvh->pa_head, dvh->pa_tail, pa); | 8289 | GNUNET_CONTAINER_MDLL_insert (dvh, dvh->pa_head, dvh->pa_tail, pa); |
8231 | pa->transmission_time = GNUNET_TIME_absolute_get(); | 8290 | pa->transmission_time = GNUNET_TIME_absolute_get (); |
8232 | pa->message_size = pm->bytes_msg; | 8291 | pa->message_size = pm->bytes_msg; |
8233 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8292 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8234 | "Waiting for ACKnowledgment `%s' for <%llu>\n", | 8293 | "Waiting for ACKnowledgment `%s' for <%llu>\n", |
8235 | GNUNET_uuid2s(&pa->ack_uuid.value), | 8294 | GNUNET_uuid2s (&pa->ack_uuid.value), |
8236 | pm->logging_uuid); | 8295 | pm->logging_uuid); |
8237 | return pa; | 8296 | return pa; |
8238 | } | 8297 | } |
8239 | 8298 | ||
@@ -8250,9 +8309,9 @@ prepare_pending_acknowledgement(struct Queue *queue, | |||
8250 | * @return new message to transmit | 8309 | * @return new message to transmit |
8251 | */ | 8310 | */ |
8252 | static struct PendingMessage * | 8311 | static struct PendingMessage * |
8253 | fragment_message(struct Queue *queue, | 8312 | fragment_message (struct Queue *queue, |
8254 | struct DistanceVectorHop *dvh, | 8313 | struct DistanceVectorHop *dvh, |
8255 | struct PendingMessage *pm) | 8314 | struct PendingMessage *pm) |
8256 | { | 8315 | { |
8257 | struct PendingAcknowledgement *pa; | 8316 | struct PendingAcknowledgement *pa; |
8258 | struct PendingMessage *ff; | 8317 | struct PendingMessage *ff; |
@@ -8261,17 +8320,17 @@ fragment_message(struct Queue *queue, | |||
8261 | mtu = (0 == queue->mtu) | 8320 | mtu = (0 == queue->mtu) |
8262 | ? UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) | 8321 | ? UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) |
8263 | : queue->mtu; | 8322 | : queue->mtu; |
8264 | set_pending_message_uuid(pm); | 8323 | set_pending_message_uuid (pm); |
8265 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8266 | "Fragmenting message %llu <%llu> to %s for MTU %u\n", | 8325 | "Fragmenting message %llu <%llu> to %s for MTU %u\n", |
8267 | (unsigned long long)pm->msg_uuid.uuid, | 8326 | (unsigned long long) pm->msg_uuid.uuid, |
8268 | pm->logging_uuid, | 8327 | pm->logging_uuid, |
8269 | GNUNET_i2s(&pm->vl->target), | 8328 | GNUNET_i2s (&pm->vl->target), |
8270 | (unsigned int)mtu); | 8329 | (unsigned int) mtu); |
8271 | pa = prepare_pending_acknowledgement(queue, dvh, pm); | 8330 | pa = prepare_pending_acknowledgement (queue, dvh, pm); |
8272 | 8331 | ||
8273 | /* This invariant is established in #handle_add_queue_message() */ | 8332 | /* This invariant is established in #handle_add_queue_message() */ |
8274 | GNUNET_assert(mtu > sizeof(struct TransportFragmentBoxMessage)); | 8333 | GNUNET_assert (mtu > sizeof(struct TransportFragmentBoxMessage)); |
8275 | 8334 | ||
8276 | /* select fragment for transmission, descending the tree if it has | 8335 | /* select fragment for transmission, descending the tree if it has |
8277 | been expanded until we are at a leaf or at a fragment that is small | 8336 | been expanded until we are at a leaf or at a fragment that is small |
@@ -8280,68 +8339,68 @@ fragment_message(struct Queue *queue, | |||
8280 | ff = pm; | 8339 | ff = pm; |
8281 | while (((ff->bytes_msg > mtu) || (pm == ff)) && | 8340 | while (((ff->bytes_msg > mtu) || (pm == ff)) && |
8282 | (ff->frag_off == ff->bytes_msg) && (NULL != ff->head_frag)) | 8341 | (ff->frag_off == ff->bytes_msg) && (NULL != ff->head_frag)) |
8283 | { | 8342 | { |
8284 | ff = ff->head_frag; /* descent into fragmented fragments */ | 8343 | ff = ff->head_frag; /* descent into fragmented fragments */ |
8285 | } | 8344 | } |
8286 | 8345 | ||
8287 | if (((ff->bytes_msg > mtu) || (pm == ff)) && (pm->frag_off < pm->bytes_msg)) | 8346 | if (((ff->bytes_msg > mtu) || (pm == ff)) && (pm->frag_off < pm->bytes_msg)) |
8288 | { | 8347 | { |
8289 | /* Did not yet calculate all fragments, calculate next fragment */ | 8348 | /* Did not yet calculate all fragments, calculate next fragment */ |
8290 | struct PendingMessage *frag; | 8349 | struct PendingMessage *frag; |
8291 | struct TransportFragmentBoxMessage tfb; | 8350 | struct TransportFragmentBoxMessage tfb; |
8292 | const char *orig; | 8351 | const char *orig; |
8293 | char *msg; | 8352 | char *msg; |
8294 | uint16_t fragmax; | 8353 | uint16_t fragmax; |
8295 | uint16_t fragsize; | 8354 | uint16_t fragsize; |
8296 | uint16_t msize; | 8355 | uint16_t msize; |
8297 | uint16_t xoff = 0; | 8356 | uint16_t xoff = 0; |
8298 | 8357 | ||
8299 | orig = (const char *)&ff[1]; | 8358 | orig = (const char *) &ff[1]; |
8300 | msize = ff->bytes_msg; | 8359 | msize = ff->bytes_msg; |
8301 | if (pm != ff) | 8360 | if (pm != ff) |
8302 | { | 8361 | { |
8303 | const struct TransportFragmentBoxMessage *tfbo; | 8362 | const struct TransportFragmentBoxMessage *tfbo; |
8304 | 8363 | ||
8305 | tfbo = (const struct TransportFragmentBoxMessage *)orig; | 8364 | tfbo = (const struct TransportFragmentBoxMessage *) orig; |
8306 | orig += sizeof(struct TransportFragmentBoxMessage); | 8365 | orig += sizeof(struct TransportFragmentBoxMessage); |
8307 | msize -= sizeof(struct TransportFragmentBoxMessage); | 8366 | msize -= sizeof(struct TransportFragmentBoxMessage); |
8308 | xoff = ntohs(tfbo->frag_off); | 8367 | xoff = ntohs (tfbo->frag_off); |
8309 | } | 8368 | } |
8310 | fragmax = mtu - sizeof(struct TransportFragmentBoxMessage); | 8369 | fragmax = mtu - sizeof(struct TransportFragmentBoxMessage); |
8311 | fragsize = GNUNET_MIN(msize - ff->frag_off, fragmax); | 8370 | fragsize = GNUNET_MIN (msize - ff->frag_off, fragmax); |
8312 | frag = | 8371 | frag = |
8313 | GNUNET_malloc(sizeof(struct PendingMessage) + | 8372 | GNUNET_malloc (sizeof(struct PendingMessage) |
8314 | sizeof(struct TransportFragmentBoxMessage) + fragsize); | 8373 | + sizeof(struct TransportFragmentBoxMessage) + fragsize); |
8315 | frag->logging_uuid = logging_uuid_gen++; | 8374 | frag->logging_uuid = logging_uuid_gen++; |
8316 | frag->vl = pm->vl; | 8375 | frag->vl = pm->vl; |
8317 | frag->frag_parent = ff; | 8376 | frag->frag_parent = ff; |
8318 | frag->timeout = pm->timeout; | 8377 | frag->timeout = pm->timeout; |
8319 | frag->bytes_msg = sizeof(struct TransportFragmentBoxMessage) + fragsize; | 8378 | frag->bytes_msg = sizeof(struct TransportFragmentBoxMessage) + fragsize; |
8320 | frag->pmt = PMT_FRAGMENT_BOX; | 8379 | frag->pmt = PMT_FRAGMENT_BOX; |
8321 | msg = (char *)&frag[1]; | 8380 | msg = (char *) &frag[1]; |
8322 | tfb.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT); | 8381 | tfb.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT); |
8323 | tfb.header.size = | 8382 | tfb.header.size = |
8324 | htons(sizeof(struct TransportFragmentBoxMessage) + fragsize); | 8383 | htons (sizeof(struct TransportFragmentBoxMessage) + fragsize); |
8325 | tfb.ack_uuid = pa->ack_uuid; | 8384 | tfb.ack_uuid = pa->ack_uuid; |
8326 | tfb.msg_uuid = pm->msg_uuid; | 8385 | tfb.msg_uuid = pm->msg_uuid; |
8327 | tfb.frag_off = htons(ff->frag_off + xoff); | 8386 | tfb.frag_off = htons (ff->frag_off + xoff); |
8328 | tfb.msg_size = htons(pm->bytes_msg); | 8387 | tfb.msg_size = htons (pm->bytes_msg); |
8329 | memcpy(msg, &tfb, sizeof(tfb)); | 8388 | memcpy (msg, &tfb, sizeof(tfb)); |
8330 | memcpy(&msg[sizeof(tfb)], &orig[ff->frag_off], fragsize); | 8389 | memcpy (&msg[sizeof(tfb)], &orig[ff->frag_off], fragsize); |
8331 | GNUNET_CONTAINER_MDLL_insert(frag, ff->head_frag, ff->tail_frag, frag); | 8390 | GNUNET_CONTAINER_MDLL_insert (frag, ff->head_frag, ff->tail_frag, frag); |
8332 | ff->frag_off += fragsize; | 8391 | ff->frag_off += fragsize; |
8333 | ff = frag; | 8392 | ff = frag; |
8334 | } | 8393 | } |
8335 | 8394 | ||
8336 | /* Move head to the tail and return it */ | 8395 | /* Move head to the tail and return it */ |
8337 | GNUNET_CONTAINER_MDLL_remove(frag, | 8396 | GNUNET_CONTAINER_MDLL_remove (frag, |
8338 | ff->frag_parent->head_frag, | 8397 | ff->frag_parent->head_frag, |
8339 | ff->frag_parent->tail_frag, | 8398 | ff->frag_parent->tail_frag, |
8340 | ff); | 8399 | ff); |
8341 | GNUNET_CONTAINER_MDLL_insert_tail(frag, | 8400 | GNUNET_CONTAINER_MDLL_insert_tail (frag, |
8342 | ff->frag_parent->head_frag, | 8401 | ff->frag_parent->head_frag, |
8343 | ff->frag_parent->tail_frag, | 8402 | ff->frag_parent->tail_frag, |
8344 | ff); | 8403 | ff); |
8345 | return ff; | 8404 | return ff; |
8346 | } | 8405 | } |
8347 | 8406 | ||
@@ -8359,9 +8418,9 @@ fragment_message(struct Queue *queue, | |||
8359 | * @return new message to transmit | 8418 | * @return new message to transmit |
8360 | */ | 8419 | */ |
8361 | static struct PendingMessage * | 8420 | static struct PendingMessage * |
8362 | reliability_box_message(struct Queue *queue, | 8421 | reliability_box_message (struct Queue *queue, |
8363 | struct DistanceVectorHop *dvh, | 8422 | struct DistanceVectorHop *dvh, |
8364 | struct PendingMessage *pm) | 8423 | struct PendingMessage *pm) |
8365 | { | 8424 | { |
8366 | struct TransportReliabilityBoxMessage rbox; | 8425 | struct TransportReliabilityBoxMessage rbox; |
8367 | struct PendingAcknowledgement *pa; | 8426 | struct PendingAcknowledgement *pa; |
@@ -8373,39 +8432,39 @@ reliability_box_message(struct Queue *queue, | |||
8373 | do nothing */ | 8432 | do nothing */ |
8374 | if (NULL != pm->bpm) | 8433 | if (NULL != pm->bpm) |
8375 | return pm->bpm; /* already computed earlier: do nothing */ | 8434 | return pm->bpm; /* already computed earlier: do nothing */ |
8376 | GNUNET_assert(NULL == pm->head_frag); | 8435 | GNUNET_assert (NULL == pm->head_frag); |
8377 | if (pm->bytes_msg + sizeof(rbox) > UINT16_MAX) | 8436 | if (pm->bytes_msg + sizeof(rbox) > UINT16_MAX) |
8378 | { | 8437 | { |
8379 | /* failed hard */ | 8438 | /* failed hard */ |
8380 | GNUNET_break(0); | 8439 | GNUNET_break (0); |
8381 | client_send_response(pm); | 8440 | client_send_response (pm); |
8382 | return NULL; | 8441 | return NULL; |
8383 | } | 8442 | } |
8384 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8385 | "Preparing reliability box for message <%llu> to %s on queue %s\n", | 8444 | "Preparing reliability box for message <%llu> to %s on queue %s\n", |
8386 | pm->logging_uuid, | 8445 | pm->logging_uuid, |
8387 | GNUNET_i2s(&pm->vl->target), | 8446 | GNUNET_i2s (&pm->vl->target), |
8388 | queue->address); | 8447 | queue->address); |
8389 | pa = prepare_pending_acknowledgement(queue, dvh, pm); | 8448 | pa = prepare_pending_acknowledgement (queue, dvh, pm); |
8390 | 8449 | ||
8391 | bpm = GNUNET_malloc(sizeof(struct PendingMessage) + sizeof(rbox) + | 8450 | bpm = GNUNET_malloc (sizeof(struct PendingMessage) + sizeof(rbox) |
8392 | pm->bytes_msg); | 8451 | + pm->bytes_msg); |
8393 | bpm->logging_uuid = logging_uuid_gen++; | 8452 | bpm->logging_uuid = logging_uuid_gen++; |
8394 | bpm->vl = pm->vl; | 8453 | bpm->vl = pm->vl; |
8395 | bpm->frag_parent = pm; | 8454 | bpm->frag_parent = pm; |
8396 | GNUNET_CONTAINER_MDLL_insert(frag, pm->head_frag, pm->tail_frag, bpm); | 8455 | GNUNET_CONTAINER_MDLL_insert (frag, pm->head_frag, pm->tail_frag, bpm); |
8397 | bpm->timeout = pm->timeout; | 8456 | bpm->timeout = pm->timeout; |
8398 | bpm->pmt = PMT_RELIABILITY_BOX; | 8457 | bpm->pmt = PMT_RELIABILITY_BOX; |
8399 | bpm->bytes_msg = pm->bytes_msg + sizeof(rbox); | 8458 | bpm->bytes_msg = pm->bytes_msg + sizeof(rbox); |
8400 | set_pending_message_uuid(bpm); | 8459 | set_pending_message_uuid (bpm); |
8401 | rbox.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX); | 8460 | rbox.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX); |
8402 | rbox.header.size = htons(sizeof(rbox) + pm->bytes_msg); | 8461 | rbox.header.size = htons (sizeof(rbox) + pm->bytes_msg); |
8403 | rbox.ack_countdown = htonl(0); // FIXME: implement ACK countdown support | 8462 | rbox.ack_countdown = htonl (0); // FIXME: implement ACK countdown support |
8404 | 8463 | ||
8405 | rbox.ack_uuid = pa->ack_uuid; | 8464 | rbox.ack_uuid = pa->ack_uuid; |
8406 | msg = (char *)&bpm[1]; | 8465 | msg = (char *) &bpm[1]; |
8407 | memcpy(msg, &rbox, sizeof(rbox)); | 8466 | memcpy (msg, &rbox, sizeof(rbox)); |
8408 | memcpy(&msg[sizeof(rbox)], &pm[1], pm->bytes_msg); | 8467 | memcpy (&msg[sizeof(rbox)], &pm[1], pm->bytes_msg); |
8409 | pm->bpm = bpm; | 8468 | pm->bpm = bpm; |
8410 | return bpm; | 8469 | return bpm; |
8411 | } | 8470 | } |
@@ -8420,60 +8479,61 @@ reliability_box_message(struct Queue *queue, | |||
8420 | * @param next_attempt timestamp to use | 8479 | * @param next_attempt timestamp to use |
8421 | */ | 8480 | */ |
8422 | static void | 8481 | static void |
8423 | update_pm_next_attempt(struct PendingMessage *pm, | 8482 | update_pm_next_attempt (struct PendingMessage *pm, |
8424 | struct GNUNET_TIME_Absolute next_attempt) | 8483 | struct GNUNET_TIME_Absolute next_attempt) |
8425 | { | 8484 | { |
8426 | struct VirtualLink *vl = pm->vl; | 8485 | struct VirtualLink *vl = pm->vl; |
8427 | 8486 | ||
8428 | pm->next_attempt = next_attempt; | 8487 | pm->next_attempt = next_attempt; |
8429 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8430 | "Next attempt for message <%llu> set to %s\n", | 8489 | "Next attempt for message <%llu> set to %s\n", |
8431 | pm->logging_uuid, | 8490 | pm->logging_uuid, |
8432 | GNUNET_STRINGS_absolute_time_to_string(next_attempt)); | 8491 | GNUNET_STRINGS_absolute_time_to_string (next_attempt)); |
8433 | 8492 | ||
8434 | if (NULL == pm->frag_parent) | 8493 | if (NULL == pm->frag_parent) |
8435 | { | 8494 | { |
8436 | struct PendingMessage *pos; | 8495 | struct PendingMessage *pos; |
8437 | 8496 | ||
8438 | /* re-insert sort in neighbour list */ | 8497 | /* re-insert sort in neighbour list */ |
8439 | GNUNET_CONTAINER_MDLL_remove(vl, | 8498 | GNUNET_CONTAINER_MDLL_remove (vl, |
8440 | vl->pending_msg_head, | 8499 | vl->pending_msg_head, |
8441 | vl->pending_msg_tail, | 8500 | vl->pending_msg_tail, |
8442 | pm); | 8501 | pm); |
8443 | pos = vl->pending_msg_tail; | 8502 | pos = vl->pending_msg_tail; |
8444 | while ((NULL != pos) && | 8503 | while ((NULL != pos) && |
8445 | (next_attempt.abs_value_us > pos->next_attempt.abs_value_us)) | 8504 | (next_attempt.abs_value_us > pos->next_attempt.abs_value_us)) |
8446 | pos = pos->prev_vl; | 8505 | pos = pos->prev_vl; |
8447 | GNUNET_CONTAINER_MDLL_insert_after(vl, | 8506 | GNUNET_CONTAINER_MDLL_insert_after (vl, |
8448 | vl->pending_msg_head, | 8507 | vl->pending_msg_head, |
8449 | vl->pending_msg_tail, | 8508 | vl->pending_msg_tail, |
8450 | pos, | 8509 | pos, |
8451 | pm); | 8510 | pm); |
8452 | } | 8511 | } |
8453 | else | 8512 | else |
8454 | { | 8513 | { |
8455 | /* re-insert sort in fragment list */ | 8514 | /* re-insert sort in fragment list */ |
8456 | struct PendingMessage *fp = pm->frag_parent; | 8515 | struct PendingMessage *fp = pm->frag_parent; |
8457 | struct PendingMessage *pos; | 8516 | struct PendingMessage *pos; |
8458 | 8517 | ||
8459 | GNUNET_CONTAINER_MDLL_remove(frag, fp->head_frag, fp->tail_frag, pm); | 8518 | GNUNET_CONTAINER_MDLL_remove (frag, fp->head_frag, fp->tail_frag, pm); |
8460 | pos = fp->tail_frag; | 8519 | pos = fp->tail_frag; |
8461 | while ((NULL != pos) && | 8520 | while ((NULL != pos) && |
8462 | (next_attempt.abs_value_us > pos->next_attempt.abs_value_us)) | 8521 | (next_attempt.abs_value_us > pos->next_attempt.abs_value_us)) |
8463 | pos = pos->prev_frag; | 8522 | pos = pos->prev_frag; |
8464 | GNUNET_CONTAINER_MDLL_insert_after(frag, | 8523 | GNUNET_CONTAINER_MDLL_insert_after (frag, |
8465 | fp->head_frag, | 8524 | fp->head_frag, |
8466 | fp->tail_frag, | 8525 | fp->tail_frag, |
8467 | pos, | 8526 | pos, |
8468 | pm); | 8527 | pm); |
8469 | } | 8528 | } |
8470 | } | 8529 | } |
8471 | 8530 | ||
8472 | 8531 | ||
8473 | /** | 8532 | /** |
8474 | * Context for #select_best_pending_from_link(). | 8533 | * Context for #select_best_pending_from_link(). |
8475 | */ | 8534 | */ |
8476 | struct PendingMessageScoreContext { | 8535 | struct PendingMessageScoreContext |
8536 | { | ||
8477 | /** | 8537 | /** |
8478 | * Set to the best message that was found, NULL for none. | 8538 | * Set to the best message that was found, NULL for none. |
8479 | */ | 8539 | */ |
@@ -8518,107 +8578,109 @@ struct PendingMessageScoreContext { | |||
8518 | * from DV encapsulation (0 for without DV) | 8578 | * from DV encapsulation (0 for without DV) |
8519 | */ | 8579 | */ |
8520 | static void | 8580 | static void |
8521 | select_best_pending_from_link(struct PendingMessageScoreContext *sc, | 8581 | select_best_pending_from_link (struct PendingMessageScoreContext *sc, |
8522 | struct Queue *queue, | 8582 | struct Queue *queue, |
8523 | struct VirtualLink *vl, | 8583 | struct VirtualLink *vl, |
8524 | struct DistanceVectorHop *dvh, | 8584 | struct DistanceVectorHop *dvh, |
8525 | size_t overhead) | 8585 | size_t overhead) |
8526 | { | 8586 | { |
8527 | struct GNUNET_TIME_Absolute now; | 8587 | struct GNUNET_TIME_Absolute now; |
8528 | 8588 | ||
8529 | now = GNUNET_TIME_absolute_get(); | 8589 | now = GNUNET_TIME_absolute_get (); |
8530 | for (struct PendingMessage *pos = vl->pending_msg_head; NULL != pos; | 8590 | for (struct PendingMessage *pos = vl->pending_msg_head; NULL != pos; |
8531 | pos = pos->next_vl) | 8591 | pos = pos->next_vl) |
8532 | { | 8592 | { |
8533 | size_t real_overhead = overhead; | 8593 | size_t real_overhead = overhead; |
8534 | int frag; | 8594 | int frag; |
8535 | int relb; | 8595 | int relb; |
8536 | 8596 | ||
8537 | if ((NULL != dvh) && (PMT_DV_BOX == pos->pmt)) | 8597 | if ((NULL != dvh) && (PMT_DV_BOX == pos->pmt)) |
8538 | continue; /* DV messages must not be DV-routed to next hop! */ | 8598 | continue; /* DV messages must not be DV-routed to next hop! */ |
8539 | if (pos->next_attempt.abs_value_us > now.abs_value_us) | 8599 | if (pos->next_attempt.abs_value_us > now.abs_value_us) |
8540 | break; /* too early for all messages, they are sorted by next_attempt */ | 8600 | break; /* too early for all messages, they are sorted by next_attempt */ |
8541 | if (NULL != pos->qe) | 8601 | if (NULL != pos->qe) |
8542 | continue; /* not eligible */ | 8602 | continue; /* not eligible */ |
8543 | sc->consideration_counter++; | 8603 | sc->consideration_counter++; |
8544 | /* determine if we have to fragment, if so add fragmentation | 8604 | /* determine if we have to fragment, if so add fragmentation |
8545 | overhead! */ | 8605 | overhead! */ |
8546 | frag = GNUNET_NO; | 8606 | frag = GNUNET_NO; |
8547 | if (((0 != queue->mtu) && | 8607 | if (((0 != queue->mtu) && |
8548 | (pos->bytes_msg + real_overhead > queue->mtu)) || | 8608 | (pos->bytes_msg + real_overhead > queue->mtu)) || |
8549 | (pos->bytes_msg > UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo)) || | 8609 | (pos->bytes_msg > UINT16_MAX - sizeof(struct |
8550 | (NULL != pos->head_frag /* fragments already exist, should | 8610 | GNUNET_TRANSPORT_SendMessageTo)) |
8611 | || | ||
8612 | (NULL != pos->head_frag /* fragments already exist, should | ||
8551 | respect that even if MTU is 0 for | 8613 | respect that even if MTU is 0 for |
8552 | this queue */)) | 8614 | this queue */)) |
8553 | { | 8615 | { |
8554 | frag = GNUNET_YES; | 8616 | frag = GNUNET_YES; |
8555 | if (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) | 8617 | if (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) |
8556 | { | 8618 | { |
8557 | /* FIXME-FRAG-REL-UUID: we could use an optimized, shorter fragmentation | 8619 | /* FIXME-FRAG-REL-UUID: we could use an optimized, shorter fragmentation |
8558 | header without the ACK UUID when using a *reliable* channel! */ | 8620 | header without the ACK UUID when using a *reliable* channel! */ |
8559 | } | 8621 | } |
8560 | real_overhead = overhead + sizeof(struct TransportFragmentBoxMessage); | 8622 | real_overhead = overhead + sizeof(struct TransportFragmentBoxMessage); |
8561 | } | 8623 | } |
8562 | /* determine if we have to reliability-box, if so add reliability box | 8624 | /* determine if we have to reliability-box, if so add reliability box |
8563 | overhead */ | 8625 | overhead */ |
8564 | relb = GNUNET_NO; | 8626 | relb = GNUNET_NO; |
8565 | if ((GNUNET_NO == frag) && | 8627 | if ((GNUNET_NO == frag) && |
8566 | (0 == (pos->prefs & GNUNET_MQ_PREF_UNRELIABLE)) && | 8628 | (0 == (pos->prefs & GNUNET_MQ_PREF_UNRELIABLE)) && |
8567 | (GNUNET_TRANSPORT_CC_RELIABLE != queue->tc->details.communicator.cc)) | 8629 | (GNUNET_TRANSPORT_CC_RELIABLE != queue->tc->details.communicator.cc)) |
8568 | { | 8630 | { |
8569 | relb = GNUNET_YES; | 8631 | relb = GNUNET_YES; |
8570 | real_overhead += sizeof(struct TransportReliabilityBoxMessage); | 8632 | real_overhead += sizeof(struct TransportReliabilityBoxMessage); |
8571 | } | 8633 | } |
8572 | 8634 | ||
8573 | /* Finally, compare to existing 'best' in sc to see if this 'pos' pending | 8635 | /* Finally, compare to existing 'best' in sc to see if this 'pos' pending |
8574 | message would beat it! */ | 8636 | message would beat it! */ |
8575 | if (NULL != sc->best) | 8637 | if (NULL != sc->best) |
8576 | { | 8638 | { |
8577 | /* CHECK if pos fits queue BETTER (=smaller) than pm, if not: continue; | 8639 | /* CHECK if pos fits queue BETTER (=smaller) than pm, if not: continue; |
8578 | OPTIMIZE-ME: This is a heuristic, which so far has NOT been | 8640 | OPTIMIZE-ME: This is a heuristic, which so far has NOT been |
8579 | experimentally validated. There may be some huge potential for | 8641 | experimentally validated. There may be some huge potential for |
8580 | improvement here. Also, we right now only compare how well the | 8642 | improvement here. Also, we right now only compare how well the |
8581 | given message fits _this_ queue, and do not consider how well other | 8643 | given message fits _this_ queue, and do not consider how well other |
8582 | queues might suit the message. Taking other queues into consideration | 8644 | queues might suit the message. Taking other queues into consideration |
8583 | may further improve the result, but could also be expensive | 8645 | may further improve the result, but could also be expensive |
8584 | in terms of CPU time. */ | 8646 | in terms of CPU time. */ |
8585 | long long sc_score = sc->frag * 40 + sc->relb * 20 + sc->real_overhead; | 8647 | long long sc_score = sc->frag * 40 + sc->relb * 20 + sc->real_overhead; |
8586 | long long pm_score = frag * 40 + relb * 20 + real_overhead; | 8648 | long long pm_score = frag * 40 + relb * 20 + real_overhead; |
8587 | long long time_delta = | 8649 | long long time_delta = |
8588 | (sc->best->next_attempt.abs_value_us - pos->next_attempt.abs_value_us) / | 8650 | (sc->best->next_attempt.abs_value_us - pos->next_attempt.abs_value_us) |
8589 | 1000LL; | 8651 | / 1000LL; |
8590 | 8652 | ||
8591 | /* "time_delta" considers which message has been 'ready' for transmission | 8653 | /* "time_delta" considers which message has been 'ready' for transmission |
8592 | for longer, if a message has a preference for low latency, increase | 8654 | for longer, if a message has a preference for low latency, increase |
8593 | the weight of the time_delta by 10x if it is favorable for that message */ | 8655 | the weight of the time_delta by 10x if it is favorable for that message */ |
8594 | if ((0 != (pos->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) && | 8656 | if ((0 != (pos->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) && |
8595 | (0 != (sc->best->prefs & GNUNET_MQ_PREF_LOW_LATENCY))) | 8657 | (0 != (sc->best->prefs & GNUNET_MQ_PREF_LOW_LATENCY))) |
8596 | time_delta *= 10; /* increase weight (always, both are low latency) */ | 8658 | time_delta *= 10; /* increase weight (always, both are low latency) */ |
8597 | else if ((0 != (pos->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) && | 8659 | else if ((0 != (pos->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) && |
8598 | (time_delta > 0)) | 8660 | (time_delta > 0)) |
8599 | time_delta *= | 8661 | time_delta *= |
8600 | 10; /* increase weight, favors 'pos', which is low latency */ | 8662 | 10; /* increase weight, favors 'pos', which is low latency */ |
8601 | else if ((0 != (sc->best->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) && | 8663 | else if ((0 != (sc->best->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) && |
8602 | (time_delta < 0)) | 8664 | (time_delta < 0)) |
8603 | time_delta *= | 8665 | time_delta *= |
8604 | 10; /* increase weight, favors 'sc->best', which is low latency */ | 8666 | 10; /* increase weight, favors 'sc->best', which is low latency */ |
8605 | if (0 != queue->mtu) | 8667 | if (0 != queue->mtu) |
8606 | { | 8668 | { |
8607 | /* Grant bonus if we are bellow MTU, larger bonus the closer we will | 8669 | /* Grant bonus if we are bellow MTU, larger bonus the closer we will |
8608 | be to the MTU */ | 8670 | be to the MTU */ |
8609 | if (queue->mtu > sc->real_overhead + sc->best->bytes_msg) | 8671 | if (queue->mtu > sc->real_overhead + sc->best->bytes_msg) |
8610 | sc_score -= queue->mtu - (sc->real_overhead + sc->best->bytes_msg); | 8672 | sc_score -= queue->mtu - (sc->real_overhead + sc->best->bytes_msg); |
8611 | if (queue->mtu > real_overhead + pos->bytes_msg) | 8673 | if (queue->mtu > real_overhead + pos->bytes_msg) |
8612 | pm_score -= queue->mtu - (real_overhead + pos->bytes_msg); | 8674 | pm_score -= queue->mtu - (real_overhead + pos->bytes_msg); |
8613 | } | 8675 | } |
8614 | if (sc_score + time_delta > pm_score) | 8676 | if (sc_score + time_delta > pm_score) |
8615 | continue; /* sc_score larger, keep sc->best */ | 8677 | continue; /* sc_score larger, keep sc->best */ |
8616 | } | ||
8617 | sc->best = pos; | ||
8618 | sc->dvh = dvh; | ||
8619 | sc->frag = frag; | ||
8620 | sc->relb = relb; | ||
8621 | } | 8678 | } |
8679 | sc->best = pos; | ||
8680 | sc->dvh = dvh; | ||
8681 | sc->frag = frag; | ||
8682 | sc->relb = relb; | ||
8683 | } | ||
8622 | } | 8684 | } |
8623 | 8685 | ||
8624 | 8686 | ||
@@ -8633,26 +8695,26 @@ select_best_pending_from_link(struct PendingMessageScoreContext *sc, | |||
8633 | * @param options options of the original message | 8695 | * @param options options of the original message |
8634 | */ | 8696 | */ |
8635 | static void | 8697 | static void |
8636 | extract_box_cb(void *cls, | 8698 | extract_box_cb (void *cls, |
8637 | struct Neighbour *next_hop, | 8699 | struct Neighbour *next_hop, |
8638 | const struct GNUNET_MessageHeader *hdr, | 8700 | const struct GNUNET_MessageHeader *hdr, |
8639 | enum RouteMessageOptions options) | 8701 | enum RouteMessageOptions options) |
8640 | { | 8702 | { |
8641 | struct PendingMessageScoreContext *sc = cls; | 8703 | struct PendingMessageScoreContext *sc = cls; |
8642 | struct PendingMessage *pm = sc->best; | 8704 | struct PendingMessage *pm = sc->best; |
8643 | struct PendingMessage *bpm; | 8705 | struct PendingMessage *bpm; |
8644 | uint16_t bsize = ntohs(hdr->size); | 8706 | uint16_t bsize = ntohs (hdr->size); |
8645 | 8707 | ||
8646 | GNUNET_assert(NULL == pm->bpm); | 8708 | GNUNET_assert (NULL == pm->bpm); |
8647 | bpm = GNUNET_malloc(sizeof(struct PendingMessage) + bsize); | 8709 | bpm = GNUNET_malloc (sizeof(struct PendingMessage) + bsize); |
8648 | bpm->logging_uuid = logging_uuid_gen++; | 8710 | bpm->logging_uuid = logging_uuid_gen++; |
8649 | bpm->pmt = PMT_DV_BOX; | 8711 | bpm->pmt = PMT_DV_BOX; |
8650 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8651 | "Creating DV Box %llu for original message %llu (next hop is %s)\n", | 8713 | "Creating DV Box %llu for original message %llu (next hop is %s)\n", |
8652 | bpm->logging_uuid, | 8714 | bpm->logging_uuid, |
8653 | pm->logging_uuid, | 8715 | pm->logging_uuid, |
8654 | GNUNET_i2s(&next_hop->pid)); | 8716 | GNUNET_i2s (&next_hop->pid)); |
8655 | memcpy(&bpm[1], hdr, bsize); | 8717 | memcpy (&bpm[1], hdr, bsize); |
8656 | pm->bpm = bpm; | 8718 | pm->bpm = bpm; |
8657 | } | 8719 | } |
8658 | 8720 | ||
@@ -8673,7 +8735,7 @@ extract_box_cb(void *cls, | |||
8673 | * @param cls the `struct Queue` to process transmissions for | 8735 | * @param cls the `struct Queue` to process transmissions for |
8674 | */ | 8736 | */ |
8675 | static void | 8737 | static void |
8676 | transmit_on_queue(void *cls) | 8738 | transmit_on_queue (void *cls) |
8677 | { | 8739 | { |
8678 | struct Queue *queue = cls; | 8740 | struct Queue *queue = cls; |
8679 | struct Neighbour *n = queue->neighbour; | 8741 | struct Neighbour *n = queue->neighbour; |
@@ -8682,104 +8744,104 @@ transmit_on_queue(void *cls) | |||
8682 | 8744 | ||
8683 | queue->transmit_task = NULL; | 8745 | queue->transmit_task = NULL; |
8684 | if (NULL == n->vl) | 8746 | if (NULL == n->vl) |
8685 | { | 8747 | { |
8686 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8748 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8687 | "Virtual link `%s' is down, cannot have PM for queue `%s'\n", | 8749 | "Virtual link `%s' is down, cannot have PM for queue `%s'\n", |
8688 | GNUNET_i2s(&n->pid), | 8750 | GNUNET_i2s (&n->pid), |
8689 | queue->address); | 8751 | queue->address); |
8690 | queue->idle = GNUNET_YES; | 8752 | queue->idle = GNUNET_YES; |
8691 | return; | 8753 | return; |
8692 | } | 8754 | } |
8693 | memset(&sc, 0, sizeof(sc)); | 8755 | memset (&sc, 0, sizeof(sc)); |
8694 | select_best_pending_from_link(&sc, queue, n->vl, NULL, 0); | 8756 | select_best_pending_from_link (&sc, queue, n->vl, NULL, 0); |
8695 | if (NULL == sc.best) | 8757 | if (NULL == sc.best) |
8696 | { | 8758 | { |
8697 | /* Also look at DVH that have the n as first hop! */ | 8759 | /* Also look at DVH that have the n as first hop! */ |
8698 | for (struct DistanceVectorHop *dvh = n->dv_head; NULL != dvh; | 8760 | for (struct DistanceVectorHop *dvh = n->dv_head; NULL != dvh; |
8699 | dvh = dvh->next_neighbour) | 8761 | dvh = dvh->next_neighbour) |
8700 | { | 8762 | { |
8701 | select_best_pending_from_link(&sc, | 8763 | select_best_pending_from_link (&sc, |
8702 | queue, | 8764 | queue, |
8703 | dvh->dv->vl, | 8765 | dvh->dv->vl, |
8704 | dvh, | 8766 | dvh, |
8705 | sizeof(struct GNUNET_PeerIdentity) * | 8767 | sizeof(struct GNUNET_PeerIdentity) |
8706 | (1 + dvh->distance) + | 8768 | * (1 + dvh->distance) |
8707 | sizeof(struct TransportDVBoxMessage) + | 8769 | + sizeof(struct TransportDVBoxMessage) |
8708 | sizeof(struct TransportDVBoxPayloadP)); | 8770 | + sizeof(struct TransportDVBoxPayloadP)); |
8709 | } | ||
8710 | } | 8771 | } |
8772 | } | ||
8711 | if (NULL == sc.best) | 8773 | if (NULL == sc.best) |
8712 | { | 8774 | { |
8713 | /* no message pending, nothing to do here! */ | 8775 | /* no message pending, nothing to do here! */ |
8714 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8776 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8715 | "No pending messages, queue `%s' to %s now idle\n", | 8777 | "No pending messages, queue `%s' to %s now idle\n", |
8716 | queue->address, | 8778 | queue->address, |
8717 | GNUNET_i2s(&n->pid)); | 8779 | GNUNET_i2s (&n->pid)); |
8718 | queue->idle = GNUNET_YES; | 8780 | queue->idle = GNUNET_YES; |
8719 | return; | 8781 | return; |
8720 | } | 8782 | } |
8721 | 8783 | ||
8722 | /* Given selection in `sc`, do transmission */ | 8784 | /* Given selection in `sc`, do transmission */ |
8723 | pm = sc.best; | 8785 | pm = sc.best; |
8724 | if (NULL != sc.dvh) | 8786 | if (NULL != sc.dvh) |
8725 | { | 8787 | { |
8726 | GNUNET_assert(PMT_DV_BOX != pm->pmt); | 8788 | GNUNET_assert (PMT_DV_BOX != pm->pmt); |
8727 | if (NULL != sc.best->bpm) | 8789 | if (NULL != sc.best->bpm) |
8728 | { | 8790 | { |
8729 | /* We did this boxing before, but possibly for a different path! | 8791 | /* We did this boxing before, but possibly for a different path! |
8730 | Discard old DV box! OPTIMIZE-ME: we might want to check if | 8792 | Discard old DV box! OPTIMIZE-ME: we might want to check if |
8731 | it is the same and then not re-build the message... */ | 8793 | it is the same and then not re-build the message... */ |
8732 | free_pending_message(sc.best->bpm); | 8794 | free_pending_message (sc.best->bpm); |
8733 | sc.best->bpm = NULL; | 8795 | sc.best->bpm = NULL; |
8734 | } | 8796 | } |
8735 | encapsulate_for_dv(sc.dvh->dv, | 8797 | encapsulate_for_dv (sc.dvh->dv, |
8736 | 1, | 8798 | 1, |
8737 | &sc.dvh, | 8799 | &sc.dvh, |
8738 | (const struct GNUNET_MessageHeader *)&sc.best[1], | 8800 | (const struct GNUNET_MessageHeader *) &sc.best[1], |
8739 | &extract_box_cb, | 8801 | &extract_box_cb, |
8740 | &sc, | 8802 | &sc, |
8741 | RMO_NONE); | 8803 | RMO_NONE); |
8742 | GNUNET_assert(NULL != sc.best->bpm); | 8804 | GNUNET_assert (NULL != sc.best->bpm); |
8743 | pm = sc.best->bpm; | 8805 | pm = sc.best->bpm; |
8744 | } | 8806 | } |
8745 | if (GNUNET_YES == sc.frag) | 8807 | if (GNUNET_YES == sc.frag) |
8746 | { | 8808 | { |
8747 | pm = fragment_message(queue, sc.dvh, pm); | 8809 | pm = fragment_message (queue, sc.dvh, pm); |
8748 | if (NULL == pm) | 8810 | if (NULL == pm) |
8749 | { | 8811 | { |
8750 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8751 | "Fragmentation failed queue %s to %s for <%llu>, trying again\n", | 8813 | "Fragmentation failed queue %s to %s for <%llu>, trying again\n", |
8752 | queue->address, | 8814 | queue->address, |
8753 | GNUNET_i2s(&n->pid), | 8815 | GNUNET_i2s (&n->pid), |
8754 | sc.best->logging_uuid); | 8816 | sc.best->logging_uuid); |
8755 | schedule_transmit_on_queue(queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 8817 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
8756 | return; | 8818 | return; |
8757 | } | ||
8758 | } | 8819 | } |
8820 | } | ||
8759 | else if (GNUNET_YES == sc.relb) | 8821 | else if (GNUNET_YES == sc.relb) |
8760 | { | 8822 | { |
8761 | pm = reliability_box_message(queue, sc.dvh, pm); | 8823 | pm = reliability_box_message (queue, sc.dvh, pm); |
8762 | if (NULL == pm) | 8824 | if (NULL == pm) |
8763 | { | 8825 | { |
8764 | /* Reliability boxing failed, try next message... */ | 8826 | /* Reliability boxing failed, try next message... */ |
8765 | GNUNET_log( | 8827 | GNUNET_log ( |
8766 | GNUNET_ERROR_TYPE_DEBUG, | 8828 | GNUNET_ERROR_TYPE_DEBUG, |
8767 | "Reliability boxing failed queue %s to %s for <%llu>, trying again\n", | 8829 | "Reliability boxing failed queue %s to %s for <%llu>, trying again\n", |
8768 | queue->address, | 8830 | queue->address, |
8769 | GNUNET_i2s(&n->pid), | 8831 | GNUNET_i2s (&n->pid), |
8770 | sc.best->logging_uuid); | 8832 | sc.best->logging_uuid); |
8771 | schedule_transmit_on_queue(queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 8833 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
8772 | return; | 8834 | return; |
8773 | } | ||
8774 | } | 8835 | } |
8836 | } | ||
8775 | 8837 | ||
8776 | /* Pass 'pm' for transission to the communicator */ | 8838 | /* Pass 'pm' for transission to the communicator */ |
8777 | GNUNET_log( | 8839 | GNUNET_log ( |
8778 | GNUNET_ERROR_TYPE_DEBUG, | 8840 | GNUNET_ERROR_TYPE_DEBUG, |
8779 | "Passing message <%llu> to queue %s for peer %s (considered %u others)\n", | 8841 | "Passing message <%llu> to queue %s for peer %s (considered %u others)\n", |
8780 | pm->logging_uuid, | 8842 | pm->logging_uuid, |
8781 | queue->address, | 8843 | queue->address, |
8782 | GNUNET_i2s(&n->pid), | 8844 | GNUNET_i2s (&n->pid), |
8783 | sc.consideration_counter); | 8845 | sc.consideration_counter); |
8784 | 8846 | ||
8785 | /* Flow control: increment amount of traffic sent; if we are routing | 8847 | /* Flow control: increment amount of traffic sent; if we are routing |
@@ -8790,50 +8852,50 @@ transmit_on_queue(void *cls) | |||
8790 | pm->vl->outbound_fc_window_size_used += pm->bytes_msg; | 8852 | pm->vl->outbound_fc_window_size_used += pm->bytes_msg; |
8791 | 8853 | ||
8792 | if (pm->vl != queue->neighbour->vl) | 8854 | if (pm->vl != queue->neighbour->vl) |
8793 | { | 8855 | { |
8794 | /* If the virtual link of the queue differs, this better be distance | 8856 | /* If the virtual link of the queue differs, this better be distance |
8795 | vector routing! */ | 8857 | vector routing! */ |
8796 | GNUNET_assert(NULL != sc.dvh); | 8858 | GNUNET_assert (NULL != sc.dvh); |
8797 | /* If we do distance vector routing, we better not do this for a | 8859 | /* If we do distance vector routing, we better not do this for a |
8798 | message that was itself DV-routed */ | 8860 | message that was itself DV-routed */ |
8799 | GNUNET_assert(PMT_DV_BOX != sc.best->pmt); | 8861 | GNUNET_assert (PMT_DV_BOX != sc.best->pmt); |
8800 | /* We use the size of the unboxed message here, to avoid counting | 8862 | /* We use the size of the unboxed message here, to avoid counting |
8801 | the DV-Box header which is eaten up on the way by intermediaries */ | 8863 | the DV-Box header which is eaten up on the way by intermediaries */ |
8802 | queue->neighbour->vl->outbound_fc_window_size_used += sc.best->bytes_msg; | 8864 | queue->neighbour->vl->outbound_fc_window_size_used += sc.best->bytes_msg; |
8803 | } | 8865 | } |
8804 | else | 8866 | else |
8805 | { | 8867 | { |
8806 | GNUNET_assert(NULL == sc.dvh); | 8868 | GNUNET_assert (NULL == sc.dvh); |
8807 | } | 8869 | } |
8808 | 8870 | ||
8809 | queue_send_msg(queue, pm, &pm[1], pm->bytes_msg); | 8871 | queue_send_msg (queue, pm, &pm[1], pm->bytes_msg); |
8810 | 8872 | ||
8811 | /* Check if this transmission somehow conclusively finished handing 'pm' | 8873 | /* Check if this transmission somehow conclusively finished handing 'pm' |
8812 | even without any explicit ACKs */ | 8874 | even without any explicit ACKs */ |
8813 | if ((PMT_CORE == pm->pmt) || | 8875 | if ((PMT_CORE == pm->pmt) || |
8814 | (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc)) | 8876 | (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc)) |
8815 | { | 8877 | { |
8816 | completed_pending_message(pm); | 8878 | completed_pending_message (pm); |
8817 | } | 8879 | } |
8818 | else | 8880 | else |
8819 | { | 8881 | { |
8820 | /* Message not finished, waiting for acknowledgement. | 8882 | /* Message not finished, waiting for acknowledgement. |
8821 | Update time by which we might retransmit 's' based on queue | 8883 | Update time by which we might retransmit 's' based on queue |
8822 | characteristics (i.e. RTT); it takes one RTT for the message to | 8884 | characteristics (i.e. RTT); it takes one RTT for the message to |
8823 | arrive and the ACK to come back in the best case; but the other | 8885 | arrive and the ACK to come back in the best case; but the other |
8824 | side is allowed to delay ACKs by 2 RTTs, so we use 4 RTT before | 8886 | side is allowed to delay ACKs by 2 RTTs, so we use 4 RTT before |
8825 | retransmitting. | 8887 | retransmitting. |
8826 | 8888 | ||
8827 | OPTIMIZE: Note that in the future this heuristic should likely | 8889 | OPTIMIZE: Note that in the future this heuristic should likely |
8828 | be improved further (measure RTT stability, consider message | 8890 | be improved further (measure RTT stability, consider message |
8829 | urgency and size when delaying ACKs, etc.) */ | 8891 | urgency and size when delaying ACKs, etc.) */ |
8830 | update_pm_next_attempt(pm, | 8892 | update_pm_next_attempt (pm, |
8831 | GNUNET_TIME_relative_to_absolute( | 8893 | GNUNET_TIME_relative_to_absolute ( |
8832 | GNUNET_TIME_relative_multiply(queue->pd.aged_rtt, | 8894 | GNUNET_TIME_relative_multiply (queue->pd.aged_rtt, |
8833 | 4))); | 8895 | 4))); |
8834 | } | 8896 | } |
8835 | /* finally, re-schedule queue transmission task itself */ | 8897 | /* finally, re-schedule queue transmission task itself */ |
8836 | schedule_transmit_on_queue(queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 8898 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
8837 | } | 8899 | } |
8838 | 8900 | ||
8839 | 8901 | ||
@@ -8844,35 +8906,35 @@ transmit_on_queue(void *cls) | |||
8844 | * @param dqm the send message that was sent | 8906 | * @param dqm the send message that was sent |
8845 | */ | 8907 | */ |
8846 | static void | 8908 | static void |
8847 | handle_del_queue_message(void *cls, | 8909 | handle_del_queue_message (void *cls, |
8848 | const struct GNUNET_TRANSPORT_DelQueueMessage *dqm) | 8910 | const struct GNUNET_TRANSPORT_DelQueueMessage *dqm) |
8849 | { | 8911 | { |
8850 | struct TransportClient *tc = cls; | 8912 | struct TransportClient *tc = cls; |
8851 | 8913 | ||
8852 | if (CT_COMMUNICATOR != tc->type) | 8914 | if (CT_COMMUNICATOR != tc->type) |
8853 | { | 8915 | { |
8854 | GNUNET_break(0); | 8916 | GNUNET_break (0); |
8855 | GNUNET_SERVICE_client_drop(tc->client); | 8917 | GNUNET_SERVICE_client_drop (tc->client); |
8856 | return; | 8918 | return; |
8857 | } | 8919 | } |
8858 | for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; | 8920 | for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; |
8859 | queue = queue->next_client) | 8921 | queue = queue->next_client) |
8860 | { | 8922 | { |
8861 | struct Neighbour *neighbour = queue->neighbour; | 8923 | struct Neighbour *neighbour = queue->neighbour; |
8862 | 8924 | ||
8863 | if ((dqm->qid != queue->qid) || | 8925 | if ((dqm->qid != queue->qid) || |
8864 | (0 != GNUNET_memcmp(&dqm->receiver, &neighbour->pid))) | 8926 | (0 != GNUNET_memcmp (&dqm->receiver, &neighbour->pid))) |
8865 | continue; | 8927 | continue; |
8866 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8928 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8867 | "Dropped queue %s to peer %s\n", | 8929 | "Dropped queue %s to peer %s\n", |
8868 | queue->address, | 8930 | queue->address, |
8869 | GNUNET_i2s(&neighbour->pid)); | 8931 | GNUNET_i2s (&neighbour->pid)); |
8870 | free_queue(queue); | 8932 | free_queue (queue); |
8871 | GNUNET_SERVICE_client_continue(tc->client); | 8933 | GNUNET_SERVICE_client_continue (tc->client); |
8872 | return; | 8934 | return; |
8873 | } | 8935 | } |
8874 | GNUNET_break(0); | 8936 | GNUNET_break (0); |
8875 | GNUNET_SERVICE_client_drop(tc->client); | 8937 | GNUNET_SERVICE_client_drop (tc->client); |
8876 | } | 8938 | } |
8877 | 8939 | ||
8878 | 8940 | ||
@@ -8883,97 +8945,97 @@ handle_del_queue_message(void *cls, | |||
8883 | * @param sma the send message that was sent | 8945 | * @param sma the send message that was sent |
8884 | */ | 8946 | */ |
8885 | static void | 8947 | static void |
8886 | handle_send_message_ack(void *cls, | 8948 | handle_send_message_ack (void *cls, |
8887 | const struct GNUNET_TRANSPORT_SendMessageToAck *sma) | 8949 | const struct GNUNET_TRANSPORT_SendMessageToAck *sma) |
8888 | { | 8950 | { |
8889 | struct TransportClient *tc = cls; | 8951 | struct TransportClient *tc = cls; |
8890 | struct QueueEntry *qe; | 8952 | struct QueueEntry *qe; |
8891 | struct PendingMessage *pm; | 8953 | struct PendingMessage *pm; |
8892 | 8954 | ||
8893 | if (CT_COMMUNICATOR != tc->type) | 8955 | if (CT_COMMUNICATOR != tc->type) |
8894 | { | 8956 | { |
8895 | GNUNET_break(0); | 8957 | GNUNET_break (0); |
8896 | GNUNET_SERVICE_client_drop(tc->client); | 8958 | GNUNET_SERVICE_client_drop (tc->client); |
8897 | return; | 8959 | return; |
8898 | } | 8960 | } |
8899 | 8961 | ||
8900 | /* find our queue entry matching the ACK */ | 8962 | /* find our queue entry matching the ACK */ |
8901 | qe = NULL; | 8963 | qe = NULL; |
8902 | for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; | 8964 | for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; |
8903 | queue = queue->next_client) | 8965 | queue = queue->next_client) |
8966 | { | ||
8967 | if (0 != GNUNET_memcmp (&queue->neighbour->pid, &sma->receiver)) | ||
8968 | continue; | ||
8969 | for (struct QueueEntry *qep = queue->queue_head; NULL != qep; | ||
8970 | qep = qep->next) | ||
8904 | { | 8971 | { |
8905 | if (0 != GNUNET_memcmp(&queue->neighbour->pid, &sma->receiver)) | 8972 | if (qep->mid != sma->mid) |
8906 | continue; | 8973 | continue; |
8907 | for (struct QueueEntry *qep = queue->queue_head; NULL != qep; | 8974 | qe = qep; |
8908 | qep = qep->next) | ||
8909 | { | ||
8910 | if (qep->mid != sma->mid) | ||
8911 | continue; | ||
8912 | qe = qep; | ||
8913 | break; | ||
8914 | } | ||
8915 | break; | 8975 | break; |
8916 | } | 8976 | } |
8977 | break; | ||
8978 | } | ||
8917 | if (NULL == qe) | 8979 | if (NULL == qe) |
8918 | { | 8980 | { |
8919 | /* this should never happen */ | 8981 | /* this should never happen */ |
8920 | GNUNET_break(0); | 8982 | GNUNET_break (0); |
8921 | GNUNET_SERVICE_client_drop(tc->client); | 8983 | GNUNET_SERVICE_client_drop (tc->client); |
8922 | return; | 8984 | return; |
8923 | } | 8985 | } |
8924 | GNUNET_CONTAINER_DLL_remove(qe->queue->queue_head, | 8986 | GNUNET_CONTAINER_DLL_remove (qe->queue->queue_head, |
8925 | qe->queue->queue_tail, | 8987 | qe->queue->queue_tail, |
8926 | qe); | 8988 | qe); |
8927 | qe->queue->queue_length--; | 8989 | qe->queue->queue_length--; |
8928 | tc->details.communicator.total_queue_length--; | 8990 | tc->details.communicator.total_queue_length--; |
8929 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 8991 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8930 | "Received ACK on queue %s to peer %s (new length: %u/%u)\n", | 8992 | "Received ACK on queue %s to peer %s (new length: %u/%u)\n", |
8931 | qe->queue->address, | 8993 | qe->queue->address, |
8932 | GNUNET_i2s(&qe->queue->neighbour->pid), | 8994 | GNUNET_i2s (&qe->queue->neighbour->pid), |
8933 | qe->queue->queue_length, | 8995 | qe->queue->queue_length, |
8934 | tc->details.communicator.total_queue_length); | 8996 | tc->details.communicator.total_queue_length); |
8935 | GNUNET_SERVICE_client_continue(tc->client); | 8997 | GNUNET_SERVICE_client_continue (tc->client); |
8936 | 8998 | ||
8937 | /* if applicable, resume transmissions that waited on ACK */ | 8999 | /* if applicable, resume transmissions that waited on ACK */ |
8938 | if (COMMUNICATOR_TOTAL_QUEUE_LIMIT - 1 == | 9000 | if (COMMUNICATOR_TOTAL_QUEUE_LIMIT - 1 == |
8939 | tc->details.communicator.total_queue_length) | 9001 | tc->details.communicator.total_queue_length) |
8940 | { | 9002 | { |
8941 | /* Communicator dropped below threshold, resume all queues | 9003 | /* Communicator dropped below threshold, resume all queues |
8942 | incident with this client! */ | 9004 | incident with this client! */ |
8943 | GNUNET_STATISTICS_update( | 9005 | GNUNET_STATISTICS_update ( |
8944 | GST_stats, | 9006 | GST_stats, |
8945 | "# Transmission throttled due to communicator queue limit", | 9007 | "# Transmission throttled due to communicator queue limit", |
8946 | -1, | 9008 | -1, |
8947 | GNUNET_NO); | 9009 | GNUNET_NO); |
8948 | for (struct Queue *queue = tc->details.communicator.queue_head; | 9010 | for (struct Queue *queue = tc->details.communicator.queue_head; |
8949 | NULL != queue; | 9011 | NULL != queue; |
8950 | queue = queue->next_client) | 9012 | queue = queue->next_client) |
8951 | schedule_transmit_on_queue(queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 9013 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
8952 | } | 9014 | } |
8953 | else if (QUEUE_LENGTH_LIMIT - 1 == qe->queue->queue_length) | 9015 | else if (QUEUE_LENGTH_LIMIT - 1 == qe->queue->queue_length) |
8954 | { | 9016 | { |
8955 | /* queue dropped below threshold; only resume this one queue */ | 9017 | /* queue dropped below threshold; only resume this one queue */ |
8956 | GNUNET_STATISTICS_update(GST_stats, | 9018 | GNUNET_STATISTICS_update (GST_stats, |
8957 | "# Transmission throttled due to queue queue limit", | 9019 | "# Transmission throttled due to queue queue limit", |
8958 | -1, | 9020 | -1, |
8959 | GNUNET_NO); | 9021 | GNUNET_NO); |
8960 | schedule_transmit_on_queue(qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 9022 | schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
8961 | } | 9023 | } |
8962 | 9024 | ||
8963 | if (NULL != (pm = qe->pm)) | 9025 | if (NULL != (pm = qe->pm)) |
8964 | { | 9026 | { |
8965 | struct VirtualLink *vl; | 9027 | struct VirtualLink *vl; |
8966 | 9028 | ||
8967 | GNUNET_assert(qe == pm->qe); | 9029 | GNUNET_assert (qe == pm->qe); |
8968 | pm->qe = NULL; | 9030 | pm->qe = NULL; |
8969 | /* If waiting for this communicator may have blocked transmission | 9031 | /* If waiting for this communicator may have blocked transmission |
8970 | of pm on other queues for this neighbour, force schedule | 9032 | of pm on other queues for this neighbour, force schedule |
8971 | transmit on queue for queues of the neighbour */ | 9033 | transmit on queue for queues of the neighbour */ |
8972 | vl = pm->vl; | 9034 | vl = pm->vl; |
8973 | if (vl->pending_msg_head == pm) | 9035 | if (vl->pending_msg_head == pm) |
8974 | check_vl_transmission(vl); | 9036 | check_vl_transmission (vl); |
8975 | } | 9037 | } |
8976 | GNUNET_free(qe); | 9038 | GNUNET_free (qe); |
8977 | } | 9039 | } |
8978 | 9040 | ||
8979 | 9041 | ||
@@ -8987,24 +9049,24 @@ handle_send_message_ack(void *cls, | |||
8987 | * @return #GNUNET_OK (continue to iterate) | 9049 | * @return #GNUNET_OK (continue to iterate) |
8988 | */ | 9050 | */ |
8989 | static int | 9051 | static int |
8990 | notify_client_queues(void *cls, | 9052 | notify_client_queues (void *cls, |
8991 | const struct GNUNET_PeerIdentity *pid, | 9053 | const struct GNUNET_PeerIdentity *pid, |
8992 | void *value) | 9054 | void *value) |
8993 | { | 9055 | { |
8994 | struct TransportClient *tc = cls; | 9056 | struct TransportClient *tc = cls; |
8995 | struct Neighbour *neighbour = value; | 9057 | struct Neighbour *neighbour = value; |
8996 | 9058 | ||
8997 | GNUNET_assert(CT_MONITOR == tc->type); | 9059 | GNUNET_assert (CT_MONITOR == tc->type); |
8998 | for (struct Queue *q = neighbour->queue_head; NULL != q; | 9060 | for (struct Queue *q = neighbour->queue_head; NULL != q; |
8999 | q = q->next_neighbour) | 9061 | q = q->next_neighbour) |
9000 | { | 9062 | { |
9001 | struct MonitorEvent me = { .rtt = q->pd.aged_rtt, | 9063 | struct MonitorEvent me = { .rtt = q->pd.aged_rtt, |
9002 | .cs = q->cs, | 9064 | .cs = q->cs, |
9003 | .num_msg_pending = q->num_msg_pending, | 9065 | .num_msg_pending = q->num_msg_pending, |
9004 | .num_bytes_pending = q->num_bytes_pending }; | 9066 | .num_bytes_pending = q->num_bytes_pending }; |
9005 | 9067 | ||
9006 | notify_monitor(tc, pid, q->address, q->nt, &me); | 9068 | notify_monitor (tc, pid, q->address, q->nt, &me); |
9007 | } | 9069 | } |
9008 | return GNUNET_OK; | 9070 | return GNUNET_OK; |
9009 | } | 9071 | } |
9010 | 9072 | ||
@@ -9016,23 +9078,23 @@ notify_client_queues(void *cls, | |||
9016 | * @param start the start message that was sent | 9078 | * @param start the start message that was sent |
9017 | */ | 9079 | */ |
9018 | static void | 9080 | static void |
9019 | handle_monitor_start(void *cls, | 9081 | handle_monitor_start (void *cls, |
9020 | const struct GNUNET_TRANSPORT_MonitorStart *start) | 9082 | const struct GNUNET_TRANSPORT_MonitorStart *start) |
9021 | { | 9083 | { |
9022 | struct TransportClient *tc = cls; | 9084 | struct TransportClient *tc = cls; |
9023 | 9085 | ||
9024 | if (CT_NONE != tc->type) | 9086 | if (CT_NONE != tc->type) |
9025 | { | 9087 | { |
9026 | GNUNET_break(0); | 9088 | GNUNET_break (0); |
9027 | GNUNET_SERVICE_client_drop(tc->client); | 9089 | GNUNET_SERVICE_client_drop (tc->client); |
9028 | return; | 9090 | return; |
9029 | } | 9091 | } |
9030 | tc->type = CT_MONITOR; | 9092 | tc->type = CT_MONITOR; |
9031 | tc->details.monitor.peer = start->peer; | 9093 | tc->details.monitor.peer = start->peer; |
9032 | tc->details.monitor.one_shot = ntohl(start->one_shot); | 9094 | tc->details.monitor.one_shot = ntohl (start->one_shot); |
9033 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, ¬ify_client_queues, tc); | 9095 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, ¬ify_client_queues, tc); |
9034 | GNUNET_SERVICE_client_mark_monitor(tc->client); | 9096 | GNUNET_SERVICE_client_mark_monitor (tc->client); |
9035 | GNUNET_SERVICE_client_continue(tc->client); | 9097 | GNUNET_SERVICE_client_continue (tc->client); |
9036 | } | 9098 | } |
9037 | 9099 | ||
9038 | 9100 | ||
@@ -9044,16 +9106,16 @@ handle_monitor_start(void *cls, | |||
9044 | * @return NULL if no such transport client is available | 9106 | * @return NULL if no such transport client is available |
9045 | */ | 9107 | */ |
9046 | static struct TransportClient * | 9108 | static struct TransportClient * |
9047 | lookup_communicator(const char *prefix) | 9109 | lookup_communicator (const char *prefix) |
9048 | { | 9110 | { |
9049 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) | 9111 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
9050 | { | 9112 | { |
9051 | if (CT_COMMUNICATOR != tc->type) | 9113 | if (CT_COMMUNICATOR != tc->type) |
9052 | continue; | 9114 | continue; |
9053 | if (0 == strcmp(prefix, tc->details.communicator.address_prefix)) | 9115 | if (0 == strcmp (prefix, tc->details.communicator.address_prefix)) |
9054 | return tc; | 9116 | return tc; |
9055 | } | 9117 | } |
9056 | GNUNET_log( | 9118 | GNUNET_log ( |
9057 | GNUNET_ERROR_TYPE_WARNING, | 9119 | GNUNET_ERROR_TYPE_WARNING, |
9058 | "Somone suggested use of communicator for `%s', but we do not have such a communicator!\n", | 9120 | "Somone suggested use of communicator for `%s', but we do not have such a communicator!\n", |
9059 | prefix); | 9121 | prefix); |
@@ -9069,7 +9131,7 @@ lookup_communicator(const char *prefix) | |||
9069 | * @param address the address to try | 9131 | * @param address the address to try |
9070 | */ | 9132 | */ |
9071 | static void | 9133 | static void |
9072 | suggest_to_connect(const struct GNUNET_PeerIdentity *pid, const char *address) | 9134 | suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address) |
9073 | { | 9135 | { |
9074 | static uint32_t idgen; | 9136 | static uint32_t idgen; |
9075 | struct TransportClient *tc; | 9137 | struct TransportClient *tc; |
@@ -9078,40 +9140,40 @@ suggest_to_connect(const struct GNUNET_PeerIdentity *pid, const char *address) | |||
9078 | struct GNUNET_MQ_Envelope *env; | 9140 | struct GNUNET_MQ_Envelope *env; |
9079 | size_t alen; | 9141 | size_t alen; |
9080 | 9142 | ||
9081 | prefix = GNUNET_HELLO_address_to_prefix(address); | 9143 | prefix = GNUNET_HELLO_address_to_prefix (address); |
9082 | if (NULL == prefix) | 9144 | if (NULL == prefix) |
9083 | { | 9145 | { |
9084 | GNUNET_break(0); /* We got an invalid address!? */ | 9146 | GNUNET_break (0); /* We got an invalid address!? */ |
9085 | return; | 9147 | return; |
9086 | } | 9148 | } |
9087 | tc = lookup_communicator(prefix); | 9149 | tc = lookup_communicator (prefix); |
9088 | if (NULL == tc) | 9150 | if (NULL == tc) |
9089 | { | 9151 | { |
9090 | GNUNET_STATISTICS_update(GST_stats, | 9152 | GNUNET_STATISTICS_update (GST_stats, |
9091 | "# Suggestions ignored due to missing communicator", | 9153 | "# Suggestions ignored due to missing communicator", |
9092 | 1, | 9154 | 1, |
9093 | GNUNET_NO); | 9155 | GNUNET_NO); |
9094 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 9156 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
9095 | "Cannot connect to %s at `%s', no matching communicator present\n", | 9157 | "Cannot connect to %s at `%s', no matching communicator present\n", |
9096 | GNUNET_i2s(pid), | 9158 | GNUNET_i2s (pid), |
9097 | address); | 9159 | address); |
9098 | GNUNET_free(prefix); | 9160 | GNUNET_free (prefix); |
9099 | return; | 9161 | return; |
9100 | } | 9162 | } |
9101 | /* forward suggestion for queue creation to communicator */ | 9163 | /* forward suggestion for queue creation to communicator */ |
9102 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9103 | "Request #%u for `%s' communicator to create queue to `%s'\n", | 9165 | "Request #%u for `%s' communicator to create queue to `%s'\n", |
9104 | (unsigned int)idgen, | 9166 | (unsigned int) idgen, |
9105 | prefix, | 9167 | prefix, |
9106 | address); | 9168 | address); |
9107 | GNUNET_free(prefix); | 9169 | GNUNET_free (prefix); |
9108 | alen = strlen(address) + 1; | 9170 | alen = strlen (address) + 1; |
9109 | env = | 9171 | env = |
9110 | GNUNET_MQ_msg_extra(cqm, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE); | 9172 | GNUNET_MQ_msg_extra (cqm, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE); |
9111 | cqm->request_id = htonl(idgen++); | 9173 | cqm->request_id = htonl (idgen++); |
9112 | cqm->receiver = *pid; | 9174 | cqm->receiver = *pid; |
9113 | memcpy(&cqm[1], address, alen); | 9175 | memcpy (&cqm[1], address, alen); |
9114 | GNUNET_MQ_send(tc->mq, env); | 9176 | GNUNET_MQ_send (tc->mq, env); |
9115 | } | 9177 | } |
9116 | 9178 | ||
9117 | 9179 | ||
@@ -9123,22 +9185,22 @@ suggest_to_connect(const struct GNUNET_PeerIdentity *pid, const char *address) | |||
9123 | * @param vs state to derive validation challenge from | 9185 | * @param vs state to derive validation challenge from |
9124 | */ | 9186 | */ |
9125 | static void | 9187 | static void |
9126 | validation_transmit_on_queue(struct Queue *q, struct ValidationState *vs) | 9188 | validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs) |
9127 | { | 9189 | { |
9128 | struct TransportValidationChallengeMessage tvc; | 9190 | struct TransportValidationChallengeMessage tvc; |
9129 | 9191 | ||
9130 | vs->last_challenge_use = GNUNET_TIME_absolute_get_monotonic(GST_cfg); | 9192 | vs->last_challenge_use = GNUNET_TIME_absolute_get_monotonic (GST_cfg); |
9131 | tvc.header.type = | 9193 | tvc.header.type = |
9132 | htons(GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE); | 9194 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE); |
9133 | tvc.header.size = htons(sizeof(tvc)); | 9195 | tvc.header.size = htons (sizeof(tvc)); |
9134 | tvc.reserved = htonl(0); | 9196 | tvc.reserved = htonl (0); |
9135 | tvc.challenge = vs->challenge; | 9197 | tvc.challenge = vs->challenge; |
9136 | tvc.sender_time = GNUNET_TIME_absolute_hton(vs->last_challenge_use); | 9198 | tvc.sender_time = GNUNET_TIME_absolute_hton (vs->last_challenge_use); |
9137 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 9199 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
9138 | "Sending address validation challenge %s to %s\n", | 9200 | "Sending address validation challenge %s to %s\n", |
9139 | GNUNET_sh2s(&tvc.challenge.value), | 9201 | GNUNET_sh2s (&tvc.challenge.value), |
9140 | GNUNET_i2s(&q->neighbour->pid)); | 9202 | GNUNET_i2s (&q->neighbour->pid)); |
9141 | queue_send_msg(q, NULL, &tvc, sizeof(tvc)); | 9203 | queue_send_msg (q, NULL, &tvc, sizeof(tvc)); |
9142 | } | 9204 | } |
9143 | 9205 | ||
9144 | 9206 | ||
@@ -9148,55 +9210,56 @@ validation_transmit_on_queue(struct Queue *q, struct ValidationState *vs) | |||
9148 | * @param cls NULL | 9210 | * @param cls NULL |
9149 | */ | 9211 | */ |
9150 | static void | 9212 | static void |
9151 | validation_start_cb(void *cls) | 9213 | validation_start_cb (void *cls) |
9152 | { | 9214 | { |
9153 | struct ValidationState *vs; | 9215 | struct ValidationState *vs; |
9154 | struct Queue *q; | 9216 | struct Queue *q; |
9155 | 9217 | ||
9156 | (void)cls; | 9218 | (void) cls; |
9157 | validation_task = NULL; | 9219 | validation_task = NULL; |
9158 | vs = GNUNET_CONTAINER_heap_peek(validation_heap); | 9220 | vs = GNUNET_CONTAINER_heap_peek (validation_heap); |
9159 | /* drop validations past their expiration */ | 9221 | /* drop validations past their expiration */ |
9160 | while ( | 9222 | while ( |
9161 | (NULL != vs) && | 9223 | (NULL != vs) && |
9162 | (0 == GNUNET_TIME_absolute_get_remaining(vs->valid_until).rel_value_us)) | 9224 | (0 == GNUNET_TIME_absolute_get_remaining (vs->valid_until).rel_value_us)) |
9163 | { | 9225 | { |
9164 | free_validation_state(vs); | 9226 | free_validation_state (vs); |
9165 | vs = GNUNET_CONTAINER_heap_peek(validation_heap); | 9227 | vs = GNUNET_CONTAINER_heap_peek (validation_heap); |
9166 | } | 9228 | } |
9167 | if (NULL == vs) | 9229 | if (NULL == vs) |
9168 | { | 9230 | { |
9169 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 9231 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
9170 | "Address validation task not scheduled anymore, nothing to do\n"); | 9232 | "Address validation task not scheduled anymore, nothing to do\n"); |
9171 | return; /* woopsie, no more addresses known, should only | 9233 | return; /* woopsie, no more addresses known, should only |
9172 | happen if we're really a lonely peer */ | 9234 | happen if we're really a lonely peer */ |
9173 | } | 9235 | } |
9174 | q = find_queue(&vs->pid, vs->address); | 9236 | q = find_queue (&vs->pid, vs->address); |
9175 | if (NULL == q) | 9237 | if (NULL == q) |
9176 | { | 9238 | { |
9177 | vs->awaiting_queue = GNUNET_YES; | 9239 | vs->awaiting_queue = GNUNET_YES; |
9178 | suggest_to_connect(&vs->pid, vs->address); | 9240 | suggest_to_connect (&vs->pid, vs->address); |
9179 | } | 9241 | } |
9180 | else | 9242 | else |
9181 | validation_transmit_on_queue(q, vs); | 9243 | validation_transmit_on_queue (q, vs); |
9182 | /* Finally, reschedule next attempt */ | 9244 | /* Finally, reschedule next attempt */ |
9183 | vs->challenge_backoff = | 9245 | vs->challenge_backoff = |
9184 | GNUNET_TIME_randomized_backoff(vs->challenge_backoff, | 9246 | GNUNET_TIME_randomized_backoff (vs->challenge_backoff, |
9185 | MAX_VALIDATION_CHALLENGE_FREQ); | 9247 | MAX_VALIDATION_CHALLENGE_FREQ); |
9186 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9248 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9187 | "Address validation task will run again in %s\n", | 9249 | "Address validation task will run again in %s\n", |
9188 | GNUNET_STRINGS_relative_time_to_string(vs->challenge_backoff, | 9250 | GNUNET_STRINGS_relative_time_to_string (vs->challenge_backoff, |
9189 | GNUNET_YES)); | 9251 | GNUNET_YES)); |
9190 | update_next_challenge_time(vs, | 9252 | update_next_challenge_time (vs, |
9191 | GNUNET_TIME_relative_to_absolute( | 9253 | GNUNET_TIME_relative_to_absolute ( |
9192 | vs->challenge_backoff)); | 9254 | vs->challenge_backoff)); |
9193 | } | 9255 | } |
9194 | 9256 | ||
9195 | 9257 | ||
9196 | /** | 9258 | /** |
9197 | * Closure for #check_connection_quality. | 9259 | * Closure for #check_connection_quality. |
9198 | */ | 9260 | */ |
9199 | struct QueueQualityContext { | 9261 | struct QueueQualityContext |
9262 | { | ||
9200 | /** | 9263 | /** |
9201 | * Set to the @e k'th queue encountered. | 9264 | * Set to the @e k'th queue encountered. |
9202 | */ | 9265 | */ |
@@ -9232,26 +9295,26 @@ struct QueueQualityContext { | |||
9232 | * @return #GNUNET_OK (continue to iterate) | 9295 | * @return #GNUNET_OK (continue to iterate) |
9233 | */ | 9296 | */ |
9234 | static int | 9297 | static int |
9235 | check_connection_quality(void *cls, | 9298 | check_connection_quality (void *cls, |
9236 | const struct GNUNET_PeerIdentity *pid, | 9299 | const struct GNUNET_PeerIdentity *pid, |
9237 | void *value) | 9300 | void *value) |
9238 | { | 9301 | { |
9239 | struct QueueQualityContext *ctx = cls; | 9302 | struct QueueQualityContext *ctx = cls; |
9240 | struct Neighbour *n = value; | 9303 | struct Neighbour *n = value; |
9241 | int do_inc; | 9304 | int do_inc; |
9242 | 9305 | ||
9243 | (void)pid; | 9306 | (void) pid; |
9244 | do_inc = GNUNET_NO; | 9307 | do_inc = GNUNET_NO; |
9245 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) | 9308 | for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) |
9246 | { | 9309 | { |
9247 | ctx->num_queues++; | 9310 | ctx->num_queues++; |
9248 | if (0 == ctx->k--) | 9311 | if (0 == ctx->k--) |
9249 | ctx->q = q; | 9312 | ctx->q = q; |
9250 | /* FIXME-CONQ-STATISTICS: in the future, add reliability / goodput | 9313 | /* FIXME-CONQ-STATISTICS: in the future, add reliability / goodput |
9251 | statistics and consider those as well here? */ | 9314 | statistics and consider those as well here? */ |
9252 | if (q->pd.aged_rtt.rel_value_us < DV_QUALITY_RTT_THRESHOLD.rel_value_us) | 9315 | if (q->pd.aged_rtt.rel_value_us < DV_QUALITY_RTT_THRESHOLD.rel_value_us) |
9253 | do_inc = GNUNET_YES; | 9316 | do_inc = GNUNET_YES; |
9254 | } | 9317 | } |
9255 | if (GNUNET_YES == do_inc) | 9318 | if (GNUNET_YES == do_inc) |
9256 | ctx->quality_count++; | 9319 | ctx->quality_count++; |
9257 | return GNUNET_OK; | 9320 | return GNUNET_OK; |
@@ -9270,103 +9333,103 @@ check_connection_quality(void *cls, | |||
9270 | * @param cls NULL | 9333 | * @param cls NULL |
9271 | */ | 9334 | */ |
9272 | static void | 9335 | static void |
9273 | start_dv_learn(void *cls) | 9336 | start_dv_learn (void *cls) |
9274 | { | 9337 | { |
9275 | struct LearnLaunchEntry *lle; | 9338 | struct LearnLaunchEntry *lle; |
9276 | struct QueueQualityContext qqc; | 9339 | struct QueueQualityContext qqc; |
9277 | struct TransportDVLearnMessage dvl; | 9340 | struct TransportDVLearnMessage dvl; |
9278 | 9341 | ||
9279 | (void)cls; | 9342 | (void) cls; |
9280 | dvlearn_task = NULL; | 9343 | dvlearn_task = NULL; |
9281 | if (0 == GNUNET_CONTAINER_multipeermap_size(neighbours)) | 9344 | if (0 == GNUNET_CONTAINER_multipeermap_size (neighbours)) |
9282 | return; /* lost all connectivity, cannot do learning */ | 9345 | return; /* lost all connectivity, cannot do learning */ |
9283 | qqc.quality_count = 0; | 9346 | qqc.quality_count = 0; |
9284 | qqc.num_queues = 0; | 9347 | qqc.num_queues = 0; |
9285 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, | 9348 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
9286 | &check_connection_quality, | 9349 | &check_connection_quality, |
9287 | &qqc); | 9350 | &qqc); |
9288 | if (qqc.quality_count > DV_LEARN_QUALITY_THRESHOLD) | 9351 | if (qqc.quality_count > DV_LEARN_QUALITY_THRESHOLD) |
9289 | { | 9352 | { |
9290 | struct GNUNET_TIME_Relative delay; | 9353 | struct GNUNET_TIME_Relative delay; |
9291 | unsigned int factor; | 9354 | unsigned int factor; |
9292 | 9355 | ||
9293 | /* scale our retries by how far we are above the threshold */ | 9356 | /* scale our retries by how far we are above the threshold */ |
9294 | factor = qqc.quality_count / DV_LEARN_QUALITY_THRESHOLD; | 9357 | factor = qqc.quality_count / DV_LEARN_QUALITY_THRESHOLD; |
9295 | delay = GNUNET_TIME_relative_multiply(DV_LEARN_BASE_FREQUENCY, factor); | 9358 | delay = GNUNET_TIME_relative_multiply (DV_LEARN_BASE_FREQUENCY, factor); |
9296 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9297 | "At connection quality %u, will launch DV learn in %s\n", | 9360 | "At connection quality %u, will launch DV learn in %s\n", |
9298 | qqc.quality_count, | 9361 | qqc.quality_count, |
9299 | GNUNET_STRINGS_relative_time_to_string(delay, GNUNET_YES)); | 9362 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
9300 | dvlearn_task = GNUNET_SCHEDULER_add_delayed(delay, &start_dv_learn, NULL); | 9363 | dvlearn_task = GNUNET_SCHEDULER_add_delayed (delay, &start_dv_learn, NULL); |
9301 | return; | 9364 | return; |
9302 | } | 9365 | } |
9303 | /* remove old entries in #dvlearn_map if it has grown too big */ | 9366 | /* remove old entries in #dvlearn_map if it has grown too big */ |
9304 | while (MAX_DV_LEARN_PENDING >= | 9367 | while (MAX_DV_LEARN_PENDING >= |
9305 | GNUNET_CONTAINER_multishortmap_size(dvlearn_map)) | 9368 | GNUNET_CONTAINER_multishortmap_size (dvlearn_map)) |
9306 | { | 9369 | { |
9307 | lle = lle_tail; | 9370 | lle = lle_tail; |
9308 | GNUNET_assert(GNUNET_YES == | 9371 | GNUNET_assert (GNUNET_YES == |
9309 | GNUNET_CONTAINER_multishortmap_remove(dvlearn_map, | 9372 | GNUNET_CONTAINER_multishortmap_remove (dvlearn_map, |
9310 | &lle->challenge.value, | 9373 | &lle->challenge.value, |
9311 | lle)); | 9374 | lle)); |
9312 | GNUNET_CONTAINER_DLL_remove(lle_head, lle_tail, lle); | 9375 | GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle); |
9313 | GNUNET_free(lle); | 9376 | GNUNET_free (lle); |
9314 | } | 9377 | } |
9315 | /* setup data structure for learning */ | 9378 | /* setup data structure for learning */ |
9316 | lle = GNUNET_new(struct LearnLaunchEntry); | 9379 | lle = GNUNET_new (struct LearnLaunchEntry); |
9317 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_NONCE, | 9380 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
9318 | &lle->challenge, | 9381 | &lle->challenge, |
9319 | sizeof(lle->challenge)); | 9382 | sizeof(lle->challenge)); |
9320 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9321 | "Starting launch DV learn with challenge %s\n", | 9384 | "Starting launch DV learn with challenge %s\n", |
9322 | GNUNET_sh2s(&lle->challenge.value)); | 9385 | GNUNET_sh2s (&lle->challenge.value)); |
9323 | GNUNET_CONTAINER_DLL_insert(lle_head, lle_tail, lle); | 9386 | GNUNET_CONTAINER_DLL_insert (lle_head, lle_tail, lle); |
9324 | GNUNET_break(GNUNET_YES == | 9387 | GNUNET_break (GNUNET_YES == |
9325 | GNUNET_CONTAINER_multishortmap_put( | 9388 | GNUNET_CONTAINER_multishortmap_put ( |
9326 | dvlearn_map, | 9389 | dvlearn_map, |
9327 | &lle->challenge.value, | 9390 | &lle->challenge.value, |
9328 | lle, | 9391 | lle, |
9329 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 9392 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
9330 | dvl.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN); | 9393 | dvl.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN); |
9331 | dvl.header.size = htons(sizeof(dvl)); | 9394 | dvl.header.size = htons (sizeof(dvl)); |
9332 | dvl.num_hops = htons(0); | 9395 | dvl.num_hops = htons (0); |
9333 | dvl.bidirectional = htons(0); | 9396 | dvl.bidirectional = htons (0); |
9334 | dvl.non_network_delay = GNUNET_TIME_relative_hton(GNUNET_TIME_UNIT_ZERO); | 9397 | dvl.non_network_delay = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO); |
9335 | dvl.monotonic_time = | 9398 | dvl.monotonic_time = |
9336 | GNUNET_TIME_absolute_hton(GNUNET_TIME_absolute_get_monotonic(GST_cfg)); | 9399 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg)); |
9337 | { | 9400 | { |
9338 | struct DvInitPS dvip = { .purpose.purpose = htonl( | 9401 | struct DvInitPS dvip = { .purpose.purpose = htonl ( |
9339 | GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR), | 9402 | GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR), |
9340 | .purpose.size = htonl(sizeof(dvip)), | 9403 | .purpose.size = htonl (sizeof(dvip)), |
9341 | .monotonic_time = dvl.monotonic_time, | 9404 | .monotonic_time = dvl.monotonic_time, |
9342 | .challenge = lle->challenge }; | 9405 | .challenge = lle->challenge }; |
9343 | 9406 | ||
9344 | GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_eddsa_sign(GST_my_private_key, | 9407 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, |
9345 | &dvip.purpose, | 9408 | &dvip.purpose, |
9346 | &dvl.init_sig)); | 9409 | &dvl.init_sig)); |
9347 | } | 9410 | } |
9348 | dvl.initiator = GST_my_identity; | 9411 | dvl.initiator = GST_my_identity; |
9349 | dvl.challenge = lle->challenge; | 9412 | dvl.challenge = lle->challenge; |
9350 | 9413 | ||
9351 | qqc.quality_count = 0; | 9414 | qqc.quality_count = 0; |
9352 | qqc.k = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, qqc.num_queues); | 9415 | qqc.k = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, qqc.num_queues); |
9353 | qqc.num_queues = 0; | 9416 | qqc.num_queues = 0; |
9354 | qqc.q = NULL; | 9417 | qqc.q = NULL; |
9355 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, | 9418 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
9356 | &check_connection_quality, | 9419 | &check_connection_quality, |
9357 | &qqc); | 9420 | &qqc); |
9358 | GNUNET_assert(NULL != qqc.q); | 9421 | GNUNET_assert (NULL != qqc.q); |
9359 | 9422 | ||
9360 | /* Do this as close to transmission time as possible! */ | 9423 | /* Do this as close to transmission time as possible! */ |
9361 | lle->launch_time = GNUNET_TIME_absolute_get(); | 9424 | lle->launch_time = GNUNET_TIME_absolute_get (); |
9362 | 9425 | ||
9363 | queue_send_msg(qqc.q, NULL, &dvl, sizeof(dvl)); | 9426 | queue_send_msg (qqc.q, NULL, &dvl, sizeof(dvl)); |
9364 | /* reschedule this job, randomizing the time it runs (but no | 9427 | /* reschedule this job, randomizing the time it runs (but no |
9365 | actual backoff!) */ | 9428 | actual backoff!) */ |
9366 | dvlearn_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_randomize( | 9429 | dvlearn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_randomize ( |
9367 | DV_LEARN_BASE_FREQUENCY), | 9430 | DV_LEARN_BASE_FREQUENCY), |
9368 | &start_dv_learn, | 9431 | &start_dv_learn, |
9369 | NULL); | 9432 | NULL); |
9370 | } | 9433 | } |
9371 | 9434 | ||
9372 | 9435 | ||
@@ -9380,21 +9443,21 @@ start_dv_learn(void *cls) | |||
9380 | * @return #GNUNET_NO if a match was found and we can stop looking | 9443 | * @return #GNUNET_NO if a match was found and we can stop looking |
9381 | */ | 9444 | */ |
9382 | static int | 9445 | static int |
9383 | check_validation_request_pending(void *cls, | 9446 | check_validation_request_pending (void *cls, |
9384 | const struct GNUNET_PeerIdentity *pid, | 9447 | const struct GNUNET_PeerIdentity *pid, |
9385 | void *value) | 9448 | void *value) |
9386 | { | 9449 | { |
9387 | struct Queue *q = cls; | 9450 | struct Queue *q = cls; |
9388 | struct ValidationState *vs = value; | 9451 | struct ValidationState *vs = value; |
9389 | 9452 | ||
9390 | (void)pid; | 9453 | (void) pid; |
9391 | if ((GNUNET_YES == vs->awaiting_queue) && | 9454 | if ((GNUNET_YES == vs->awaiting_queue) && |
9392 | (0 == strcmp(vs->address, q->address))) | 9455 | (0 == strcmp (vs->address, q->address))) |
9393 | { | 9456 | { |
9394 | vs->awaiting_queue = GNUNET_NO; | 9457 | vs->awaiting_queue = GNUNET_NO; |
9395 | validation_transmit_on_queue(q, vs); | 9458 | validation_transmit_on_queue (q, vs); |
9396 | return GNUNET_NO; | 9459 | return GNUNET_NO; |
9397 | } | 9460 | } |
9398 | return GNUNET_OK; | 9461 | return GNUNET_OK; |
9399 | } | 9462 | } |
9400 | 9463 | ||
@@ -9408,31 +9471,31 @@ check_validation_request_pending(void *cls, | |||
9408 | * @param emsg error message | 9471 | * @param emsg error message |
9409 | */ | 9472 | */ |
9410 | static void | 9473 | static void |
9411 | neighbour_dv_monotime_cb(void *cls, | 9474 | neighbour_dv_monotime_cb (void *cls, |
9412 | const struct GNUNET_PEERSTORE_Record *record, | 9475 | const struct GNUNET_PEERSTORE_Record *record, |
9413 | const char *emsg) | 9476 | const char *emsg) |
9414 | { | 9477 | { |
9415 | struct Neighbour *n = cls; | 9478 | struct Neighbour *n = cls; |
9416 | struct GNUNET_TIME_AbsoluteNBO *mtbe; | 9479 | struct GNUNET_TIME_AbsoluteNBO *mtbe; |
9417 | 9480 | ||
9418 | (void)emsg; | 9481 | (void) emsg; |
9419 | if (NULL == record) | 9482 | if (NULL == record) |
9420 | { | 9483 | { |
9421 | /* we're done with #neighbour_dv_monotime_cb() invocations, | 9484 | /* we're done with #neighbour_dv_monotime_cb() invocations, |
9422 | continue normal processing */ | 9485 | continue normal processing */ |
9423 | n->get = NULL; | 9486 | n->get = NULL; |
9424 | n->dv_monotime_available = GNUNET_YES; | 9487 | n->dv_monotime_available = GNUNET_YES; |
9425 | return; | 9488 | return; |
9426 | } | 9489 | } |
9427 | if (sizeof(*mtbe) != record->value_size) | 9490 | if (sizeof(*mtbe) != record->value_size) |
9428 | { | 9491 | { |
9429 | GNUNET_break(0); | 9492 | GNUNET_break (0); |
9430 | return; | 9493 | return; |
9431 | } | 9494 | } |
9432 | mtbe = record->value; | 9495 | mtbe = record->value; |
9433 | n->last_dv_learn_monotime = | 9496 | n->last_dv_learn_monotime = |
9434 | GNUNET_TIME_absolute_max(n->last_dv_learn_monotime, | 9497 | GNUNET_TIME_absolute_max (n->last_dv_learn_monotime, |
9435 | GNUNET_TIME_absolute_ntoh(*mtbe)); | 9498 | GNUNET_TIME_absolute_ntoh (*mtbe)); |
9436 | } | 9499 | } |
9437 | 9500 | ||
9438 | 9501 | ||
@@ -9443,8 +9506,8 @@ neighbour_dv_monotime_cb(void *cls, | |||
9443 | * @param aqm the send message that was sent | 9506 | * @param aqm the send message that was sent |
9444 | */ | 9507 | */ |
9445 | static void | 9508 | static void |
9446 | handle_add_queue_message(void *cls, | 9509 | handle_add_queue_message (void *cls, |
9447 | const struct GNUNET_TRANSPORT_AddQueueMessage *aqm) | 9510 | const struct GNUNET_TRANSPORT_AddQueueMessage *aqm) |
9448 | { | 9511 | { |
9449 | struct TransportClient *tc = cls; | 9512 | struct TransportClient *tc = cls; |
9450 | struct Queue *queue; | 9513 | struct Queue *queue; |
@@ -9452,77 +9515,77 @@ handle_add_queue_message(void *cls, | |||
9452 | const char *addr; | 9515 | const char *addr; |
9453 | uint16_t addr_len; | 9516 | uint16_t addr_len; |
9454 | 9517 | ||
9455 | if (ntohl(aqm->mtu) <= sizeof(struct TransportFragmentBoxMessage)) | 9518 | if (ntohl (aqm->mtu) <= sizeof(struct TransportFragmentBoxMessage)) |
9456 | { | 9519 | { |
9457 | /* MTU so small as to be useless for transmissions, | 9520 | /* MTU so small as to be useless for transmissions, |
9458 | required for #fragment_message()! */ | 9521 | required for #fragment_message()! */ |
9459 | GNUNET_break_op(0); | 9522 | GNUNET_break_op (0); |
9460 | GNUNET_SERVICE_client_drop(tc->client); | 9523 | GNUNET_SERVICE_client_drop (tc->client); |
9461 | return; | 9524 | return; |
9462 | } | 9525 | } |
9463 | neighbour = lookup_neighbour(&aqm->receiver); | 9526 | neighbour = lookup_neighbour (&aqm->receiver); |
9464 | if (NULL == neighbour) | 9527 | if (NULL == neighbour) |
9465 | { | 9528 | { |
9466 | neighbour = GNUNET_new(struct Neighbour); | 9529 | neighbour = GNUNET_new (struct Neighbour); |
9467 | neighbour->pid = aqm->receiver; | 9530 | neighbour->pid = aqm->receiver; |
9468 | GNUNET_assert(GNUNET_OK == | 9531 | GNUNET_assert (GNUNET_OK == |
9469 | GNUNET_CONTAINER_multipeermap_put( | 9532 | GNUNET_CONTAINER_multipeermap_put ( |
9470 | neighbours, | 9533 | neighbours, |
9471 | &neighbour->pid, | 9534 | &neighbour->pid, |
9472 | neighbour, | 9535 | neighbour, |
9473 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 9536 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
9474 | neighbour->get = | 9537 | neighbour->get = |
9475 | GNUNET_PEERSTORE_iterate(peerstore, | 9538 | GNUNET_PEERSTORE_iterate (peerstore, |
9476 | "transport", | 9539 | "transport", |
9477 | &neighbour->pid, | 9540 | &neighbour->pid, |
9478 | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME, | 9541 | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME, |
9479 | &neighbour_dv_monotime_cb, | 9542 | &neighbour_dv_monotime_cb, |
9480 | neighbour); | 9543 | neighbour); |
9481 | } | 9544 | } |
9482 | addr_len = ntohs(aqm->header.size) - sizeof(*aqm); | 9545 | addr_len = ntohs (aqm->header.size) - sizeof(*aqm); |
9483 | addr = (const char *)&aqm[1]; | 9546 | addr = (const char *) &aqm[1]; |
9484 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9485 | "New queue %s to %s available with QID %llu\n", | 9548 | "New queue %s to %s available with QID %llu\n", |
9486 | addr, | 9549 | addr, |
9487 | GNUNET_i2s(&aqm->receiver), | 9550 | GNUNET_i2s (&aqm->receiver), |
9488 | (unsigned long long)aqm->qid); | 9551 | (unsigned long long) aqm->qid); |
9489 | queue = GNUNET_malloc(sizeof(struct Queue) + addr_len); | 9552 | queue = GNUNET_malloc (sizeof(struct Queue) + addr_len); |
9490 | queue->tc = tc; | 9553 | queue->tc = tc; |
9491 | queue->address = (const char *)&queue[1]; | 9554 | queue->address = (const char *) &queue[1]; |
9492 | queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 9555 | queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
9493 | queue->qid = aqm->qid; | 9556 | queue->qid = aqm->qid; |
9494 | queue->mtu = ntohl(aqm->mtu); | 9557 | queue->mtu = ntohl (aqm->mtu); |
9495 | queue->nt = (enum GNUNET_NetworkType)ntohl(aqm->nt); | 9558 | queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); |
9496 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus)ntohl(aqm->cs); | 9559 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); |
9497 | queue->neighbour = neighbour; | 9560 | queue->neighbour = neighbour; |
9498 | queue->idle = GNUNET_YES; | 9561 | queue->idle = GNUNET_YES; |
9499 | memcpy(&queue[1], addr, addr_len); | 9562 | memcpy (&queue[1], addr, addr_len); |
9500 | /* notify monitors about new queue */ | 9563 | /* notify monitors about new queue */ |
9501 | { | 9564 | { |
9502 | struct MonitorEvent me = { .rtt = queue->pd.aged_rtt, .cs = queue->cs }; | 9565 | struct MonitorEvent me = { .rtt = queue->pd.aged_rtt, .cs = queue->cs }; |
9503 | 9566 | ||
9504 | notify_monitors(&neighbour->pid, queue->address, queue->nt, &me); | 9567 | notify_monitors (&neighbour->pid, queue->address, queue->nt, &me); |
9505 | } | 9568 | } |
9506 | GNUNET_CONTAINER_MDLL_insert(neighbour, | 9569 | GNUNET_CONTAINER_MDLL_insert (neighbour, |
9507 | neighbour->queue_head, | 9570 | neighbour->queue_head, |
9508 | neighbour->queue_tail, | 9571 | neighbour->queue_tail, |
9509 | queue); | 9572 | queue); |
9510 | GNUNET_CONTAINER_MDLL_insert(client, | 9573 | GNUNET_CONTAINER_MDLL_insert (client, |
9511 | tc->details.communicator.queue_head, | 9574 | tc->details.communicator.queue_head, |
9512 | tc->details.communicator.queue_tail, | 9575 | tc->details.communicator.queue_tail, |
9513 | queue); | 9576 | queue); |
9514 | /* check if valdiations are waiting for the queue */ | 9577 | /* check if valdiations are waiting for the queue */ |
9515 | (void) | 9578 | (void) |
9516 | GNUNET_CONTAINER_multipeermap_get_multiple(validation_map, | 9579 | GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, |
9517 | &aqm->receiver, | 9580 | &aqm->receiver, |
9518 | &check_validation_request_pending, | 9581 | &check_validation_request_pending, |
9519 | queue); | 9582 | queue); |
9520 | /* look for traffic for this queue */ | 9583 | /* look for traffic for this queue */ |
9521 | schedule_transmit_on_queue(queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 9584 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
9522 | /* might be our first queue, try launching DV learning */ | 9585 | /* might be our first queue, try launching DV learning */ |
9523 | if (NULL == dvlearn_task) | 9586 | if (NULL == dvlearn_task) |
9524 | dvlearn_task = GNUNET_SCHEDULER_add_now(&start_dv_learn, NULL); | 9587 | dvlearn_task = GNUNET_SCHEDULER_add_now (&start_dv_learn, NULL); |
9525 | GNUNET_SERVICE_client_continue(tc->client); | 9588 | GNUNET_SERVICE_client_continue (tc->client); |
9526 | } | 9589 | } |
9527 | 9590 | ||
9528 | 9591 | ||
@@ -9534,25 +9597,25 @@ handle_add_queue_message(void *cls, | |||
9534 | * @param cqr confirmation message | 9597 | * @param cqr confirmation message |
9535 | */ | 9598 | */ |
9536 | static void | 9599 | static void |
9537 | handle_queue_create_ok(void *cls, | 9600 | handle_queue_create_ok (void *cls, |
9538 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) | 9601 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) |
9539 | { | 9602 | { |
9540 | struct TransportClient *tc = cls; | 9603 | struct TransportClient *tc = cls; |
9541 | 9604 | ||
9542 | if (CT_COMMUNICATOR != tc->type) | 9605 | if (CT_COMMUNICATOR != tc->type) |
9543 | { | 9606 | { |
9544 | GNUNET_break(0); | 9607 | GNUNET_break (0); |
9545 | GNUNET_SERVICE_client_drop(tc->client); | 9608 | GNUNET_SERVICE_client_drop (tc->client); |
9546 | return; | 9609 | return; |
9547 | } | 9610 | } |
9548 | GNUNET_STATISTICS_update(GST_stats, | 9611 | GNUNET_STATISTICS_update (GST_stats, |
9549 | "# Suggestions succeeded at communicator", | 9612 | "# Suggestions succeeded at communicator", |
9550 | 1, | 9613 | 1, |
9551 | GNUNET_NO); | 9614 | GNUNET_NO); |
9552 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9553 | "Request #%u for communicator to create queue succeeded\n", | 9616 | "Request #%u for communicator to create queue succeeded\n", |
9554 | (unsigned int)ntohs(cqr->request_id)); | 9617 | (unsigned int) ntohs (cqr->request_id)); |
9555 | GNUNET_SERVICE_client_continue(tc->client); | 9618 | GNUNET_SERVICE_client_continue (tc->client); |
9556 | } | 9619 | } |
9557 | 9620 | ||
9558 | 9621 | ||
@@ -9565,26 +9628,26 @@ handle_queue_create_ok(void *cls, | |||
9565 | * @param cqr failure message | 9628 | * @param cqr failure message |
9566 | */ | 9629 | */ |
9567 | static void | 9630 | static void |
9568 | handle_queue_create_fail( | 9631 | handle_queue_create_fail ( |
9569 | void *cls, | 9632 | void *cls, |
9570 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) | 9633 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) |
9571 | { | 9634 | { |
9572 | struct TransportClient *tc = cls; | 9635 | struct TransportClient *tc = cls; |
9573 | 9636 | ||
9574 | if (CT_COMMUNICATOR != tc->type) | 9637 | if (CT_COMMUNICATOR != tc->type) |
9575 | { | 9638 | { |
9576 | GNUNET_break(0); | 9639 | GNUNET_break (0); |
9577 | GNUNET_SERVICE_client_drop(tc->client); | 9640 | GNUNET_SERVICE_client_drop (tc->client); |
9578 | return; | 9641 | return; |
9579 | } | 9642 | } |
9580 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9581 | "Request #%u for communicator to create queue failed\n", | 9644 | "Request #%u for communicator to create queue failed\n", |
9582 | (unsigned int)ntohs(cqr->request_id)); | 9645 | (unsigned int) ntohs (cqr->request_id)); |
9583 | GNUNET_STATISTICS_update(GST_stats, | 9646 | GNUNET_STATISTICS_update (GST_stats, |
9584 | "# Suggestions failed in queue creation at communicator", | 9647 | "# Suggestions failed in queue creation at communicator", |
9585 | 1, | 9648 | 1, |
9586 | GNUNET_NO); | 9649 | GNUNET_NO); |
9587 | GNUNET_SERVICE_client_continue(tc->client); | 9650 | GNUNET_SERVICE_client_continue (tc->client); |
9588 | } | 9651 | } |
9589 | 9652 | ||
9590 | 9653 | ||
@@ -9596,27 +9659,27 @@ handle_queue_create_fail( | |||
9596 | * @param msg the start message | 9659 | * @param msg the start message |
9597 | */ | 9660 | */ |
9598 | static void | 9661 | static void |
9599 | handle_suggest_cancel(void *cls, const struct ExpressPreferenceMessage *msg) | 9662 | handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg) |
9600 | { | 9663 | { |
9601 | struct TransportClient *tc = cls; | 9664 | struct TransportClient *tc = cls; |
9602 | struct PeerRequest *pr; | 9665 | struct PeerRequest *pr; |
9603 | 9666 | ||
9604 | if (CT_APPLICATION != tc->type) | 9667 | if (CT_APPLICATION != tc->type) |
9605 | { | 9668 | { |
9606 | GNUNET_break(0); | 9669 | GNUNET_break (0); |
9607 | GNUNET_SERVICE_client_drop(tc->client); | 9670 | GNUNET_SERVICE_client_drop (tc->client); |
9608 | return; | 9671 | return; |
9609 | } | 9672 | } |
9610 | pr = GNUNET_CONTAINER_multipeermap_get(tc->details.application.requests, | 9673 | pr = GNUNET_CONTAINER_multipeermap_get (tc->details.application.requests, |
9611 | &msg->peer); | 9674 | &msg->peer); |
9612 | if (NULL == pr) | 9675 | if (NULL == pr) |
9613 | { | 9676 | { |
9614 | GNUNET_break(0); | 9677 | GNUNET_break (0); |
9615 | GNUNET_SERVICE_client_drop(tc->client); | 9678 | GNUNET_SERVICE_client_drop (tc->client); |
9616 | return; | 9679 | return; |
9617 | } | 9680 | } |
9618 | (void)stop_peer_request(tc, &pr->pid, pr); | 9681 | (void) stop_peer_request (tc, &pr->pid, pr); |
9619 | GNUNET_SERVICE_client_continue(tc->client); | 9682 | GNUNET_SERVICE_client_continue (tc->client); |
9620 | } | 9683 | } |
9621 | 9684 | ||
9622 | 9685 | ||
@@ -9628,27 +9691,27 @@ handle_suggest_cancel(void *cls, const struct ExpressPreferenceMessage *msg) | |||
9628 | * @param emsg error message, or NULL if no errors | 9691 | * @param emsg error message, or NULL if no errors |
9629 | */ | 9692 | */ |
9630 | static void | 9693 | static void |
9631 | handle_hello_for_client(void *cls, | 9694 | handle_hello_for_client (void *cls, |
9632 | const struct GNUNET_PEERSTORE_Record *record, | 9695 | const struct GNUNET_PEERSTORE_Record *record, |
9633 | const char *emsg) | 9696 | const char *emsg) |
9634 | { | 9697 | { |
9635 | struct PeerRequest *pr = cls; | 9698 | struct PeerRequest *pr = cls; |
9636 | const char *val; | 9699 | const char *val; |
9637 | 9700 | ||
9638 | if (NULL != emsg) | 9701 | if (NULL != emsg) |
9639 | { | 9702 | { |
9640 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 9703 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
9641 | "Got failure from PEERSTORE: %s\n", | 9704 | "Got failure from PEERSTORE: %s\n", |
9642 | emsg); | 9705 | emsg); |
9643 | return; | 9706 | return; |
9644 | } | 9707 | } |
9645 | val = record->value; | 9708 | val = record->value; |
9646 | if ((0 == record->value_size) || ('\0' != val[record->value_size - 1])) | 9709 | if ((0 == record->value_size) || ('\0' != val[record->value_size - 1])) |
9647 | { | 9710 | { |
9648 | GNUNET_break(0); | 9711 | GNUNET_break (0); |
9649 | return; | 9712 | return; |
9650 | } | 9713 | } |
9651 | start_address_validation(&pr->pid, (const char *)record->value); | 9714 | start_address_validation (&pr->pid, (const char *) record->value); |
9652 | } | 9715 | } |
9653 | 9716 | ||
9654 | 9717 | ||
@@ -9660,51 +9723,51 @@ handle_hello_for_client(void *cls, | |||
9660 | * @param msg the start message | 9723 | * @param msg the start message |
9661 | */ | 9724 | */ |
9662 | static void | 9725 | static void |
9663 | handle_suggest(void *cls, const struct ExpressPreferenceMessage *msg) | 9726 | handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg) |
9664 | { | 9727 | { |
9665 | struct TransportClient *tc = cls; | 9728 | struct TransportClient *tc = cls; |
9666 | struct PeerRequest *pr; | 9729 | struct PeerRequest *pr; |
9667 | 9730 | ||
9668 | if (CT_NONE == tc->type) | 9731 | if (CT_NONE == tc->type) |
9669 | { | 9732 | { |
9670 | tc->type = CT_APPLICATION; | 9733 | tc->type = CT_APPLICATION; |
9671 | tc->details.application.requests = | 9734 | tc->details.application.requests = |
9672 | GNUNET_CONTAINER_multipeermap_create(16, GNUNET_YES); | 9735 | GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); |
9673 | } | 9736 | } |
9674 | if (CT_APPLICATION != tc->type) | 9737 | if (CT_APPLICATION != tc->type) |
9675 | { | 9738 | { |
9676 | GNUNET_break(0); | 9739 | GNUNET_break (0); |
9677 | GNUNET_SERVICE_client_drop(tc->client); | 9740 | GNUNET_SERVICE_client_drop (tc->client); |
9678 | return; | 9741 | return; |
9679 | } | 9742 | } |
9680 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 9743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9681 | "Client suggested we talk to %s with preference %d at rate %u\n", | 9744 | "Client suggested we talk to %s with preference %d at rate %u\n", |
9682 | GNUNET_i2s(&msg->peer), | 9745 | GNUNET_i2s (&msg->peer), |
9683 | (int)ntohl(msg->pk), | 9746 | (int) ntohl (msg->pk), |
9684 | (int)ntohl(msg->bw.value__)); | 9747 | (int) ntohl (msg->bw.value__)); |
9685 | pr = GNUNET_new(struct PeerRequest); | 9748 | pr = GNUNET_new (struct PeerRequest); |
9686 | pr->tc = tc; | 9749 | pr->tc = tc; |
9687 | pr->pid = msg->peer; | 9750 | pr->pid = msg->peer; |
9688 | pr->bw = msg->bw; | 9751 | pr->bw = msg->bw; |
9689 | pr->pk = (enum GNUNET_MQ_PriorityPreferences)ntohl(msg->pk); | 9752 | pr->pk = (enum GNUNET_MQ_PriorityPreferences) ntohl (msg->pk); |
9690 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put( | 9753 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put ( |
9691 | tc->details.application.requests, | 9754 | tc->details.application.requests, |
9692 | &pr->pid, | 9755 | &pr->pid, |
9693 | pr, | 9756 | pr, |
9694 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 9757 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
9695 | { | 9758 | { |
9696 | GNUNET_break(0); | 9759 | GNUNET_break (0); |
9697 | GNUNET_free(pr); | 9760 | GNUNET_free (pr); |
9698 | GNUNET_SERVICE_client_drop(tc->client); | 9761 | GNUNET_SERVICE_client_drop (tc->client); |
9699 | return; | 9762 | return; |
9700 | } | 9763 | } |
9701 | pr->wc = GNUNET_PEERSTORE_watch(peerstore, | 9764 | pr->wc = GNUNET_PEERSTORE_watch (peerstore, |
9702 | "transport", | 9765 | "transport", |
9703 | &pr->pid, | 9766 | &pr->pid, |
9704 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, | 9767 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, |
9705 | &handle_hello_for_client, | 9768 | &handle_hello_for_client, |
9706 | pr); | 9769 | pr); |
9707 | GNUNET_SERVICE_client_continue(tc->client); | 9770 | GNUNET_SERVICE_client_continue (tc->client); |
9708 | } | 9771 | } |
9709 | 9772 | ||
9710 | 9773 | ||
@@ -9717,11 +9780,11 @@ handle_suggest(void *cls, const struct ExpressPreferenceMessage *msg) | |||
9717 | * @return #GNUNET_OK on success | 9780 | * @return #GNUNET_OK on success |
9718 | */ | 9781 | */ |
9719 | static int | 9782 | static int |
9720 | check_request_hello_validation(void *cls, | 9783 | check_request_hello_validation (void *cls, |
9721 | const struct RequestHelloValidationMessage *m) | 9784 | const struct RequestHelloValidationMessage *m) |
9722 | { | 9785 | { |
9723 | (void)cls; | 9786 | (void) cls; |
9724 | GNUNET_MQ_check_zero_termination(m); | 9787 | GNUNET_MQ_check_zero_termination (m); |
9725 | return GNUNET_OK; | 9788 | return GNUNET_OK; |
9726 | } | 9789 | } |
9727 | 9790 | ||
@@ -9734,13 +9797,13 @@ check_request_hello_validation(void *cls, | |||
9734 | * @param m message to verify | 9797 | * @param m message to verify |
9735 | */ | 9798 | */ |
9736 | static void | 9799 | static void |
9737 | handle_request_hello_validation(void *cls, | 9800 | handle_request_hello_validation (void *cls, |
9738 | const struct RequestHelloValidationMessage *m) | 9801 | const struct RequestHelloValidationMessage *m) |
9739 | { | 9802 | { |
9740 | struct TransportClient *tc = cls; | 9803 | struct TransportClient *tc = cls; |
9741 | 9804 | ||
9742 | start_address_validation(&m->peer, (const char *)&m[1]); | 9805 | start_address_validation (&m->peer, (const char *) &m[1]); |
9743 | GNUNET_SERVICE_client_continue(tc->client); | 9806 | GNUNET_SERVICE_client_continue (tc->client); |
9744 | } | 9807 | } |
9745 | 9808 | ||
9746 | 9809 | ||
@@ -9753,16 +9816,16 @@ handle_request_hello_validation(void *cls, | |||
9753 | * @return #GNUNET_OK (always) | 9816 | * @return #GNUNET_OK (always) |
9754 | */ | 9817 | */ |
9755 | static int | 9818 | static int |
9756 | free_neighbour_cb(void *cls, | 9819 | free_neighbour_cb (void *cls, |
9757 | const struct GNUNET_PeerIdentity *pid, | 9820 | const struct GNUNET_PeerIdentity *pid, |
9758 | void *value) | 9821 | void *value) |
9759 | { | 9822 | { |
9760 | struct Neighbour *neighbour = value; | 9823 | struct Neighbour *neighbour = value; |
9761 | 9824 | ||
9762 | (void)cls; | 9825 | (void) cls; |
9763 | (void)pid; | 9826 | (void) pid; |
9764 | GNUNET_break(0); // should this ever happen? | 9827 | GNUNET_break (0); // should this ever happen? |
9765 | free_neighbour(neighbour); | 9828 | free_neighbour (neighbour); |
9766 | 9829 | ||
9767 | return GNUNET_OK; | 9830 | return GNUNET_OK; |
9768 | } | 9831 | } |
@@ -9777,15 +9840,15 @@ free_neighbour_cb(void *cls, | |||
9777 | * @return #GNUNET_OK (always) | 9840 | * @return #GNUNET_OK (always) |
9778 | */ | 9841 | */ |
9779 | static int | 9842 | static int |
9780 | free_dv_routes_cb(void *cls, | 9843 | free_dv_routes_cb (void *cls, |
9781 | const struct GNUNET_PeerIdentity *pid, | 9844 | const struct GNUNET_PeerIdentity *pid, |
9782 | void *value) | 9845 | void *value) |
9783 | { | 9846 | { |
9784 | struct DistanceVector *dv = value; | 9847 | struct DistanceVector *dv = value; |
9785 | 9848 | ||
9786 | (void)cls; | 9849 | (void) cls; |
9787 | (void)pid; | 9850 | (void) pid; |
9788 | free_dv_route(dv); | 9851 | free_dv_route (dv); |
9789 | 9852 | ||
9790 | return GNUNET_OK; | 9853 | return GNUNET_OK; |
9791 | } | 9854 | } |
@@ -9800,15 +9863,15 @@ free_dv_routes_cb(void *cls, | |||
9800 | * @return #GNUNET_OK (always) | 9863 | * @return #GNUNET_OK (always) |
9801 | */ | 9864 | */ |
9802 | static int | 9865 | static int |
9803 | free_validation_state_cb(void *cls, | 9866 | free_validation_state_cb (void *cls, |
9804 | const struct GNUNET_PeerIdentity *pid, | 9867 | const struct GNUNET_PeerIdentity *pid, |
9805 | void *value) | 9868 | void *value) |
9806 | { | 9869 | { |
9807 | struct ValidationState *vs = value; | 9870 | struct ValidationState *vs = value; |
9808 | 9871 | ||
9809 | (void)cls; | 9872 | (void) cls; |
9810 | (void)pid; | 9873 | (void) pid; |
9811 | free_validation_state(vs); | 9874 | free_validation_state (vs); |
9812 | return GNUNET_OK; | 9875 | return GNUNET_OK; |
9813 | } | 9876 | } |
9814 | 9877 | ||
@@ -9822,13 +9885,13 @@ free_validation_state_cb(void *cls, | |||
9822 | * @return #GNUNET_OK (always) | 9885 | * @return #GNUNET_OK (always) |
9823 | */ | 9886 | */ |
9824 | static int | 9887 | static int |
9825 | free_pending_ack_cb(void *cls, const struct GNUNET_Uuid *key, void *value) | 9888 | free_pending_ack_cb (void *cls, const struct GNUNET_Uuid *key, void *value) |
9826 | { | 9889 | { |
9827 | struct PendingAcknowledgement *pa = value; | 9890 | struct PendingAcknowledgement *pa = value; |
9828 | 9891 | ||
9829 | (void)cls; | 9892 | (void) cls; |
9830 | (void)key; | 9893 | (void) key; |
9831 | free_pending_acknowledgement(pa); | 9894 | free_pending_acknowledgement (pa); |
9832 | return GNUNET_OK; | 9895 | return GNUNET_OK; |
9833 | } | 9896 | } |
9834 | 9897 | ||
@@ -9842,15 +9905,15 @@ free_pending_ack_cb(void *cls, const struct GNUNET_Uuid *key, void *value) | |||
9842 | * @return #GNUNET_OK (always) | 9905 | * @return #GNUNET_OK (always) |
9843 | */ | 9906 | */ |
9844 | static int | 9907 | static int |
9845 | free_ack_cummulator_cb(void *cls, | 9908 | free_ack_cummulator_cb (void *cls, |
9846 | const struct GNUNET_PeerIdentity *pid, | 9909 | const struct GNUNET_PeerIdentity *pid, |
9847 | void *value) | 9910 | void *value) |
9848 | { | 9911 | { |
9849 | struct AcknowledgementCummulator *ac = value; | 9912 | struct AcknowledgementCummulator *ac = value; |
9850 | 9913 | ||
9851 | (void)cls; | 9914 | (void) cls; |
9852 | (void)pid; | 9915 | (void) pid; |
9853 | GNUNET_free(ac); | 9916 | GNUNET_free (ac); |
9854 | return GNUNET_OK; | 9917 | return GNUNET_OK; |
9855 | } | 9918 | } |
9856 | 9919 | ||
@@ -9862,68 +9925,68 @@ free_ack_cummulator_cb(void *cls, | |||
9862 | * @param cls closure, unused | 9925 | * @param cls closure, unused |
9863 | */ | 9926 | */ |
9864 | static void | 9927 | static void |
9865 | do_shutdown(void *cls) | 9928 | do_shutdown (void *cls) |
9866 | { | 9929 | { |
9867 | struct LearnLaunchEntry *lle; | 9930 | struct LearnLaunchEntry *lle; |
9868 | 9931 | ||
9869 | (void)cls; | 9932 | (void) cls; |
9870 | 9933 | ||
9871 | GNUNET_CONTAINER_multipeermap_iterate(neighbours, &free_neighbour_cb, NULL); | 9934 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, &free_neighbour_cb, NULL); |
9872 | if (NULL != peerstore) | 9935 | if (NULL != peerstore) |
9873 | { | 9936 | { |
9874 | GNUNET_PEERSTORE_disconnect(peerstore, GNUNET_NO); | 9937 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); |
9875 | peerstore = NULL; | 9938 | peerstore = NULL; |
9876 | } | 9939 | } |
9877 | if (NULL != GST_stats) | 9940 | if (NULL != GST_stats) |
9878 | { | 9941 | { |
9879 | GNUNET_STATISTICS_destroy(GST_stats, GNUNET_NO); | 9942 | GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); |
9880 | GST_stats = NULL; | 9943 | GST_stats = NULL; |
9881 | } | 9944 | } |
9882 | if (NULL != GST_my_private_key) | 9945 | if (NULL != GST_my_private_key) |
9883 | { | 9946 | { |
9884 | GNUNET_free(GST_my_private_key); | 9947 | GNUNET_free (GST_my_private_key); |
9885 | GST_my_private_key = NULL; | 9948 | GST_my_private_key = NULL; |
9886 | } | 9949 | } |
9887 | GNUNET_CONTAINER_multipeermap_iterate(ack_cummulators, | 9950 | GNUNET_CONTAINER_multipeermap_iterate (ack_cummulators, |
9888 | &free_ack_cummulator_cb, | 9951 | &free_ack_cummulator_cb, |
9889 | NULL); | 9952 | NULL); |
9890 | GNUNET_CONTAINER_multipeermap_destroy(ack_cummulators); | 9953 | GNUNET_CONTAINER_multipeermap_destroy (ack_cummulators); |
9891 | ack_cummulators = NULL; | 9954 | ack_cummulators = NULL; |
9892 | GNUNET_CONTAINER_multiuuidmap_iterate(pending_acks, | 9955 | GNUNET_CONTAINER_multiuuidmap_iterate (pending_acks, |
9893 | &free_pending_ack_cb, | 9956 | &free_pending_ack_cb, |
9894 | NULL); | 9957 | NULL); |
9895 | GNUNET_CONTAINER_multiuuidmap_destroy(pending_acks); | 9958 | GNUNET_CONTAINER_multiuuidmap_destroy (pending_acks); |
9896 | pending_acks = NULL; | 9959 | pending_acks = NULL; |
9897 | GNUNET_break(0 == GNUNET_CONTAINER_multipeermap_size(neighbours)); | 9960 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (neighbours)); |
9898 | GNUNET_CONTAINER_multipeermap_destroy(neighbours); | 9961 | GNUNET_CONTAINER_multipeermap_destroy (neighbours); |
9899 | neighbours = NULL; | 9962 | neighbours = NULL; |
9900 | GNUNET_break(0 == GNUNET_CONTAINER_multipeermap_size(links)); | 9963 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (links)); |
9901 | GNUNET_CONTAINER_multipeermap_destroy(links); | 9964 | GNUNET_CONTAINER_multipeermap_destroy (links); |
9902 | links = NULL; | 9965 | links = NULL; |
9903 | GNUNET_CONTAINER_multipeermap_iterate(backtalkers, | 9966 | GNUNET_CONTAINER_multipeermap_iterate (backtalkers, |
9904 | &free_backtalker_cb, | 9967 | &free_backtalker_cb, |
9905 | NULL); | 9968 | NULL); |
9906 | GNUNET_CONTAINER_multipeermap_destroy(backtalkers); | 9969 | GNUNET_CONTAINER_multipeermap_destroy (backtalkers); |
9907 | backtalkers = NULL; | 9970 | backtalkers = NULL; |
9908 | GNUNET_CONTAINER_multipeermap_iterate(validation_map, | 9971 | GNUNET_CONTAINER_multipeermap_iterate (validation_map, |
9909 | &free_validation_state_cb, | 9972 | &free_validation_state_cb, |
9910 | NULL); | 9973 | NULL); |
9911 | GNUNET_CONTAINER_multipeermap_destroy(validation_map); | 9974 | GNUNET_CONTAINER_multipeermap_destroy (validation_map); |
9912 | validation_map = NULL; | 9975 | validation_map = NULL; |
9913 | while (NULL != ir_head) | 9976 | while (NULL != ir_head) |
9914 | free_incoming_request(ir_head); | 9977 | free_incoming_request (ir_head); |
9915 | GNUNET_assert(0 == ir_total); | 9978 | GNUNET_assert (0 == ir_total); |
9916 | while (NULL != (lle = lle_head)) | 9979 | while (NULL != (lle = lle_head)) |
9917 | { | 9980 | { |
9918 | GNUNET_CONTAINER_DLL_remove(lle_head, lle_tail, lle); | 9981 | GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle); |
9919 | GNUNET_free(lle); | 9982 | GNUNET_free (lle); |
9920 | } | 9983 | } |
9921 | GNUNET_CONTAINER_multishortmap_destroy(dvlearn_map); | 9984 | GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map); |
9922 | dvlearn_map = NULL; | 9985 | dvlearn_map = NULL; |
9923 | GNUNET_CONTAINER_heap_destroy(validation_heap); | 9986 | GNUNET_CONTAINER_heap_destroy (validation_heap); |
9924 | validation_heap = NULL; | 9987 | validation_heap = NULL; |
9925 | GNUNET_CONTAINER_multipeermap_iterate(dv_routes, &free_dv_routes_cb, NULL); | 9988 | GNUNET_CONTAINER_multipeermap_iterate (dv_routes, &free_dv_routes_cb, NULL); |
9926 | GNUNET_CONTAINER_multipeermap_destroy(dv_routes); | 9989 | GNUNET_CONTAINER_multipeermap_destroy (dv_routes); |
9927 | dv_routes = NULL; | 9990 | dv_routes = NULL; |
9928 | } | 9991 | } |
9929 | 9992 | ||
@@ -9936,58 +9999,58 @@ do_shutdown(void *cls) | |||
9936 | * @param service the initialized service | 9999 | * @param service the initialized service |
9937 | */ | 10000 | */ |
9938 | static void | 10001 | static void |
9939 | run(void *cls, | 10002 | run (void *cls, |
9940 | const struct GNUNET_CONFIGURATION_Handle *c, | 10003 | const struct GNUNET_CONFIGURATION_Handle *c, |
9941 | struct GNUNET_SERVICE_Handle *service) | 10004 | struct GNUNET_SERVICE_Handle *service) |
9942 | { | 10005 | { |
9943 | (void)cls; | 10006 | (void) cls; |
9944 | (void)service; | 10007 | (void) service; |
9945 | /* setup globals */ | 10008 | /* setup globals */ |
9946 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic(c); | 10009 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); |
9947 | GST_cfg = c; | 10010 | GST_cfg = c; |
9948 | backtalkers = GNUNET_CONTAINER_multipeermap_create(16, GNUNET_YES); | 10011 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); |
9949 | pending_acks = GNUNET_CONTAINER_multiuuidmap_create(32768, GNUNET_YES); | 10012 | pending_acks = GNUNET_CONTAINER_multiuuidmap_create (32768, GNUNET_YES); |
9950 | ack_cummulators = GNUNET_CONTAINER_multipeermap_create(256, GNUNET_YES); | 10013 | ack_cummulators = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_YES); |
9951 | neighbours = GNUNET_CONTAINER_multipeermap_create(1024, GNUNET_YES); | 10014 | neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
9952 | links = GNUNET_CONTAINER_multipeermap_create(512, GNUNET_YES); | 10015 | links = GNUNET_CONTAINER_multipeermap_create (512, GNUNET_YES); |
9953 | dv_routes = GNUNET_CONTAINER_multipeermap_create(1024, GNUNET_YES); | 10016 | dv_routes = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
9954 | dvlearn_map = GNUNET_CONTAINER_multishortmap_create(2 * MAX_DV_LEARN_PENDING, | 10017 | dvlearn_map = GNUNET_CONTAINER_multishortmap_create (2 * MAX_DV_LEARN_PENDING, |
9955 | GNUNET_YES); | 10018 | GNUNET_YES); |
9956 | validation_map = GNUNET_CONTAINER_multipeermap_create(1024, GNUNET_YES); | 10019 | validation_map = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
9957 | validation_heap = | 10020 | validation_heap = |
9958 | GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); | 10021 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
9959 | GST_my_private_key = | 10022 | GST_my_private_key = |
9960 | GNUNET_CRYPTO_eddsa_key_create_from_configuration(GST_cfg); | 10023 | GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg); |
9961 | if (NULL == GST_my_private_key) | 10024 | if (NULL == GST_my_private_key) |
9962 | { | 10025 | { |
9963 | GNUNET_log( | 10026 | GNUNET_log ( |
9964 | GNUNET_ERROR_TYPE_ERROR, | 10027 | GNUNET_ERROR_TYPE_ERROR, |
9965 | _( | 10028 | _ ( |
9966 | "Transport service is lacking key configuration settings. Exiting.\n")); | 10029 | "Transport service is lacking key configuration settings. Exiting.\n")); |
9967 | GNUNET_SCHEDULER_shutdown(); | 10030 | GNUNET_SCHEDULER_shutdown (); |
9968 | return; | 10031 | return; |
9969 | } | 10032 | } |
9970 | GNUNET_CRYPTO_eddsa_key_get_public(GST_my_private_key, | 10033 | GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key, |
9971 | &GST_my_identity.public_key); | 10034 | &GST_my_identity.public_key); |
9972 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 10035 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
9973 | "My identity is `%s'\n", | 10036 | "My identity is `%s'\n", |
9974 | GNUNET_i2s_full(&GST_my_identity)); | 10037 | GNUNET_i2s_full (&GST_my_identity)); |
9975 | GST_stats = GNUNET_STATISTICS_create("transport", GST_cfg); | 10038 | GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); |
9976 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | 10039 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
9977 | peerstore = GNUNET_PEERSTORE_connect(GST_cfg); | 10040 | peerstore = GNUNET_PEERSTORE_connect (GST_cfg); |
9978 | if (NULL == peerstore) | 10041 | if (NULL == peerstore) |
9979 | { | 10042 | { |
9980 | GNUNET_break(0); | 10043 | GNUNET_break (0); |
9981 | GNUNET_SCHEDULER_shutdown(); | 10044 | GNUNET_SCHEDULER_shutdown (); |
9982 | return; | 10045 | return; |
9983 | } | 10046 | } |
9984 | } | 10047 | } |
9985 | 10048 | ||
9986 | 10049 | ||
9987 | /** | 10050 | /** |
9988 | * Define "main" method using service macro. | 10051 | * Define "main" method using service macro. |
9989 | */ | 10052 | */ |
9990 | GNUNET_SERVICE_MAIN( | 10053 | GNUNET_SERVICE_MAIN ( |
9991 | "transport", | 10054 | "transport", |
9992 | GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN, | 10055 | GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN, |
9993 | &run, | 10056 | &run, |
@@ -9995,78 +10058,78 @@ GNUNET_SERVICE_MAIN( | |||
9995 | &client_disconnect_cb, | 10058 | &client_disconnect_cb, |
9996 | NULL, | 10059 | NULL, |
9997 | /* communication with applications */ | 10060 | /* communication with applications */ |
9998 | GNUNET_MQ_hd_fixed_size(suggest, | 10061 | GNUNET_MQ_hd_fixed_size (suggest, |
9999 | GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST, | 10062 | GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST, |
10000 | struct ExpressPreferenceMessage, | 10063 | struct ExpressPreferenceMessage, |
10001 | NULL), | 10064 | NULL), |
10002 | GNUNET_MQ_hd_fixed_size(suggest_cancel, | 10065 | GNUNET_MQ_hd_fixed_size (suggest_cancel, |
10003 | GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, | 10066 | GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, |
10004 | struct ExpressPreferenceMessage, | 10067 | struct ExpressPreferenceMessage, |
10005 | NULL), | 10068 | NULL), |
10006 | GNUNET_MQ_hd_var_size(request_hello_validation, | 10069 | GNUNET_MQ_hd_var_size (request_hello_validation, |
10007 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, | 10070 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, |
10008 | struct RequestHelloValidationMessage, | 10071 | struct RequestHelloValidationMessage, |
10009 | NULL), | 10072 | NULL), |
10010 | /* communication with core */ | 10073 | /* communication with core */ |
10011 | GNUNET_MQ_hd_fixed_size(client_start, | 10074 | GNUNET_MQ_hd_fixed_size (client_start, |
10012 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, | 10075 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, |
10013 | struct StartMessage, | 10076 | struct StartMessage, |
10014 | NULL), | 10077 | NULL), |
10015 | GNUNET_MQ_hd_var_size(client_send, | 10078 | GNUNET_MQ_hd_var_size (client_send, |
10016 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, | 10079 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, |
10017 | struct OutboundMessage, | 10080 | struct OutboundMessage, |
10018 | NULL), | 10081 | NULL), |
10019 | GNUNET_MQ_hd_fixed_size(client_recv_ok, | 10082 | GNUNET_MQ_hd_fixed_size (client_recv_ok, |
10020 | GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK, | 10083 | GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK, |
10021 | struct RecvOkMessage, | 10084 | struct RecvOkMessage, |
10022 | NULL), | 10085 | NULL), |
10023 | /* communication with communicators */ | 10086 | /* communication with communicators */ |
10024 | GNUNET_MQ_hd_var_size(communicator_available, | 10087 | GNUNET_MQ_hd_var_size (communicator_available, |
10025 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, | 10088 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, |
10026 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, | 10089 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, |
10027 | NULL), | 10090 | NULL), |
10028 | GNUNET_MQ_hd_var_size(communicator_backchannel, | 10091 | GNUNET_MQ_hd_var_size (communicator_backchannel, |
10029 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, | 10092 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, |
10030 | struct GNUNET_TRANSPORT_CommunicatorBackchannel, | 10093 | struct GNUNET_TRANSPORT_CommunicatorBackchannel, |
10031 | NULL), | 10094 | NULL), |
10032 | GNUNET_MQ_hd_var_size(add_address, | 10095 | GNUNET_MQ_hd_var_size (add_address, |
10033 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, | 10096 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, |
10034 | struct GNUNET_TRANSPORT_AddAddressMessage, | 10097 | struct GNUNET_TRANSPORT_AddAddressMessage, |
10035 | NULL), | 10098 | NULL), |
10036 | GNUNET_MQ_hd_fixed_size(del_address, | 10099 | GNUNET_MQ_hd_fixed_size (del_address, |
10037 | GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, | 10100 | GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, |
10038 | struct GNUNET_TRANSPORT_DelAddressMessage, | 10101 | struct GNUNET_TRANSPORT_DelAddressMessage, |
10039 | NULL), | 10102 | NULL), |
10040 | GNUNET_MQ_hd_var_size(incoming_msg, | 10103 | GNUNET_MQ_hd_var_size (incoming_msg, |
10041 | GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, | 10104 | GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, |
10042 | struct GNUNET_TRANSPORT_IncomingMessage, | 10105 | struct GNUNET_TRANSPORT_IncomingMessage, |
10043 | NULL), | 10106 | NULL), |
10044 | GNUNET_MQ_hd_fixed_size(queue_create_ok, | 10107 | GNUNET_MQ_hd_fixed_size (queue_create_ok, |
10045 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, | 10108 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, |
10046 | struct GNUNET_TRANSPORT_CreateQueueResponse, | 10109 | struct GNUNET_TRANSPORT_CreateQueueResponse, |
10047 | NULL), | 10110 | NULL), |
10048 | GNUNET_MQ_hd_fixed_size(queue_create_fail, | 10111 | GNUNET_MQ_hd_fixed_size (queue_create_fail, |
10049 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, | 10112 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, |
10050 | struct GNUNET_TRANSPORT_CreateQueueResponse, | 10113 | struct GNUNET_TRANSPORT_CreateQueueResponse, |
10051 | NULL), | 10114 | NULL), |
10052 | GNUNET_MQ_hd_var_size(add_queue_message, | 10115 | GNUNET_MQ_hd_var_size (add_queue_message, |
10053 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, | 10116 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, |
10054 | struct GNUNET_TRANSPORT_AddQueueMessage, | 10117 | struct GNUNET_TRANSPORT_AddQueueMessage, |
10055 | NULL), | 10118 | NULL), |
10056 | GNUNET_MQ_hd_fixed_size(del_queue_message, | 10119 | GNUNET_MQ_hd_fixed_size (del_queue_message, |
10057 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, | 10120 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, |
10058 | struct GNUNET_TRANSPORT_DelQueueMessage, | 10121 | struct GNUNET_TRANSPORT_DelQueueMessage, |
10059 | NULL), | 10122 | NULL), |
10060 | GNUNET_MQ_hd_fixed_size(send_message_ack, | 10123 | GNUNET_MQ_hd_fixed_size (send_message_ack, |
10061 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, | 10124 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, |
10062 | struct GNUNET_TRANSPORT_SendMessageToAck, | 10125 | struct GNUNET_TRANSPORT_SendMessageToAck, |
10063 | NULL), | 10126 | NULL), |
10064 | /* communication with monitors */ | 10127 | /* communication with monitors */ |
10065 | GNUNET_MQ_hd_fixed_size(monitor_start, | 10128 | GNUNET_MQ_hd_fixed_size (monitor_start, |
10066 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START, | 10129 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START, |
10067 | struct GNUNET_TRANSPORT_MonitorStart, | 10130 | struct GNUNET_TRANSPORT_MonitorStart, |
10068 | NULL), | 10131 | NULL), |
10069 | GNUNET_MQ_handler_end()); | 10132 | GNUNET_MQ_handler_end ()); |
10070 | 10133 | ||
10071 | 10134 | ||
10072 | /* end of file gnunet-service-transport.c */ | 10135 | /* end of file gnunet-service-transport.c */ |