diff options
-rw-r--r-- | src/hello/hello-ng.c | 99 | ||||
-rw-r--r-- | src/include/gnunet_hello_lib.h | 67 | ||||
-rw-r--r-- | src/include/gnunet_transport_application_service.h | 20 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 10 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 36 | ||||
-rw-r--r-- | src/transport/transport.h | 5 | ||||
-rw-r--r-- | src/transport/transport_api2_application.c | 113 |
7 files changed, 152 insertions, 198 deletions
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c index 2d60b04f3..29ab17f9b 100644 --- a/src/hello/hello-ng.c +++ b/src/hello/hello-ng.c | |||
@@ -41,9 +41,9 @@ struct SignedAddress | |||
41 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | 41 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * When does the address expire. | 44 | * When was the address generated. |
45 | */ | 45 | */ |
46 | struct GNUNET_TIME_AbsoluteNBO expiration; | 46 | struct GNUNET_TIME_AbsoluteNBO mono_time; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Hash of the address. | 49 | * Hash of the address. |
@@ -57,18 +57,19 @@ struct SignedAddress | |||
57 | * | 57 | * |
58 | * @param address text address at @a communicator to sign | 58 | * @param address text address at @a communicator to sign |
59 | * @param nt network type of @a address | 59 | * @param nt network type of @a address |
60 | * @param expiration how long is @a address valid | 60 | * @param mono_time monotonic time at which @a address was valid |
61 | * @param private_key signing key to use | 61 | * @param private_key signing key to use |
62 | * @param result[out] where to write address record (allocated) | 62 | * @param result[out] where to write address record (allocated) |
63 | * @param result_size[out] set to size of @a result | 63 | * @param result_size[out] set to size of @a result |
64 | */ | 64 | */ |
65 | void | 65 | void |
66 | GNUNET_HELLO_sign_address (const char *address, | 66 | GNUNET_HELLO_sign_address ( |
67 | enum GNUNET_NetworkType nt, | 67 | const char *address, |
68 | struct GNUNET_TIME_Absolute expiration, | 68 | enum GNUNET_NetworkType nt, |
69 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, | 69 | struct GNUNET_TIME_Absolute mono_time, |
70 | void **result, | 70 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, |
71 | size_t *result_size) | 71 | void **result, |
72 | size_t *result_size) | ||
72 | { | 73 | { |
73 | struct SignedAddress sa; | 74 | struct SignedAddress sa; |
74 | struct GNUNET_CRYPTO_EddsaSignature sig; | 75 | struct GNUNET_CRYPTO_EddsaSignature sig; |
@@ -76,24 +77,19 @@ GNUNET_HELLO_sign_address (const char *address, | |||
76 | 77 | ||
77 | sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); | 78 | sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); |
78 | sa.purpose.size = htonl (sizeof (sa)); | 79 | sa.purpose.size = htonl (sizeof (sa)); |
79 | sa.expiration = GNUNET_TIME_absolute_hton (expiration); | 80 | sa.mono_time = GNUNET_TIME_absolute_hton (mono_time); |
80 | GNUNET_CRYPTO_hash (address, | 81 | GNUNET_CRYPTO_hash (address, strlen (address), &sa.h_addr); |
81 | strlen (address), | ||
82 | &sa.h_addr); | ||
83 | GNUNET_assert (GNUNET_YES == | 82 | GNUNET_assert (GNUNET_YES == |
84 | GNUNET_CRYPTO_eddsa_sign (private_key, | 83 | GNUNET_CRYPTO_eddsa_sign (private_key, &sa.purpose, &sig)); |
85 | &sa.purpose, | ||
86 | &sig)); | ||
87 | sig_str = NULL; | 84 | sig_str = NULL; |
88 | (void) GNUNET_STRINGS_base64_encode (&sig, | 85 | (void) GNUNET_STRINGS_base64_encode (&sig, sizeof (sig), &sig_str); |
89 | sizeof (sig), | 86 | *result_size = |
90 | &sig_str); | 87 | 1 + GNUNET_asprintf ((char **) result, |
91 | *result_size = 1 + GNUNET_asprintf ((char **) result, | 88 | "%s;%llu;%u;%s", |
92 | "%s;%llu;%u;%s", | 89 | sig_str, |
93 | sig_str, | 90 | (unsigned long long) mono_time.abs_value_us, |
94 | (unsigned long long) expiration.abs_value_us, | 91 | (unsigned int) nt, |
95 | (unsigned int) nt, | 92 | address); |
96 | address); | ||
97 | GNUNET_free (sig_str); | 93 | GNUNET_free (sig_str); |
98 | } | 94 | } |
99 | 95 | ||
@@ -105,15 +101,15 @@ GNUNET_HELLO_sign_address (const char *address, | |||
105 | * @param raw_size size of @a raw | 101 | * @param raw_size size of @a raw |
106 | * @param pid public key to use for signature verification | 102 | * @param pid public key to use for signature verification |
107 | * @param nt[out] set to network type | 103 | * @param nt[out] set to network type |
108 | * @param expiration[out] how long is the address valid | 104 | * @param mono_time[out] when was the address generated |
109 | * @return NULL on error, otherwise the address | 105 | * @return NULL on error, otherwise the address |
110 | */ | 106 | */ |
111 | char * | 107 | char * |
112 | GNUNET_HELLO_extract_address (const void *raw, | 108 | GNUNET_HELLO_extract_address (const void *raw, |
113 | size_t raw_size, | 109 | size_t raw_size, |
114 | const struct GNUNET_PeerIdentity *pid, | 110 | const struct GNUNET_PeerIdentity *pid, |
115 | enum GNUNET_NetworkType *nt, | 111 | enum GNUNET_NetworkType *nt, |
116 | struct GNUNET_TIME_Absolute *expiration) | 112 | struct GNUNET_TIME_Absolute *mono_time) |
117 | { | 113 | { |
118 | const struct GNUNET_CRYPTO_EddsaPublicKey *public_key = &pid->public_key; | 114 | const struct GNUNET_CRYPTO_EddsaPublicKey *public_key = &pid->public_key; |
119 | const char *raws = raw; | 115 | const char *raws = raw; |
@@ -123,7 +119,7 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
123 | const char *sc2; | 119 | const char *sc2; |
124 | const char *sc3; | 120 | const char *sc3; |
125 | const char *raw_addr; | 121 | const char *raw_addr; |
126 | struct GNUNET_TIME_Absolute raw_expiration; | 122 | struct GNUNET_TIME_Absolute raw_mono_time; |
127 | struct SignedAddress sa; | 123 | struct SignedAddress sa; |
128 | struct GNUNET_CRYPTO_EddsaSignature *sig; | 124 | struct GNUNET_CRYPTO_EddsaSignature *sig; |
129 | 125 | ||
@@ -132,40 +128,30 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
132 | GNUNET_break_op (0); | 128 | GNUNET_break_op (0); |
133 | return NULL; | 129 | return NULL; |
134 | } | 130 | } |
135 | if (NULL == (sc = strchr (raws, | 131 | if (NULL == (sc = strchr (raws, ';'))) |
136 | ';'))) | ||
137 | { | 132 | { |
138 | GNUNET_break_op (0); | 133 | GNUNET_break_op (0); |
139 | return NULL; | 134 | return NULL; |
140 | } | 135 | } |
141 | if (NULL == (sc2 = strchr (sc + 1, | 136 | if (NULL == (sc2 = strchr (sc + 1, ';'))) |
142 | ';'))) | ||
143 | { | 137 | { |
144 | GNUNET_break_op (0); | 138 | GNUNET_break_op (0); |
145 | return NULL; | 139 | return NULL; |
146 | } | 140 | } |
147 | if (NULL == (sc3 = strchr (sc2 + 1, | 141 | if (NULL == (sc3 = strchr (sc2 + 1, ';'))) |
148 | ';'))) | ||
149 | { | 142 | { |
150 | GNUNET_break_op (0); | 143 | GNUNET_break_op (0); |
151 | return NULL; | 144 | return NULL; |
152 | } | 145 | } |
153 | if (1 != sscanf (sc + 1, | 146 | if (1 != sscanf (sc + 1, "%llu;%u;", &raw_us, &raw_nt)) |
154 | "%llu;%u;", | ||
155 | &raw_us, | ||
156 | &raw_nt)) | ||
157 | { | 147 | { |
158 | GNUNET_break_op (0); | 148 | GNUNET_break_op (0); |
159 | return NULL; | 149 | return NULL; |
160 | } | 150 | } |
161 | raw_expiration.abs_value_us = raw_us; | 151 | raw_mono_time.abs_value_us = raw_us; |
162 | if (0 == GNUNET_TIME_absolute_get_remaining (raw_expiration).rel_value_us) | ||
163 | return NULL; /* expired */ | ||
164 | sig = NULL; | 152 | sig = NULL; |
165 | if (sizeof (struct GNUNET_CRYPTO_EddsaSignature) != | 153 | if (sizeof (struct GNUNET_CRYPTO_EddsaSignature) != |
166 | GNUNET_STRINGS_base64_decode (raws, | 154 | GNUNET_STRINGS_base64_decode (raws, sc - raws, (void **) &sig)) |
167 | sc - raws, | ||
168 | (void **) &sig)) | ||
169 | { | 155 | { |
170 | GNUNET_break_op (0); | 156 | GNUNET_break_op (0); |
171 | GNUNET_free_non_null (sig); | 157 | GNUNET_free_non_null (sig); |
@@ -175,22 +161,20 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
175 | 161 | ||
176 | sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); | 162 | sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); |
177 | sa.purpose.size = htonl (sizeof (sa)); | 163 | sa.purpose.size = htonl (sizeof (sa)); |
178 | sa.expiration = GNUNET_TIME_absolute_hton (raw_expiration); | 164 | sa.mono_time = GNUNET_TIME_absolute_hton (raw_mono_time); |
179 | GNUNET_CRYPTO_hash (raw_addr, | 165 | GNUNET_CRYPTO_hash (raw_addr, strlen (raw_addr), &sa.h_addr); |
180 | strlen (raw_addr), | ||
181 | &sa.h_addr); | ||
182 | if (GNUNET_YES != | 166 | if (GNUNET_YES != |
183 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS, | 167 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS, |
184 | &sa.purpose, | 168 | &sa.purpose, |
185 | sig, | 169 | sig, |
186 | public_key)) | 170 | public_key)) |
187 | { | 171 | { |
188 | GNUNET_break_op (0); | 172 | GNUNET_break_op (0); |
189 | GNUNET_free (sig); | 173 | GNUNET_free (sig); |
190 | return NULL; | 174 | return NULL; |
191 | } | 175 | } |
192 | GNUNET_free (sig); | 176 | GNUNET_free (sig); |
193 | *expiration = raw_expiration; | 177 | *mono_time = raw_mono_time; |
194 | *nt = (enum GNUNET_NetworkType) raw_nt; | 178 | *nt = (enum GNUNET_NetworkType) raw_nt; |
195 | return GNUNET_strdup (raw_addr); | 179 | return GNUNET_strdup (raw_addr); |
196 | } | 180 | } |
@@ -202,7 +186,7 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
202 | * | 186 | * |
203 | * @param address a peer's address | 187 | * @param address a peer's address |
204 | * @return NULL if the address is mal-formed, otherwise the prefix | 188 | * @return NULL if the address is mal-formed, otherwise the prefix |
205 | */ | 189 | */ |
206 | char * | 190 | char * |
207 | GNUNET_HELLO_address_to_prefix (const char *address) | 191 | GNUNET_HELLO_address_to_prefix (const char *address) |
208 | { | 192 | { |
@@ -211,6 +195,5 @@ GNUNET_HELLO_address_to_prefix (const char *address) | |||
211 | dash = strchr (address, '-'); | 195 | dash = strchr (address, '-'); |
212 | if (NULL == dash) | 196 | if (NULL == dash) |
213 | return NULL; | 197 | return NULL; |
214 | return GNUNET_strndup (address, | 198 | return GNUNET_strndup (address, dash - address); |
215 | dash - address); | ||
216 | } | 199 | } |
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index c46e847f1..3b494f0a2 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -35,9 +35,8 @@ | |||
35 | #define GNUNET_HELLO_LIB_H | 35 | #define GNUNET_HELLO_LIB_H |
36 | 36 | ||
37 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
38 | extern "C" | 38 | extern "C" { |
39 | { | 39 | #if 0 /* keep Emacsens' auto-indent happy */ |
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | 40 | } |
42 | #endif | 41 | #endif |
43 | #endif | 42 | #endif |
@@ -122,7 +121,6 @@ struct GNUNET_HELLO_Address | |||
122 | * when a #GNUNET_HELLO_Message is created | 121 | * when a #GNUNET_HELLO_Message is created |
123 | */ | 122 | */ |
124 | enum GNUNET_HELLO_AddressInfo local_info; | 123 | enum GNUNET_HELLO_AddressInfo local_info; |
125 | |||
126 | }; | 124 | }; |
127 | 125 | ||
128 | 126 | ||
@@ -194,7 +192,7 @@ GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, | |||
194 | * | 192 | * |
195 | * @param addr address to free | 193 | * @param addr address to free |
196 | */ | 194 | */ |
197 | #define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) | 195 | #define GNUNET_HELLO_address_free(addr) GNUNET_free (addr) |
198 | 196 | ||
199 | 197 | ||
200 | GNUNET_NETWORK_STRUCT_BEGIN | 198 | GNUNET_NETWORK_STRUCT_BEGIN |
@@ -228,12 +226,10 @@ struct GNUNET_HELLO_Message | |||
228 | * The public key of the peer. | 226 | * The public key of the peer. |
229 | */ | 227 | */ |
230 | struct GNUNET_CRYPTO_EddsaPublicKey publicKey; | 228 | struct GNUNET_CRYPTO_EddsaPublicKey publicKey; |
231 | |||
232 | }; | 229 | }; |
233 | GNUNET_NETWORK_STRUCT_END | 230 | GNUNET_NETWORK_STRUCT_END |
234 | 231 | ||
235 | 232 | ||
236 | |||
237 | /** | 233 | /** |
238 | * Return HELLO type | 234 | * Return HELLO type |
239 | * | 235 | * |
@@ -273,10 +269,9 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | |||
273 | * @return number of bytes written or 0, #GNUNET_SYSERR to signal the | 269 | * @return number of bytes written or 0, #GNUNET_SYSERR to signal the |
274 | * end of the iteration. | 270 | * end of the iteration. |
275 | */ | 271 | */ |
276 | typedef ssize_t | 272 | typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, |
277 | (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, | 273 | size_t max, |
278 | size_t max, | 274 | void *buf); |
279 | void *buf); | ||
280 | 275 | ||
281 | 276 | ||
282 | /** | 277 | /** |
@@ -356,10 +351,10 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | |||
356 | * #GNUNET_NO to delete it from the HELLO | 351 | * #GNUNET_NO to delete it from the HELLO |
357 | * #GNUNET_SYSERR to stop iterating (but keep current address) | 352 | * #GNUNET_SYSERR to stop iterating (but keep current address) |
358 | */ | 353 | */ |
359 | typedef int | 354 | typedef int (*GNUNET_HELLO_AddressIterator) ( |
360 | (*GNUNET_HELLO_AddressIterator) (void *cls, | 355 | void *cls, |
361 | const struct GNUNET_HELLO_Address *address, | 356 | const struct GNUNET_HELLO_Address *address, |
362 | struct GNUNET_TIME_Absolute expiration); | 357 | struct GNUNET_TIME_Absolute expiration); |
363 | 358 | ||
364 | 359 | ||
365 | /** | 360 | /** |
@@ -387,7 +382,8 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); | |||
387 | struct GNUNET_HELLO_Message * | 382 | struct GNUNET_HELLO_Message * |
388 | GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | 383 | GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, |
389 | int return_modified, | 384 | int return_modified, |
390 | GNUNET_HELLO_AddressIterator it, void *it_cls); | 385 | GNUNET_HELLO_AddressIterator it, |
386 | void *it_cls); | ||
391 | 387 | ||
392 | 388 | ||
393 | /** | 389 | /** |
@@ -404,11 +400,12 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
404 | * @param it_cls closure for @a it | 400 | * @param it_cls closure for @a it |
405 | */ | 401 | */ |
406 | void | 402 | void |
407 | GNUNET_HELLO_iterate_new_addresses (const struct GNUNET_HELLO_Message *new_hello, | 403 | GNUNET_HELLO_iterate_new_addresses ( |
408 | const struct GNUNET_HELLO_Message *old_hello, | 404 | const struct GNUNET_HELLO_Message *new_hello, |
409 | struct GNUNET_TIME_Absolute expiration_limit, | 405 | const struct GNUNET_HELLO_Message *old_hello, |
410 | GNUNET_HELLO_AddressIterator it, | 406 | struct GNUNET_TIME_Absolute expiration_limit, |
411 | void *it_cls); | 407 | GNUNET_HELLO_AddressIterator it, |
408 | void *it_cls); | ||
412 | 409 | ||
413 | 410 | ||
414 | /** | 411 | /** |
@@ -442,8 +439,8 @@ GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); | |||
442 | * @param name name of the transport plugin to load | 439 | * @param name name of the transport plugin to load |
443 | * @return NULL if a plugin with name @a name is not known/loadable | 440 | * @return NULL if a plugin with name @a name is not known/loadable |
444 | */ | 441 | */ |
445 | typedef struct GNUNET_TRANSPORT_PluginFunctions * | 442 | typedef struct GNUNET_TRANSPORT_PluginFunctions *( |
446 | (*GNUNET_HELLO_TransportPluginsFind) (const char *name); | 443 | *GNUNET_HELLO_TransportPluginsFind) (const char *name); |
447 | 444 | ||
448 | 445 | ||
449 | /** | 446 | /** |
@@ -474,7 +471,6 @@ GNUNET_HELLO_parse_uri (const char *uri, | |||
474 | GNUNET_HELLO_TransportPluginsFind plugins_find); | 471 | GNUNET_HELLO_TransportPluginsFind plugins_find); |
475 | 472 | ||
476 | 473 | ||
477 | |||
478 | /* NG API */ | 474 | /* NG API */ |
479 | #include "gnunet_nt_lib.h" | 475 | #include "gnunet_nt_lib.h" |
480 | 476 | ||
@@ -484,18 +480,19 @@ GNUNET_HELLO_parse_uri (const char *uri, | |||
484 | * | 480 | * |
485 | * @param address text address to sign | 481 | * @param address text address to sign |
486 | * @param nt network type of @a address | 482 | * @param nt network type of @a address |
487 | * @param expiration how long is @a address valid | 483 | * @param mono_time when was @a address valid |
488 | * @param private_key signing key to use | 484 | * @param private_key signing key to use |
489 | * @param result[out] where to write address record (allocated) | 485 | * @param result[out] where to write address record (allocated) |
490 | * @param result_size[out] set to size of @a result | 486 | * @param result_size[out] set to size of @a result |
491 | */ | 487 | */ |
492 | void | 488 | void |
493 | GNUNET_HELLO_sign_address (const char *address, | 489 | GNUNET_HELLO_sign_address ( |
494 | enum GNUNET_NetworkType nt, | 490 | const char *address, |
495 | struct GNUNET_TIME_Absolute expiration, | 491 | enum GNUNET_NetworkType nt, |
496 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, | 492 | struct GNUNET_TIME_Absolute mono_time, |
497 | void **result, | 493 | const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, |
498 | size_t *result_size); | 494 | void **result, |
495 | size_t *result_size); | ||
499 | 496 | ||
500 | 497 | ||
501 | /** | 498 | /** |
@@ -505,7 +502,7 @@ GNUNET_HELLO_sign_address (const char *address, | |||
505 | * @param raw_size size of @a raw | 502 | * @param raw_size size of @a raw |
506 | * @param pid public key to use for signature verification | 503 | * @param pid public key to use for signature verification |
507 | * @param nt[out] set to network type | 504 | * @param nt[out] set to network type |
508 | * @param expiration[out] how long is the address valid | 505 | * @param mono_time[out] when was the address generated |
509 | * @return NULL on error, otherwise the address | 506 | * @return NULL on error, otherwise the address |
510 | */ | 507 | */ |
511 | char * | 508 | char * |
@@ -513,7 +510,7 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
513 | size_t raw_size, | 510 | size_t raw_size, |
514 | const struct GNUNET_PeerIdentity *pid, | 511 | const struct GNUNET_PeerIdentity *pid, |
515 | enum GNUNET_NetworkType *nt, | 512 | enum GNUNET_NetworkType *nt, |
516 | struct GNUNET_TIME_Absolute *expiration); | 513 | struct GNUNET_TIME_Absolute *mono_time); |
517 | 514 | ||
518 | 515 | ||
519 | /** | 516 | /** |
@@ -527,7 +524,7 @@ char * | |||
527 | GNUNET_HELLO_address_to_prefix (const char *address); | 524 | GNUNET_HELLO_address_to_prefix (const char *address); |
528 | 525 | ||
529 | 526 | ||
530 | #if 0 /* keep Emacsens' auto-indent happy */ | 527 | #if 0 /* keep Emacsens' auto-indent happy */ |
531 | { | 528 | { |
532 | #endif | 529 | #endif |
533 | #ifdef __cplusplus | 530 | #ifdef __cplusplus |
@@ -537,6 +534,6 @@ GNUNET_HELLO_address_to_prefix (const char *address); | |||
537 | /* ifndef GNUNET_HELLO_LIB_H */ | 534 | /* ifndef GNUNET_HELLO_LIB_H */ |
538 | #endif | 535 | #endif |
539 | 536 | ||
540 | /** @} */ /* end of group */ | 537 | /** @} */ /* end of group */ |
541 | 538 | ||
542 | /* end of gnunet_hello_lib.h */ | 539 | /* end of gnunet_hello_lib.h */ |
diff --git a/src/include/gnunet_transport_application_service.h b/src/include/gnunet_transport_application_service.h index bbd4e3ddf..8c63a8234 100644 --- a/src/include/gnunet_transport_application_service.h +++ b/src/include/gnunet_transport_application_service.h | |||
@@ -50,7 +50,8 @@ struct GNUNET_TRANSPORT_ApplicationHandle; | |||
50 | * @return ats application handle, NULL on error | 50 | * @return ats application handle, NULL on error |
51 | */ | 51 | */ |
52 | struct GNUNET_TRANSPORT_ApplicationHandle * | 52 | struct GNUNET_TRANSPORT_ApplicationHandle * |
53 | GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg); | 53 | GNUNET_TRANSPORT_application_init ( |
54 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
54 | 55 | ||
55 | 56 | ||
56 | /** | 57 | /** |
@@ -59,7 +60,8 @@ GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
59 | * @param ch handle to destroy | 60 | * @param ch handle to destroy |
60 | */ | 61 | */ |
61 | void | 62 | void |
62 | GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch); | 63 | GNUNET_TRANSPORT_application_done ( |
64 | struct GNUNET_TRANSPORT_ApplicationHandle *ch); | ||
63 | 65 | ||
64 | 66 | ||
65 | /** | 67 | /** |
@@ -72,21 +74,19 @@ GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch | |||
72 | * | 74 | * |
73 | * @param ch handle | 75 | * @param ch handle |
74 | * @param peer identity of the peer we have an address for | 76 | * @param peer identity of the peer we have an address for |
75 | * @param expiration when does @a addr expire; used by TRANSPORT to know when | ||
76 | * to definitively give up attempting to validate | ||
77 | * @param nt network type of @a addr (as claimed by the other peer); | 77 | * @param nt network type of @a addr (as claimed by the other peer); |
78 | * used by TRANSPORT to avoid trying @a addr's that really cannot work | 78 | * used by TRANSPORT to avoid trying @a addr's that really cannot work |
79 | * due to network type missmatches | 79 | * due to network type missmatches |
80 | * @param addr address to validate | 80 | * @param addr address to validate |
81 | */ | 81 | */ |
82 | void | 82 | void |
83 | GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, | 83 | GNUNET_TRANSPORT_application_validate ( |
84 | const struct GNUNET_PeerIdentity *peer, | 84 | struct GNUNET_TRANSPORT_ApplicationHandle *ch, |
85 | struct GNUNET_TIME_Absolute expiration, | 85 | const struct GNUNET_PeerIdentity *peer, |
86 | enum GNUNET_NetworkType nt, | 86 | enum GNUNET_NetworkType nt, |
87 | const char *addr); | 87 | const char *addr); |
88 | 88 | ||
89 | /** @} */ /* end of group */ | 89 | /** @} */ /* end of group */ |
90 | 90 | ||
91 | #endif | 91 | #endif |
92 | /* end of file gnunet_ats_application_service.h */ | 92 | /* end of file gnunet_ats_application_service.h */ |
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 9420b9b5c..1c2063d58 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1630,23 +1630,15 @@ sock_read (void *cls) | |||
1630 | &ub->sender.public_key)) | 1630 | &ub->sender.public_key)) |
1631 | { | 1631 | { |
1632 | char *addr_s; | 1632 | char *addr_s; |
1633 | struct GNUNET_TIME_Absolute expiration; | ||
1634 | enum GNUNET_NetworkType nt; | 1633 | enum GNUNET_NetworkType nt; |
1635 | 1634 | ||
1636 | addr_s = | 1635 | addr_s = |
1637 | sockaddr_to_udpaddr_string ((const struct sockaddr *) &sa, salen); | 1636 | sockaddr_to_udpaddr_string ((const struct sockaddr *) &sa, salen); |
1638 | GNUNET_STATISTICS_update (stats, "# broadcasts received", 1, GNUNET_NO); | 1637 | GNUNET_STATISTICS_update (stats, "# broadcasts received", 1, GNUNET_NO); |
1639 | /* expire at the broadcast frequency, as then we'll get the next one | ||
1640 | * anyway */ | ||
1641 | expiration = GNUNET_TIME_relative_to_absolute (BROADCAST_FREQUENCY); | ||
1642 | /* use our own mechanism to determine network type */ | 1638 | /* use our own mechanism to determine network type */ |
1643 | nt = | 1639 | nt = |
1644 | GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); | 1640 | GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); |
1645 | GNUNET_TRANSPORT_application_validate (ah, | 1641 | GNUNET_TRANSPORT_application_validate (ah, &ub->sender, nt, addr_s); |
1646 | &ub->sender, | ||
1647 | expiration, | ||
1648 | nt, | ||
1649 | addr_s); | ||
1650 | GNUNET_free (addr_s); | 1642 | GNUNET_free (addr_s); |
1651 | return; | 1643 | return; |
1652 | } | 1644 | } |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index a8f70986b..95ea102df 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -2546,6 +2546,16 @@ static struct PendingAcknowledgement *pa_tail; | |||
2546 | */ | 2546 | */ |
2547 | static unsigned int pa_count; | 2547 | static unsigned int pa_count; |
2548 | 2548 | ||
2549 | /** | ||
2550 | * Monotonic time we use for HELLOs generated at this time. TODO: we | ||
2551 | * should increase this value from time to time (i.e. whenever a | ||
2552 | * `struct AddressListEntry` actually expires), but IF we do this, we | ||
2553 | * must also update *all* (remaining) addresses in the PEERSTORE at | ||
2554 | * that time! (So for now only increased when the peer is restarted, | ||
2555 | * which hopefully roughly matches whenever our addresses change.) | ||
2556 | */ | ||
2557 | static struct GNUNET_TIME_Absolute hello_mono_time; | ||
2558 | |||
2549 | 2559 | ||
2550 | /** | 2560 | /** |
2551 | * Get an offset into the transmission history buffer for `struct | 2561 | * Get an offset into the transmission history buffer for `struct |
@@ -4657,7 +4667,7 @@ store_pi (void *cls) | |||
4657 | expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); | 4667 | expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); |
4658 | GNUNET_HELLO_sign_address (ale->address, | 4668 | GNUNET_HELLO_sign_address (ale->address, |
4659 | ale->nt, | 4669 | ale->nt, |
4660 | expiration, | 4670 | hello_mono_time, |
4661 | GST_my_private_key, | 4671 | GST_my_private_key, |
4662 | &addr, | 4672 | &addr, |
4663 | &addr_len); | 4673 | &addr_len); |
@@ -8442,19 +8452,15 @@ check_known_address (void *cls, | |||
8442 | * | 8452 | * |
8443 | * @param pid peer the @a address is for | 8453 | * @param pid peer the @a address is for |
8444 | * @param address an address to reach @a pid (presumably) | 8454 | * @param address an address to reach @a pid (presumably) |
8445 | * @param expiration when did @a pid claim @a address will become invalid | ||
8446 | */ | 8455 | */ |
8447 | static void | 8456 | static void |
8448 | start_address_validation (const struct GNUNET_PeerIdentity *pid, | 8457 | start_address_validation (const struct GNUNET_PeerIdentity *pid, |
8449 | const char *address, | 8458 | const char *address) |
8450 | struct GNUNET_TIME_Absolute expiration) | ||
8451 | { | 8459 | { |
8452 | struct GNUNET_TIME_Absolute now; | 8460 | struct GNUNET_TIME_Absolute now; |
8453 | struct ValidationState *vs; | 8461 | struct ValidationState *vs; |
8454 | struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL}; | 8462 | struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL}; |
8455 | 8463 | ||
8456 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | ||
8457 | return; /* expired */ | ||
8458 | (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, | 8464 | (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, |
8459 | pid, | 8465 | pid, |
8460 | &check_known_address, | 8466 | &check_known_address, |
@@ -8479,7 +8485,8 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid, | |||
8479 | now = GNUNET_TIME_absolute_get (); | 8485 | now = GNUNET_TIME_absolute_get (); |
8480 | vs = GNUNET_new (struct ValidationState); | 8486 | vs = GNUNET_new (struct ValidationState); |
8481 | vs->pid = *pid; | 8487 | vs->pid = *pid; |
8482 | vs->valid_until = expiration; | 8488 | vs->valid_until = |
8489 | GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME); | ||
8483 | vs->first_challenge_use = now; | 8490 | vs->first_challenge_use = now; |
8484 | vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 8491 | vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
8485 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, | 8492 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, |
@@ -8524,9 +8531,7 @@ handle_hello (void *cls, | |||
8524 | GNUNET_break (0); | 8531 | GNUNET_break (0); |
8525 | return; | 8532 | return; |
8526 | } | 8533 | } |
8527 | start_address_validation (&pr->pid, | 8534 | start_address_validation (&pr->pid, (const char *) record->value); |
8528 | (const char *) record->value, | ||
8529 | record->expiry); | ||
8530 | } | 8535 | } |
8531 | 8536 | ||
8532 | 8537 | ||
@@ -8602,7 +8607,7 @@ handle_address_consider_verify ( | |||
8602 | struct TransportClient *tc = cls; | 8607 | struct TransportClient *tc = cls; |
8603 | char *address; | 8608 | char *address; |
8604 | enum GNUNET_NetworkType nt; | 8609 | enum GNUNET_NetworkType nt; |
8605 | struct GNUNET_TIME_Absolute expiration; | 8610 | struct GNUNET_TIME_Absolute mono_time; |
8606 | 8611 | ||
8607 | (void) cls; | 8612 | (void) cls; |
8608 | // OPTIMIZE-FIXME: checking that we know this address already should | 8613 | // OPTIMIZE-FIXME: checking that we know this address already should |
@@ -8614,13 +8619,13 @@ handle_address_consider_verify ( | |||
8614 | ntohs (hdr->header.size) - sizeof (*hdr), | 8619 | ntohs (hdr->header.size) - sizeof (*hdr), |
8615 | &hdr->peer, | 8620 | &hdr->peer, |
8616 | &nt, | 8621 | &nt, |
8617 | &expiration); | 8622 | &mono_time); |
8618 | if (NULL == address) | 8623 | if (NULL == address) |
8619 | { | 8624 | { |
8620 | GNUNET_break_op (0); | 8625 | GNUNET_break_op (0); |
8621 | return; | 8626 | return; |
8622 | } | 8627 | } |
8623 | start_address_validation (&hdr->peer, address, expiration); | 8628 | start_address_validation (&hdr->peer, address); |
8624 | GNUNET_free (address); | 8629 | GNUNET_free (address); |
8625 | GNUNET_SERVICE_client_continue (tc->client); | 8630 | GNUNET_SERVICE_client_continue (tc->client); |
8626 | } | 8631 | } |
@@ -8657,9 +8662,7 @@ handle_request_hello_validation (void *cls, | |||
8657 | { | 8662 | { |
8658 | struct TransportClient *tc = cls; | 8663 | struct TransportClient *tc = cls; |
8659 | 8664 | ||
8660 | start_address_validation (&m->peer, | 8665 | start_address_validation (&m->peer, (const char *) &m[1]); |
8661 | (const char *) &m[1], | ||
8662 | GNUNET_TIME_absolute_ntoh (m->expiration)); | ||
8663 | GNUNET_SERVICE_client_continue (tc->client); | 8666 | GNUNET_SERVICE_client_continue (tc->client); |
8664 | } | 8667 | } |
8665 | 8668 | ||
@@ -8895,6 +8898,7 @@ run (void *cls, | |||
8895 | (void) cls; | 8898 | (void) cls; |
8896 | (void) service; | 8899 | (void) service; |
8897 | /* setup globals */ | 8900 | /* setup globals */ |
8901 | hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c); | ||
8898 | GST_cfg = c; | 8902 | GST_cfg = c; |
8899 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); | 8903 | backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); |
8900 | pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES); | 8904 | pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES); |
diff --git a/src/transport/transport.h b/src/transport/transport.h index ed89940cc..4ba628112 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -1203,11 +1203,6 @@ struct RequestHelloValidationMessage | |||
1203 | */ | 1203 | */ |
1204 | struct GNUNET_PeerIdentity peer; | 1204 | struct GNUNET_PeerIdentity peer; |
1205 | 1205 | ||
1206 | /** | ||
1207 | * When does the address expire? | ||
1208 | */ | ||
1209 | struct GNUNET_TIME_AbsoluteNBO expiration; | ||
1210 | |||
1211 | /* followed by 0-terminated address to validate */ | 1206 | /* followed by 0-terminated address to validate */ |
1212 | }; | 1207 | }; |
1213 | 1208 | ||
diff --git a/src/transport/transport_api2_application.c b/src/transport/transport_api2_application.c index 414a21fe4..49f0f36c7 100644 --- a/src/transport/transport_api2_application.c +++ b/src/transport/transport_api2_application.c | |||
@@ -29,7 +29,8 @@ | |||
29 | #include "transport.h" | 29 | #include "transport.h" |
30 | 30 | ||
31 | 31 | ||
32 | #define LOG(kind,...) GNUNET_log_from(kind, "transport-application-api", __VA_ARGS__) | 32 | #define LOG(kind, ...) \ |
33 | GNUNET_log_from (kind, "transport-application-api", __VA_ARGS__) | ||
33 | 34 | ||
34 | 35 | ||
35 | /** | 36 | /** |
@@ -132,9 +133,7 @@ force_reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) | |||
132 | ch->mq = NULL; | 133 | ch->mq = NULL; |
133 | } | 134 | } |
134 | ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff); | 135 | ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff); |
135 | ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, | 136 | ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, &reconnect_task, ch); |
136 | &reconnect_task, | ||
137 | ch); | ||
138 | } | 137 | } |
139 | 138 | ||
140 | 139 | ||
@@ -146,8 +145,7 @@ force_reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) | |||
146 | * @param error details about the error | 145 | * @param error details about the error |
147 | */ | 146 | */ |
148 | static void | 147 | static void |
149 | error_handler (void *cls, | 148 | error_handler (void *cls, enum GNUNET_MQ_Error error) |
150 | enum GNUNET_MQ_Error error) | ||
151 | { | 149 | { |
152 | struct GNUNET_TRANSPORT_ApplicationHandle *ch = cls; | 150 | struct GNUNET_TRANSPORT_ApplicationHandle *ch = cls; |
153 | 151 | ||
@@ -179,8 +177,7 @@ transmit_suggestion (void *cls, | |||
179 | 177 | ||
180 | if (NULL == ch->mq) | 178 | if (NULL == ch->mq) |
181 | return GNUNET_SYSERR; | 179 | return GNUNET_SYSERR; |
182 | ev = GNUNET_MQ_msg (m, | 180 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST); |
183 | GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST); | ||
184 | m->pk = htonl ((uint32_t) sh->pk); | 181 | m->pk = htonl ((uint32_t) sh->pk); |
185 | m->bw = sh->bw; | 182 | m->bw = sh->bw; |
186 | m->peer = *peer; | 183 | m->peer = *peer; |
@@ -197,16 +194,11 @@ transmit_suggestion (void *cls, | |||
197 | static void | 194 | static void |
198 | reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) | 195 | reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) |
199 | { | 196 | { |
200 | static const struct GNUNET_MQ_MessageHandler handlers[] = { | 197 | static const struct GNUNET_MQ_MessageHandler handlers[] = {{NULL, 0, 0}}; |
201 | { NULL, 0, 0 } | ||
202 | }; | ||
203 | 198 | ||
204 | GNUNET_assert (NULL == ch->mq); | 199 | GNUNET_assert (NULL == ch->mq); |
205 | ch->mq = GNUNET_CLIENT_connect (ch->cfg, | 200 | ch->mq = |
206 | "transport", | 201 | GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch); |
207 | handlers, | ||
208 | &error_handler, | ||
209 | ch); | ||
210 | if (NULL == ch->mq) | 202 | if (NULL == ch->mq) |
211 | { | 203 | { |
212 | force_reconnect (ch); | 204 | force_reconnect (ch); |
@@ -225,14 +217,14 @@ reconnect (struct GNUNET_TRANSPORT_ApplicationHandle *ch) | |||
225 | * @return transport application handle, NULL on error | 217 | * @return transport application handle, NULL on error |
226 | */ | 218 | */ |
227 | struct GNUNET_TRANSPORT_ApplicationHandle * | 219 | struct GNUNET_TRANSPORT_ApplicationHandle * |
228 | GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg) | 220 | GNUNET_TRANSPORT_application_init ( |
221 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
229 | { | 222 | { |
230 | struct GNUNET_TRANSPORT_ApplicationHandle *ch; | 223 | struct GNUNET_TRANSPORT_ApplicationHandle *ch; |
231 | 224 | ||
232 | ch = GNUNET_new (struct GNUNET_TRANSPORT_ApplicationHandle); | 225 | ch = GNUNET_new (struct GNUNET_TRANSPORT_ApplicationHandle); |
233 | ch->cfg = cfg; | 226 | ch->cfg = cfg; |
234 | ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32, | 227 | ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES); |
235 | GNUNET_YES); | ||
236 | reconnect (ch); | 228 | reconnect (ch); |
237 | return ch; | 229 | return ch; |
238 | } | 230 | } |
@@ -248,9 +240,7 @@ GNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
248 | * @return #GNUNET_OK (continue to iterate) | 240 | * @return #GNUNET_OK (continue to iterate) |
249 | */ | 241 | */ |
250 | static int | 242 | static int |
251 | free_sug_handle (void *cls, | 243 | free_sug_handle (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
252 | const struct GNUNET_PeerIdentity *key, | ||
253 | void *value) | ||
254 | { | 244 | { |
255 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle *cur = value; | 245 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle *cur = value; |
256 | 246 | ||
@@ -265,7 +255,8 @@ free_sug_handle (void *cls, | |||
265 | * @param ch handle to release | 255 | * @param ch handle to release |
266 | */ | 256 | */ |
267 | void | 257 | void |
268 | GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch) | 258 | GNUNET_TRANSPORT_application_done ( |
259 | struct GNUNET_TRANSPORT_ApplicationHandle *ch) | ||
269 | { | 260 | { |
270 | if (NULL != ch->mq) | 261 | if (NULL != ch->mq) |
271 | { | 262 | { |
@@ -299,10 +290,11 @@ GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch | |||
299 | * @return suggest handle, NULL if a request is already pending | 290 | * @return suggest handle, NULL if a request is already pending |
300 | */ | 291 | */ |
301 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle * | 292 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle * |
302 | GNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle *ch, | 293 | GNUNET_TRANSPORT_application_suggest ( |
303 | const struct GNUNET_PeerIdentity *peer, | 294 | struct GNUNET_TRANSPORT_ApplicationHandle *ch, |
304 | enum GNUNET_MQ_PreferenceKind pk, | 295 | const struct GNUNET_PeerIdentity *peer, |
305 | struct GNUNET_BANDWIDTH_Value32NBO bw) | 296 | enum GNUNET_MQ_PreferenceKind pk, |
297 | struct GNUNET_BANDWIDTH_Value32NBO bw) | ||
306 | { | 298 | { |
307 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s; | 299 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s; |
308 | 300 | ||
@@ -311,19 +303,17 @@ GNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle | |||
311 | s->id = *peer; | 303 | s->id = *peer; |
312 | s->pk = pk; | 304 | s->pk = pk; |
313 | s->bw = bw; | 305 | s->bw = bw; |
314 | (void) GNUNET_CONTAINER_multipeermap_put (ch->sug_requests, | 306 | (void) GNUNET_CONTAINER_multipeermap_put ( |
315 | &s->id, | 307 | ch->sug_requests, |
316 | s, | 308 | &s->id, |
317 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 309 | s, |
310 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
318 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 311 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
319 | "Requesting TRANSPORT to suggest address for `%s'\n", | 312 | "Requesting TRANSPORT to suggest address for `%s'\n", |
320 | GNUNET_i2s (peer)); | 313 | GNUNET_i2s (peer)); |
321 | if (NULL == ch->mq) | 314 | if (NULL == ch->mq) |
322 | return s; | 315 | return s; |
323 | GNUNET_assert (GNUNET_OK == | 316 | GNUNET_assert (GNUNET_OK == transmit_suggestion (ch, &s->id, s)); |
324 | transmit_suggestion (ch, | ||
325 | &s->id, | ||
326 | s)); | ||
327 | return s; | 317 | return s; |
328 | } | 318 | } |
329 | 319 | ||
@@ -334,7 +324,8 @@ GNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle | |||
334 | * @param sh handle to stop | 324 | * @param sh handle to stop |
335 | */ | 325 | */ |
336 | void | 326 | void |
337 | GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh) | 327 | GNUNET_TRANSPORT_application_suggest_cancel ( |
328 | struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh) | ||
338 | { | 329 | { |
339 | struct GNUNET_TRANSPORT_ApplicationHandle *ch = sh->ch; | 330 | struct GNUNET_TRANSPORT_ApplicationHandle *ch = sh->ch; |
340 | struct GNUNET_MQ_Envelope *ev; | 331 | struct GNUNET_MQ_Envelope *ev; |
@@ -343,27 +334,23 @@ GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_Application | |||
343 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 334 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
344 | "Telling TRANSPORT we no longer care for an address for `%s'\n", | 335 | "Telling TRANSPORT we no longer care for an address for `%s'\n", |
345 | GNUNET_i2s (&sh->id)); | 336 | GNUNET_i2s (&sh->id)); |
346 | GNUNET_assert (GNUNET_OK == | 337 | GNUNET_assert ( |
347 | GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, | 338 | GNUNET_OK == |
348 | &sh->id, | 339 | GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, &sh->id, sh)); |
349 | sh)); | ||
350 | if (NULL == ch->mq) | 340 | if (NULL == ch->mq) |
351 | { | 341 | { |
352 | GNUNET_free (sh); | 342 | GNUNET_free (sh); |
353 | return; | 343 | return; |
354 | } | 344 | } |
355 | ev = GNUNET_MQ_msg (m, | 345 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL); |
356 | GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL); | ||
357 | m->pk = htonl ((uint32_t) sh->pk); | 346 | m->pk = htonl ((uint32_t) sh->pk); |
358 | m->bw = sh->bw; | 347 | m->bw = sh->bw; |
359 | m->peer = sh->id; | 348 | m->peer = sh->id; |
360 | GNUNET_MQ_send (ch->mq, | 349 | GNUNET_MQ_send (ch->mq, ev); |
361 | ev); | ||
362 | GNUNET_free (sh); | 350 | GNUNET_free (sh); |
363 | } | 351 | } |
364 | 352 | ||
365 | 353 | ||
366 | |||
367 | /** | 354 | /** |
368 | * An application (or a communicator) has received a HELLO (or other address | 355 | * An application (or a communicator) has received a HELLO (or other address |
369 | * data of another peer) and wants TRANSPORT to validate that the address is | 356 | * data of another peer) and wants TRANSPORT to validate that the address is |
@@ -374,19 +361,17 @@ GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_Application | |||
374 | * | 361 | * |
375 | * @param ch handle | 362 | * @param ch handle |
376 | * @param peer identity of the peer we have an address for | 363 | * @param peer identity of the peer we have an address for |
377 | * @param expiration when does @a addr expire; used by TRANSPORT to know when | ||
378 | * to definitively give up attempting to validate | ||
379 | * @param nt network type of @a addr (as claimed by the other peer); | 364 | * @param nt network type of @a addr (as claimed by the other peer); |
380 | * used by TRANSPORT to avoid trying @a addr's that really cannot work | 365 | * used by TRANSPORT to avoid trying @a addr's that really cannot work |
381 | * due to network type missmatches | 366 | * due to network type missmatches |
382 | * @param addr address to validate | 367 | * @param addr address to validate |
383 | */ | 368 | */ |
384 | void | 369 | void |
385 | GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, | 370 | GNUNET_TRANSPORT_application_validate ( |
386 | const struct GNUNET_PeerIdentity *peer, | 371 | struct GNUNET_TRANSPORT_ApplicationHandle *ch, |
387 | struct GNUNET_TIME_Absolute expiration, | 372 | const struct GNUNET_PeerIdentity *peer, |
388 | enum GNUNET_NetworkType nt, | 373 | enum GNUNET_NetworkType nt, |
389 | const char *addr) | 374 | const char *addr) |
390 | { | 375 | { |
391 | struct GNUNET_MQ_Envelope *ev; | 376 | struct GNUNET_MQ_Envelope *ev; |
392 | struct RequestHelloValidationMessage *m; | 377 | struct RequestHelloValidationMessage *m; |
@@ -394,24 +379,22 @@ GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle | |||
394 | 379 | ||
395 | if (NULL == ch->mq) | 380 | if (NULL == ch->mq) |
396 | { | 381 | { |
397 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 382 | GNUNET_log ( |
398 | "Address validation for %s:%s skipped as transport is not connected\n", | 383 | GNUNET_ERROR_TYPE_WARNING, |
399 | GNUNET_i2s (peer), | 384 | "Address validation for %s:%s skipped as transport is not connected\n", |
400 | addr); | 385 | GNUNET_i2s (peer), |
386 | addr); | ||
401 | return; | 387 | return; |
402 | } | 388 | } |
403 | alen = strlen (addr) + 1; | 389 | alen = strlen (addr) + 1; |
404 | ev = GNUNET_MQ_msg_extra (m, | 390 | ev = |
405 | alen, | 391 | GNUNET_MQ_msg_extra (m, |
406 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION); | 392 | alen, |
393 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION); | ||
407 | m->peer = *peer; | 394 | m->peer = *peer; |
408 | m->expiration = GNUNET_TIME_absolute_hton (expiration); | ||
409 | m->nt = htonl ((uint32_t) nt); | 395 | m->nt = htonl ((uint32_t) nt); |
410 | memcpy (&m[1], | 396 | memcpy (&m[1], addr, alen); |
411 | addr, | 397 | GNUNET_MQ_send (ch->mq, ev); |
412 | alen); | ||
413 | GNUNET_MQ_send (ch->mq, | ||
414 | ev); | ||
415 | } | 398 | } |
416 | 399 | ||
417 | 400 | ||