diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
commit | 83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch) | |
tree | d0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/transport | |
parent | 28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff) | |
download | gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip |
curly wars / auto-indentation
Diffstat (limited to 'src/transport')
35 files changed, 2344 insertions, 2192 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 10c1c68a8..878ab2618 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -90,9 +90,7 @@ struct GNUNET_ATS_SchedulingHandle *GST_ats; | |||
90 | static void | 90 | static void |
91 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, | 91 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, |
92 | const struct GNUNET_ATS_Information *ats, | 92 | const struct GNUNET_ATS_Information *ats, |
93 | uint32_t ats_count, | 93 | uint32_t ats_count, const char *transport, const void *addr, |
94 | const char * transport, | ||
95 | const void * addr, | ||
96 | size_t addrlen) | 94 | size_t addrlen) |
97 | { | 95 | { |
98 | const struct GNUNET_MessageHeader *hello = cls; | 96 | const struct GNUNET_MessageHeader *hello = cls; |
@@ -118,7 +116,7 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) | |||
118 | 116 | ||
119 | 117 | ||
120 | /** | 118 | /** |
121 | * We received some payload. Prepare to pass it on to our clients. | 119 | * We received some payload. Prepare to pass it on to our clients. |
122 | * | 120 | * |
123 | * @param peer (claimed) identity of the other peer | 121 | * @param peer (claimed) identity of the other peer |
124 | * @param message the message, never NULL | 122 | * @param message the message, never NULL |
@@ -128,48 +126,45 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) | |||
128 | */ | 126 | */ |
129 | static struct GNUNET_TIME_Relative | 127 | static struct GNUNET_TIME_Relative |
130 | process_payload (const struct GNUNET_PeerIdentity *peer, | 128 | process_payload (const struct GNUNET_PeerIdentity *peer, |
131 | const struct GNUNET_MessageHeader *message, | 129 | const struct GNUNET_MessageHeader *message, |
132 | const struct GNUNET_ATS_Information *ats, | 130 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
133 | uint32_t ats_count) | ||
134 | { | 131 | { |
135 | struct GNUNET_TIME_Relative ret; | 132 | struct GNUNET_TIME_Relative ret; |
136 | int do_forward; | 133 | int do_forward; |
137 | struct InboundMessage *im; | 134 | struct InboundMessage *im; |
138 | size_t msg_size = ntohs (message->size); | 135 | size_t msg_size = ntohs (message->size); |
139 | size_t size = sizeof (struct InboundMessage) + msg_size + sizeof (struct GNUNET_ATS_Information) * ats_count; | 136 | size_t size = |
137 | sizeof (struct InboundMessage) + msg_size + | ||
138 | sizeof (struct GNUNET_ATS_Information) * ats_count; | ||
140 | char buf[size]; | 139 | char buf[size]; |
141 | struct GNUNET_ATS_Information *ap; | 140 | struct GNUNET_ATS_Information *ap; |
142 | 141 | ||
143 | ret = GNUNET_TIME_UNIT_ZERO; | 142 | ret = GNUNET_TIME_UNIT_ZERO; |
144 | do_forward = GNUNET_SYSERR; | 143 | do_forward = GNUNET_SYSERR; |
145 | ret = | 144 | ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward); |
146 | GST_neighbours_calculate_receive_delay (peer, | ||
147 | msg_size, | ||
148 | &do_forward); | ||
149 | 145 | ||
150 | if (!GST_neighbours_test_connected (peer)) | 146 | if (!GST_neighbours_test_connected (peer)) |
151 | { | 147 | { |
152 | 148 | ||
153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Discarded %u bytes type %u payload from peer `%s'\n", | 149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
154 | msg_size, | 150 | "Discarded %u bytes type %u payload from peer `%s'\n", msg_size, |
155 | ntohs (message->type), | 151 | ntohs (message->type), GNUNET_i2s (peer)); |
156 | GNUNET_i2s (peer)); | ||
157 | 152 | ||
158 | GNUNET_STATISTICS_update (GST_stats, | 153 | GNUNET_STATISTICS_update (GST_stats, |
159 | gettext_noop ("# bytes payload discarded due to not connected peer "), | 154 | gettext_noop |
160 | msg_size, | 155 | ("# bytes payload discarded due to not connected peer "), |
161 | GNUNET_NO); | 156 | msg_size, GNUNET_NO); |
162 | return ret; | 157 | return ret; |
163 | } | 158 | } |
164 | 159 | ||
165 | if (do_forward != GNUNET_YES) | 160 | if (do_forward != GNUNET_YES) |
166 | return ret; | 161 | return ret; |
167 | im = (struct InboundMessage*) buf; | 162 | im = (struct InboundMessage *) buf; |
168 | im->header.size = htons (size); | 163 | im->header.size = htons (size); |
169 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); | 164 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); |
170 | im->ats_count = htonl (ats_count); | 165 | im->ats_count = htonl (ats_count); |
171 | im->peer = *peer; | 166 | im->peer = *peer; |
172 | ap = (struct GNUNET_ATS_Information*) &im[1]; | 167 | ap = (struct GNUNET_ATS_Information *) &im[1]; |
173 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | 168 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
174 | memcpy (&ap[ats_count], message, ntohs (message->size)); | 169 | memcpy (&ap[ats_count], message, ntohs (message->size)); |
175 | 170 | ||
@@ -213,7 +208,7 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
213 | const char *plugin_name = cls; | 208 | const char *plugin_name = cls; |
214 | struct GNUNET_TIME_Relative ret; | 209 | struct GNUNET_TIME_Relative ret; |
215 | uint16_t type; | 210 | uint16_t type; |
216 | 211 | ||
217 | ret = GNUNET_TIME_UNIT_ZERO; | 212 | ret = GNUNET_TIME_UNIT_ZERO; |
218 | if (NULL == message) | 213 | if (NULL == message) |
219 | goto end; | 214 | goto end; |
@@ -231,43 +226,38 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
231 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: | 226 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: |
232 | #if DEBUG_TRANSPORT | 227 | #if DEBUG_TRANSPORT |
233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
234 | "Processing `%s' from `%s'\n", "PING", | 229 | "Processing `%s' from `%s'\n", "PING", |
235 | (sender_address != NULL) ? GST_plugins_a2s (plugin_name, | 230 | (sender_address != NULL) ? GST_plugins_a2s (plugin_name, |
236 | sender_address, | 231 | sender_address, |
237 | sender_address_len) | 232 | sender_address_len) |
238 | : "<inbound>"); | 233 | : "<inbound>"); |
239 | #endif | 234 | #endif |
240 | GST_validation_handle_ping (peer, message, plugin_name, session, | 235 | GST_validation_handle_ping (peer, message, plugin_name, session, |
241 | sender_address, sender_address_len); | 236 | sender_address, sender_address_len); |
242 | break; | 237 | break; |
243 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: | 238 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: |
244 | #if DEBUG_TRANSPORT | 239 | #if DEBUG_TRANSPORT |
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
246 | "Processing `%s' from `%s'\n", "PONG", | 241 | "Processing `%s' from `%s'\n", "PONG", |
247 | (sender_address != NULL) ? GST_plugins_a2s (plugin_name, | 242 | (sender_address != NULL) ? GST_plugins_a2s (plugin_name, |
248 | sender_address, | 243 | sender_address, |
249 | sender_address_len) | 244 | sender_address_len) |
250 | : "<inbound>"); | 245 | : "<inbound>"); |
251 | #endif | 246 | #endif |
252 | GST_validation_handle_pong (peer, message); | 247 | GST_validation_handle_pong (peer, message); |
253 | break; | 248 | break; |
254 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: | 249 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: |
255 | GST_neighbours_handle_connect (message, | 250 | GST_neighbours_handle_connect (message, peer, plugin_name, sender_address, |
256 | peer, | 251 | sender_address_len, session, ats, ats_count); |
257 | plugin_name, sender_address, sender_address_len, | ||
258 | session, ats, ats_count); | ||
259 | break; | 252 | break; |
260 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: | 253 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: |
261 | GST_neighbours_handle_connect_ack (message, | 254 | GST_neighbours_handle_connect_ack (message, peer, plugin_name, |
262 | peer, | 255 | sender_address, sender_address_len, |
263 | plugin_name, sender_address, sender_address_len, | 256 | session, ats, ats_count); |
264 | session, ats, ats_count); | ||
265 | break; | 257 | break; |
266 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: | 258 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: |
267 | GST_neighbours_handle_ack (message, | 259 | GST_neighbours_handle_ack (message, peer, plugin_name, sender_address, |
268 | peer, | 260 | sender_address_len, session, ats, ats_count); |
269 | plugin_name, sender_address, sender_address_len, | ||
270 | session, ats, ats_count); | ||
271 | break; | 261 | break; |
272 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: | 262 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: |
273 | GST_neighbours_handle_disconnect_message (peer, message); | 263 | GST_neighbours_handle_disconnect_message (peer, message); |
@@ -277,25 +267,20 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
277 | break; | 267 | break; |
278 | default: | 268 | default: |
279 | /* should be payload */ | 269 | /* should be payload */ |
280 | ret = process_payload (peer, | 270 | ret = process_payload (peer, message, ats, ats_count); |
281 | message, | ||
282 | ats, ats_count); | ||
283 | break; | 271 | break; |
284 | } | 272 | } |
285 | end: | 273 | end: |
286 | #if 1 | 274 | #if 1 |
287 | /* FIXME: this should not be needed, and not sure it's good to have it, but without | 275 | /* FIXME: this should not be needed, and not sure it's good to have it, but without |
288 | this connections seem to go extra-slow */ | 276 | * this connections seem to go extra-slow */ |
289 | GNUNET_ATS_address_update (GST_ats, peer, | 277 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, |
290 | plugin_name, sender_address, sender_address_len, | 278 | sender_address_len, session, ats, ats_count); |
291 | session, | ||
292 | ats, ats_count); | ||
293 | #endif | 279 | #endif |
294 | #if DEBUG_TRANSPORT | 280 | #if DEBUG_TRANSPORT |
295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
296 | "Allowing receive from peer %s to continue in %llu ms\n", | 282 | "Allowing receive from peer %s to continue in %llu ms\n", |
297 | GNUNET_i2s (peer), | 283 | GNUNET_i2s (peer), (unsigned long long) ret.rel_value); |
298 | (unsigned long long) ret.rel_value); | ||
299 | #endif | 284 | #endif |
300 | return ret; | 285 | return ret; |
301 | } | 286 | } |
@@ -340,16 +325,14 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
340 | struct Session *session) | 325 | struct Session *session) |
341 | { | 326 | { |
342 | #if DEBUG_TRANSPORT | 327 | #if DEBUG_TRANSPORT |
343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n", |
344 | "Session %X to peer `%s' ended \n", | ||
345 | session, GNUNET_i2s (peer)); | 329 | session, GNUNET_i2s (peer)); |
346 | #endif | 330 | #endif |
347 | if (NULL != session) | 331 | if (NULL != session) |
348 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 332 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
349 | "transport-ats", | 333 | "transport-ats", |
350 | "Telling ATS to destroy session %p from peer %s\n", | 334 | "Telling ATS to destroy session %p from peer %s\n", |
351 | session, | 335 | session, GNUNET_i2s (peer)); |
352 | GNUNET_i2s (peer)); | ||
353 | GNUNET_ATS_address_destroyed (GST_ats, peer, NULL, NULL, 0, session); | 336 | GNUNET_ATS_address_destroyed (GST_ats, peer, NULL, NULL, 0, session); |
354 | GST_neighbours_session_terminated (peer, session); | 337 | GST_neighbours_session_terminated (peer, session); |
355 | } | 338 | } |
@@ -373,32 +356,32 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
373 | */ | 356 | */ |
374 | static void | 357 | static void |
375 | ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, | 358 | ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, |
376 | const char *plugin_name, | 359 | const char *plugin_name, const void *plugin_addr, |
377 | const void *plugin_addr, size_t plugin_addr_len, | 360 | size_t plugin_addr_len, struct Session *session, |
378 | struct Session *session, | ||
379 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 361 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
380 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 362 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
381 | const struct GNUNET_ATS_Information * ats, | 363 | const struct GNUNET_ATS_Information *ats, |
382 | uint32_t ats_count) | 364 | uint32_t ats_count) |
383 | { | 365 | { |
384 | uint32_t bw_in = ntohl (bandwidth_in.value__); | 366 | uint32_t bw_in = ntohl (bandwidth_in.value__); |
385 | uint32_t bw_out = ntohl (bandwidth_out.value__); | 367 | uint32_t bw_out = ntohl (bandwidth_out.value__); |
386 | 368 | ||
387 | /* ATS tells me to disconnect from peer*/ | 369 | /* ATS tells me to disconnect from peer */ |
388 | if ((bw_in == 0) && (bw_out == 0)) | 370 | if ((bw_in == 0) && (bw_out == 0)) |
389 | { | 371 | { |
390 | #if DEBUG_TRANSPORT | 372 | #if DEBUG_TRANSPORT |
391 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
392 | "ATS tells me to disconnect from peer `%s'\n", | 374 | "ATS tells me to disconnect from peer `%s'\n", |
393 | GNUNET_i2s (peer)); | 375 | GNUNET_i2s (peer)); |
394 | #endif | 376 | #endif |
395 | GST_neighbours_force_disconnect(peer); | 377 | GST_neighbours_force_disconnect (peer); |
396 | return; | 378 | return; |
397 | } | 379 | } |
398 | /* will never return GNUNET_YES since connection is to be established */ | 380 | /* will never return GNUNET_YES since connection is to be established */ |
399 | GST_neighbours_switch_to_address_3way (peer, plugin_name, plugin_addr, | 381 | GST_neighbours_switch_to_address_3way (peer, plugin_name, plugin_addr, |
400 | plugin_addr_len, session, ats, ats_count, | 382 | plugin_addr_len, session, ats, |
401 | bandwidth_in, bandwidth_out); | 383 | ats_count, bandwidth_in, |
384 | bandwidth_out); | ||
402 | } | 385 | } |
403 | 386 | ||
404 | 387 | ||
@@ -414,10 +397,11 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
414 | static void | 397 | static void |
415 | neighbours_connect_notification (void *cls, | 398 | neighbours_connect_notification (void *cls, |
416 | const struct GNUNET_PeerIdentity *peer, | 399 | const struct GNUNET_PeerIdentity *peer, |
417 | const struct GNUNET_ATS_Information | 400 | const struct GNUNET_ATS_Information *ats, |
418 | *ats, uint32_t ats_count) | 401 | uint32_t ats_count) |
419 | { | 402 | { |
420 | size_t len = sizeof (struct ConnectInfoMessage) + | 403 | size_t len = |
404 | sizeof (struct ConnectInfoMessage) + | ||
421 | ats_count * sizeof (struct GNUNET_ATS_Information); | 405 | ats_count * sizeof (struct GNUNET_ATS_Information); |
422 | char buf[len]; | 406 | char buf[len]; |
423 | struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; | 407 | struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; |
@@ -428,8 +412,7 @@ neighbours_connect_notification (void *cls, | |||
428 | connect_msg->ats_count = htonl (ats_count); | 412 | connect_msg->ats_count = htonl (ats_count); |
429 | connect_msg->id = *peer; | 413 | connect_msg->id = *peer; |
430 | ap = (struct GNUNET_ATS_Information *) &connect_msg[1]; | 414 | ap = (struct GNUNET_ATS_Information *) &connect_msg[1]; |
431 | memcpy (ap, ats, | 415 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
432 | ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
433 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); | 416 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); |
434 | } | 417 | } |
435 | 418 | ||
@@ -548,7 +531,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
548 | GST_plugins_load (&plugin_env_receive_callback, | 531 | GST_plugins_load (&plugin_env_receive_callback, |
549 | &plugin_env_address_change_notification, | 532 | &plugin_env_address_change_notification, |
550 | &plugin_env_session_end); | 533 | &plugin_env_session_end); |
551 | GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); | 534 | GST_ats = |
535 | GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); | ||
552 | GST_neighbours_start (NULL, &neighbours_connect_notification, | 536 | GST_neighbours_start (NULL, &neighbours_connect_notification, |
553 | &neighbours_disconnect_notification); | 537 | &neighbours_disconnect_notification); |
554 | GST_clients_start (server); | 538 | GST_clients_start (server); |
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 45d01e1e2..78eea2ff9 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -557,9 +557,7 @@ struct TestConnectionContext | |||
557 | static void | 557 | static void |
558 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, | 558 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, |
559 | const struct GNUNET_ATS_Information *ats, | 559 | const struct GNUNET_ATS_Information *ats, |
560 | uint32_t ats_count, | 560 | uint32_t ats_count, const char *transport, const void *addr, |
561 | const char * transport, | ||
562 | const void * addr, | ||
563 | size_t addrlen) | 561 | size_t addrlen) |
564 | { | 562 | { |
565 | struct TestConnectionContext *tcc = cls; | 563 | struct TestConnectionContext *tcc = cls; |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 8b022ef7e..ebab72db6 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -165,8 +165,7 @@ setup_client (struct GNUNET_SERVER_Client *client) | |||
165 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); | 165 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); |
166 | 166 | ||
167 | #if DEBUG_TRANSPORT | 167 | #if DEBUG_TRANSPORT |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %X connected\n", tc); |
169 | "Client %X connected\n", tc); | ||
170 | #endif | 169 | #endif |
171 | return tc; | 170 | return tc; |
172 | } | 171 | } |
@@ -333,29 +332,26 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) | |||
333 | static void | 332 | static void |
334 | notify_client_about_neighbour (void *cls, | 333 | notify_client_about_neighbour (void *cls, |
335 | const struct GNUNET_PeerIdentity *peer, | 334 | const struct GNUNET_PeerIdentity *peer, |
336 | const struct GNUNET_ATS_Information | 335 | const struct GNUNET_ATS_Information *ats, |
337 | *ats, uint32_t ats_count, | 336 | uint32_t ats_count, const char *transport, |
338 | const char * transport, | 337 | const void *addr, size_t addrlen) |
339 | const void * addr, | ||
340 | size_t addrlen) | ||
341 | { | 338 | { |
342 | struct TransportClient *tc = cls; | 339 | struct TransportClient *tc = cls; |
343 | struct ConnectInfoMessage *cim; | 340 | struct ConnectInfoMessage *cim; |
344 | struct GNUNET_ATS_Information *ap; | 341 | struct GNUNET_ATS_Information *ap; |
345 | size_t size = | 342 | size_t size = |
346 | sizeof (struct ConnectInfoMessage) + | 343 | sizeof (struct ConnectInfoMessage) + |
347 | ats_count * sizeof (struct GNUNET_ATS_Information); | 344 | ats_count * sizeof (struct GNUNET_ATS_Information); |
348 | char buf[size]; | 345 | char buf[size]; |
349 | 346 | ||
350 | GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 347 | GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
351 | cim = (struct ConnectInfoMessage*) buf; | 348 | cim = (struct ConnectInfoMessage *) buf; |
352 | cim->header.size = htons (size); | 349 | cim->header.size = htons (size); |
353 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 350 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
354 | cim->ats_count = htonl (ats_count); | 351 | cim->ats_count = htonl (ats_count); |
355 | cim->id = *peer; | 352 | cim->id = *peer; |
356 | ap = (struct GNUNET_ATS_Information *) &cim[1]; | 353 | ap = (struct GNUNET_ATS_Information *) &cim[1]; |
357 | memcpy (ap, ats, | 354 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
358 | ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
359 | unicast (tc, &cim->header, GNUNET_NO); | 355 | unicast (tc, &cim->header, GNUNET_NO); |
360 | } | 356 | } |
361 | 357 | ||
@@ -401,10 +397,10 @@ clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
401 | } | 397 | } |
402 | start = (const struct StartMessage *) message; | 398 | start = (const struct StartMessage *) message; |
403 | options = ntohl (start->options); | 399 | options = ntohl (start->options); |
404 | if ((0 != (1 & options) ) && | 400 | if ((0 != (1 & options)) && |
405 | (0 != | 401 | (0 != |
406 | memcmp (&start->self, &GST_my_identity, | 402 | memcmp (&start->self, &GST_my_identity, |
407 | sizeof (struct GNUNET_PeerIdentity)))) | 403 | sizeof (struct GNUNET_PeerIdentity)))) |
408 | { | 404 | { |
409 | /* client thinks this is a different peer, reject */ | 405 | /* client thinks this is a different peer, reject */ |
410 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 406 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -799,26 +795,23 @@ clients_handle_peer_address_lookup (void *cls, | |||
799 | */ | 795 | */ |
800 | static void | 796 | static void |
801 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, | 797 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, |
802 | const struct GNUNET_ATS_Information *ats, | 798 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count, |
803 | uint32_t ats_count, | 799 | const char *transport, const void *addr, size_t addrlen) |
804 | const char * transport, | ||
805 | const void * addr, | ||
806 | size_t addrlen) | ||
807 | { | 800 | { |
808 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 801 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
809 | struct AddressIterateResponseMessage * msg; | 802 | struct AddressIterateResponseMessage *msg; |
810 | size_t size; | 803 | size_t size; |
811 | 804 | ||
812 | size = | 805 | size = |
813 | (sizeof (struct AddressIterateResponseMessage) + strlen(transport) + 1); | 806 | (sizeof (struct AddressIterateResponseMessage) + strlen (transport) + 1); |
814 | msg = GNUNET_malloc (size); | 807 | msg = GNUNET_malloc (size); |
815 | memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); | 808 | memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
816 | memcpy (&msg[0], transport, strlen(transport)+1); | 809 | memcpy (&msg[0], transport, strlen (transport) + 1); |
817 | msg->addrlen = ntohs (addrlen); | 810 | msg->addrlen = ntohs (addrlen); |
818 | msg->pluginlen = ntohs (strlen(transport)+1); | 811 | msg->pluginlen = ntohs (strlen (transport) + 1); |
819 | 812 | ||
820 | transmit_binary_to_client (tc, msg, size); | 813 | transmit_binary_to_client (tc, msg, size); |
821 | GNUNET_free(msg); | 814 | GNUNET_free (msg); |
822 | } | 815 | } |
823 | 816 | ||
824 | 817 | ||
@@ -908,9 +901,8 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop) | |||
908 | 901 | ||
909 | for (tc = clients_head; tc != NULL; tc = tc->next) | 902 | for (tc = clients_head; tc != NULL; tc = tc->next) |
910 | { | 903 | { |
911 | if ( (GNUNET_YES == may_drop) && | 904 | if ((GNUNET_YES == may_drop) && (GNUNET_YES != tc->send_payload)) |
912 | (GNUNET_YES != tc->send_payload) ) | 905 | continue; /* skip, this client does not care about payload */ |
913 | continue; /* skip, this client does not care about payload */ | ||
914 | unicast (tc, msg, may_drop); | 906 | unicast (tc, msg, may_drop); |
915 | } | 907 | } |
916 | } | 908 | } |
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index a1c721857..45fdf0a26 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c | |||
@@ -166,7 +166,8 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
166 | hello_task = GNUNET_SCHEDULER_NO_TASK; | 166 | hello_task = GNUNET_SCHEDULER_NO_TASK; |
167 | gc.addr_pos = oal_head; | 167 | gc.addr_pos = oal_head; |
168 | gc.expiration = | 168 | gc.expiration = |
169 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION); | 169 | GNUNET_TIME_relative_to_absolute |
170 | (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION); | ||
170 | GNUNET_free (our_hello); | 171 | GNUNET_free (our_hello); |
171 | our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc); | 172 | our_hello = GNUNET_HELLO_create (&GST_my_public_key, &address_generator, &gc); |
172 | #if DEBUG_TRANSPORT | 173 | #if DEBUG_TRANSPORT |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index d0d5b099c..0ceba53bc 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -122,7 +122,7 @@ struct SessionDisconnectMessage | |||
122 | * Public key of the sender. | 122 | * Public key of the sender. |
123 | */ | 123 | */ |
124 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 124 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Signature of the peer that sends us the disconnect. Only | 127 | * Signature of the peer that sends us the disconnect. Only |
128 | * valid if the timestamp is AFTER the timestamp from the | 128 | * valid if the timestamp is AFTER the timestamp from the |
@@ -186,18 +186,18 @@ struct MessageQueue | |||
186 | 186 | ||
187 | enum State | 187 | enum State |
188 | { | 188 | { |
189 | /* fresh peer or completely disconnected */ | 189 | /* fresh peer or completely disconnected */ |
190 | S_NOT_CONNECTED = 0, | 190 | S_NOT_CONNECTED = 0, |
191 | /* sent CONNECT message to other peer, waiting for CONNECT_ACK */ | 191 | /* sent CONNECT message to other peer, waiting for CONNECT_ACK */ |
192 | S_CONNECT_SENT = 1, | 192 | S_CONNECT_SENT = 1, |
193 | /* received CONNECT message to other peer, sending CONNECT_ACK */ | 193 | /* received CONNECT message to other peer, sending CONNECT_ACK */ |
194 | S_CONNECT_RECV = 4, | 194 | S_CONNECT_RECV = 4, |
195 | /* sent CONNECT_ACK message to other peer, wait for ACK or payload */ | 195 | /* sent CONNECT_ACK message to other peer, wait for ACK or payload */ |
196 | S_CONNECT_RECV_ACK_SENT = 8, | 196 | S_CONNECT_RECV_ACK_SENT = 8, |
197 | /* received ACK or payload */ | 197 | /* received ACK or payload */ |
198 | S_CONNECTED = 16, | 198 | S_CONNECTED = 16, |
199 | /* Disconnect in progress */ | 199 | /* Disconnect in progress */ |
200 | S_DISCONNECT = 32 | 200 | S_DISCONNECT = 32 |
201 | }; | 201 | }; |
202 | 202 | ||
203 | /** | 203 | /** |
@@ -359,7 +359,7 @@ lookup_neighbour (const struct GNUNET_PeerIdentity *pid) | |||
359 | #define change_state(n, state, ...) change (n, state, __LINE__) | 359 | #define change_state(n, state, ...) change (n, state, __LINE__) |
360 | 360 | ||
361 | static int | 361 | static int |
362 | is_connecting (struct NeighbourMapEntry * n) | 362 | is_connecting (struct NeighbourMapEntry *n) |
363 | { | 363 | { |
364 | if ((n->state > S_NOT_CONNECTED) && (n->state < S_CONNECTED)) | 364 | if ((n->state > S_NOT_CONNECTED) && (n->state < S_CONNECTED)) |
365 | return GNUNET_YES; | 365 | return GNUNET_YES; |
@@ -367,7 +367,7 @@ is_connecting (struct NeighbourMapEntry * n) | |||
367 | } | 367 | } |
368 | 368 | ||
369 | static int | 369 | static int |
370 | is_connected (struct NeighbourMapEntry * n) | 370 | is_connected (struct NeighbourMapEntry *n) |
371 | { | 371 | { |
372 | if (n->state == S_CONNECTED) | 372 | if (n->state == S_CONNECTED) |
373 | return GNUNET_YES; | 373 | return GNUNET_YES; |
@@ -375,7 +375,7 @@ is_connected (struct NeighbourMapEntry * n) | |||
375 | } | 375 | } |
376 | 376 | ||
377 | static int | 377 | static int |
378 | is_disconnecting (struct NeighbourMapEntry * n) | 378 | is_disconnecting (struct NeighbourMapEntry *n) |
379 | { | 379 | { |
380 | if (n->state == S_DISCONNECT) | 380 | if (n->state == S_DISCONNECT) |
381 | return GNUNET_YES; | 381 | return GNUNET_YES; |
@@ -385,84 +385,85 @@ is_disconnecting (struct NeighbourMapEntry * n) | |||
385 | static const char * | 385 | static const char * |
386 | print_state (int state) | 386 | print_state (int state) |
387 | { | 387 | { |
388 | switch (state) { | 388 | switch (state) |
389 | case S_CONNECTED: | 389 | { |
390 | return "S_CONNECTED"; | 390 | case S_CONNECTED: |
391 | break; | 391 | return "S_CONNECTED"; |
392 | case S_CONNECT_RECV: | 392 | break; |
393 | return "S_CONNECT_RECV"; | 393 | case S_CONNECT_RECV: |
394 | break; | 394 | return "S_CONNECT_RECV"; |
395 | case S_CONNECT_RECV_ACK_SENT: | 395 | break; |
396 | return"S_CONNECT_RECV_ACK_SENT"; | 396 | case S_CONNECT_RECV_ACK_SENT: |
397 | break; | 397 | return "S_CONNECT_RECV_ACK_SENT"; |
398 | case S_CONNECT_SENT: | 398 | break; |
399 | return "S_CONNECT_SENT"; | 399 | case S_CONNECT_SENT: |
400 | break; | 400 | return "S_CONNECT_SENT"; |
401 | case S_DISCONNECT: | 401 | break; |
402 | return "S_DISCONNECT"; | 402 | case S_DISCONNECT: |
403 | break; | 403 | return "S_DISCONNECT"; |
404 | case S_NOT_CONNECTED: | 404 | break; |
405 | return "S_NOT_CONNECTED"; | 405 | case S_NOT_CONNECTED: |
406 | break; | 406 | return "S_NOT_CONNECTED"; |
407 | default: | 407 | break; |
408 | GNUNET_break (0); | 408 | default: |
409 | break; | 409 | GNUNET_break (0); |
410 | break; | ||
410 | } | 411 | } |
411 | return NULL; | 412 | return NULL; |
412 | } | 413 | } |
413 | 414 | ||
414 | static int | 415 | static int |
415 | change (struct NeighbourMapEntry * n, int state, int line); | 416 | change (struct NeighbourMapEntry *n, int state, int line); |
416 | 417 | ||
417 | static void | 418 | static void |
418 | ats_suggest_cancel (void *cls, | 419 | ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
419 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
420 | 420 | ||
421 | static void | 421 | static void |
422 | reset_task (void *cls, | 422 | reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
423 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
424 | { | 423 | { |
425 | struct NeighbourMapEntry * n = cls; | 424 | struct NeighbourMapEntry *n = cls; |
426 | 425 | ||
427 | n->state_reset = GNUNET_SCHEDULER_NO_TASK; | 426 | n->state_reset = GNUNET_SCHEDULER_NO_TASK; |
428 | 427 | ||
429 | #if DEBUG_TRANSPORT | 428 | #if DEBUG_TRANSPORT |
430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
431 | "Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n", | 430 | "Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n", |
432 | GNUNET_i2s (&n->id), GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen), print_state(n->state)); | 431 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, n->addr, |
432 | n->addrlen), | ||
433 | print_state (n->state)); | ||
433 | #endif | 434 | #endif |
434 | GNUNET_STATISTICS_update (GST_stats, | 435 | GNUNET_STATISTICS_update (GST_stats, |
435 | gettext_noop ("# failed connection attempts due to timeout"), | 436 | gettext_noop |
436 | 1, | 437 | ("# failed connection attempts due to timeout"), 1, |
437 | GNUNET_NO); | 438 | GNUNET_NO); |
438 | 439 | ||
439 | /* resetting state */ | 440 | /* resetting state */ |
440 | n->state = S_NOT_CONNECTED; | 441 | n->state = S_NOT_CONNECTED; |
441 | 442 | ||
442 | /* destroying address */ | 443 | /* destroying address */ |
443 | GNUNET_ATS_address_destroyed (GST_ats, | 444 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, |
444 | &n->id, | 445 | n->addrlen, NULL); |
445 | n->plugin_name, | ||
446 | n->addr, | ||
447 | n->addrlen, | ||
448 | NULL); | ||
449 | 446 | ||
450 | /* request new address */ | 447 | /* request new address */ |
451 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 448 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
452 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 449 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
453 | n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n); | 450 | n->ats_suggest = |
454 | GNUNET_ATS_suggest_address(GST_ats, &n->id); | 451 | GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, |
452 | n); | ||
453 | GNUNET_ATS_suggest_address (GST_ats, &n->id); | ||
455 | } | 454 | } |
456 | 455 | ||
457 | static int | 456 | static int |
458 | change (struct NeighbourMapEntry * n, int state, int line) | 457 | change (struct NeighbourMapEntry *n, int state, int line) |
459 | { | 458 | { |
460 | char * old = strdup(print_state(n->state)); | 459 | char *old = strdup (print_state (n->state)); |
461 | char * new = strdup(print_state(state)); | 460 | char *new = strdup (print_state (state)); |
462 | 461 | ||
463 | /* allowed transitions */ | 462 | /* allowed transitions */ |
464 | int allowed = GNUNET_NO; | 463 | int allowed = GNUNET_NO; |
465 | switch (n->state) { | 464 | |
465 | switch (n->state) | ||
466 | { | ||
466 | case S_NOT_CONNECTED: | 467 | case S_NOT_CONNECTED: |
467 | if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT) || | 468 | if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT) || |
468 | (state == S_DISCONNECT)) | 469 | (state == S_DISCONNECT)) |
@@ -470,10 +471,12 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
470 | allowed = GNUNET_YES; | 471 | allowed = GNUNET_YES; |
471 | 472 | ||
472 | /* Schedule reset task */ | 473 | /* Schedule reset task */ |
473 | if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT) ) | 474 | if ((state == S_CONNECT_RECV) || (state == S_CONNECT_SENT)) |
474 | { | 475 | { |
475 | GNUNET_assert (n->state_reset == GNUNET_SCHEDULER_NO_TASK); | 476 | GNUNET_assert (n->state_reset == GNUNET_SCHEDULER_NO_TASK); |
476 | n->state_reset = GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task, n); | 477 | n->state_reset = |
478 | GNUNET_SCHEDULER_add_delayed (SETUP_CONNECTION_TIMEOUT, &reset_task, | ||
479 | n); | ||
477 | } | 480 | } |
478 | 481 | ||
479 | break; | 482 | break; |
@@ -481,14 +484,18 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
481 | break; | 484 | break; |
482 | case S_CONNECT_RECV: | 485 | case S_CONNECT_RECV: |
483 | if ((state == S_NOT_CONNECTED) || (state == S_DISCONNECT) || | 486 | if ((state == S_NOT_CONNECTED) || (state == S_DISCONNECT) || |
484 | (state == S_CONNECTED) || /* FIXME SENT -> RECV ISSUE!*/ (state == S_CONNECT_SENT)) | 487 | (state == S_CONNECTED) || |
488 | /* FIXME SENT -> RECV ISSUE! */ (state == S_CONNECT_SENT)) | ||
485 | { | 489 | { |
486 | if ((state == S_CONNECTED) || (state == S_DISCONNECT) || (state == S_NOT_CONNECTED)) | 490 | if ((state == S_CONNECTED) || (state == S_DISCONNECT) || |
491 | (state == S_NOT_CONNECTED)) | ||
487 | { | 492 | { |
488 | #if DEBUG_TRANSPORT | 493 | #if DEBUG_TRANSPORT |
489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
490 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", | 495 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", |
491 | GNUNET_i2s (&n->id), GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen), print_state(n->state), print_state(state)); | 496 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, |
497 | n->addr, n->addrlen), | ||
498 | print_state (n->state), print_state (state)); | ||
492 | #endif | 499 | #endif |
493 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); | 500 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); |
494 | GNUNET_SCHEDULER_cancel (n->state_reset); | 501 | GNUNET_SCHEDULER_cancel (n->state_reset); |
@@ -501,14 +508,18 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
501 | break; | 508 | break; |
502 | case S_CONNECT_SENT: | 509 | case S_CONNECT_SENT: |
503 | if ((state == S_NOT_CONNECTED) || (state == S_CONNECTED) || | 510 | if ((state == S_NOT_CONNECTED) || (state == S_CONNECTED) || |
504 | (state == S_DISCONNECT) || /* FIXME SENT -> RECV ISSUE!*/ (state == S_CONNECT_RECV)) | 511 | (state == S_DISCONNECT) || |
512 | /* FIXME SENT -> RECV ISSUE! */ (state == S_CONNECT_RECV)) | ||
505 | { | 513 | { |
506 | if ((state == S_CONNECTED) || (state == S_DISCONNECT) || (state == S_NOT_CONNECTED)) | 514 | if ((state == S_CONNECTED) || (state == S_DISCONNECT) || |
515 | (state == S_NOT_CONNECTED)) | ||
507 | { | 516 | { |
508 | #if DEBUG_TRANSPORT | 517 | #if DEBUG_TRANSPORT |
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
510 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", | 519 | "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", |
511 | GNUNET_i2s (&n->id), GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen), print_state(n->state), print_state(state)); | 520 | GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, |
521 | n->addr, n->addrlen), | ||
522 | print_state (n->state), print_state (state)); | ||
512 | #endif | 523 | #endif |
513 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); | 524 | GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); |
514 | GNUNET_SCHEDULER_cancel (n->state_reset); | 525 | GNUNET_SCHEDULER_cancel (n->state_reset); |
@@ -528,11 +539,11 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
528 | break; | 539 | break; |
529 | case S_DISCONNECT: | 540 | case S_DISCONNECT: |
530 | /* | 541 | /* |
531 | if (state == S_NOT_CONNECTED) | 542 | * if (state == S_NOT_CONNECTED) |
532 | { | 543 | * { |
533 | allowed = GNUNET_YES; | 544 | * allowed = GNUNET_YES; |
534 | break; | 545 | * break; |
535 | }*/ | 546 | * } */ |
536 | break; | 547 | break; |
537 | default: | 548 | default: |
538 | GNUNET_break (0); | 549 | GNUNET_break (0); |
@@ -543,8 +554,8 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
543 | if (allowed == GNUNET_NO) | 554 | if (allowed == GNUNET_NO) |
544 | { | 555 | { |
545 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 556 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
546 | "Illegal state transition from `%s' to `%s' in line %u \n", | 557 | "Illegal state transition from `%s' to `%s' in line %u \n", old, |
547 | old, new, line); | 558 | new, line); |
548 | GNUNET_break (0); | 559 | GNUNET_break (0); |
549 | GNUNET_free (old); | 560 | GNUNET_free (old); |
550 | GNUNET_free (new); | 561 | GNUNET_free (new); |
@@ -553,8 +564,9 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
553 | 564 | ||
554 | n->state = state; | 565 | n->state = state; |
555 | #if DEBUG_TRANSPORT | 566 | #if DEBUG_TRANSPORT |
556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n", | 567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
557 | GNUNET_i2s (&n->id), n, old, new, line); | 568 | "State for neighbour `%s' %X changed from `%s' to `%s' in line %u\n", |
569 | GNUNET_i2s (&n->id), n, old, new, line); | ||
558 | #endif | 570 | #endif |
559 | GNUNET_free (old); | 571 | GNUNET_free (old); |
560 | GNUNET_free (new); | 572 | GNUNET_free (new); |
@@ -562,19 +574,12 @@ change (struct NeighbourMapEntry * n, int state, int line) | |||
562 | } | 574 | } |
563 | 575 | ||
564 | static ssize_t | 576 | static ssize_t |
565 | send_with_plugin ( const struct GNUNET_PeerIdentity * target, | 577 | send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, |
566 | const char *msgbuf, | 578 | size_t msgbuf_size, uint32_t priority, |
567 | size_t msgbuf_size, | 579 | struct GNUNET_TIME_Relative timeout, struct Session *session, |
568 | uint32_t priority, | 580 | const char *plugin_name, const void *addr, size_t addrlen, |
569 | struct GNUNET_TIME_Relative timeout, | 581 | int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, |
570 | struct Session * session, | 582 | void *cont_cls) |
571 | const char * plugin_name, | ||
572 | const void *addr, | ||
573 | size_t addrlen, | ||
574 | int force_address, | ||
575 | GNUNET_TRANSPORT_TransmitContinuation cont, | ||
576 | void *cont_cls) | ||
577 | |||
578 | { | 583 | { |
579 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 584 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
580 | size_t ret = GNUNET_SYSERR; | 585 | size_t ret = GNUNET_SYSERR; |
@@ -602,15 +607,9 @@ send_with_plugin ( const struct GNUNET_PeerIdentity * target, | |||
602 | return GNUNET_SYSERR; | 607 | return GNUNET_SYSERR; |
603 | } | 608 | } |
604 | 609 | ||
605 | ret = papi->send (papi->cls, | 610 | ret = |
606 | target, | 611 | papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session, |
607 | msgbuf, msgbuf_size, | 612 | addr, addrlen, GNUNET_YES, cont, cont_cls); |
608 | 0, | ||
609 | timeout, | ||
610 | session, | ||
611 | addr, addrlen, | ||
612 | GNUNET_YES, | ||
613 | cont, cont_cls); | ||
614 | 613 | ||
615 | if (ret == -1) | 614 | if (ret == -1) |
616 | { | 615 | { |
@@ -713,7 +712,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
713 | n->is_active = mq; | 712 | n->is_active = mq; |
714 | mq->n = n; | 713 | mq->n = n; |
715 | 714 | ||
716 | if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) | 715 | if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) |
717 | { | 716 | { |
718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n", | 717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n", |
719 | GNUNET_i2s (&n->id)); | 718 | GNUNET_i2s (&n->id)); |
@@ -723,12 +722,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
723 | return; | 722 | return; |
724 | } | 723 | } |
725 | 724 | ||
726 | ret = send_with_plugin (&n->id, | 725 | ret = |
727 | mq->message_buf, mq->message_buf_size, 0, | 726 | send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0, |
728 | timeout, | 727 | timeout, n->session, n->plugin_name, n->addr, |
729 | n->session, n->plugin_name, n->addr, n->addrlen, | 728 | n->addrlen, GNUNET_YES, &transmit_send_continuation, |
730 | GNUNET_YES, | 729 | mq); |
731 | &transmit_send_continuation, mq); | ||
732 | if (ret == -1) | 730 | if (ret == -1) |
733 | { | 731 | { |
734 | /* failure, but 'send' would not call continuation in this case, | 732 | /* failure, but 'send' would not call continuation in this case, |
@@ -749,7 +747,8 @@ static void | |||
749 | transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 747 | transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
750 | { | 748 | { |
751 | struct NeighbourMapEntry *n = cls; | 749 | struct NeighbourMapEntry *n = cls; |
752 | GNUNET_assert (NULL != lookup_neighbour(&n->id)); | 750 | |
751 | GNUNET_assert (NULL != lookup_neighbour (&n->id)); | ||
753 | n->transmission_task = GNUNET_SCHEDULER_NO_TASK; | 752 | n->transmission_task = GNUNET_SCHEDULER_NO_TASK; |
754 | try_transmission_to_peer (n); | 753 | try_transmission_to_peer (n); |
755 | } | 754 | } |
@@ -774,56 +773,61 @@ GST_neighbours_start (void *cls, GNUNET_TRANSPORT_NotifyConnect connect_cb, | |||
774 | 773 | ||
775 | 774 | ||
776 | static void | 775 | static void |
777 | send_disconnect_cont (void *cls, | 776 | send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target, |
778 | const struct GNUNET_PeerIdentity * target, | 777 | int result) |
779 | int result) | ||
780 | { | 778 | { |
781 | #if DEBUG_TRANSPORT | 779 | #if DEBUG_TRANSPORT |
782 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending DISCONNECT message to peer `%4s': %i\n", | 780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
781 | "Sending DISCONNECT message to peer `%4s': %i\n", | ||
783 | GNUNET_i2s (target), result); | 782 | GNUNET_i2s (target), result); |
784 | #endif | 783 | #endif |
785 | } | 784 | } |
786 | 785 | ||
787 | 786 | ||
788 | static int | 787 | static int |
789 | send_disconnect (const struct GNUNET_PeerIdentity * target, | 788 | send_disconnect (const struct GNUNET_PeerIdentity *target, |
790 | const char *plugin_name, | 789 | const char *plugin_name, const char *sender_address, |
791 | const char *sender_address, uint16_t sender_address_len, | 790 | uint16_t sender_address_len, struct Session *session) |
792 | struct Session *session) | ||
793 | { | 791 | { |
794 | size_t ret; | 792 | size_t ret; |
795 | struct SessionDisconnectMessage disconnect_msg; | 793 | struct SessionDisconnectMessage disconnect_msg; |
796 | 794 | ||
797 | #if DEBUG_TRANSPORT | 795 | #if DEBUG_TRANSPORT |
798 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending DISCONNECT message to peer `%4s'\n", | 796 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
797 | "Sending DISCONNECT message to peer `%4s'\n", | ||
799 | GNUNET_i2s (target)); | 798 | GNUNET_i2s (target)); |
800 | #endif | 799 | #endif |
801 | 800 | ||
802 | disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage)); | 801 | disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage)); |
803 | disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); | 802 | disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); |
804 | disconnect_msg.reserved = htonl (0); | 803 | disconnect_msg.reserved = htonl (0); |
805 | disconnect_msg.purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 804 | disconnect_msg.purpose.size = |
806 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 805 | htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
807 | sizeof (struct GNUNET_TIME_AbsoluteNBO) ); | 806 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + |
808 | disconnect_msg.purpose.purpose = htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT); | 807 | sizeof (struct GNUNET_TIME_AbsoluteNBO)); |
809 | disconnect_msg.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | 808 | disconnect_msg.purpose.purpose = |
809 | htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT); | ||
810 | disconnect_msg.timestamp = | ||
811 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | ||
810 | disconnect_msg.public_key = GST_my_public_key; | 812 | disconnect_msg.public_key = GST_my_public_key; |
811 | GNUNET_assert (GNUNET_OK == | 813 | GNUNET_assert (GNUNET_OK == |
812 | GNUNET_CRYPTO_rsa_sign (GST_my_private_key, | 814 | GNUNET_CRYPTO_rsa_sign (GST_my_private_key, |
813 | &disconnect_msg.purpose, | 815 | &disconnect_msg.purpose, |
814 | &disconnect_msg.signature)); | 816 | &disconnect_msg.signature)); |
815 | 817 | ||
816 | ret = send_with_plugin(target, | 818 | ret = |
817 | (const char *) &disconnect_msg, sizeof (disconnect_msg), | 819 | send_with_plugin (target, (const char *) &disconnect_msg, |
818 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, | 820 | sizeof (disconnect_msg), UINT32_MAX, |
819 | session, plugin_name, sender_address, sender_address_len, | 821 | GNUNET_TIME_UNIT_FOREVER_REL, session, plugin_name, |
820 | GNUNET_YES, &send_disconnect_cont, NULL); | 822 | sender_address, sender_address_len, GNUNET_YES, |
823 | &send_disconnect_cont, NULL); | ||
821 | 824 | ||
822 | if (ret == GNUNET_SYSERR) | 825 | if (ret == GNUNET_SYSERR) |
823 | return GNUNET_SYSERR; | 826 | return GNUNET_SYSERR; |
824 | 827 | ||
825 | GNUNET_STATISTICS_update (GST_stats, | 828 | GNUNET_STATISTICS_update (GST_stats, |
826 | gettext_noop ("# peers disconnected due to external request"), 1, | 829 | gettext_noop |
830 | ("# peers disconnected due to external request"), 1, | ||
827 | GNUNET_NO); | 831 | GNUNET_NO); |
828 | return GNUNET_OK; | 832 | return GNUNET_OK; |
829 | } | 833 | } |
@@ -837,21 +841,24 @@ static void | |||
837 | disconnect_neighbour (struct NeighbourMapEntry *n) | 841 | disconnect_neighbour (struct NeighbourMapEntry *n) |
838 | { | 842 | { |
839 | struct MessageQueue *mq; | 843 | struct MessageQueue *mq; |
840 | int was_connected = is_connected(n); | 844 | int was_connected = is_connected (n); |
841 | 845 | ||
842 | /* send DISCONNECT MESSAGE */ | 846 | /* send DISCONNECT MESSAGE */ |
843 | if (is_connected(n) || is_connecting(n)) | 847 | if (is_connected (n) || is_connecting (n)) |
844 | { | 848 | { |
845 | if (GNUNET_OK == send_disconnect(&n->id, n->plugin_name, n->addr, n->addrlen, n->session)) | 849 | if (GNUNET_OK == |
850 | send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, | ||
851 | n->session)) | ||
846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n", | 852 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n", |
847 | GNUNET_i2s (&n->id)); | 853 | GNUNET_i2s (&n->id)); |
848 | else | 854 | else |
849 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Could not send DISCONNECT_MSG to `%s'\n", | 855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
856 | "Could not send DISCONNECT_MSG to `%s'\n", | ||
850 | GNUNET_i2s (&n->id)); | 857 | GNUNET_i2s (&n->id)); |
851 | } | 858 | } |
852 | 859 | ||
853 | 860 | ||
854 | if (is_disconnecting(n)) | 861 | if (is_disconnecting (n)) |
855 | return; | 862 | return; |
856 | change_state (n, S_DISCONNECT); | 863 | change_state (n, S_DISCONNECT); |
857 | 864 | ||
@@ -871,7 +878,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
871 | { | 878 | { |
872 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task); | 879 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->keepalive_task); |
873 | GNUNET_SCHEDULER_cancel (n->keepalive_task); | 880 | GNUNET_SCHEDULER_cancel (n->keepalive_task); |
874 | n->keepalive_task = GNUNET_SCHEDULER_NO_TASK; | 881 | n->keepalive_task = GNUNET_SCHEDULER_NO_TASK; |
875 | GNUNET_assert (neighbours_connected > 0); | 882 | GNUNET_assert (neighbours_connected > 0); |
876 | neighbours_connected--; | 883 | neighbours_connected--; |
877 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1, | 884 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), -1, |
@@ -929,7 +936,8 @@ neighbour_timeout_task (void *cls, | |||
929 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 936 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
930 | 937 | ||
931 | GNUNET_STATISTICS_update (GST_stats, | 938 | GNUNET_STATISTICS_update (GST_stats, |
932 | gettext_noop ("# peers disconnected due to timeout"), 1, | 939 | gettext_noop |
940 | ("# peers disconnected due to timeout"), 1, | ||
933 | GNUNET_NO); | 941 | GNUNET_NO); |
934 | disconnect_neighbour (n); | 942 | disconnect_neighbour (n); |
935 | } | 943 | } |
@@ -943,27 +951,24 @@ neighbour_timeout_task (void *cls, | |||
943 | */ | 951 | */ |
944 | static void | 952 | static void |
945 | neighbour_keepalive_task (void *cls, | 953 | neighbour_keepalive_task (void *cls, |
946 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 954 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
947 | { | 955 | { |
948 | struct NeighbourMapEntry *n = cls; | 956 | struct NeighbourMapEntry *n = cls; |
949 | struct GNUNET_MessageHeader m; | 957 | struct GNUNET_MessageHeader m; |
950 | 958 | ||
951 | n->keepalive_task = GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, | 959 | n->keepalive_task = |
952 | &neighbour_keepalive_task, | 960 | GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, |
953 | n); | 961 | &neighbour_keepalive_task, n); |
954 | GNUNET_assert (is_connected(n)); | 962 | GNUNET_assert (is_connected (n)); |
955 | GNUNET_STATISTICS_update (GST_stats, | 963 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# keepalives sent"), 1, |
956 | gettext_noop ("# keepalives sent"), 1, | 964 | GNUNET_NO); |
957 | GNUNET_NO); | ||
958 | m.size = htons (sizeof (struct GNUNET_MessageHeader)); | 965 | m.size = htons (sizeof (struct GNUNET_MessageHeader)); |
959 | m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE); | 966 | m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE); |
960 | 967 | ||
961 | send_with_plugin(&n->id, (const void *) &m, | 968 | send_with_plugin (&n->id, (const void *) &m, sizeof (m), |
962 | sizeof (m), | 969 | UINT32_MAX /* priority */ , |
963 | UINT32_MAX /* priority */ , | 970 | GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->plugin_name, |
964 | GNUNET_TIME_UNIT_FOREVER_REL, | 971 | n->addr, n->addrlen, GNUNET_YES, NULL, NULL); |
965 | n->session, n->plugin_name, n->addr, n->addrlen, | ||
966 | GNUNET_YES, NULL, NULL); | ||
967 | } | 972 | } |
968 | 973 | ||
969 | 974 | ||
@@ -983,18 +988,18 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value) | |||
983 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", | 988 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", |
984 | GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); | 989 | GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); |
985 | #endif | 990 | #endif |
986 | if (is_connected(n)) | 991 | if (is_connected (n)) |
987 | GNUNET_STATISTICS_update (GST_stats, | 992 | GNUNET_STATISTICS_update (GST_stats, |
988 | gettext_noop ("# peers disconnected due to global disconnect"), 1, | 993 | gettext_noop |
989 | GNUNET_NO); | 994 | ("# peers disconnected due to global disconnect"), |
995 | 1, GNUNET_NO); | ||
990 | disconnect_neighbour (n); | 996 | disconnect_neighbour (n); |
991 | return GNUNET_OK; | 997 | return GNUNET_OK; |
992 | } | 998 | } |
993 | 999 | ||
994 | 1000 | ||
995 | static void | 1001 | static void |
996 | ats_suggest_cancel (void *cls, | 1002 | ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
997 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
998 | { | 1003 | { |
999 | struct NeighbourMapEntry *n = cls; | 1004 | struct NeighbourMapEntry *n = cls; |
1000 | 1005 | ||
@@ -1004,7 +1009,7 @@ ats_suggest_cancel (void *cls, | |||
1004 | " ATS did not suggested address to connect to peer `%s'\n", | 1009 | " ATS did not suggested address to connect to peer `%s'\n", |
1005 | GNUNET_i2s (&n->id)); | 1010 | GNUNET_i2s (&n->id)); |
1006 | 1011 | ||
1007 | disconnect_neighbour(n); | 1012 | disconnect_neighbour (n); |
1008 | } | 1013 | } |
1009 | 1014 | ||
1010 | /** | 1015 | /** |
@@ -1039,44 +1044,39 @@ GST_neighbours_stop () | |||
1039 | * @param success GNUNET_OK on success | 1044 | * @param success GNUNET_OK on success |
1040 | */ | 1045 | */ |
1041 | static void | 1046 | static void |
1042 | send_connect_continuation (void *cls, | 1047 | send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target, |
1043 | const struct GNUNET_PeerIdentity * target, | 1048 | int success) |
1044 | int success) | ||
1045 | |||
1046 | { | 1049 | { |
1047 | struct NeighbourMapEntry *n = cls; | 1050 | struct NeighbourMapEntry *n = cls; |
1048 | 1051 | ||
1049 | GNUNET_assert (n != NULL); | 1052 | GNUNET_assert (n != NULL); |
1050 | GNUNET_assert (!is_connected(n)); | 1053 | GNUNET_assert (!is_connected (n)); |
1051 | 1054 | ||
1052 | if (is_disconnecting(n)) | 1055 | if (is_disconnecting (n)) |
1053 | return; /* neighbour is going away */ | 1056 | return; /* neighbour is going away */ |
1054 | 1057 | ||
1055 | if (GNUNET_YES != success) | 1058 | if (GNUNET_YES != success) |
1056 | { | 1059 | { |
1057 | #if DEBUG_TRANSPORT | 1060 | #if DEBUG_TRANSPORT |
1058 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1059 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", | 1062 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", |
1060 | GNUNET_i2s (&n->id), n->plugin_name, | 1063 | GNUNET_i2s (&n->id), n->plugin_name, |
1061 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 1064 | (n->addrlen == |
1062 | n->addr, | 1065 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, |
1063 | n->addrlen), | 1066 | n->addrlen), n->session); |
1064 | n->session); | ||
1065 | #endif | 1067 | #endif |
1066 | 1068 | ||
1067 | GNUNET_ATS_address_destroyed (GST_ats, | 1069 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, |
1068 | &n->id, | 1070 | n->addrlen, NULL); |
1069 | n->plugin_name, | ||
1070 | n->addr, | ||
1071 | n->addrlen, | ||
1072 | NULL); | ||
1073 | 1071 | ||
1074 | change_state(n, S_NOT_CONNECTED); | 1072 | change_state (n, S_NOT_CONNECTED); |
1075 | 1073 | ||
1076 | if (n->ats_suggest!= GNUNET_SCHEDULER_NO_TASK) | 1074 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1077 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 1075 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
1078 | n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n); | 1076 | n->ats_suggest = |
1079 | GNUNET_ATS_suggest_address(GST_ats, &n->id); | 1077 | GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, |
1078 | n); | ||
1079 | GNUNET_ATS_suggest_address (GST_ats, &n->id); | ||
1080 | return; | 1080 | return; |
1081 | } | 1081 | } |
1082 | 1082 | ||
@@ -1093,40 +1093,36 @@ send_connect_continuation (void *cls, | |||
1093 | */ | 1093 | */ |
1094 | static void | 1094 | static void |
1095 | send_switch_address_continuation (void *cls, | 1095 | send_switch_address_continuation (void *cls, |
1096 | const struct GNUNET_PeerIdentity * target, | 1096 | const struct GNUNET_PeerIdentity *target, |
1097 | int success) | 1097 | int success) |
1098 | |||
1099 | { | 1098 | { |
1100 | struct NeighbourMapEntry *n = cls; | 1099 | struct NeighbourMapEntry *n = cls; |
1101 | 1100 | ||
1102 | GNUNET_assert (n != NULL); | 1101 | GNUNET_assert (n != NULL); |
1103 | if (is_disconnecting(n)) | 1102 | if (is_disconnecting (n)) |
1104 | return; /* neighbour is going away */ | 1103 | return; /* neighbour is going away */ |
1105 | 1104 | ||
1106 | GNUNET_assert (n->state == S_CONNECTED); | 1105 | GNUNET_assert (n->state == S_CONNECTED); |
1107 | if (GNUNET_YES != success) | 1106 | if (GNUNET_YES != success) |
1108 | { | 1107 | { |
1109 | #if DEBUG_TRANSPORT | 1108 | #if DEBUG_TRANSPORT |
1110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1111 | "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n", | 1110 | "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n", |
1112 | GNUNET_i2s (&n->id), n->plugin_name, | 1111 | GNUNET_i2s (&n->id), n->plugin_name, |
1113 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 1112 | (n->addrlen == |
1114 | n->addr, | 1113 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, |
1115 | n->addrlen), | 1114 | n->addrlen), n->session); |
1116 | n->session); | ||
1117 | #endif | 1115 | #endif |
1118 | 1116 | ||
1119 | GNUNET_ATS_address_destroyed (GST_ats, | 1117 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, |
1120 | &n->id, | 1118 | n->addrlen, NULL); |
1121 | n->plugin_name, | ||
1122 | n->addr, | ||
1123 | n->addrlen, | ||
1124 | NULL); | ||
1125 | 1119 | ||
1126 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1120 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1127 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 1121 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
1128 | n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n); | 1122 | n->ats_suggest = |
1129 | GNUNET_ATS_suggest_address(GST_ats, &n->id); | 1123 | GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, |
1124 | n); | ||
1125 | GNUNET_ATS_suggest_address (GST_ats, &n->id); | ||
1130 | return; | 1126 | return; |
1131 | } | 1127 | } |
1132 | } | 1128 | } |
@@ -1141,40 +1137,37 @@ send_switch_address_continuation (void *cls, | |||
1141 | */ | 1137 | */ |
1142 | static void | 1138 | static void |
1143 | send_connect_ack_continuation (void *cls, | 1139 | send_connect_ack_continuation (void *cls, |
1144 | const struct GNUNET_PeerIdentity * target, | 1140 | const struct GNUNET_PeerIdentity *target, |
1145 | int success) | 1141 | int success) |
1146 | |||
1147 | { | 1142 | { |
1148 | struct NeighbourMapEntry *n = cls; | 1143 | struct NeighbourMapEntry *n = cls; |
1149 | 1144 | ||
1150 | GNUNET_assert (n != NULL); | 1145 | GNUNET_assert (n != NULL); |
1151 | 1146 | ||
1152 | if (GNUNET_YES == success) | 1147 | if (GNUNET_YES == success) |
1153 | return; /* sending successful */ | 1148 | return; /* sending successful */ |
1154 | 1149 | ||
1155 | /* sending failed, ask for next address */ | 1150 | /* sending failed, ask for next address */ |
1156 | #if DEBUG_TRANSPORT | 1151 | #if DEBUG_TRANSPORT |
1157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1158 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", | 1153 | "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", |
1159 | GNUNET_i2s (&n->id), n->plugin_name, | 1154 | GNUNET_i2s (&n->id), n->plugin_name, |
1160 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 1155 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, |
1161 | n->addr, | 1156 | n->addr, |
1162 | n->addrlen), | 1157 | n->addrlen), |
1163 | n->session); | 1158 | n->session); |
1164 | #endif | 1159 | #endif |
1165 | change_state(n, S_NOT_CONNECTED); | 1160 | change_state (n, S_NOT_CONNECTED); |
1166 | 1161 | ||
1167 | GNUNET_ATS_address_destroyed (GST_ats, | 1162 | GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, |
1168 | &n->id, | 1163 | n->addrlen, NULL); |
1169 | n->plugin_name, | ||
1170 | n->addr, | ||
1171 | n->addrlen, | ||
1172 | NULL); | ||
1173 | 1164 | ||
1174 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1165 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1175 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 1166 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
1176 | n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n); | 1167 | n->ats_suggest = |
1177 | GNUNET_ATS_suggest_address(GST_ats, &n->id); | 1168 | GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, |
1169 | n); | ||
1170 | GNUNET_ATS_suggest_address (GST_ats, &n->id); | ||
1178 | } | 1171 | } |
1179 | 1172 | ||
1180 | /** | 1173 | /** |
@@ -1194,12 +1187,15 @@ send_connect_ack_continuation (void *cls, | |||
1194 | */ | 1187 | */ |
1195 | int | 1188 | int |
1196 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | 1189 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, |
1197 | const char *plugin_name, const void *address, | 1190 | const char *plugin_name, |
1198 | size_t address_len, struct Session *session, | 1191 | const void *address, size_t address_len, |
1199 | const struct GNUNET_ATS_Information | 1192 | struct Session *session, |
1200 | *ats, uint32_t ats_count, | 1193 | const struct GNUNET_ATS_Information *ats, |
1201 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1194 | uint32_t ats_count, |
1202 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 1195 | struct GNUNET_BANDWIDTH_Value32NBO |
1196 | bandwidth_in, | ||
1197 | struct GNUNET_BANDWIDTH_Value32NBO | ||
1198 | bandwidth_out) | ||
1203 | { | 1199 | { |
1204 | struct NeighbourMapEntry *n; | 1200 | struct NeighbourMapEntry *n; |
1205 | struct SessionConnectMessage connect_msg; | 1201 | struct SessionConnectMessage connect_msg; |
@@ -1219,14 +1215,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1219 | { | 1215 | { |
1220 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1216 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1221 | "ATS offered suggested us empty address: plugin NULL"); | 1217 | "ATS offered suggested us empty address: plugin NULL"); |
1222 | GNUNET_break_op(0); | 1218 | GNUNET_break_op (0); |
1223 | checks_failed = GNUNET_YES; | 1219 | checks_failed = GNUNET_YES; |
1224 | } | 1220 | } |
1225 | if ((address == NULL) && (address_len == 0 ) && (session == NULL)) | 1221 | if ((address == NULL) && (address_len == 0) && (session == NULL)) |
1226 | { | 1222 | { |
1227 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1223 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1228 | "ATS offered suggested us empty address: address NULL & session NULL"); | 1224 | "ATS offered suggested us empty address: address NULL & session NULL"); |
1229 | GNUNET_break_op(0); | 1225 | GNUNET_break_op (0); |
1230 | checks_failed = GNUNET_YES; | 1226 | checks_failed = GNUNET_YES; |
1231 | } | 1227 | } |
1232 | 1228 | ||
@@ -1236,12 +1232,10 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1236 | 1232 | ||
1237 | if (checks_failed == GNUNET_YES) | 1233 | if (checks_failed == GNUNET_YES) |
1238 | { | 1234 | { |
1239 | GNUNET_ATS_address_destroyed (GST_ats, | 1235 | GNUNET_ATS_address_destroyed (GST_ats, peer, plugin_name, address, |
1240 | peer, | 1236 | address_len, session); |
1241 | plugin_name, address, | ||
1242 | address_len, session); | ||
1243 | if (n != NULL) | 1237 | if (n != NULL) |
1244 | GNUNET_ATS_suggest_address(GST_ats, peer); | 1238 | GNUNET_ATS_suggest_address (GST_ats, peer); |
1245 | return GNUNET_NO; | 1239 | return GNUNET_NO; |
1246 | } | 1240 | } |
1247 | 1241 | ||
@@ -1253,18 +1247,18 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1253 | (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, | 1247 | (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, |
1254 | address, | 1248 | address, |
1255 | address_len), | 1249 | address_len), |
1256 | session, (is_connected(n) ? "CONNECTED" : "NOT CONNECTED"), | 1250 | session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"), |
1257 | GNUNET_i2s (peer)); | 1251 | GNUNET_i2s (peer)); |
1258 | #endif | 1252 | #endif |
1259 | 1253 | ||
1260 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1254 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1261 | { | 1255 | { |
1262 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 1256 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
1263 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; | 1257 | n->ats_suggest = GNUNET_SCHEDULER_NO_TASK; |
1264 | } | 1258 | } |
1265 | 1259 | ||
1266 | // do not switch addresses just update quotas | 1260 | // do not switch addresses just update quotas |
1267 | if ((is_connected(n)) && (address_len == n->addrlen)) | 1261 | if ((is_connected (n)) && (address_len == n->addrlen)) |
1268 | { | 1262 | { |
1269 | if ((0 == memcmp (address, n->addr, address_len)) && | 1263 | if ((0 == memcmp (address, n->addr, address_len)) && |
1270 | (n->session == session)) | 1264 | (n->session == session)) |
@@ -1272,16 +1266,15 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1272 | struct QuotaSetMessage q_msg; | 1266 | struct QuotaSetMessage q_msg; |
1273 | 1267 | ||
1274 | #if DEBUG_TRANSPORT | 1268 | #if DEBUG_TRANSPORT |
1275 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1276 | "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", | 1270 | "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", |
1277 | ntohl (n->bandwidth_out.value__), | 1271 | ntohl (n->bandwidth_out.value__), |
1278 | ntohl (n->bandwidth_in.value__), | 1272 | ntohl (n->bandwidth_in.value__), GNUNET_i2s (peer)); |
1279 | GNUNET_i2s (peer)); | ||
1280 | #endif | 1273 | #endif |
1281 | 1274 | ||
1282 | n->bandwidth_in = bandwidth_in; | 1275 | n->bandwidth_in = bandwidth_in; |
1283 | n->bandwidth_out = bandwidth_out; | 1276 | n->bandwidth_out = bandwidth_out; |
1284 | GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in); | 1277 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); |
1285 | 1278 | ||
1286 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); | 1279 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); |
1287 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); | 1280 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); |
@@ -1324,9 +1317,11 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |||
1324 | 1317 | ||
1325 | change_state (n, S_CONNECT_SENT); | 1318 | change_state (n, S_CONNECT_SENT); |
1326 | 1319 | ||
1327 | ret = send_with_plugin (peer, (const char *) &connect_msg, msg_len, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, | 1320 | ret = |
1328 | session, plugin_name, address, address_len, | 1321 | send_with_plugin (peer, (const char *) &connect_msg, msg_len, |
1329 | GNUNET_YES, &send_connect_continuation, n); | 1322 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, |
1323 | plugin_name, address, address_len, GNUNET_YES, | ||
1324 | &send_connect_continuation, n); | ||
1330 | 1325 | ||
1331 | return GNUNET_NO; | 1326 | return GNUNET_NO; |
1332 | } | 1327 | } |
@@ -1336,13 +1331,16 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |||
1336 | msg_len = sizeof (struct SessionConnectMessage); | 1331 | msg_len = sizeof (struct SessionConnectMessage); |
1337 | connect_msg.header.size = htons (msg_len); | 1332 | connect_msg.header.size = htons (msg_len); |
1338 | connect_msg.header.type = | 1333 | connect_msg.header.type = |
1339 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK); | 1334 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK); |
1340 | connect_msg.reserved = htonl (0); | 1335 | connect_msg.reserved = htonl (0); |
1341 | connect_msg.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | 1336 | connect_msg.timestamp = |
1337 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | ||
1342 | 1338 | ||
1343 | ret = send_with_plugin(&n->id, (const void *) &connect_msg, msg_len, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, | 1339 | ret = |
1344 | session, plugin_name, address, address_len, | 1340 | send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, |
1345 | GNUNET_YES, &send_connect_ack_continuation, n); | 1341 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, |
1342 | plugin_name, address, address_len, GNUNET_YES, | ||
1343 | &send_connect_ack_continuation, n); | ||
1346 | return GNUNET_NO; | 1344 | return GNUNET_NO; |
1347 | } | 1345 | } |
1348 | /* connected peer is switching addresses */ | 1346 | /* connected peer is switching addresses */ |
@@ -1356,26 +1354,28 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |||
1356 | connect_msg.timestamp = | 1354 | connect_msg.timestamp = |
1357 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | 1355 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); |
1358 | 1356 | ||
1359 | ret = send_with_plugin (peer, (const char *) &connect_msg, msg_len, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, | 1357 | ret = |
1360 | session, plugin_name, address, address_len, | 1358 | send_with_plugin (peer, (const char *) &connect_msg, msg_len, |
1361 | GNUNET_YES, &send_switch_address_continuation, n); | 1359 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, |
1360 | plugin_name, address, address_len, GNUNET_YES, | ||
1361 | &send_switch_address_continuation, n); | ||
1362 | if (ret == GNUNET_SYSERR) | 1362 | if (ret == GNUNET_SYSERR) |
1363 | { | 1363 | { |
1364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1365 | "Failed to send CONNECT_MESSAGE to `%4s' using plugin `%s' address '%s' session %X\n", | 1365 | "Failed to send CONNECT_MESSAGE to `%4s' using plugin `%s' address '%s' session %X\n", |
1366 | GNUNET_i2s (peer), plugin_name, | 1366 | GNUNET_i2s (peer), plugin_name, |
1367 | (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, | 1367 | (address_len == |
1368 | address, | 1368 | 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, address, |
1369 | address_len), | 1369 | address_len), session); |
1370 | session); | ||
1371 | } | 1370 | } |
1372 | return GNUNET_NO; | 1371 | return GNUNET_NO; |
1373 | } | 1372 | } |
1374 | else if (n->state == S_CONNECT_SENT) | 1373 | else if (n->state == S_CONNECT_SENT) |
1375 | { | 1374 | { |
1376 | return GNUNET_NO; | 1375 | return GNUNET_NO; |
1377 | } | 1376 | } |
1378 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid connection state to switch addresses %u \n", n->state); | 1377 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1378 | "Invalid connection state to switch addresses %u \n", n->state); | ||
1379 | GNUNET_break_op (0); | 1379 | GNUNET_break_op (0); |
1380 | return GNUNET_NO; | 1380 | return GNUNET_NO; |
1381 | } | 1381 | } |
@@ -1383,7 +1383,7 @@ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |||
1383 | 1383 | ||
1384 | /** | 1384 | /** |
1385 | * Create an entry in the neighbour map for the given peer | 1385 | * Create an entry in the neighbour map for the given peer |
1386 | * | 1386 | * |
1387 | * @param peer peer to create an entry for | 1387 | * @param peer peer to create an entry for |
1388 | * @return new neighbour map entry | 1388 | * @return new neighbour map entry |
1389 | */ | 1389 | */ |
@@ -1394,22 +1394,21 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer) | |||
1394 | 1394 | ||
1395 | #if DEBUG_TRANSPORT | 1395 | #if DEBUG_TRANSPORT |
1396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1397 | "Unknown peer `%s', creating new neighbour\n", | 1397 | "Unknown peer `%s', creating new neighbour\n", GNUNET_i2s (peer)); |
1398 | GNUNET_i2s (peer)); | ||
1399 | #endif | 1398 | #endif |
1400 | n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); | 1399 | n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); |
1401 | n->id = *peer; | 1400 | n->id = *peer; |
1402 | n->state = S_NOT_CONNECTED; | 1401 | n->state = S_NOT_CONNECTED; |
1403 | GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, | 1402 | GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, |
1404 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | 1403 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, |
1405 | MAX_BANDWIDTH_CARRY_S); | 1404 | MAX_BANDWIDTH_CARRY_S); |
1406 | n->timeout_task = | 1405 | n->timeout_task = |
1407 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1406 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1408 | &neighbour_timeout_task, n); | 1407 | &neighbour_timeout_task, n); |
1409 | GNUNET_assert (GNUNET_OK == | 1408 | GNUNET_assert (GNUNET_OK == |
1410 | GNUNET_CONTAINER_multihashmap_put (neighbours, | 1409 | GNUNET_CONTAINER_multihashmap_put (neighbours, |
1411 | &n->id.hashPubKey, n, | 1410 | &n->id.hashPubKey, n, |
1412 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1411 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1413 | return n; | 1412 | return n; |
1414 | } | 1413 | } |
1415 | 1414 | ||
@@ -1433,8 +1432,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) | |||
1433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to peer `%s'\n", | 1432 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to peer `%s'\n", |
1434 | GNUNET_i2s (target)); | 1433 | GNUNET_i2s (target)); |
1435 | #endif | 1434 | #endif |
1436 | if (0 == memcmp (target, &GST_my_identity, | 1435 | if (0 == |
1437 | sizeof (struct GNUNET_PeerIdentity))) | 1436 | memcmp (target, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) |
1438 | { | 1437 | { |
1439 | /* my own hello */ | 1438 | /* my own hello */ |
1440 | return; | 1439 | return; |
@@ -1443,9 +1442,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) | |||
1443 | 1442 | ||
1444 | if (NULL != n) | 1443 | if (NULL != n) |
1445 | { | 1444 | { |
1446 | if ((is_connected(n)) || (is_connecting(n))) | 1445 | if ((is_connected (n)) || (is_connecting (n))) |
1447 | return; /* already connecting or connected */ | 1446 | return; /* already connecting or connected */ |
1448 | if (is_disconnecting(n)) | 1447 | if (is_disconnecting (n)) |
1449 | change_state (n, S_NOT_CONNECTED); | 1448 | change_state (n, S_NOT_CONNECTED); |
1450 | } | 1449 | } |
1451 | 1450 | ||
@@ -1458,7 +1457,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) | |||
1458 | GNUNET_i2s (&n->id)); | 1457 | GNUNET_i2s (&n->id)); |
1459 | #endif | 1458 | #endif |
1460 | 1459 | ||
1461 | GNUNET_ATS_suggest_address (GST_ats, &n->id); | 1460 | GNUNET_ATS_suggest_address (GST_ats, &n->id); |
1462 | } | 1461 | } |
1463 | 1462 | ||
1464 | /** | 1463 | /** |
@@ -1480,7 +1479,7 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target) | |||
1480 | 1479 | ||
1481 | n = lookup_neighbour (target); | 1480 | n = lookup_neighbour (target); |
1482 | 1481 | ||
1483 | if ((NULL == n) || (!is_connected(n))) | 1482 | if ((NULL == n) || (!is_connected (n))) |
1484 | return GNUNET_NO; /* not connected */ | 1483 | return GNUNET_NO; /* not connected */ |
1485 | return GNUNET_YES; | 1484 | return GNUNET_YES; |
1486 | } | 1485 | } |
@@ -1505,8 +1504,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1505 | } | 1504 | } |
1506 | 1505 | ||
1507 | #if DEBUG_TRANSPORT | 1506 | #if DEBUG_TRANSPORT |
1508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n", |
1509 | "Session %X to peer `%s' ended \n", | ||
1510 | session, GNUNET_i2s (peer)); | 1508 | session, GNUNET_i2s (peer)); |
1511 | #endif | 1509 | #endif |
1512 | 1510 | ||
@@ -1522,7 +1520,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1522 | n->addrlen = 0; | 1520 | n->addrlen = 0; |
1523 | 1521 | ||
1524 | /* not connected anymore anyway, shouldn't matter */ | 1522 | /* not connected anymore anyway, shouldn't matter */ |
1525 | if ((!is_connected(n)) && (!is_connecting(n))) | 1523 | if ((!is_connected (n)) && (!is_connecting (n))) |
1526 | return; | 1524 | return; |
1527 | 1525 | ||
1528 | /* We are connected, so ask ATS to switch addresses */ | 1526 | /* We are connected, so ask ATS to switch addresses */ |
@@ -1532,8 +1530,10 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
1532 | &neighbour_timeout_task, n); | 1530 | &neighbour_timeout_task, n); |
1533 | /* try QUICKLY to re-establish a connection, reduce timeout! */ | 1531 | /* try QUICKLY to re-establish a connection, reduce timeout! */ |
1534 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 1532 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
1535 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 1533 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
1536 | n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n); | 1534 | n->ats_suggest = |
1535 | GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, | ||
1536 | n); | ||
1537 | GNUNET_ATS_suggest_address (GST_ats, peer); | 1537 | GNUNET_ATS_suggest_address (GST_ats, peer); |
1538 | } | 1538 | } |
1539 | 1539 | ||
@@ -1563,7 +1563,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, | |||
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | n = lookup_neighbour (target); | 1565 | n = lookup_neighbour (target); |
1566 | if ((n == NULL) || (!is_connected(n))) | 1566 | if ((n == NULL) || (!is_connected (n))) |
1567 | { | 1567 | { |
1568 | GNUNET_STATISTICS_update (GST_stats, | 1568 | GNUNET_STATISTICS_update (GST_stats, |
1569 | gettext_noop | 1569 | gettext_noop |
@@ -1574,7 +1574,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, | |||
1574 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1574 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1575 | "Could not send message to peer `%s': unknown neighbour", | 1575 | "Could not send message to peer `%s': unknown neighbour", |
1576 | GNUNET_i2s (target)); | 1576 | GNUNET_i2s (target)); |
1577 | else if (!is_connected(n)) | 1577 | else if (!is_connected (n)) |
1578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1579 | "Could not send message to peer `%s': not connected\n", | 1579 | "Could not send message to peer `%s': not connected\n", |
1580 | GNUNET_i2s (target)); | 1580 | GNUNET_i2s (target)); |
@@ -1584,16 +1584,16 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, | |||
1584 | return; | 1584 | return; |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen ==0)) | 1587 | if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) |
1588 | { | 1588 | { |
1589 | GNUNET_STATISTICS_update (GST_stats, | 1589 | GNUNET_STATISTICS_update (GST_stats, |
1590 | gettext_noop | 1590 | gettext_noop |
1591 | ("# messages not sent (no such peer or not connected)"), | 1591 | ("# messages not sent (no such peer or not connected)"), |
1592 | 1, GNUNET_NO); | 1592 | 1, GNUNET_NO); |
1593 | #if DEBUG_TRANSPORT | 1593 | #if DEBUG_TRANSPORT |
1594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1595 | "Could not send message to peer `%s': no address available\n", | 1595 | "Could not send message to peer `%s': no address available\n", |
1596 | GNUNET_i2s (target)); | 1596 | GNUNET_i2s (target)); |
1597 | #endif | 1597 | #endif |
1598 | 1598 | ||
1599 | if (NULL != cont) | 1599 | if (NULL != cont) |
@@ -1655,14 +1655,14 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity | |||
1655 | if (NULL == n) | 1655 | if (NULL == n) |
1656 | { | 1656 | { |
1657 | GNUNET_STATISTICS_update (GST_stats, | 1657 | GNUNET_STATISTICS_update (GST_stats, |
1658 | gettext_noop | 1658 | gettext_noop |
1659 | ("# messages discarded due to lack of neighbour record"), | 1659 | ("# messages discarded due to lack of neighbour record"), |
1660 | 1, GNUNET_NO); | 1660 | 1, GNUNET_NO); |
1661 | *do_forward = GNUNET_NO; | 1661 | *do_forward = GNUNET_NO; |
1662 | return GNUNET_TIME_UNIT_ZERO; | 1662 | return GNUNET_TIME_UNIT_ZERO; |
1663 | } | 1663 | } |
1664 | } | 1664 | } |
1665 | if (!is_connected(n)) | 1665 | if (!is_connected (n)) |
1666 | { | 1666 | { |
1667 | *do_forward = GNUNET_SYSERR; | 1667 | *do_forward = GNUNET_SYSERR; |
1668 | return GNUNET_TIME_UNIT_ZERO; | 1668 | return GNUNET_TIME_UNIT_ZERO; |
@@ -1784,10 +1784,10 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour, | |||
1784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n", | 1784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n", |
1785 | GNUNET_i2s (&n->id), "SET_QUOTA"); | 1785 | GNUNET_i2s (&n->id), "SET_QUOTA"); |
1786 | #endif | 1786 | #endif |
1787 | if (is_connected(n)) | 1787 | if (is_connected (n)) |
1788 | GNUNET_STATISTICS_update (GST_stats, | 1788 | GNUNET_STATISTICS_update (GST_stats, |
1789 | gettext_noop ("# disconnects due to quota of 0"), 1, | 1789 | gettext_noop ("# disconnects due to quota of 0"), |
1790 | GNUNET_NO); | 1790 | 1, GNUNET_NO); |
1791 | disconnect_neighbour (n); | 1791 | disconnect_neighbour (n); |
1792 | } | 1792 | } |
1793 | 1793 | ||
@@ -1823,7 +1823,7 @@ neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value) | |||
1823 | struct IteratorContext *ic = cls; | 1823 | struct IteratorContext *ic = cls; |
1824 | struct NeighbourMapEntry *n = value; | 1824 | struct NeighbourMapEntry *n = value; |
1825 | 1825 | ||
1826 | if (!is_connected(n)) | 1826 | if (!is_connected (n)) |
1827 | return GNUNET_OK; | 1827 | return GNUNET_OK; |
1828 | 1828 | ||
1829 | ic->cb (ic->cb_cls, &n->id, NULL, 0, n->plugin_name, n->addr, n->addrlen); | 1829 | ic->cb (ic->cb_cls, &n->id, NULL, 0, n->plugin_name, n->addr, n->addrlen); |
@@ -1872,13 +1872,13 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target) | |||
1872 | n = lookup_neighbour (target); | 1872 | n = lookup_neighbour (target); |
1873 | if (NULL == n) | 1873 | if (NULL == n) |
1874 | return; /* not active */ | 1874 | return; /* not active */ |
1875 | if (is_connected(n)) | 1875 | if (is_connected (n)) |
1876 | { | 1876 | { |
1877 | send_disconnect(&n->id, n->plugin_name, n->addr, n->addrlen, n->session); | 1877 | send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, n->session); |
1878 | 1878 | ||
1879 | n = lookup_neighbour (target); | 1879 | n = lookup_neighbour (target); |
1880 | if (NULL == n) | 1880 | if (NULL == n) |
1881 | return; /* gone already */ | 1881 | return; /* gone already */ |
1882 | } | 1882 | } |
1883 | disconnect_neighbour (n); | 1883 | disconnect_neighbour (n); |
1884 | } | 1884 | } |
@@ -1887,13 +1887,15 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target) | |||
1887 | /** | 1887 | /** |
1888 | * We received a disconnect message from the given peer, | 1888 | * We received a disconnect message from the given peer, |
1889 | * validate and process. | 1889 | * validate and process. |
1890 | * | 1890 | * |
1891 | * @param peer sender of the message | 1891 | * @param peer sender of the message |
1892 | * @param msg the disconnect message | 1892 | * @param msg the disconnect message |
1893 | */ | 1893 | */ |
1894 | void | 1894 | void |
1895 | GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer, | 1895 | GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity |
1896 | const struct GNUNET_MessageHeader *msg) | 1896 | *peer, |
1897 | const struct GNUNET_MessageHeader | ||
1898 | *msg) | ||
1897 | { | 1899 | { |
1898 | struct NeighbourMapEntry *n; | 1900 | struct NeighbourMapEntry *n; |
1899 | const struct SessionDisconnectMessage *sdm; | 1901 | const struct SessionDisconnectMessage *sdm; |
@@ -1901,18 +1903,20 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer | |||
1901 | 1903 | ||
1902 | #if DEBUG_TRANSPORT | 1904 | #if DEBUG_TRANSPORT |
1903 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1905 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1904 | "Received DISCONNECT message from peer `%s'\n", GNUNET_i2s (peer)); | 1906 | "Received DISCONNECT message from peer `%s'\n", |
1907 | GNUNET_i2s (peer)); | ||
1905 | #endif | 1908 | #endif |
1906 | 1909 | ||
1907 | if (ntohs (msg->size) != sizeof (struct SessionDisconnectMessage)) | 1910 | if (ntohs (msg->size) != sizeof (struct SessionDisconnectMessage)) |
1908 | { | 1911 | { |
1909 | // GNUNET_break_op (0); | 1912 | // GNUNET_break_op (0); |
1910 | GNUNET_STATISTICS_update (GST_stats, | 1913 | GNUNET_STATISTICS_update (GST_stats, |
1911 | gettext_noop ("# disconnect messages ignored (old format)"), 1, | 1914 | gettext_noop |
1912 | GNUNET_NO); | 1915 | ("# disconnect messages ignored (old format)"), 1, |
1916 | GNUNET_NO); | ||
1913 | return; | 1917 | return; |
1914 | } | 1918 | } |
1915 | sdm = (const struct SessionDisconnectMessage* ) msg; | 1919 | sdm = (const struct SessionDisconnectMessage *) msg; |
1916 | n = lookup_neighbour (peer); | 1920 | n = lookup_neighbour (peer); |
1917 | if (NULL == n) | 1921 | if (NULL == n) |
1918 | return; /* gone already */ | 1922 | return; /* gone already */ |
@@ -1920,21 +1924,20 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer | |||
1920 | n->connect_ts.abs_value) | 1924 | n->connect_ts.abs_value) |
1921 | { | 1925 | { |
1922 | GNUNET_STATISTICS_update (GST_stats, | 1926 | GNUNET_STATISTICS_update (GST_stats, |
1923 | gettext_noop ("# disconnect messages ignored (timestamp)"), 1, | 1927 | gettext_noop |
1924 | GNUNET_NO); | 1928 | ("# disconnect messages ignored (timestamp)"), 1, |
1929 | GNUNET_NO); | ||
1925 | return; | 1930 | return; |
1926 | } | 1931 | } |
1927 | GNUNET_CRYPTO_hash (&sdm->public_key, | 1932 | GNUNET_CRYPTO_hash (&sdm->public_key, |
1928 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 1933 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1929 | &hc); | 1934 | &hc); |
1930 | if (0 != memcmp (peer, | 1935 | if (0 != memcmp (peer, &hc, sizeof (struct GNUNET_PeerIdentity))) |
1931 | &hc, | ||
1932 | sizeof (struct GNUNET_PeerIdentity))) | ||
1933 | { | 1936 | { |
1934 | GNUNET_break_op (0); | 1937 | GNUNET_break_op (0); |
1935 | return; | 1938 | return; |
1936 | } | 1939 | } |
1937 | if (ntohl (sdm->purpose.size) != | 1940 | if (ntohl (sdm->purpose.size) != |
1938 | sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 1941 | sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
1939 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 1942 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + |
1940 | sizeof (struct GNUNET_TIME_AbsoluteNBO)) | 1943 | sizeof (struct GNUNET_TIME_AbsoluteNBO)) |
@@ -1943,10 +1946,9 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer | |||
1943 | return; | 1946 | return; |
1944 | } | 1947 | } |
1945 | if (GNUNET_OK != | 1948 | if (GNUNET_OK != |
1946 | GNUNET_CRYPTO_rsa_verify (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, | 1949 | GNUNET_CRYPTO_rsa_verify |
1947 | &sdm->purpose, | 1950 | (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT, &sdm->purpose, |
1948 | &sdm->signature, | 1951 | &sdm->signature, &sdm->public_key)) |
1949 | &sdm->public_key)) | ||
1950 | { | 1952 | { |
1951 | GNUNET_break_op (0); | 1953 | GNUNET_break_op (0); |
1952 | return; | 1954 | return; |
@@ -1970,12 +1972,13 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer | |||
1970 | */ | 1972 | */ |
1971 | void | 1973 | void |
1972 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | 1974 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, |
1973 | const struct GNUNET_PeerIdentity *peer, | 1975 | const struct GNUNET_PeerIdentity *peer, |
1974 | const char *plugin_name, | 1976 | const char *plugin_name, |
1975 | const char *sender_address, uint16_t sender_address_len, | 1977 | const char *sender_address, |
1976 | struct Session *session, | 1978 | uint16_t sender_address_len, |
1977 | const struct GNUNET_ATS_Information *ats, | 1979 | struct Session *session, |
1978 | uint32_t ats_count) | 1980 | const struct GNUNET_ATS_Information *ats, |
1981 | uint32_t ats_count) | ||
1979 | { | 1982 | { |
1980 | const struct SessionConnectMessage *scm; | 1983 | const struct SessionConnectMessage *scm; |
1981 | struct QuotaSetMessage q_msg; | 1984 | struct QuotaSetMessage q_msg; |
@@ -1987,7 +1990,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
1987 | 1990 | ||
1988 | #if DEBUG_TRANSPORT | 1991 | #if DEBUG_TRANSPORT |
1989 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1992 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1990 | "Received CONNECT_ACK message from peer `%s'\n", GNUNET_i2s (peer)); | 1993 | "Received CONNECT_ACK message from peer `%s'\n", |
1994 | GNUNET_i2s (peer)); | ||
1991 | #endif | 1995 | #endif |
1992 | 1996 | ||
1993 | if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) | 1997 | if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) |
@@ -2013,104 +2017,94 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2013 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2017 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2014 | "transport-ats", | 2018 | "transport-ats", |
2015 | "Giving ATS session %p of plugin %s for peer %s\n", | 2019 | "Giving ATS session %p of plugin %s for peer %s\n", |
2016 | session, | 2020 | session, plugin_name, GNUNET_i2s (peer)); |
2017 | plugin_name, | 2021 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, |
2018 | GNUNET_i2s (peer)); | 2022 | sender_address_len, session, ats, ats_count); |
2019 | GNUNET_ATS_address_update (GST_ats, | 2023 | |
2020 | peer, | 2024 | was_connected = is_connected (n); |
2021 | plugin_name, sender_address, sender_address_len, | 2025 | if (!is_connected (n)) |
2022 | session, ats, ats_count); | ||
2023 | |||
2024 | was_connected = is_connected(n); | ||
2025 | if (!is_connected(n)) | ||
2026 | change_state (n, S_CONNECTED); | 2026 | change_state (n, S_CONNECTED); |
2027 | 2027 | ||
2028 | GNUNET_ATS_address_in_use (GST_ats, | 2028 | GNUNET_ATS_address_in_use (GST_ats, peer, plugin_name, sender_address, |
2029 | peer, | 2029 | sender_address_len, session, GNUNET_YES); |
2030 | plugin_name, | ||
2031 | sender_address, | ||
2032 | sender_address_len, | ||
2033 | session, | ||
2034 | GNUNET_YES); | ||
2035 | 2030 | ||
2036 | #if DEBUG_TRANSPORT | 2031 | #if DEBUG_TRANSPORT |
2037 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2032 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2038 | "Setting inbound quota of %u for peer `%s' to \n", | 2033 | "Setting inbound quota of %u for peer `%s' to \n", |
2039 | ntohl (n->bandwidth_in.value__), GNUNET_i2s (&n->id)); | 2034 | ntohl (n->bandwidth_in.value__), GNUNET_i2s (&n->id)); |
2040 | #endif | 2035 | #endif |
2041 | GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in); | 2036 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); |
2042 | 2037 | ||
2043 | /* send ACK (ACK)*/ | 2038 | /* send ACK (ACK) */ |
2044 | msg_len = sizeof (msg); | 2039 | msg_len = sizeof (msg); |
2045 | msg.size = htons (msg_len); | 2040 | msg.size = htons (msg_len); |
2046 | msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK); | 2041 | msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK); |
2047 | 2042 | ||
2048 | ret = send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX, | 2043 | ret = |
2049 | GNUNET_TIME_UNIT_FOREVER_REL, | 2044 | send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX, |
2050 | n->session, n->plugin_name, n->addr, n->addrlen, | 2045 | GNUNET_TIME_UNIT_FOREVER_REL, n->session, |
2051 | GNUNET_YES, NULL, NULL); | 2046 | n->plugin_name, n->addr, n->addrlen, GNUNET_YES, NULL, |
2047 | NULL); | ||
2052 | 2048 | ||
2053 | if (ret == GNUNET_SYSERR) | 2049 | if (ret == GNUNET_SYSERR) |
2054 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2055 | "Failed to send SESSION_ACK to `%4s' using plugin `%s' address '%s' session %X\n", | 2051 | "Failed to send SESSION_ACK to `%4s' using plugin `%s' address '%s' session %X\n", |
2056 | GNUNET_i2s (&n->id), n->plugin_name, | 2052 | GNUNET_i2s (&n->id), n->plugin_name, |
2057 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 2053 | (n->addrlen == |
2058 | n->addr, | 2054 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, |
2059 | n->addrlen), | 2055 | n->addrlen), n->session); |
2060 | n->session); | ||
2061 | 2056 | ||
2062 | 2057 | ||
2063 | if (!was_connected) | 2058 | if (!was_connected) |
2064 | { | 2059 | { |
2065 | if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) | 2060 | if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) |
2066 | n->keepalive_task = GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, | 2061 | n->keepalive_task = |
2067 | &neighbour_keepalive_task, | 2062 | GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, |
2068 | n); | 2063 | &neighbour_keepalive_task, n); |
2069 | 2064 | ||
2070 | neighbours_connected++; | 2065 | neighbours_connected++; |
2071 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, | 2066 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, |
2072 | GNUNET_NO); | 2067 | GNUNET_NO); |
2073 | #if DEBUG_TRANSPORT | 2068 | #if DEBUG_TRANSPORT |
2074 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2069 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2075 | "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", | 2070 | "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", |
2076 | GNUNET_i2s (&n->id), n->plugin_name, | 2071 | GNUNET_i2s (&n->id), n->plugin_name, |
2077 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 2072 | (n->addrlen == |
2078 | n->addr, | 2073 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, |
2079 | n->addrlen), | 2074 | n->addrlen), n->session, |
2080 | n->session, __LINE__); | 2075 | __LINE__); |
2081 | #endif | 2076 | #endif |
2082 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2077 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); |
2083 | } | 2078 | } |
2084 | 2079 | ||
2085 | #if DEBUG_TRANSPORT | 2080 | #if DEBUG_TRANSPORT |
2086 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2087 | "Sending outbound quota of %u Bps for peer `%s' to all clients\n", | 2082 | "Sending outbound quota of %u Bps for peer `%s' to all clients\n", |
2088 | ntohl (n->bandwidth_out.value__), GNUNET_i2s (peer)); | 2083 | ntohl (n->bandwidth_out.value__), GNUNET_i2s (peer)); |
2089 | #endif | 2084 | #endif |
2090 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); | 2085 | q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); |
2091 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); | 2086 | q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); |
2092 | q_msg.quota = n->bandwidth_out; | 2087 | q_msg.quota = n->bandwidth_out; |
2093 | q_msg.peer = (*peer); | 2088 | q_msg.peer = (*peer); |
2094 | GST_clients_broadcast (&q_msg.header, GNUNET_NO); | 2089 | GST_clients_broadcast (&q_msg.header, GNUNET_NO); |
2095 | 2090 | ||
2096 | } | 2091 | } |
2097 | 2092 | ||
2098 | void | 2093 | void |
2099 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | 2094 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, |
2100 | const struct GNUNET_PeerIdentity *peer, | 2095 | const struct GNUNET_PeerIdentity *peer, |
2101 | const char *plugin_name, | 2096 | const char *plugin_name, const char *sender_address, |
2102 | const char *sender_address, uint16_t sender_address_len, | 2097 | uint16_t sender_address_len, struct Session *session, |
2103 | struct Session *session, | 2098 | const struct GNUNET_ATS_Information *ats, |
2104 | const struct GNUNET_ATS_Information *ats, | 2099 | uint32_t ats_count) |
2105 | uint32_t ats_count) | ||
2106 | { | 2100 | { |
2107 | struct NeighbourMapEntry *n; | 2101 | struct NeighbourMapEntry *n; |
2108 | struct QuotaSetMessage q_msg; | 2102 | struct QuotaSetMessage q_msg; |
2109 | int was_connected; | 2103 | int was_connected; |
2110 | 2104 | ||
2111 | #if DEBUG_TRANSPORT | 2105 | #if DEBUG_TRANSPORT |
2112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ACK message from peer `%s'\n", |
2113 | "Received ACK message from peer `%s'\n", GNUNET_i2s (peer)); | 2107 | GNUNET_i2s (peer)); |
2114 | #endif | 2108 | #endif |
2115 | 2109 | ||
2116 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) | 2110 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) |
@@ -2122,60 +2116,52 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2122 | n = lookup_neighbour (peer); | 2116 | n = lookup_neighbour (peer); |
2123 | if (NULL == n) | 2117 | if (NULL == n) |
2124 | { | 2118 | { |
2125 | send_disconnect(peer, plugin_name, sender_address, sender_address_len, session); | 2119 | send_disconnect (peer, plugin_name, sender_address, sender_address_len, |
2120 | session); | ||
2126 | GNUNET_break (0); | 2121 | GNUNET_break (0); |
2127 | return; | 2122 | return; |
2128 | } | 2123 | } |
2129 | 2124 | ||
2130 | if (is_connected(n)) | 2125 | if (is_connected (n)) |
2131 | return; | 2126 | return; |
2132 | 2127 | ||
2133 | if (NULL != session) | 2128 | if (NULL != session) |
2134 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2129 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2135 | "transport-ats", | 2130 | "transport-ats", |
2136 | "Giving ATS session %p of plugin %s for peer %s\n", | 2131 | "Giving ATS session %p of plugin %s for peer %s\n", |
2137 | session, | 2132 | session, plugin_name, GNUNET_i2s (peer)); |
2138 | plugin_name, | 2133 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, |
2139 | GNUNET_i2s (peer)); | 2134 | sender_address_len, session, ats, ats_count); |
2140 | GNUNET_ATS_address_update (GST_ats, | 2135 | |
2141 | peer, | 2136 | was_connected = is_connected (n); |
2142 | plugin_name, sender_address, sender_address_len, | ||
2143 | session, ats, ats_count); | ||
2144 | |||
2145 | was_connected = is_connected(n); | ||
2146 | change_state (n, S_CONNECTED); | 2137 | change_state (n, S_CONNECTED); |
2147 | 2138 | ||
2148 | GNUNET_ATS_address_in_use (GST_ats, | 2139 | GNUNET_ATS_address_in_use (GST_ats, peer, plugin_name, sender_address, |
2149 | peer, | 2140 | sender_address_len, session, GNUNET_YES); |
2150 | plugin_name, | ||
2151 | sender_address, | ||
2152 | sender_address_len, | ||
2153 | session, | ||
2154 | GNUNET_YES); | ||
2155 | 2141 | ||
2156 | GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in); | 2142 | GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); |
2157 | 2143 | ||
2158 | if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) | 2144 | if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK) |
2159 | n->keepalive_task = GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, | 2145 | n->keepalive_task = |
2160 | &neighbour_keepalive_task, | 2146 | GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY, |
2161 | n); | 2147 | &neighbour_keepalive_task, n); |
2162 | 2148 | ||
2163 | if (!was_connected) | 2149 | if (!was_connected) |
2164 | { | 2150 | { |
2165 | neighbours_connected++; | 2151 | neighbours_connected++; |
2166 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, | 2152 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, |
2167 | GNUNET_NO); | 2153 | GNUNET_NO); |
2168 | 2154 | ||
2169 | #if DEBUG_TRANSPORT | 2155 | #if DEBUG_TRANSPORT |
2170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2171 | "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", | 2157 | "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", |
2172 | GNUNET_i2s (&n->id), n->plugin_name, | 2158 | GNUNET_i2s (&n->id), n->plugin_name, |
2173 | (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, | 2159 | (n->addrlen == |
2174 | n->addr, | 2160 | 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, |
2175 | n->addrlen), | 2161 | n->addrlen), n->session, |
2176 | n->session, __LINE__); | 2162 | __LINE__); |
2177 | #endif | 2163 | #endif |
2178 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); | 2164 | connect_notify_cb (callback_cls, &n->id, ats, ats_count); |
2179 | } | 2165 | } |
2180 | #if DEBUG_TRANSPORT | 2166 | #if DEBUG_TRANSPORT |
2181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2209,15 +2195,17 @@ struct BlackListCheckContext | |||
2209 | 2195 | ||
2210 | static void | 2196 | static void |
2211 | handle_connect_blacklist_cont (void *cls, | 2197 | handle_connect_blacklist_cont (void *cls, |
2212 | const struct GNUNET_PeerIdentity | 2198 | const struct GNUNET_PeerIdentity *peer, |
2213 | * peer, int result) | 2199 | int result) |
2214 | { | 2200 | { |
2215 | struct NeighbourMapEntry *n; | 2201 | struct NeighbourMapEntry *n; |
2216 | struct BlackListCheckContext * bcc = cls; | 2202 | struct BlackListCheckContext *bcc = cls; |
2217 | 2203 | ||
2218 | #if DEBUG_TRANSPORT | 2204 | #if DEBUG_TRANSPORT |
2219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2220 | "Blacklist check due to CONNECT message: `%s'\n", GNUNET_i2s (peer), (result == GNUNET_OK) ? "ALLOWED" : "FORBIDDEN"); | 2206 | "Blacklist check due to CONNECT message: `%s'\n", |
2207 | GNUNET_i2s (peer), | ||
2208 | (result == GNUNET_OK) ? "ALLOWED" : "FORBIDDEN"); | ||
2221 | #endif | 2209 | #endif |
2222 | 2210 | ||
2223 | /* not allowed */ | 2211 | /* not allowed */ |
@@ -2237,13 +2225,12 @@ handle_connect_blacklist_cont (void *cls, | |||
2237 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2225 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2238 | "transport-ats", | 2226 | "transport-ats", |
2239 | "Giving ATS session %p of plugin %s address `%s' for peer %s\n", | 2227 | "Giving ATS session %p of plugin %s address `%s' for peer %s\n", |
2240 | bcc->session, | 2228 | bcc->session, bcc->plugin_name, |
2241 | bcc->plugin_name, | 2229 | GST_plugins_a2s (bcc->plugin_name, bcc->sender_address, |
2242 | GST_plugins_a2s (bcc->plugin_name, bcc->sender_address, bcc->sender_address_len), | 2230 | bcc->sender_address_len), |
2243 | GNUNET_i2s (peer)); | 2231 | GNUNET_i2s (peer)); |
2244 | GNUNET_ATS_address_update (GST_ats, | 2232 | GNUNET_ATS_address_update (GST_ats, peer, bcc->plugin_name, |
2245 | peer, | 2233 | bcc->sender_address, bcc->sender_address_len, |
2246 | bcc->plugin_name, bcc->sender_address, bcc->sender_address_len, | ||
2247 | bcc->session, bcc->ats, bcc->ats_count); | 2234 | bcc->session, bcc->ats, bcc->ats_count); |
2248 | n->connect_ts = bcc->ts; | 2235 | n->connect_ts = bcc->ts; |
2249 | } | 2236 | } |
@@ -2251,13 +2238,15 @@ handle_connect_blacklist_cont (void *cls, | |||
2251 | GNUNET_free (bcc); | 2238 | GNUNET_free (bcc); |
2252 | 2239 | ||
2253 | if (n->state != S_CONNECT_RECV) | 2240 | if (n->state != S_CONNECT_RECV) |
2254 | change_state (n, S_CONNECT_RECV); | 2241 | change_state (n, S_CONNECT_RECV); |
2255 | 2242 | ||
2256 | /* Ask ATS for an address to connect via that address */ | 2243 | /* Ask ATS for an address to connect via that address */ |
2257 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) | 2244 | if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) |
2258 | GNUNET_SCHEDULER_cancel(n->ats_suggest); | 2245 | GNUNET_SCHEDULER_cancel (n->ats_suggest); |
2259 | n->ats_suggest = GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, n); | 2246 | n->ats_suggest = |
2260 | GNUNET_ATS_suggest_address(GST_ats, peer); | 2247 | GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel, |
2248 | n); | ||
2249 | GNUNET_ATS_suggest_address (GST_ats, peer); | ||
2261 | } | 2250 | } |
2262 | 2251 | ||
2263 | /** | 2252 | /** |
@@ -2276,20 +2265,21 @@ handle_connect_blacklist_cont (void *cls, | |||
2276 | */ | 2265 | */ |
2277 | void | 2266 | void |
2278 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | 2267 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, |
2279 | const struct GNUNET_PeerIdentity *peer, | 2268 | const struct GNUNET_PeerIdentity *peer, |
2280 | const char *plugin_name, | 2269 | const char *plugin_name, |
2281 | const char *sender_address, uint16_t sender_address_len, | 2270 | const char *sender_address, |
2282 | struct Session *session, | 2271 | uint16_t sender_address_len, |
2283 | const struct GNUNET_ATS_Information *ats, | 2272 | struct Session *session, |
2284 | uint32_t ats_count) | 2273 | const struct GNUNET_ATS_Information *ats, |
2274 | uint32_t ats_count) | ||
2285 | { | 2275 | { |
2286 | const struct SessionConnectMessage *scm; | 2276 | const struct SessionConnectMessage *scm; |
2287 | struct NeighbourMapEntry * n; | 2277 | struct NeighbourMapEntry *n; |
2288 | struct BlackListCheckContext * bcc = NULL; | 2278 | struct BlackListCheckContext *bcc = NULL; |
2289 | 2279 | ||
2290 | #if DEBUG_TRANSPORT | 2280 | #if DEBUG_TRANSPORT |
2291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2292 | "Received CONNECT message from peer `%s'\n", GNUNET_i2s (peer)); | 2282 | "Received CONNECT message from peer `%s'\n", GNUNET_i2s (peer)); |
2293 | #endif | 2283 | #endif |
2294 | 2284 | ||
2295 | if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) | 2285 | if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) |
@@ -2301,23 +2291,24 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2301 | scm = (const struct SessionConnectMessage *) message; | 2291 | scm = (const struct SessionConnectMessage *) message; |
2302 | GNUNET_break_op (ntohl (scm->reserved) == 0); | 2292 | GNUNET_break_op (ntohl (scm->reserved) == 0); |
2303 | 2293 | ||
2304 | n = lookup_neighbour(peer); | 2294 | n = lookup_neighbour (peer); |
2305 | if (n != NULL) | 2295 | if (n != NULL) |
2306 | { | 2296 | { |
2307 | /* connected peer switches addresses */ | 2297 | /* connected peer switches addresses */ |
2308 | if (is_connected(n)) | 2298 | if (is_connected (n)) |
2309 | { | 2299 | { |
2310 | GNUNET_ATS_address_update(GST_ats, peer, plugin_name, sender_address, sender_address_len, session, ats, ats_count); | 2300 | GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, |
2301 | sender_address_len, session, ats, ats_count); | ||
2311 | return; | 2302 | return; |
2312 | } | 2303 | } |
2313 | } | 2304 | } |
2314 | 2305 | ||
2315 | /* we are not connected to this peer */ | 2306 | /* we are not connected to this peer */ |
2316 | /* do blacklist check*/ | 2307 | /* do blacklist check */ |
2317 | bcc = GNUNET_malloc (sizeof (struct BlackListCheckContext) + | 2308 | bcc = |
2318 | sizeof (struct GNUNET_ATS_Information) * ats_count + | 2309 | GNUNET_malloc (sizeof (struct BlackListCheckContext) + |
2319 | sender_address_len + | 2310 | sizeof (struct GNUNET_ATS_Information) * ats_count + |
2320 | strlen (plugin_name)+1); | 2311 | sender_address_len + strlen (plugin_name) + 1); |
2321 | 2312 | ||
2322 | bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); | 2313 | bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); |
2323 | 2314 | ||
@@ -2326,15 +2317,16 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2326 | bcc->session = session; | 2317 | bcc->session = session; |
2327 | 2318 | ||
2328 | bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; | 2319 | bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; |
2329 | memcpy (bcc->ats, ats,sizeof (struct GNUNET_ATS_Information) * ats_count ); | 2320 | memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); |
2330 | 2321 | ||
2331 | bcc->sender_address = (char *) &bcc->ats[ats_count]; | 2322 | bcc->sender_address = (char *) &bcc->ats[ats_count]; |
2332 | memcpy (bcc->sender_address, sender_address , sender_address_len); | 2323 | memcpy (bcc->sender_address, sender_address, sender_address_len); |
2333 | 2324 | ||
2334 | bcc->plugin_name = &bcc->sender_address[sender_address_len]; | 2325 | bcc->plugin_name = &bcc->sender_address[sender_address_len]; |
2335 | strcpy (bcc->plugin_name, plugin_name); | 2326 | strcpy (bcc->plugin_name, plugin_name); |
2336 | 2327 | ||
2337 | GST_blacklist_test_allowed (peer, plugin_name, handle_connect_blacklist_cont, bcc); | 2328 | GST_blacklist_test_allowed (peer, plugin_name, handle_connect_blacklist_cont, |
2329 | bcc); | ||
2338 | } | 2330 | } |
2339 | 2331 | ||
2340 | 2332 | ||
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 3868ef2cf..3aafc3d55 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -159,11 +159,9 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target); | |||
159 | typedef void (*GST_NeighbourIterator) (void *cls, | 159 | typedef void (*GST_NeighbourIterator) (void *cls, |
160 | const struct GNUNET_PeerIdentity * | 160 | const struct GNUNET_PeerIdentity * |
161 | neighbour, | 161 | neighbour, |
162 | const struct | 162 | const struct GNUNET_ATS_Information * |
163 | GNUNET_ATS_Information * ats, | 163 | ats, uint32_t ats_count, |
164 | uint32_t ats_count, | 164 | const char *transport, const void *addr, |
165 | const char * transport, | ||
166 | const void * addr, | ||
167 | size_t addrlen); | 165 | size_t addrlen); |
168 | 166 | ||
169 | 167 | ||
@@ -209,17 +207,20 @@ int | |||
209 | GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | 207 | GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, |
210 | const char *plugin_name, const void *address, | 208 | const char *plugin_name, const void *address, |
211 | size_t address_len, struct Session *session, | 209 | size_t address_len, struct Session *session, |
212 | const struct GNUNET_ATS_Information | 210 | const struct GNUNET_ATS_Information *ats, |
213 | *ats, uint32_t ats_count); | 211 | uint32_t ats_count); |
214 | 212 | ||
215 | int | 213 | int |
216 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | 214 | GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, |
217 | const char *plugin_name, const void *address, | 215 | const char *plugin_name, |
218 | size_t address_len, struct Session *session, | 216 | const void *address, size_t address_len, |
219 | const struct GNUNET_ATS_Information | 217 | struct Session *session, |
220 | *ats, uint32_t ats_count, | 218 | const struct GNUNET_ATS_Information *ats, |
221 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 219 | uint32_t ats_count, |
222 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); | 220 | struct GNUNET_BANDWIDTH_Value32NBO |
221 | bandwidth_in, | ||
222 | struct GNUNET_BANDWIDTH_Value32NBO | ||
223 | bandwidth_out); | ||
223 | 224 | ||
224 | 225 | ||
225 | /** | 226 | /** |
@@ -238,41 +239,44 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
238 | */ | 239 | */ |
239 | void | 240 | void |
240 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | 241 | GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, |
241 | const struct GNUNET_PeerIdentity *peer, | ||
242 | const char *plugin_name, | ||
243 | const char *sender_address, uint16_t sender_address_len, | ||
244 | struct Session *session, | ||
245 | const struct GNUNET_ATS_Information *ats, | ||
246 | uint32_t ats_count); | ||
247 | |||
248 | void | ||
249 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | ||
250 | const struct GNUNET_PeerIdentity *peer, | 242 | const struct GNUNET_PeerIdentity *peer, |
251 | const char *plugin_name, | 243 | const char *plugin_name, |
252 | const char *sender_address, uint16_t sender_address_len, | 244 | const char *sender_address, |
245 | uint16_t sender_address_len, | ||
253 | struct Session *session, | 246 | struct Session *session, |
254 | const struct GNUNET_ATS_Information *ats, | 247 | const struct GNUNET_ATS_Information *ats, |
255 | uint32_t ats_count); | 248 | uint32_t ats_count); |
256 | 249 | ||
257 | void | 250 | void |
251 | GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | ||
252 | const struct GNUNET_PeerIdentity *peer, | ||
253 | const char *plugin_name, | ||
254 | const char *sender_address, | ||
255 | uint16_t sender_address_len, | ||
256 | struct Session *session, | ||
257 | const struct GNUNET_ATS_Information *ats, | ||
258 | uint32_t ats_count); | ||
259 | |||
260 | void | ||
258 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | 261 | GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, |
259 | const struct GNUNET_PeerIdentity *peer, | 262 | const struct GNUNET_PeerIdentity *peer, |
260 | const char *plugin_name, | 263 | const char *plugin_name, const char *sender_address, |
261 | const char *sender_address, uint16_t sender_address_len, | 264 | uint16_t sender_address_len, struct Session *session, |
262 | struct Session *session, | 265 | const struct GNUNET_ATS_Information *ats, |
263 | const struct GNUNET_ATS_Information *ats, | 266 | uint32_t ats_count); |
264 | uint32_t ats_count); | ||
265 | 267 | ||
266 | /** | 268 | /** |
267 | * We received a disconnect message from the given peer, | 269 | * We received a disconnect message from the given peer, |
268 | * validate and process. | 270 | * validate and process. |
269 | * | 271 | * |
270 | * @param peer sender of the message | 272 | * @param peer sender of the message |
271 | * @param msg the disconnect message | 273 | * @param msg the disconnect message |
272 | */ | 274 | */ |
273 | void | 275 | void |
274 | GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer, | 276 | GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity |
275 | const struct GNUNET_MessageHeader *msg); | 277 | *peer, |
278 | const struct GNUNET_MessageHeader | ||
279 | *msg); | ||
276 | 280 | ||
277 | 281 | ||
278 | #endif | 282 | #endif |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 5758ebfbb..d7b4929b2 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -405,8 +405,8 @@ add_valid_address (void *cls, const char *tname, | |||
405 | } | 405 | } |
406 | ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); | 406 | ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); |
407 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); | 407 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); |
408 | GNUNET_ATS_address_update (GST_ats, &pid, tname, addr, | 408 | GNUNET_ATS_address_update (GST_ats, &pid, tname, addr, addrlen, NULL, NULL, |
409 | addrlen, NULL, NULL, 0); | 409 | 0); |
410 | return GNUNET_OK; | 410 | return GNUNET_OK; |
411 | } | 411 | } |
412 | 412 | ||
@@ -595,7 +595,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
595 | sizeof (struct GNUNET_PeerIdentity))) | 595 | sizeof (struct GNUNET_PeerIdentity))) |
596 | { | 596 | { |
597 | GNUNET_STATISTICS_update (GST_stats, | 597 | GNUNET_STATISTICS_update (GST_stats, |
598 | gettext_noop ("# PING message for different peer received"), 1, | 598 | gettext_noop |
599 | ("# PING message for different peer received"), 1, | ||
599 | GNUNET_NO); | 600 | GNUNET_NO); |
600 | return; | 601 | return; |
601 | } | 602 | } |
@@ -614,27 +615,28 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
614 | { | 615 | { |
615 | addrend = memchr (addr, '\0', alen); | 616 | addrend = memchr (addr, '\0', alen); |
616 | if (NULL == addrend) | 617 | if (NULL == addrend) |
617 | { | 618 | { |
618 | GNUNET_break_op (0); | 619 | GNUNET_break_op (0); |
619 | return; | 620 | return; |
620 | } | 621 | } |
621 | addrend++; | 622 | addrend++; |
622 | slen = strlen (addr) + 1; | 623 | slen = strlen (addr) + 1; |
623 | alen -= slen; | 624 | alen -= slen; |
624 | 625 | ||
625 | if (GNUNET_YES != | 626 | if (GNUNET_YES != |
626 | GST_hello_test_address (addr, addrend, alen, &sig_cache, &sig_cache_exp)) | 627 | GST_hello_test_address (addr, addrend, alen, &sig_cache, |
628 | &sig_cache_exp)) | ||
627 | { | 629 | { |
628 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 630 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
629 | _ | 631 | _ |
630 | ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"), | 632 | ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"), |
631 | GST_plugins_a2s (addr, addrend, alen)); | 633 | GST_plugins_a2s (addr, addrend, alen)); |
632 | return; | 634 | return; |
633 | } | 635 | } |
634 | } | 636 | } |
635 | else | 637 | else |
636 | { | 638 | { |
637 | addrend = NULL; /* make gcc happy */ | 639 | addrend = NULL; /* make gcc happy */ |
638 | slen = 0; | 640 | slen = 0; |
639 | static struct GNUNET_CRYPTO_RsaSignature no_address_signature; | 641 | static struct GNUNET_CRYPTO_RsaSignature no_address_signature; |
640 | static struct GNUNET_TIME_Absolute no_address_signature_expiration; | 642 | static struct GNUNET_TIME_Absolute no_address_signature_expiration; |
@@ -751,7 +753,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
751 | 753 | ||
752 | ve->bc = NULL; | 754 | ve->bc = NULL; |
753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n", | 755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n", |
754 | GNUNET_i2s (pid), GST_plugins_a2s (ve->transport_name, ve->addr, ve->addrlen)); | 756 | GNUNET_i2s (pid), GST_plugins_a2s (ve->transport_name, ve->addr, |
757 | ve->addrlen)); | ||
755 | 758 | ||
756 | slen = strlen (ve->transport_name) + 1; | 759 | slen = strlen (ve->transport_name) + 1; |
757 | hello = GST_hello_get (); | 760 | hello = GST_hello_get (); |
@@ -996,12 +999,13 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
996 | struct GNUNET_ATS_Information ats; | 999 | struct GNUNET_ATS_Information ats; |
997 | 1000 | ||
998 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | 1001 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); |
999 | ats.value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value); | 1002 | ats.value = |
1000 | GNUNET_ATS_address_update (GST_ats, &ve->pid, | 1003 | htonl ((uint32_t) |
1001 | ve->transport_name,ve->addr, ve->addrlen, NULL, | 1004 | GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value); |
1002 | &ats, 1); | 1005 | GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->transport_name, ve->addr, |
1006 | ve->addrlen, NULL, &ats, 1); | ||
1003 | } | 1007 | } |
1004 | 1008 | ||
1005 | /* build HELLO to store in PEERINFO */ | 1009 | /* build HELLO to store in PEERINFO */ |
1006 | ve->copied = GNUNET_NO; | 1010 | ve->copied = GNUNET_NO; |
1007 | hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve); | 1011 | hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve); |
@@ -1043,17 +1047,16 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) | |||
1043 | GNUNET_break (0); | 1047 | GNUNET_break (0); |
1044 | return; | 1048 | return; |
1045 | } | 1049 | } |
1046 | if (0 == memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity))) | 1050 | if (0 == |
1051 | memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity))) | ||
1047 | return; | 1052 | return; |
1048 | /* Add peer identity without addresses to peerinfo service */ | 1053 | /* Add peer identity without addresses to peerinfo service */ |
1049 | h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL); | 1054 | h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL); |
1050 | GNUNET_PEERINFO_add_peer (GST_peerinfo, h); | 1055 | GNUNET_PEERINFO_add_peer (GST_peerinfo, h); |
1051 | #if VERBOSE_VALIDATION | 1056 | #if VERBOSE_VALIDATION |
1052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1057 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1053 | _ | 1058 | _("Adding `%s' without addresses for peer `%s'\n"), "HELLO", |
1054 | ("Adding `%s' without addresses for peer `%s'\n"), | 1059 | GNUNET_i2s (&vac.pid)); |
1055 | "HELLO", | ||
1056 | GNUNET_i2s(&vac.pid)); | ||
1057 | #endif | 1060 | #endif |
1058 | GNUNET_free (h); | 1061 | GNUNET_free (h); |
1059 | 1062 | ||
diff --git a/src/transport/gnunet-transport-connect-running-peers.c b/src/transport/gnunet-transport-connect-running-peers.c index a0e3b93a2..172f34b27 100644 --- a/src/transport/gnunet-transport-connect-running-peers.c +++ b/src/transport/gnunet-transport-connect-running-peers.c | |||
@@ -174,24 +174,23 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | "Press <q> to quit or <1> to send from p1 to p2, <2> to send from p2 to p1, <enter> repeat\n"); | 174 | "Press <q> to quit or <1> to send from p1 to p2, <2> to send from p2 to p1, <enter> repeat\n"); |
175 | 175 | ||
176 | read: | 176 | read: |
177 | t = getchar(); | 177 | t = getchar (); |
178 | if (t == '1') | 178 | if (t == '1') |
179 | { | 179 | { |
180 | th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0, TIMEOUT, | 180 | th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0, |
181 | ¬ify_ready, p1); | 181 | TIMEOUT, ¬ify_ready, p1); |
182 | return; | 182 | return; |
183 | } | 183 | } |
184 | if (t == '2') | 184 | if (t == '2') |
185 | { | 185 | { |
186 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, TIMEOUT, | 186 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, |
187 | ¬ify_ready, p2); | 187 | TIMEOUT, ¬ify_ready, p2); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | if (t == 'q') | 190 | if (t == 'q') |
191 | { | 191 | { |
192 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 192 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Exiting %c!\n", t); |
193 | "Exiting %c!\n", t); | 193 | GNUNET_SCHEDULER_add_now (&end, NULL); |
194 | GNUNET_SCHEDULER_add_now(&end, NULL); | ||
195 | return; | 194 | return; |
196 | } | 195 | } |
197 | goto read; | 196 | goto read; |
@@ -200,8 +199,7 @@ read: | |||
200 | static void | 199 | static void |
201 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 200 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
202 | const struct GNUNET_MessageHeader *message, | 201 | const struct GNUNET_MessageHeader *message, |
203 | const struct GNUNET_ATS_Information *ats, | 202 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
204 | uint32_t ats_count) | ||
205 | { | 203 | { |
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
207 | "Received message of type %d from peer %s!\n", | 205 | "Received message of type %d from peer %s!\n", |
@@ -210,8 +208,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
210 | if ((MTYPE == ntohs (message->type)) && | 208 | if ((MTYPE == ntohs (message->type)) && |
211 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) | 209 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) |
212 | { | 210 | { |
213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 211 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully received message\n"); |
214 | "Successfully received message\n"); | ||
215 | 212 | ||
216 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 213 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
217 | } | 214 | } |
@@ -219,8 +216,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
219 | 216 | ||
220 | static void | 217 | static void |
221 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 218 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
222 | const struct GNUNET_ATS_Information *ats, | 219 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
223 | uint32_t ats_count) | ||
224 | { | 220 | { |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
226 | GNUNET_i2s (peer), cls); | 222 | GNUNET_i2s (peer), cls); |
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c index 016aa29dd..25e55e510 100644 --- a/src/transport/gnunet-transport-wlan-helper.c +++ b/src/transport/gnunet-transport-wlan-helper.c | |||
@@ -1016,7 +1016,9 @@ getFrequencyFromChannel (int channel) | |||
1016 | 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100 | 1016 | 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100 |
1017 | }; | 1017 | }; |
1018 | 1018 | ||
1019 | return ( (channel > 0) && (channel < sizeof(frequencies) / sizeof(int)) ) ? frequencies[channel] : -1; | 1019 | return ((channel > 0) && |
1020 | (channel < | ||
1021 | sizeof (frequencies) / sizeof (int))) ? frequencies[channel] : -1; | ||
1020 | } | 1022 | } |
1021 | 1023 | ||
1022 | /** | 1024 | /** |
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 686423a3d..4d2912c34 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -162,15 +162,11 @@ display_test_result (struct TestContext *tc, int result) | |||
162 | { | 162 | { |
163 | if (GNUNET_YES != result) | 163 | if (GNUNET_YES != result) |
164 | { | 164 | { |
165 | fprintf (stderr, | 165 | fprintf (stderr, "Configuration for plugin `%s' did not work!\n", tc->name); |
166 | "Configuration for plugin `%s' did not work!\n", | ||
167 | tc->name); | ||
168 | } | 166 | } |
169 | else | 167 | else |
170 | { | 168 | { |
171 | fprintf (stderr, | 169 | fprintf (stderr, "Configuration for plugin `%s' is working!\n", tc->name); |
172 | "Configuration for plugin `%s' is working!\n", | ||
173 | tc->name); | ||
174 | } | 170 | } |
175 | if (GNUNET_SCHEDULER_NO_TASK != tc->tsk) | 171 | if (GNUNET_SCHEDULER_NO_TASK != tc->tsk) |
176 | { | 172 | { |
@@ -184,8 +180,7 @@ display_test_result (struct TestContext *tc, int result) | |||
184 | } | 180 | } |
185 | GNUNET_free (tc); | 181 | GNUNET_free (tc); |
186 | resolver_users--; | 182 | resolver_users--; |
187 | if ( (0 == resolver_users) && | 183 | if ((0 == resolver_users) && (NULL != resolver)) |
188 | (NULL != resolver) ) | ||
189 | { | 184 | { |
190 | GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM)); | 185 | GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM)); |
191 | GNUNET_OS_process_close (resolver); | 186 | GNUNET_OS_process_close (resolver); |
@@ -242,52 +237,46 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
242 | struct TestContext *tc; | 237 | struct TestContext *tc; |
243 | 238 | ||
244 | if (GNUNET_OK != | 239 | if (GNUNET_OK != |
245 | GNUNET_CONFIGURATION_get_value_string (cfg, | 240 | GNUNET_CONFIGURATION_get_value_string (cfg, "transport", "plugins", |
246 | "transport", | 241 | &plugins)) |
247 | "plugins", | ||
248 | &plugins)) | ||
249 | { | 242 | { |
250 | fprintf (stderr, | 243 | fprintf (stderr, |
251 | _("No transport plugins configured, peer will never communicate\n")); | 244 | _ |
245 | ("No transport plugins configured, peer will never communicate\n")); | ||
252 | ret = 4; | 246 | ret = 4; |
253 | return; | 247 | return; |
254 | } | 248 | } |
255 | for (tok = strtok (plugins, " "); tok != NULL; tok = strtok (NULL, " ")) | 249 | for (tok = strtok (plugins, " "); tok != NULL; tok = strtok (NULL, " ")) |
256 | { | 250 | { |
257 | char section[12+strlen(tok)]; | 251 | char section[12 + strlen (tok)]; |
258 | 252 | ||
259 | GNUNET_snprintf (section, | 253 | GNUNET_snprintf (section, sizeof (section), "transport-%s", tok); |
260 | sizeof (section), | ||
261 | "transport-%s", | ||
262 | tok); | ||
263 | if (GNUNET_OK != | 254 | if (GNUNET_OK != |
264 | GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT", | 255 | GNUNET_CONFIGURATION_get_value_number (cfg, section, "PORT", &bnd_port)) |
265 | &bnd_port)) | 256 | { |
266 | { | 257 | fprintf (stderr, |
267 | fprintf (stderr, | 258 | _("No port configured for plugin `%s', cannot test it\n"), tok); |
268 | _("No port configured for plugin `%s', cannot test it\n"), | 259 | continue; |
269 | tok); | 260 | } |
270 | continue; | ||
271 | } | ||
272 | if (GNUNET_OK != | 261 | if (GNUNET_OK != |
273 | GNUNET_CONFIGURATION_get_value_number (cfg, section, | 262 | GNUNET_CONFIGURATION_get_value_number (cfg, section, "ADVERTISED_PORT", |
274 | "ADVERTISED_PORT", &adv_port)) | 263 | &adv_port)) |
275 | adv_port = bnd_port; | 264 | adv_port = bnd_port; |
276 | if (NULL == resolver) | 265 | if (NULL == resolver) |
277 | resolver = | 266 | resolver = |
278 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver", | 267 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver", |
279 | "gnunet-service-resolver", NULL); | 268 | "gnunet-service-resolver", NULL); |
280 | resolver_users++; | 269 | resolver_users++; |
281 | GNUNET_RESOLVER_connect (cfg); | 270 | GNUNET_RESOLVER_connect (cfg); |
282 | tc = GNUNET_malloc (sizeof (struct TestContext)); | 271 | tc = GNUNET_malloc (sizeof (struct TestContext)); |
283 | tc->name = GNUNET_strdup (tok); | 272 | tc->name = GNUNET_strdup (tok); |
284 | tc->tst = | 273 | tc->tst = |
285 | GNUNET_NAT_test_start (cfg, | 274 | GNUNET_NAT_test_start (cfg, |
286 | (0 == strcasecmp (tok, "udp")) | 275 | (0 == |
287 | ? GNUNET_NO | 276 | strcasecmp (tok, |
288 | : GNUNET_YES, | 277 | "udp")) ? GNUNET_NO : GNUNET_YES, |
289 | (uint16_t) bnd_port, | 278 | (uint16_t) bnd_port, (uint16_t) adv_port, |
290 | (uint16_t) adv_port, &result_callback, tc); | 279 | &result_callback, tc); |
291 | if (NULL == tc->tst) | 280 | if (NULL == tc->tst) |
292 | { | 281 | { |
293 | display_test_result (tc, GNUNET_SYSERR); | 282 | display_test_result (tc, GNUNET_SYSERR); |
@@ -303,8 +292,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
303 | * Shutdown, print statistics. | 292 | * Shutdown, print statistics. |
304 | */ | 293 | */ |
305 | static void | 294 | static void |
306 | do_disconnect (void *cls, | 295 | do_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
307 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
308 | { | 296 | { |
309 | struct GNUNET_TIME_Relative duration; | 297 | struct GNUNET_TIME_Relative duration; |
310 | 298 | ||
@@ -317,20 +305,16 @@ do_disconnect (void *cls, | |||
317 | if (benchmark_receive) | 305 | if (benchmark_receive) |
318 | { | 306 | { |
319 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 307 | duration = GNUNET_TIME_absolute_get_duration (start_time); |
320 | fprintf (stdout, | 308 | fprintf (stdout, _("Received %llu bytes/s (%llu bytes in %llu ms)\n"), |
321 | _("Received %llu bytes/s (%llu bytes in %llu ms)\n"), | 309 | 1000 * traffic_received / (1 + duration.rel_value), |
322 | 1000 * traffic_received / (1+duration.rel_value), | 310 | traffic_received, (unsigned long long) duration.rel_value); |
323 | traffic_received, | ||
324 | (unsigned long long) duration.rel_value); | ||
325 | } | 311 | } |
326 | if (benchmark_send) | 312 | if (benchmark_send) |
327 | { | 313 | { |
328 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 314 | duration = GNUNET_TIME_absolute_get_duration (start_time); |
329 | fprintf (stdout, | 315 | fprintf (stdout, _("Transmitted %llu bytes/s (%llu bytes in %llu ms)\n"), |
330 | _("Transmitted %llu bytes/s (%llu bytes in %llu ms)\n"), | 316 | 1000 * traffic_sent / (1 + duration.rel_value), traffic_sent, |
331 | 1000 * traffic_sent / (1+duration.rel_value), | 317 | (unsigned long long) duration.rel_value); |
332 | traffic_sent, | ||
333 | (unsigned long long) duration.rel_value); | ||
334 | } | 318 | } |
335 | } | 319 | } |
336 | 320 | ||
@@ -347,8 +331,7 @@ do_disconnect (void *cls, | |||
347 | * @return number of bytes written to buf | 331 | * @return number of bytes written to buf |
348 | */ | 332 | */ |
349 | static size_t | 333 | static size_t |
350 | transmit_data (void *cls, size_t size, | 334 | transmit_data (void *cls, size_t size, void *buf) |
351 | void *buf) | ||
352 | { | 335 | { |
353 | struct GNUNET_MessageHeader *m = buf; | 336 | struct GNUNET_MessageHeader *m = buf; |
354 | 337 | ||
@@ -358,17 +341,12 @@ transmit_data (void *cls, size_t size, | |||
358 | m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY); | 341 | m->type = ntohs (GNUNET_MESSAGE_TYPE_DUMMY); |
359 | memset (&m[1], 52, size - sizeof (struct GNUNET_MessageHeader)); | 342 | memset (&m[1], 52, size - sizeof (struct GNUNET_MessageHeader)); |
360 | traffic_sent += size; | 343 | traffic_sent += size; |
361 | th = GNUNET_TRANSPORT_notify_transmit_ready (handle, | 344 | th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, 32 * 1024, 0, |
362 | &pid, | 345 | GNUNET_TIME_UNIT_FOREVER_REL, |
363 | 32 * 1024, | 346 | &transmit_data, NULL); |
364 | 0, | ||
365 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
366 | &transmit_data, NULL); | ||
367 | if (verbosity > 0) | 347 | if (verbosity > 0) |
368 | fprintf (stdout, | 348 | fprintf (stdout, _("Transmitting %u bytes to %s\n"), (unsigned int) size, |
369 | _("Transmitting %u bytes to %s\n"), | 349 | GNUNET_i2s (&pid)); |
370 | (unsigned int) size, | ||
371 | GNUNET_i2s (&pid)); | ||
372 | return size; | 350 | return size; |
373 | } | 351 | } |
374 | 352 | ||
@@ -383,39 +361,27 @@ transmit_data (void *cls, size_t size, | |||
383 | * @param ats_count number of entries in ats (excluding 0-termination) | 361 | * @param ats_count number of entries in ats (excluding 0-termination) |
384 | */ | 362 | */ |
385 | static void | 363 | static void |
386 | notify_connect (void *cls, | 364 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
387 | const struct GNUNET_PeerIdentity | 365 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
388 | * peer, | ||
389 | const struct | ||
390 | GNUNET_ATS_Information | ||
391 | * ats, uint32_t ats_count) | ||
392 | { | 366 | { |
393 | if (verbosity > 0) | 367 | if (verbosity > 0) |
394 | fprintf (stdout, | 368 | fprintf (stdout, _("Connected to %s\n"), GNUNET_i2s (peer)); |
395 | _("Connected to %s\n"), | 369 | if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) |
396 | GNUNET_i2s (peer)); | ||
397 | if (0 != memcmp (&pid, | ||
398 | peer, | ||
399 | sizeof (struct GNUNET_PeerIdentity))) | ||
400 | return; | 370 | return; |
401 | ret = 0; | 371 | ret = 0; |
402 | if (benchmark_send) | 372 | if (benchmark_send) |
403 | { | 373 | { |
404 | start_time = GNUNET_TIME_absolute_get (); | 374 | start_time = GNUNET_TIME_absolute_get (); |
405 | th = GNUNET_TRANSPORT_notify_transmit_ready (handle, | 375 | th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer, 32 * 1024, 0, |
406 | peer, | 376 | GNUNET_TIME_UNIT_FOREVER_REL, |
407 | 32 * 1024, | 377 | &transmit_data, NULL); |
408 | 0, | ||
409 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
410 | &transmit_data, NULL); | ||
411 | } | 378 | } |
412 | else | 379 | else |
413 | { | 380 | { |
414 | /* all done, terminate instantly */ | 381 | /* all done, terminate instantly */ |
415 | GNUNET_SCHEDULER_cancel (end); | 382 | GNUNET_SCHEDULER_cancel (end); |
416 | end = GNUNET_SCHEDULER_add_now (&do_disconnect, | 383 | end = GNUNET_SCHEDULER_add_now (&do_disconnect, NULL); |
417 | NULL); | 384 | } |
418 | } | ||
419 | } | 385 | } |
420 | 386 | ||
421 | 387 | ||
@@ -427,24 +393,17 @@ notify_connect (void *cls, | |||
427 | * @param peer the peer that disconnected | 393 | * @param peer the peer that disconnected |
428 | */ | 394 | */ |
429 | static void | 395 | static void |
430 | notify_disconnect (void *cls, | 396 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
431 | const struct | ||
432 | GNUNET_PeerIdentity * peer) | ||
433 | { | 397 | { |
434 | if (verbosity > 0) | 398 | if (verbosity > 0) |
435 | fprintf (stdout, | 399 | fprintf (stdout, _("Disconnected from %s\n"), GNUNET_i2s (peer)); |
436 | _("Disconnected from %s\n"), | 400 | if ((0 == memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) && |
437 | GNUNET_i2s (peer)); | 401 | (NULL != th)) |
438 | if ( (0 == memcmp (&pid, | ||
439 | peer, | ||
440 | sizeof (struct GNUNET_PeerIdentity))) && | ||
441 | (NULL != th) ) | ||
442 | { | 402 | { |
443 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 403 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
444 | th = NULL; | 404 | th = NULL; |
445 | GNUNET_SCHEDULER_cancel (end); | 405 | GNUNET_SCHEDULER_cancel (end); |
446 | end = GNUNET_SCHEDULER_add_now (&do_disconnect, | 406 | end = GNUNET_SCHEDULER_add_now (&do_disconnect, NULL); |
447 | NULL); | ||
448 | } | 407 | } |
449 | } | 408 | } |
450 | 409 | ||
@@ -456,26 +415,18 @@ notify_disconnect (void *cls, | |||
456 | * @param peer (claimed) identity of the other peer | 415 | * @param peer (claimed) identity of the other peer |
457 | * @param message the message | 416 | * @param message the message |
458 | * @param ats performance data | 417 | * @param ats performance data |
459 | * @param ats_count number of entries in ats | 418 | * @param ats_count number of entries in ats |
460 | */ | 419 | */ |
461 | static void | 420 | static void |
462 | notify_receive (void *cls, | 421 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
463 | const struct | 422 | const struct GNUNET_MessageHeader *message, |
464 | GNUNET_PeerIdentity * peer, | 423 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
465 | const struct | ||
466 | GNUNET_MessageHeader * | ||
467 | message, | ||
468 | const struct | ||
469 | GNUNET_ATS_Information | ||
470 | * ats, uint32_t ats_count) | ||
471 | { | 424 | { |
472 | if (! benchmark_receive) | 425 | if (!benchmark_receive) |
473 | return; | 426 | return; |
474 | if (verbosity > 0) | 427 | if (verbosity > 0) |
475 | fprintf (stdout, | 428 | fprintf (stdout, _("Received %u bytes from %s\n"), |
476 | _("Received %u bytes from %s\n"), | 429 | (unsigned int) ntohs (message->size), GNUNET_i2s (peer)); |
477 | (unsigned int) ntohs (message->size), | ||
478 | GNUNET_i2s (peer)); | ||
479 | if (traffic_received == 0) | 430 | if (traffic_received == 0) |
480 | start_time = GNUNET_TIME_absolute_get (); | 431 | start_time = GNUNET_TIME_absolute_get (); |
481 | traffic_received += ntohs (message->size); | 432 | traffic_received += ntohs (message->size); |
@@ -494,11 +445,12 @@ process_address (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
494 | { | 445 | { |
495 | if ((peer != NULL) || (transport != NULL) || | 446 | if ((peer != NULL) || (transport != NULL) || |
496 | ((addr != NULL) && (addrlen > 0))) | 447 | ((addr != NULL) && (addrlen > 0))) |
497 | fprintf (stdout, | 448 | fprintf (stdout, _("Peer `%s' plugin: `%s' address `%s'\n"), |
498 | _("Peer `%s' plugin: `%s' address `%s'\n"), | ||
499 | (peer != NULL) ? GNUNET_i2s (peer) : "<unknown>", | 449 | (peer != NULL) ? GNUNET_i2s (peer) : "<unknown>", |
500 | (transport != NULL) ? transport : "<unknown>", | 450 | (transport != NULL) ? transport : "<unknown>", ((addr != NULL) && |
501 | ((addr != NULL) && (addrlen > 0) && (transport != NULL)) ? | 451 | (addrlen > 0) && |
452 | (transport != | ||
453 | NULL)) ? | ||
502 | "how do i resolve the name without transport service?" : | 454 | "how do i resolve the name without transport service?" : |
503 | "<unknown>"); | 455 | "<unknown>"); |
504 | } | 456 | } |
@@ -523,45 +475,41 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
523 | if (benchmark_send && (NULL == cpid)) | 475 | if (benchmark_send && (NULL == cpid)) |
524 | { | 476 | { |
525 | fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"), | 477 | fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"), |
526 | "-s", "-C"); | 478 | "-s", "-C"); |
527 | return; | 479 | return; |
528 | } | 480 | } |
529 | if (NULL != cpid) | 481 | if (NULL != cpid) |
530 | { | 482 | { |
531 | ret = 1; | 483 | ret = 1; |
532 | if (GNUNET_OK != | 484 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)) |
533 | GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)) | ||
534 | { | 485 | { |
535 | fprintf (stderr, | 486 | fprintf (stderr, _("Failed to parse peer identity `%s'\n"), cpid); |
536 | _("Failed to parse peer identity `%s'\n"), | ||
537 | cpid); | ||
538 | return; | 487 | return; |
539 | } | 488 | } |
540 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, | 489 | handle = |
541 | ¬ify_receive, | 490 | GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, |
542 | ¬ify_connect, | 491 | ¬ify_connect, ¬ify_disconnect); |
543 | ¬ify_disconnect); | ||
544 | GNUNET_TRANSPORT_try_connect (handle, &pid); | 492 | GNUNET_TRANSPORT_try_connect (handle, &pid); |
545 | end = GNUNET_SCHEDULER_add_delayed (benchmark_send | 493 | end = |
546 | ? GNUNET_TIME_UNIT_FOREVER_REL | 494 | GNUNET_SCHEDULER_add_delayed (benchmark_send ? |
547 | : GNUNET_TIME_UNIT_SECONDS, | 495 | GNUNET_TIME_UNIT_FOREVER_REL : |
548 | &do_disconnect, | 496 | GNUNET_TIME_UNIT_SECONDS, &do_disconnect, |
549 | NULL); | 497 | NULL); |
550 | } else if (benchmark_receive) | 498 | } |
499 | else if (benchmark_receive) | ||
551 | { | 500 | { |
552 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, | 501 | handle = |
553 | ¬ify_receive, | 502 | GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, |
554 | ¬ify_connect, | 503 | ¬ify_connect, ¬ify_disconnect); |
555 | ¬ify_disconnect); | ||
556 | GNUNET_TRANSPORT_try_connect (handle, &pid); | 504 | GNUNET_TRANSPORT_try_connect (handle, &pid); |
557 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 505 | end = |
558 | &do_disconnect, | 506 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
559 | NULL); | 507 | &do_disconnect, NULL); |
560 | } | 508 | } |
561 | if (iterate_connections) | 509 | if (iterate_connections) |
562 | { | 510 | { |
563 | GNUNET_TRANSPORT_address_iterate (cfg, GNUNET_TIME_UNIT_MINUTES, | 511 | GNUNET_TRANSPORT_address_iterate (cfg, GNUNET_TIME_UNIT_MINUTES, |
564 | &process_address, NULL); | 512 | &process_address, NULL); |
565 | } | 513 | } |
566 | } | 514 | } |
567 | 515 | ||
@@ -578,20 +526,22 @@ main (int argc, char *const *argv) | |||
578 | 1, &GNUNET_GETOPT_set_string, &cpid}, | 526 | 1, &GNUNET_GETOPT_set_string, &cpid}, |
579 | {'i', "information", NULL, | 527 | {'i', "information", NULL, |
580 | gettext_noop ("provide information about all current connections (once)"), | 528 | gettext_noop ("provide information about all current connections (once)"), |
581 | 0, &GNUNET_GETOPT_set_one, &iterate_connections}, | 529 | 0, &GNUNET_GETOPT_set_one, &iterate_connections}, |
582 | {'s', "send", NULL, | 530 | {'s', "send", NULL, |
583 | gettext_noop ("send data for benchmarking to the other peer (until CTRL-C)"), | 531 | gettext_noop |
584 | 0, &GNUNET_GETOPT_set_one, &benchmark_send}, | 532 | ("send data for benchmarking to the other peer (until CTRL-C)"), |
533 | 0, &GNUNET_GETOPT_set_one, &benchmark_send}, | ||
585 | {'t', "test", NULL, | 534 | {'t', "test", NULL, |
586 | gettext_noop ("test transport configuration (involves external server)"), | 535 | gettext_noop ("test transport configuration (involves external server)"), |
587 | 0, &GNUNET_GETOPT_set_one, &test_configuration}, | 536 | 0, &GNUNET_GETOPT_set_one, &test_configuration}, |
588 | GNUNET_GETOPT_OPTION_VERBOSE(&verbosity), | 537 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), |
589 | GNUNET_GETOPT_OPTION_END | 538 | GNUNET_GETOPT_OPTION_END |
590 | }; | 539 | }; |
591 | return (GNUNET_OK == | 540 | return (GNUNET_OK == |
592 | GNUNET_PROGRAM_run (argc, argv, "gnunet-transport", | 541 | GNUNET_PROGRAM_run (argc, argv, "gnunet-transport", |
593 | gettext_noop ("Direct access to transport service."), | 542 | gettext_noop |
594 | options, &run, NULL)) ? ret : 1; | 543 | ("Direct access to transport service."), options, |
544 | &run, NULL)) ? ret : 1; | ||
595 | } | 545 | } |
596 | 546 | ||
597 | 547 | ||
diff --git a/src/transport/gnunet_wlan_sender.c b/src/transport/gnunet_wlan_sender.c index 3aa32fb1c..f1a90178b 100644 --- a/src/transport/gnunet_wlan_sender.c +++ b/src/transport/gnunet_wlan_sender.c | |||
@@ -78,13 +78,13 @@ struct ieee80211_frame | |||
78 | * @return GNUNET_YES at success | 78 | * @return GNUNET_YES at success |
79 | */ | 79 | */ |
80 | static int | 80 | static int |
81 | getRadiotapHeader ( struct Radiotap_Send *header) | 81 | getRadiotapHeader (struct Radiotap_Send *header) |
82 | { | 82 | { |
83 | 83 | ||
84 | 84 | ||
85 | header->rate = 255; | 85 | header->rate = 255; |
86 | header->tx_power = 0; | 86 | header->tx_power = 0; |
87 | header->antenna = 0; | 87 | header->antenna = 0; |
88 | 88 | ||
89 | return GNUNET_YES; | 89 | return GNUNET_YES; |
90 | } | 90 | } |
@@ -98,9 +98,8 @@ getRadiotapHeader ( struct Radiotap_Send *header) | |||
98 | * @return GNUNET_YES if there was no error | 98 | * @return GNUNET_YES if there was no error |
99 | */ | 99 | */ |
100 | static int | 100 | static int |
101 | getWlanHeader (struct ieee80211_frame *Header, | 101 | getWlanHeader (struct ieee80211_frame *Header, const char *to_mac_addr, |
102 | const char *to_mac_addr, const char *mac, | 102 | const char *mac, unsigned int size) |
103 | unsigned int size) | ||
104 | { | 103 | { |
105 | uint16_t *tmp16; | 104 | uint16_t *tmp16; |
106 | const int rate = 11000000; | 105 | const int rate = 11000000; |
@@ -108,8 +107,7 @@ getWlanHeader (struct ieee80211_frame *Header, | |||
108 | Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; | 107 | Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; |
109 | Header->i_fc[1] = 0x00; | 108 | Header->i_fc[1] = 0x00; |
110 | memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid)); | 109 | memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid)); |
111 | memcpy (&Header->i_addr2, mac, | 110 | memcpy (&Header->i_addr2, mac, sizeof (mac_bssid)); |
112 | sizeof (mac_bssid)); | ||
113 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid)); | 111 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid)); |
114 | 112 | ||
115 | tmp16 = (uint16_t *) Header->i_dur; | 113 | tmp16 = (uint16_t *) Header->i_dur; |
@@ -120,115 +118,133 @@ getWlanHeader (struct ieee80211_frame *Header, | |||
120 | return GNUNET_YES; | 118 | return GNUNET_YES; |
121 | } | 119 | } |
122 | 120 | ||
123 | int main(int argc, char *argv[]){ | 121 | int |
122 | main (int argc, char *argv[]) | ||
123 | { | ||
124 | char msg_buf[WLAN_MTU]; | 124 | char msg_buf[WLAN_MTU]; |
125 | struct GNUNET_MessageHeader *msg; | 125 | struct GNUNET_MessageHeader *msg; |
126 | struct ieee80211_frame *wlan_header; | 126 | struct ieee80211_frame *wlan_header; |
127 | struct Radiotap_Send *radiotap; | 127 | struct Radiotap_Send *radiotap; |
128 | 128 | ||
129 | unsigned int temp[6]; | 129 | unsigned int temp[6]; |
130 | char inmac[6]; | 130 | char inmac[6]; |
131 | char outmac[6]; | 131 | char outmac[6]; |
132 | int pos; | 132 | int pos; |
133 | long long count; | 133 | long long count; |
134 | double bytes_per_s; | 134 | double bytes_per_s; |
135 | time_t start; | 135 | time_t start; |
136 | time_t akt; | 136 | time_t akt; |
137 | int i; | 137 | int i; |
138 | 138 | ||
139 | if (4 != argc) { | 139 | if (4 != argc) |
140 | fprintf( | 140 | { |
141 | stderr, | 141 | fprintf (stderr, |
142 | "This program must be started with the interface and the targets and source mac as argument.\nThis program was compiled at ----- %s ----\n", | 142 | "This program must be started with the interface and the targets and source mac as argument.\nThis program was compiled at ----- %s ----\n", |
143 | __TIMESTAMP__); | 143 | __TIMESTAMP__); |
144 | fprintf(stderr, "Usage: interface-name mac-target mac-source\n" "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); | 144 | fprintf (stderr, |
145 | return 1; | 145 | "Usage: interface-name mac-target mac-source\n" |
146 | } | 146 | "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); |
147 | if (6 != | 147 | return 1; |
148 | sscanf(argv[3], "%x-%x-%x-%x-%x-%x", &temp[0],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5])) | 148 | } |
149 | { | 149 | if (6 != |
150 | fprintf(stderr, "Usage: interface-name mac-target mac-source\n" "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); | 150 | sscanf (argv[3], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], |
151 | return 1; | 151 | &temp[3], &temp[4], &temp[5])) |
152 | } | 152 | { |
153 | if (6 != | 153 | fprintf (stderr, |
154 | sscanf(argv[2], "%x-%x-%x-%x-%x-%x", &temp[0],&temp[1],&temp[2],&temp[3],&temp[4],&temp[5])) | 154 | "Usage: interface-name mac-target mac-source\n" |
155 | { | 155 | "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); |
156 | fprintf(stderr, "Usage: interface-name mac-target mac-source\n" "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); | 156 | return 1; |
157 | return 1; | 157 | } |
158 | } | 158 | if (6 != |
159 | for (i = 0; i < 6; i++) | 159 | sscanf (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], |
160 | { | 160 | &temp[3], &temp[4], &temp[5])) |
161 | inmac[i] = temp[i]; | 161 | { |
162 | } | 162 | fprintf (stderr, |
163 | for (i = 0; i < 6; i++) | 163 | "Usage: interface-name mac-target mac-source\n" |
164 | { | 164 | "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); |
165 | outmac[i] = temp[i]; | 165 | return 1; |
166 | } | 166 | } |
167 | 167 | for (i = 0; i < 6; i++) | |
168 | 168 | { | |
169 | pid_t pid; | 169 | inmac[i] = temp[i]; |
170 | int commpipe[2]; /* This holds the fd for the input & output of the pipe */ | 170 | } |
171 | 171 | for (i = 0; i < 6; i++) | |
172 | /* Setup communication pipeline first */ | 172 | { |
173 | if(pipe(commpipe)){ | 173 | outmac[i] = temp[i]; |
174 | fprintf(stderr,"Pipe error!\n"); | 174 | } |
175 | exit(1); | 175 | |
176 | } | 176 | |
177 | 177 | pid_t pid; | |
178 | /* Attempt to fork and check for errors */ | 178 | int commpipe[2]; /* This holds the fd for the input & output of the pipe */ |
179 | if( (pid=fork()) == -1){ | 179 | |
180 | fprintf(stderr,"Fork error. Exiting.\n"); /* something went wrong */ | 180 | /* Setup communication pipeline first */ |
181 | exit(1); | 181 | if (pipe (commpipe)) |
182 | } | 182 | { |
183 | 183 | fprintf (stderr, "Pipe error!\n"); | |
184 | if(pid){ | 184 | exit (1); |
185 | /* A positive (non-negative) PID indicates the parent process */ | 185 | } |
186 | close(commpipe[0]); /* Close unused side of pipe (in side) */ | 186 | |
187 | setvbuf(stdout,(char*)NULL,_IONBF,0); /* Set non-buffered output on stdout */ | 187 | /* Attempt to fork and check for errors */ |
188 | 188 | if ((pid = fork ()) == -1) | |
189 | 189 | { | |
190 | msg = (struct GNUNET_MessageHeader*) msg_buf; | 190 | fprintf (stderr, "Fork error. Exiting.\n"); /* something went wrong */ |
191 | msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | 191 | exit (1); |
192 | msg->size = htons (WLAN_MTU); | 192 | } |
193 | radiotap = (struct Radiotap_Send *) &msg[1]; | 193 | |
194 | wlan_header = (struct ieee80211_frame *) &radiotap[1]; | 194 | if (pid) |
195 | pos = 0; | 195 | { |
196 | 196 | /* A positive (non-negative) PID indicates the parent process */ | |
197 | getRadiotapHeader(radiotap); | 197 | close (commpipe[0]); /* Close unused side of pipe (in side) */ |
198 | getWlanHeader(wlan_header, outmac, inmac, WLAN_MTU - sizeof(struct GNUNET_MessageHeader)); | 198 | setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on stdout */ |
199 | 199 | ||
200 | start = time(NULL); | 200 | |
201 | count = 0; | 201 | msg = (struct GNUNET_MessageHeader *) msg_buf; |
202 | while (1){ | 202 | msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); |
203 | pos += write(commpipe[1], msg, WLAN_MTU - pos); | 203 | msg->size = htons (WLAN_MTU); |
204 | if (pos % WLAN_MTU == 0){ | 204 | radiotap = (struct Radiotap_Send *) &msg[1]; |
205 | pos = 0; | 205 | wlan_header = (struct ieee80211_frame *) &radiotap[1]; |
206 | count ++; | 206 | pos = 0; |
207 | 207 | ||
208 | if (count % 1000 == 0){ | 208 | getRadiotapHeader (radiotap); |
209 | akt = time(NULL); | 209 | getWlanHeader (wlan_header, outmac, inmac, |
210 | bytes_per_s = count * WLAN_MTU / (akt - start); | 210 | WLAN_MTU - sizeof (struct GNUNET_MessageHeader)); |
211 | bytes_per_s /= 1024; | 211 | |
212 | printf("send %f kbytes/s\n", bytes_per_s); | 212 | start = time (NULL); |
213 | } | 213 | count = 0; |
214 | } | 214 | while (1) |
215 | 215 | { | |
216 | } | 216 | pos += write (commpipe[1], msg, WLAN_MTU - pos); |
217 | } | 217 | if (pos % WLAN_MTU == 0) |
218 | else{ | 218 | { |
219 | /* A zero PID indicates that this is the child process */ | 219 | pos = 0; |
220 | (void) close(0); | 220 | count++; |
221 | if (-1 == dup2(commpipe[0],0)) /* Replace stdin with the in side of the pipe */ | 221 | |
222 | fprintf (stderr, | 222 | if (count % 1000 == 0) |
223 | "dup2 failed: %s\n", | 223 | { |
224 | strerror (errno)); | 224 | akt = time (NULL); |
225 | (void) close(commpipe[1]); /* Close unused side of pipe (out side) */ | 225 | bytes_per_s = count * WLAN_MTU / (akt - start); |
226 | /* Replace the child fork with a new process */ | 226 | bytes_per_s /= 1024; |
227 | if (execl("gnunet-transport-wlan-helper","gnunet-transport-wlan-helper", argv[1], NULL) == -1) | 227 | printf ("send %f kbytes/s\n", bytes_per_s); |
228 | { | 228 | } |
229 | fprintf(stderr,"Could not start gnunet-transport-wlan-helper!"); | 229 | } |
230 | _exit(1); | 230 | |
231 | } | 231 | } |
232 | } | 232 | } |
233 | return 0; | 233 | else |
234 | { | ||
235 | /* A zero PID indicates that this is the child process */ | ||
236 | (void) close (0); | ||
237 | if (-1 == dup2 (commpipe[0], 0)) /* Replace stdin with the in side of the pipe */ | ||
238 | fprintf (stderr, "dup2 failed: %s\n", strerror (errno)); | ||
239 | (void) close (commpipe[1]); /* Close unused side of pipe (out side) */ | ||
240 | /* Replace the child fork with a new process */ | ||
241 | if (execl | ||
242 | ("gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper", | ||
243 | argv[1], NULL) == -1) | ||
244 | { | ||
245 | fprintf (stderr, "Could not start gnunet-transport-wlan-helper!"); | ||
246 | _exit (1); | ||
247 | } | ||
248 | } | ||
249 | return 0; | ||
234 | } | 250 | } |
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 784dd3002..9008b958d 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -155,18 +155,20 @@ http_plugin_address_pretty_printer (void *cls, const char *type, | |||
155 | struct PrettyPrinterContext *ppc; | 155 | struct PrettyPrinterContext *ppc; |
156 | const void *sb; | 156 | const void *sb; |
157 | size_t sbs; | 157 | size_t sbs; |
158 | uint16_t port = 0 ; | 158 | uint16_t port = 0; |
159 | 159 | ||
160 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 160 | if (addrlen == sizeof (struct IPv6HttpAddress)) |
161 | { | 161 | { |
162 | struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr; | 162 | struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr; |
163 | |||
163 | sb = &a6->ipv6_addr; | 164 | sb = &a6->ipv6_addr; |
164 | sbs = sizeof (struct in6_addr); | 165 | sbs = sizeof (struct in6_addr); |
165 | port = ntohs (a6->u6_port); | 166 | port = ntohs (a6->u6_port); |
166 | } | 167 | } |
167 | else if (addrlen == sizeof (struct IPv4HttpAddress)) | 168 | else if (addrlen == sizeof (struct IPv4HttpAddress)) |
168 | { | 169 | { |
169 | struct IPv4HttpAddress * a4 = (struct IPv4HttpAddress *) addr; | 170 | struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr; |
171 | |||
170 | sb = &a4->ipv4_addr; | 172 | sb = &a4->ipv4_addr; |
171 | sbs = sizeof (struct in_addr); | 173 | sbs = sizeof (struct in_addr); |
172 | port = ntohs (a4->u4_port); | 174 | port = ntohs (a4->u4_port); |
@@ -218,9 +220,12 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
218 | if (addrlen == sizeof (struct IPv4HttpAddress)) | 220 | if (addrlen == sizeof (struct IPv4HttpAddress)) |
219 | { | 221 | { |
220 | struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr; | 222 | struct IPv4HttpAddress *a4 = (struct IPv4HttpAddress *) addr; |
223 | |||
221 | while (w_tv4 != NULL) | 224 | while (w_tv4 != NULL) |
222 | { | 225 | { |
223 | if ((0 == memcmp (&w_tv4->addr.ipv4_addr, &a4->ipv4_addr, sizeof (struct in_addr))) && | 226 | if ((0 == |
227 | memcmp (&w_tv4->addr.ipv4_addr, &a4->ipv4_addr, | ||
228 | sizeof (struct in_addr))) && | ||
224 | (w_tv4->addr.u4_port == a4->u4_port)) | 229 | (w_tv4->addr.u4_port == a4->u4_port)) |
225 | break; | 230 | break; |
226 | w_tv4 = w_tv4->next; | 231 | w_tv4 = w_tv4->next; |
@@ -233,9 +238,12 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
233 | if (addrlen == sizeof (struct sockaddr_in6)) | 238 | if (addrlen == sizeof (struct sockaddr_in6)) |
234 | { | 239 | { |
235 | struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr; | 240 | struct IPv6HttpAddress *a6 = (struct IPv6HttpAddress *) addr; |
241 | |||
236 | while (w_tv6 != NULL) | 242 | while (w_tv6 != NULL) |
237 | { | 243 | { |
238 | if ((0 == memcmp (&w_tv6->addr6.ipv6_addr, &a6->ipv6_addr, sizeof (struct in6_addr))) && | 244 | if ((0 == |
245 | memcmp (&w_tv6->addr6.ipv6_addr, &a6->ipv6_addr, | ||
246 | sizeof (struct in6_addr))) && | ||
239 | (w_tv6->addr6.u6_port == a6->u6_port)) | 247 | (w_tv6->addr6.u6_port == a6->u6_port)) |
240 | break; | 248 | break; |
241 | w_tv6 = w_tv6->next; | 249 | w_tv6 = w_tv6->next; |
@@ -249,11 +257,10 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
249 | } | 257 | } |
250 | 258 | ||
251 | struct GNUNET_TIME_Relative | 259 | struct GNUNET_TIME_Relative |
252 | http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer, | 260 | http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
253 | const struct GNUNET_MessageHeader * message, | 261 | const struct GNUNET_MessageHeader *message, |
254 | struct Session * session, | 262 | struct Session *session, const char *sender_address, |
255 | const char *sender_address, | 263 | uint16_t sender_address_len) |
256 | uint16_t sender_address_len) | ||
257 | { | 264 | { |
258 | struct Session *s = cls; | 265 | struct Session *s = cls; |
259 | struct Plugin *plugin = s->plugin; | 266 | struct Plugin *plugin = s->plugin; |
@@ -263,7 +270,10 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer, | |||
263 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 270 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
264 | distance.value = htonl (1); | 271 | distance.value = htonl (1); |
265 | 272 | ||
266 | delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const struct GNUNET_ATS_Information*) &distance, 1, s, s->addr, s->addrlen); | 273 | delay = |
274 | plugin->env->receive (plugin->env->cls, &s->target, message, | ||
275 | (const struct GNUNET_ATS_Information *) &distance, | ||
276 | 1, s, s->addr, s->addrlen); | ||
267 | return delay; | 277 | return delay; |
268 | } | 278 | } |
269 | 279 | ||
@@ -293,14 +303,18 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
293 | { | 303 | { |
294 | a6 = (struct IPv6HttpAddress *) addr; | 304 | a6 = (struct IPv6HttpAddress *) addr; |
295 | address = GNUNET_malloc (INET6_ADDRSTRLEN); | 305 | address = GNUNET_malloc (INET6_ADDRSTRLEN); |
296 | GNUNET_assert(NULL != inet_ntop (AF_INET6, &a6->ipv6_addr, address, INET6_ADDRSTRLEN)); | 306 | GNUNET_assert (NULL != |
307 | inet_ntop (AF_INET6, &a6->ipv6_addr, address, | ||
308 | INET6_ADDRSTRLEN)); | ||
297 | port = ntohs (a6->u6_port); | 309 | port = ntohs (a6->u6_port); |
298 | } | 310 | } |
299 | else if (addrlen == sizeof (struct IPv4HttpAddress)) | 311 | else if (addrlen == sizeof (struct IPv4HttpAddress)) |
300 | { | 312 | { |
301 | a4 = (struct IPv4HttpAddress *) addr; | 313 | a4 = (struct IPv4HttpAddress *) addr; |
302 | address = GNUNET_malloc (INET_ADDRSTRLEN); | 314 | address = GNUNET_malloc (INET_ADDRSTRLEN); |
303 | GNUNET_assert(NULL != inet_ntop (AF_INET, &(a4->ipv4_addr), address, INET_ADDRSTRLEN)); | 315 | GNUNET_assert (NULL != |
316 | inet_ntop (AF_INET, &(a4->ipv4_addr), address, | ||
317 | INET_ADDRSTRLEN)); | ||
304 | port = ntohs (a4->u4_port); | 318 | port = ntohs (a4->u4_port); |
305 | } | 319 | } |
306 | else | 320 | else |
@@ -309,17 +323,21 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
309 | GNUNET_break (0); | 323 | GNUNET_break (0); |
310 | return NULL; | 324 | return NULL; |
311 | } | 325 | } |
312 | #if !BUILD_HTTPS | 326 | #if !BUILD_HTTPS |
313 | char * protocol = "http"; | 327 | char *protocol = "http"; |
314 | #else | 328 | #else |
315 | char * protocol = "https"; | 329 | char *protocol = "https"; |
316 | #endif | 330 | #endif |
317 | 331 | ||
318 | GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13)); | 332 | GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13)); |
319 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 333 | if (addrlen == sizeof (struct IPv6HttpAddress)) |
320 | res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, address, port); | 334 | res = |
335 | GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, | ||
336 | address, port); | ||
321 | else if (addrlen == sizeof (struct IPv4HttpAddress)) | 337 | else if (addrlen == sizeof (struct IPv4HttpAddress)) |
322 | res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, port); | 338 | res = |
339 | GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, | ||
340 | port); | ||
323 | 341 | ||
324 | GNUNET_free (address); | 342 | GNUNET_free (address); |
325 | GNUNET_assert (res != 0); | 343 | GNUNET_assert (res != 0); |
@@ -328,8 +346,8 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
328 | 346 | ||
329 | struct Session * | 347 | struct Session * |
330 | lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 348 | lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, |
331 | struct Session * session, | 349 | struct Session *session, const void *addr, size_t addrlen, |
332 | const void *addr, size_t addrlen, int force_address) | 350 | int force_address) |
333 | { | 351 | { |
334 | struct Session *s = NULL; | 352 | struct Session *s = NULL; |
335 | struct Session *t = NULL; | 353 | struct Session *t = NULL; |
@@ -343,9 +361,15 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
343 | { | 361 | { |
344 | #if 0 | 362 | #if 0 |
345 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 363 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
346 | "Comparing peer `%s' address `%s' len %i session %X to \n", GNUNET_i2s(target), GNUNET_a2s(addr,addrlen), addrlen, session); | 364 | "Comparing peer `%s' address `%s' len %i session %X to \n", |
347 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"peer `%s' address `%s' len %i session %X \n\n", GNUNET_i2s(&t->target), GNUNET_a2s(t->addr,t->addrlen), t->addrlen, t); | 365 | GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), addrlen, |
348 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"memcmp %i \n", memcmp (addr, t->addr, addrlen)); | 366 | session); |
367 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
368 | "peer `%s' address `%s' len %i session %X \n\n", | ||
369 | GNUNET_i2s (&t->target), GNUNET_a2s (t->addr, t->addrlen), | ||
370 | t->addrlen, t); | ||
371 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "memcmp %i \n", | ||
372 | memcmp (addr, t->addr, addrlen)); | ||
349 | #endif | 373 | #endif |
350 | e_peer = GNUNET_NO; | 374 | e_peer = GNUNET_NO; |
351 | e_addr = GNUNET_NO; | 375 | e_addr = GNUNET_NO; |
@@ -362,13 +386,13 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
362 | } | 386 | } |
363 | if ((t == session)) | 387 | if ((t == session)) |
364 | { | 388 | { |
365 | if(t->addrlen == session->addrlen) | 389 | if (t->addrlen == session->addrlen) |
366 | { | ||
367 | if (0 == memcmp (session->addr, t->addr, t->addrlen)) | ||
368 | { | 390 | { |
369 | e_addr = GNUNET_YES; | 391 | if (0 == memcmp (session->addr, t->addr, t->addrlen)) |
392 | { | ||
393 | e_addr = GNUNET_YES; | ||
394 | } | ||
370 | } | 395 | } |
371 | } | ||
372 | } | 396 | } |
373 | } | 397 | } |
374 | 398 | ||
@@ -377,7 +401,8 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
377 | s = t; | 401 | s = t; |
378 | break; | 402 | break; |
379 | } | 403 | } |
380 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES)) | 404 | if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && |
405 | (e_addr == GNUNET_YES)) | ||
381 | { | 406 | { |
382 | s = t; | 407 | s = t; |
383 | break; | 408 | break; |
@@ -405,8 +430,8 @@ delete_session (struct Session *s) | |||
405 | s->msg_tk = NULL; | 430 | s->msg_tk = NULL; |
406 | } | 431 | } |
407 | GNUNET_free (s->addr); | 432 | GNUNET_free (s->addr); |
408 | GNUNET_free_non_null(s->server_recv); | 433 | GNUNET_free_non_null (s->server_recv); |
409 | GNUNET_free_non_null(s->server_send); | 434 | GNUNET_free_non_null (s->server_send); |
410 | GNUNET_free (s); | 435 | GNUNET_free (s); |
411 | } | 436 | } |
412 | 437 | ||
@@ -416,7 +441,9 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
416 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 441 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
417 | { | 442 | { |
418 | struct Session *s = NULL; | 443 | struct Session *s = NULL; |
419 | GNUNET_assert ((addrlen == sizeof (struct IPv6HttpAddress)) || (addrlen == sizeof (struct IPv4HttpAddress))); | 444 | |
445 | GNUNET_assert ((addrlen == sizeof (struct IPv6HttpAddress)) || | ||
446 | (addrlen == sizeof (struct IPv4HttpAddress))); | ||
420 | s = GNUNET_malloc (sizeof (struct Session)); | 447 | s = GNUNET_malloc (sizeof (struct Session)); |
421 | memcpy (&s->target, target, sizeof (struct GNUNET_PeerIdentity)); | 448 | memcpy (&s->target, target, sizeof (struct GNUNET_PeerIdentity)); |
422 | s->plugin = plugin; | 449 | s->plugin = plugin; |
@@ -424,14 +451,13 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
424 | memcpy (s->addr, addr, addrlen); | 451 | memcpy (s->addr, addr, addrlen); |
425 | s->addrlen = addrlen; | 452 | s->addrlen = addrlen; |
426 | s->next = NULL; | 453 | s->next = NULL; |
427 | s->next_receive = GNUNET_TIME_absolute_get_zero(); | 454 | s->next_receive = GNUNET_TIME_absolute_get_zero (); |
428 | return s; | 455 | return s; |
429 | } | 456 | } |
430 | 457 | ||
431 | void | 458 | void |
432 | notify_session_end (void *cls, | 459 | notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, |
433 | const struct GNUNET_PeerIdentity * | 460 | struct Session *s) |
434 | peer, struct Session * s) | ||
435 | { | 461 | { |
436 | struct Plugin *plugin = cls; | 462 | struct Plugin *plugin = cls; |
437 | 463 | ||
@@ -486,28 +512,38 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
486 | { | 512 | { |
487 | struct Plugin *plugin = cls; | 513 | struct Plugin *plugin = cls; |
488 | struct HTTP_Message *msg; | 514 | struct HTTP_Message *msg; |
515 | |||
489 | GNUNET_assert (plugin != NULL); | 516 | GNUNET_assert (plugin != NULL); |
490 | 517 | ||
491 | int res = GNUNET_SYSERR; | 518 | int res = GNUNET_SYSERR; |
492 | 519 | ||
493 | #if DEBUG_HTTP | 520 | #if DEBUG_HTTP |
494 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 521 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
495 | "Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size, | 522 | "Sending %u bytes to peer `%s' on address `%s' %X %i\n", |
496 | GNUNET_i2s (target), ((addr != NULL) && (addrlen != 0)) ? http_plugin_address_to_string(plugin, addr, addrlen) : "<inbound>", session, force_address); | 523 | msgbuf_size, GNUNET_i2s (target), ((addr != NULL) && |
524 | (addrlen != | ||
525 | 0)) ? | ||
526 | http_plugin_address_to_string (plugin, addr, | ||
527 | addrlen) : "<inbound>", | ||
528 | session, force_address); | ||
497 | #endif | 529 | #endif |
498 | 530 | ||
499 | struct Session *s = NULL; | 531 | struct Session *s = NULL; |
500 | 532 | ||
501 | 533 | ||
502 | if (addrlen != 0) | 534 | if (addrlen != 0) |
503 | GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) || | 535 | GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) || |
504 | (addrlen == sizeof (struct IPv6HttpAddress))); | 536 | (addrlen == sizeof (struct IPv6HttpAddress))); |
505 | 537 | ||
506 | /* look for existing connection */ | 538 | /* look for existing connection */ |
507 | s = lookup_session (plugin, target, session, addr, addrlen, 1); | 539 | s = lookup_session (plugin, target, session, addr, addrlen, 1); |
508 | #if DEBUG_HTTP | 540 | #if DEBUG_HTTP |
509 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 541 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
510 | "%s existing session: %s\n", (s!=NULL) ? "Found" : "NOT Found", ((s != NULL) && (s->inbound == GNUNET_YES)) ? "inbound" : "outbound"); | 542 | "%s existing session: %s\n", |
543 | (s != NULL) ? "Found" : "NOT Found", ((s != NULL) && | ||
544 | (s->inbound == | ||
545 | GNUNET_YES)) ? | ||
546 | "inbound" : "outbound"); | ||
511 | #endif | 547 | #endif |
512 | 548 | ||
513 | /* create new outbound connection */ | 549 | /* create new outbound connection */ |
@@ -517,8 +553,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
517 | { | 553 | { |
518 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, | 554 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, |
519 | "Maximum number of connections reached, " | 555 | "Maximum number of connections reached, " |
520 | "cannot connect to peer `%s'\n", | 556 | "cannot connect to peer `%s'\n", GNUNET_i2s (target)); |
521 | GNUNET_i2s (target)); | ||
522 | return res; | 557 | return res; |
523 | } | 558 | } |
524 | 559 | ||
@@ -554,8 +589,8 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
554 | "Using outbound client session to send to `%s'\n", | 589 | "Using outbound client session to send to `%s'\n", |
555 | GNUNET_i2s (target)); | 590 | GNUNET_i2s (target)); |
556 | #endif | 591 | #endif |
557 | client_send (s, msg); | 592 | client_send (s, msg); |
558 | res = msgbuf_size; | 593 | res = msgbuf_size; |
559 | } | 594 | } |
560 | if (s->inbound == GNUNET_YES) | 595 | if (s->inbound == GNUNET_YES) |
561 | { | 596 | { |
@@ -621,14 +656,16 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
621 | case AF_INET: | 656 | case AF_INET: |
622 | w_t4 = plugin->ipv4_addr_head; | 657 | w_t4 = plugin->ipv4_addr_head; |
623 | struct sockaddr_in *a4 = (struct sockaddr_in *) addr; | 658 | struct sockaddr_in *a4 = (struct sockaddr_in *) addr; |
659 | |||
624 | while (w_t4 != NULL) | 660 | while (w_t4 != NULL) |
625 | { | 661 | { |
626 | int res = memcmp (&w_t4->addr.ipv4_addr, | 662 | int res = memcmp (&w_t4->addr.ipv4_addr, |
627 | &a4->sin_addr, | 663 | &a4->sin_addr, |
628 | sizeof (struct in_addr)); | 664 | sizeof (struct in_addr)); |
665 | |||
629 | if (res == 0) | 666 | if (res == 0) |
630 | { | 667 | { |
631 | if (a4->sin_port!= w_t4->addr.u4_port) | 668 | if (a4->sin_port != w_t4->addr.u4_port) |
632 | res = -1; | 669 | res = -1; |
633 | } | 670 | } |
634 | 671 | ||
@@ -639,8 +676,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
639 | if (w_t4 == NULL) | 676 | if (w_t4 == NULL) |
640 | { | 677 | { |
641 | w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); | 678 | w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); |
642 | memcpy (&w_t4->addr.ipv4_addr, &a4->sin_addr, | 679 | memcpy (&w_t4->addr.ipv4_addr, &a4->sin_addr, sizeof (struct in_addr)); |
643 | sizeof (struct in_addr)); | ||
644 | w_t4->addr.u4_port = a4->sin_port; | 680 | w_t4->addr.u4_port = a4->sin_port; |
645 | 681 | ||
646 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, | 682 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, |
@@ -649,18 +685,23 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
649 | #if DEBUG_HTTP | 685 | #if DEBUG_HTTP |
650 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 686 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
651 | "Notifying transport to add IPv4 address `%s'\n", | 687 | "Notifying transport to add IPv4 address `%s'\n", |
652 | http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct IPv4HttpAddress))); | 688 | http_plugin_address_to_string (NULL, &w_t4->addr, |
689 | sizeof (struct | ||
690 | IPv4HttpAddress))); | ||
653 | #endif | 691 | #endif |
654 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, sizeof (struct IPv4HttpAddress)); | 692 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, |
693 | sizeof (struct IPv4HttpAddress)); | ||
655 | 694 | ||
656 | break; | 695 | break; |
657 | case AF_INET6: | 696 | case AF_INET6: |
658 | w_t6 = plugin->ipv6_addr_head; | 697 | w_t6 = plugin->ipv6_addr_head; |
659 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr; | 698 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr; |
699 | |||
660 | while (w_t6) | 700 | while (w_t6) |
661 | { | 701 | { |
662 | int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, | 702 | int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, |
663 | sizeof (struct in6_addr)); | 703 | sizeof (struct in6_addr)); |
704 | |||
664 | if (res == 0) | 705 | if (res == 0) |
665 | { | 706 | { |
666 | if (a6->sin6_port != w_t6->addr6.u6_port) | 707 | if (a6->sin6_port != w_t6->addr6.u6_port) |
@@ -674,8 +715,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
674 | { | 715 | { |
675 | w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); | 716 | w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); |
676 | 717 | ||
677 | memcpy (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, | 718 | memcpy (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, sizeof (struct in6_addr)); |
678 | sizeof (struct in6_addr)); | ||
679 | w_t6->addr6.u6_port = a6->sin6_port; | 719 | w_t6->addr6.u6_port = a6->sin6_port; |
680 | 720 | ||
681 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, | 721 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, |
@@ -684,9 +724,12 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
684 | #if DEBUG_HTTP | 724 | #if DEBUG_HTTP |
685 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 725 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
686 | "Notifying transport to add IPv6 address `%s'\n", | 726 | "Notifying transport to add IPv6 address `%s'\n", |
687 | http_plugin_address_to_string(NULL, &w_t6->addr6, sizeof (struct IPv6HttpAddress))); | 727 | http_plugin_address_to_string (NULL, &w_t6->addr6, |
728 | sizeof (struct | ||
729 | IPv6HttpAddress))); | ||
688 | #endif | 730 | #endif |
689 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6, sizeof (struct IPv6HttpAddress)); | 731 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6, |
732 | sizeof (struct IPv6HttpAddress)); | ||
690 | break; | 733 | break; |
691 | default: | 734 | default: |
692 | return; | 735 | return; |
@@ -709,14 +752,16 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
709 | case AF_INET: | 752 | case AF_INET: |
710 | w_t4 = plugin->ipv4_addr_head; | 753 | w_t4 = plugin->ipv4_addr_head; |
711 | struct sockaddr_in *a4 = (struct sockaddr_in *) addr; | 754 | struct sockaddr_in *a4 = (struct sockaddr_in *) addr; |
755 | |||
712 | while (w_t4 != NULL) | 756 | while (w_t4 != NULL) |
713 | { | 757 | { |
714 | int res = memcmp (&w_t4->addr.ipv4_addr, | 758 | int res = memcmp (&w_t4->addr.ipv4_addr, |
715 | &a4->sin_addr, | 759 | &a4->sin_addr, |
716 | sizeof (struct in_addr)); | 760 | sizeof (struct in_addr)); |
761 | |||
717 | if (res == 0) | 762 | if (res == 0) |
718 | { | 763 | { |
719 | if (a4->sin_port!= w_t4->addr.u4_port) | 764 | if (a4->sin_port != w_t4->addr.u4_port) |
720 | res = -1; | 765 | res = -1; |
721 | } | 766 | } |
722 | 767 | ||
@@ -730,7 +775,9 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
730 | #if DEBUG_HTTP | 775 | #if DEBUG_HTTP |
731 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 776 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
732 | "Notifying transport to remove IPv4 address `%s'\n", | 777 | "Notifying transport to remove IPv4 address `%s'\n", |
733 | http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct IPv4HttpAddress))); | 778 | http_plugin_address_to_string (NULL, &w_t4->addr, |
779 | sizeof (struct | ||
780 | IPv4HttpAddress))); | ||
734 | #endif | 781 | #endif |
735 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, | 782 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, |
736 | sizeof (struct IPv4HttpAddress)); | 783 | sizeof (struct IPv4HttpAddress)); |
@@ -742,10 +789,12 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
742 | case AF_INET6: | 789 | case AF_INET6: |
743 | w_t6 = plugin->ipv6_addr_head; | 790 | w_t6 = plugin->ipv6_addr_head; |
744 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr; | 791 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) addr; |
792 | |||
745 | while (w_t6) | 793 | while (w_t6) |
746 | { | 794 | { |
747 | int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, | 795 | int res = memcmp (&w_t6->addr6.ipv6_addr, &a6->sin6_addr, |
748 | sizeof (struct in6_addr)); | 796 | sizeof (struct in6_addr)); |
797 | |||
749 | if (res == 0) | 798 | if (res == 0) |
750 | { | 799 | { |
751 | if (a6->sin6_port != w_t6->addr6.u6_port) | 800 | if (a6->sin6_port != w_t6->addr6.u6_port) |
@@ -760,7 +809,9 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
760 | #if DEBUG_HTTP | 809 | #if DEBUG_HTTP |
761 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 810 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
762 | "Notifying transport to remove IPv6 address `%s'\n", | 811 | "Notifying transport to remove IPv6 address `%s'\n", |
763 | http_plugin_address_to_string(NULL, &w_t6->addr6, sizeof (struct IPv6HttpAddress))); | 812 | http_plugin_address_to_string (NULL, &w_t6->addr6, |
813 | sizeof (struct | ||
814 | IPv6HttpAddress))); | ||
764 | #endif | 815 | #endif |
765 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6, | 816 | plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr6, |
766 | sizeof (struct IPv6HttpAddress)); | 817 | sizeof (struct IPv6HttpAddress)); |
@@ -801,7 +852,7 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
801 | switch (add_remove) | 852 | switch (add_remove) |
802 | { | 853 | { |
803 | case GNUNET_YES: | 854 | case GNUNET_YES: |
804 | nat_add_address (cls, add_remove, addr, addrlen); | 855 | nat_add_address (cls, add_remove, addr, addrlen); |
805 | break; | 856 | break; |
806 | case GNUNET_NO: | 857 | case GNUNET_NO: |
807 | nat_remove_address (cls, add_remove, addr, addrlen); | 858 | nat_remove_address (cls, add_remove, addr, addrlen); |
@@ -813,6 +864,7 @@ void | |||
813 | http_check_ipv6 (struct Plugin *plugin) | 864 | http_check_ipv6 (struct Plugin *plugin) |
814 | { | 865 | { |
815 | struct GNUNET_NETWORK_Handle *desc = NULL; | 866 | struct GNUNET_NETWORK_Handle *desc = NULL; |
867 | |||
816 | if (plugin->ipv6 == GNUNET_YES) | 868 | if (plugin->ipv6 == GNUNET_YES) |
817 | { | 869 | { |
818 | /* probe IPv6 support */ | 870 | /* probe IPv6 support */ |
@@ -825,8 +877,8 @@ http_check_ipv6 (struct Plugin *plugin) | |||
825 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 877 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
826 | } | 878 | } |
827 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, | 879 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, |
828 | _ | 880 | _ |
829 | ("Disabling IPv6 since it is not supported on this system!\n")); | 881 | ("Disabling IPv6 since it is not supported on this system!\n")); |
830 | plugin->ipv6 = GNUNET_NO; | 882 | plugin->ipv6 = GNUNET_NO; |
831 | } | 883 | } |
832 | else | 884 | else |
@@ -835,17 +887,16 @@ http_check_ipv6 (struct Plugin *plugin) | |||
835 | desc = NULL; | 887 | desc = NULL; |
836 | } | 888 | } |
837 | 889 | ||
838 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 890 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
839 | "Testing IPv6 on this system: %s\n", (plugin->ipv6 == GNUNET_YES) ? "successful" : "failed"); | 891 | "Testing IPv6 on this system: %s\n", |
892 | (plugin->ipv6 == GNUNET_YES) ? "successful" : "failed"); | ||
840 | } | 893 | } |
841 | } | 894 | } |
842 | 895 | ||
843 | int | 896 | int |
844 | http_get_addresses (struct Plugin *plugin, | 897 | http_get_addresses (struct Plugin *plugin, const char *serviceName, |
845 | const char *serviceName, | 898 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
846 | const struct GNUNET_CONFIGURATION_Handle | 899 | struct sockaddr ***addrs, socklen_t ** addr_lens) |
847 | *cfg, struct sockaddr ***addrs, | ||
848 | socklen_t ** addr_lens) | ||
849 | { | 900 | { |
850 | int disablev6; | 901 | int disablev6; |
851 | unsigned long long port; | 902 | unsigned long long port; |
@@ -892,8 +943,8 @@ http_get_addresses (struct Plugin *plugin, | |||
892 | if (hostname != NULL) | 943 | if (hostname != NULL) |
893 | { | 944 | { |
894 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 945 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
895 | "Resolving `%s' since that is where `%s' will bind to.\n", | 946 | "Resolving `%s' since that is where `%s' will bind to.\n", |
896 | hostname, serviceName); | 947 | hostname, serviceName); |
897 | memset (&hints, 0, sizeof (struct addrinfo)); | 948 | memset (&hints, 0, sizeof (struct addrinfo)); |
898 | if (disablev6) | 949 | if (disablev6) |
899 | hints.ai_family = AF_INET; | 950 | hints.ai_family = AF_INET; |
@@ -938,8 +989,8 @@ http_get_addresses (struct Plugin *plugin, | |||
938 | if ((pos->ai_socktype != SOCK_STREAM) && (pos->ai_socktype != 0)) | 989 | if ((pos->ai_socktype != SOCK_STREAM) && (pos->ai_socktype != 0)) |
939 | continue; /* huh? */ | 990 | continue; /* huh? */ |
940 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 991 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
941 | "Service will bind to `%s'\n", | 992 | "Service will bind to `%s'\n", GNUNET_a2s (pos->ai_addr, |
942 | GNUNET_a2s (pos->ai_addr, pos->ai_addrlen)); | 993 | pos->ai_addrlen)); |
943 | if (pos->ai_family == AF_INET) | 994 | if (pos->ai_family == AF_INET) |
944 | { | 995 | { |
945 | GNUNET_assert (pos->ai_addrlen == sizeof (struct sockaddr_in)); | 996 | GNUNET_assert (pos->ai_addrlen == sizeof (struct sockaddr_in)); |
@@ -1019,10 +1070,10 @@ start_report_addresses (struct Plugin *plugin) | |||
1019 | socklen_t *addrlens; | 1070 | socklen_t *addrlens; |
1020 | 1071 | ||
1021 | res = | 1072 | res = |
1022 | http_get_addresses (plugin, plugin->name, plugin->env->cfg, | 1073 | http_get_addresses (plugin, plugin->name, plugin->env->cfg, &addrs, |
1023 | &addrs, &addrlens); | 1074 | &addrlens); |
1024 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1075 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1025 | _("Found %u addresses to report to NAT service\n"),res); | 1076 | _("Found %u addresses to report to NAT service\n"), res); |
1026 | 1077 | ||
1027 | if (res != GNUNET_SYSERR) | 1078 | if (res != GNUNET_SYSERR) |
1028 | { | 1079 | { |
@@ -1030,14 +1081,12 @@ start_report_addresses (struct Plugin *plugin) | |||
1030 | GNUNET_NAT_register (plugin->env->cfg, GNUNET_YES, plugin->port, | 1081 | GNUNET_NAT_register (plugin->env->cfg, GNUNET_YES, plugin->port, |
1031 | (unsigned int) res, | 1082 | (unsigned int) res, |
1032 | (const struct sockaddr **) addrs, addrlens, | 1083 | (const struct sockaddr **) addrs, addrlens, |
1033 | &nat_port_map_callback, NULL, | 1084 | &nat_port_map_callback, NULL, plugin); |
1034 | plugin); | ||
1035 | while (res > 0) | 1085 | while (res > 0) |
1036 | { | 1086 | { |
1037 | res--; | 1087 | res--; |
1038 | #if 0 | 1088 | #if 0 |
1039 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1089 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, _("FREEING %s\n"), |
1040 | _("FREEING %s\n"), | ||
1041 | GNUNET_a2s (addrs[res], addrlens[res])); | 1090 | GNUNET_a2s (addrs[res], addrlens[res])); |
1042 | #endif | 1091 | #endif |
1043 | GNUNET_assert (addrs[res] != NULL); | 1092 | GNUNET_assert (addrs[res] != NULL); |
@@ -1136,24 +1185,28 @@ configure_plugin (struct Plugin *plugin) | |||
1136 | if (plugin->port == 0) | 1185 | if (plugin->port == 0) |
1137 | { | 1186 | { |
1138 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1187 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1139 | _("Port 0, client only mode\n")); | 1188 | _("Port 0, client only mode\n")); |
1140 | plugin->client_only = GNUNET_YES; | 1189 | plugin->client_only = GNUNET_YES; |
1141 | } | 1190 | } |
1142 | 1191 | ||
1143 | char * bind4_address = NULL; | 1192 | char *bind4_address = NULL; |
1144 | if ((plugin->ipv4 == GNUNET_YES) && (GNUNET_YES == | 1193 | |
1145 | GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | 1194 | if ((plugin->ipv4 == GNUNET_YES) && |
1146 | "BINDTO", &bind4_address))) | 1195 | (GNUNET_YES == |
1196 | GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | ||
1197 | "BINDTO", &bind4_address))) | ||
1147 | { | 1198 | { |
1148 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1199 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1149 | "Binding %s plugin to specific IPv4 address: `%s'\n", | 1200 | "Binding %s plugin to specific IPv4 address: `%s'\n", |
1150 | plugin->protocol, bind4_address); | 1201 | plugin->protocol, bind4_address); |
1151 | plugin->server_addr_v4 = GNUNET_malloc (sizeof (struct sockaddr_in)); | 1202 | plugin->server_addr_v4 = GNUNET_malloc (sizeof (struct sockaddr_in)); |
1152 | if (1 != inet_pton (AF_INET, bind4_address, &plugin->server_addr_v4->sin_addr)) | 1203 | if (1 != |
1204 | inet_pton (AF_INET, bind4_address, &plugin->server_addr_v4->sin_addr)) | ||
1153 | { | 1205 | { |
1154 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1206 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
1155 | _("Specific IPv4 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"), | 1207 | _ |
1156 | bind4_address, plugin->protocol); | 1208 | ("Specific IPv4 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"), |
1209 | bind4_address, plugin->protocol); | ||
1157 | GNUNET_free (plugin->server_addr_v4); | 1210 | GNUNET_free (plugin->server_addr_v4); |
1158 | plugin->server_addr_v4 = NULL; | 1211 | plugin->server_addr_v4 = NULL; |
1159 | } | 1212 | } |
@@ -1166,20 +1219,24 @@ configure_plugin (struct Plugin *plugin) | |||
1166 | } | 1219 | } |
1167 | 1220 | ||
1168 | 1221 | ||
1169 | char * bind6_address = NULL; | 1222 | char *bind6_address = NULL; |
1170 | if ((plugin->ipv6 == GNUNET_YES) && (GNUNET_YES == | 1223 | |
1171 | GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | 1224 | if ((plugin->ipv6 == GNUNET_YES) && |
1172 | "BINDTO6", &bind6_address))) | 1225 | (GNUNET_YES == |
1226 | GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | ||
1227 | "BINDTO6", &bind6_address))) | ||
1173 | { | 1228 | { |
1174 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1229 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1175 | "Binding %s plugin to specific IPv6 address: `%s'\n", | 1230 | "Binding %s plugin to specific IPv6 address: `%s'\n", |
1176 | plugin->protocol, bind6_address); | 1231 | plugin->protocol, bind6_address); |
1177 | plugin->server_addr_v6 = GNUNET_malloc (sizeof (struct sockaddr_in6)); | 1232 | plugin->server_addr_v6 = GNUNET_malloc (sizeof (struct sockaddr_in6)); |
1178 | if (1 != inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr)) | 1233 | if (1 != |
1234 | inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr)) | ||
1179 | { | 1235 | { |
1180 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1236 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
1181 | _("Specific IPv6 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"), | 1237 | _ |
1182 | bind6_address, plugin->protocol); | 1238 | ("Specific IPv6 address `%s' for plugin %s in configuration file is invalid! Binding to all addresses!\n"), |
1239 | bind6_address, plugin->protocol); | ||
1183 | GNUNET_free (plugin->server_addr_v6); | 1240 | GNUNET_free (plugin->server_addr_v6); |
1184 | plugin->server_addr_v6 = NULL; | 1241 | plugin->server_addr_v6 = NULL; |
1185 | } | 1242 | } |
@@ -1194,6 +1251,7 @@ configure_plugin (struct Plugin *plugin) | |||
1194 | 1251 | ||
1195 | /* Optional parameters */ | 1252 | /* Optional parameters */ |
1196 | unsigned long long maxneigh; | 1253 | unsigned long long maxneigh; |
1254 | |||
1197 | if (GNUNET_OK != | 1255 | if (GNUNET_OK != |
1198 | GNUNET_CONFIGURATION_get_value_number (plugin->env->cfg, plugin->name, | 1256 | GNUNET_CONFIGURATION_get_value_number (plugin->env->cfg, plugin->name, |
1199 | "MAX_CONNECTIONS", &maxneigh)) | 1257 | "MAX_CONNECTIONS", &maxneigh)) |
@@ -1303,8 +1361,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
1303 | while (s != NULL) | 1361 | while (s != NULL) |
1304 | { | 1362 | { |
1305 | #if DEBUG_HTTP | 1363 | #if DEBUG_HTTP |
1306 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1364 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1307 | "Disconnecting `%s' \n", GNUNET_i2s (&s->target)); | 1365 | "Disconnecting `%s' \n", GNUNET_i2s (&s->target)); |
1308 | #endif | 1366 | #endif |
1309 | if (s->inbound == GNUNET_NO) | 1367 | if (s->inbound == GNUNET_NO) |
1310 | GNUNET_assert (GNUNET_OK == client_disconnect (s)); | 1368 | GNUNET_assert (GNUNET_OK == client_disconnect (s)); |
@@ -1314,15 +1372,13 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
1314 | } | 1372 | } |
1315 | 1373 | ||
1316 | #if DEBUG_HTTP | 1374 | #if DEBUG_HTTP |
1317 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1375 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Stopping server\n"); |
1318 | "Stopping server\n"); | ||
1319 | #endif | 1376 | #endif |
1320 | /* Stop server */ | 1377 | /* Stop server */ |
1321 | server_stop (plugin); | 1378 | server_stop (plugin); |
1322 | 1379 | ||
1323 | #if DEBUG_HTTP | 1380 | #if DEBUG_HTTP |
1324 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1381 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Stopping client\n"); |
1325 | "Stopping client\n"); | ||
1326 | #endif | 1382 | #endif |
1327 | /* Stop client */ | 1383 | /* Stop client */ |
1328 | client_stop (plugin); | 1384 | client_stop (plugin); |
@@ -1332,6 +1388,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
1332 | while (s != NULL) | 1388 | while (s != NULL) |
1333 | { | 1389 | { |
1334 | struct Session *t = s->next; | 1390 | struct Session *t = s->next; |
1391 | |||
1335 | GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s); | 1392 | GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s); |
1336 | delete_session (s); | 1393 | delete_session (s); |
1337 | s = t; | 1394 | s = t; |
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index dd0bc4b9d..7ace96cb6 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h | |||
@@ -228,12 +228,12 @@ struct Plugin | |||
228 | /** | 228 | /** |
229 | * IPv4 server socket to bind to | 229 | * IPv4 server socket to bind to |
230 | */ | 230 | */ |
231 | struct sockaddr_in * server_addr_v4; | 231 | struct sockaddr_in *server_addr_v4; |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * IPv6 server socket to bind to | 234 | * IPv6 server socket to bind to |
235 | */ | 235 | */ |
236 | struct sockaddr_in6 * server_addr_v6; | 236 | struct sockaddr_in6 *server_addr_v6; |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * Server semi connections | 239 | * Server semi connections |
@@ -455,11 +455,10 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
455 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls); | 455 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls); |
456 | 456 | ||
457 | struct GNUNET_TIME_Relative | 457 | struct GNUNET_TIME_Relative |
458 | http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer, | 458 | http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
459 | const struct GNUNET_MessageHeader * message, | 459 | const struct GNUNET_MessageHeader *message, |
460 | struct Session * session, | 460 | struct Session *session, const char *sender_address, |
461 | const char *sender_address, | 461 | uint16_t sender_address_len); |
462 | uint16_t sender_address_len); | ||
463 | 462 | ||
464 | const char * | 463 | const char * |
465 | http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen); | 464 | http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen); |
@@ -483,7 +482,7 @@ int | |||
483 | server_disconnect (struct Session *s); | 482 | server_disconnect (struct Session *s); |
484 | 483 | ||
485 | int | 484 | int |
486 | server_send (struct Session *s, struct HTTP_Message * msg); | 485 | server_send (struct Session *s, struct HTTP_Message *msg); |
487 | 486 | ||
488 | int | 487 | int |
489 | server_start (struct Plugin *plugin); | 488 | server_start (struct Plugin *plugin); |
@@ -492,8 +491,7 @@ void | |||
492 | server_stop (struct Plugin *plugin); | 491 | server_stop (struct Plugin *plugin); |
493 | 492 | ||
494 | void | 493 | void |
495 | notify_session_end (void *cls, | 494 | notify_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, |
496 | const struct GNUNET_PeerIdentity * | 495 | struct Session *s); |
497 | peer, struct Session * s); | ||
498 | 496 | ||
499 | /* end of plugin_transport_http.h */ | 497 | /* end of plugin_transport_http.h */ |
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index a2024953c..62be281ab 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -52,11 +52,11 @@ client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls) | |||
52 | text[size + 1] = '\0'; | 52 | text[size + 1] = '\0'; |
53 | } | 53 | } |
54 | #if BUILD_HTTPS | 54 | #if BUILD_HTTPS |
55 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 55 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-https", |
56 | "transport-https", "Client: %X - %s", cls, text); | 56 | "Client: %X - %s", cls, text); |
57 | #else | 57 | #else |
58 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 58 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-http", |
59 | "transport-http", "Client: %X - %s", cls, text); | 59 | "Client: %X - %s", cls, text); |
60 | #endif | 60 | #endif |
61 | } | 61 | } |
62 | return 0; | 62 | return 0; |
@@ -91,7 +91,7 @@ client_schedule (struct Plugin *plugin, int now) | |||
91 | struct GNUNET_TIME_Relative timeout; | 91 | struct GNUNET_TIME_Relative timeout; |
92 | 92 | ||
93 | /* Cancel previous scheduled task */ | 93 | /* Cancel previous scheduled task */ |
94 | if (plugin->client_perform_task!= GNUNET_SCHEDULER_NO_TASK) | 94 | if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) |
95 | { | 95 | { |
96 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); | 96 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); |
97 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; | 97 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -132,12 +132,8 @@ client_schedule (struct Plugin *plugin, int now) | |||
132 | 132 | ||
133 | plugin->client_perform_task = | 133 | plugin->client_perform_task = |
134 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 134 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
135 | GNUNET_SCHEDULER_NO_TASK, | 135 | GNUNET_SCHEDULER_NO_TASK, timeout, grs, gws, |
136 | timeout, | 136 | &client_run, plugin); |
137 | grs, | ||
138 | gws, | ||
139 | &client_run, | ||
140 | plugin); | ||
141 | GNUNET_NETWORK_fdset_destroy (gws); | 137 | GNUNET_NETWORK_fdset_destroy (gws); |
142 | GNUNET_NETWORK_fdset_destroy (grs); | 138 | GNUNET_NETWORK_fdset_destroy (grs); |
143 | return GNUNET_OK; | 139 | return GNUNET_OK; |
@@ -153,10 +149,10 @@ client_send (struct Session *s, struct HTTP_Message *msg) | |||
153 | { | 149 | { |
154 | #if VERBOSE_CLIENT | 150 | #if VERBOSE_CLIENT |
155 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 151 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, |
156 | "Client: %X was suspended, unpausing\n", s->client_put); | 152 | "Client: %X was suspended, unpausing\n", s->client_put); |
157 | #endif | 153 | #endif |
158 | s->client_put_paused = GNUNET_NO; | 154 | s->client_put_paused = GNUNET_NO; |
159 | curl_easy_pause(s->client_put, CURLPAUSE_CONT); | 155 | curl_easy_pause (s->client_put, CURLPAUSE_CONT); |
160 | } | 156 | } |
161 | 157 | ||
162 | client_schedule (s->plugin, GNUNET_YES); | 158 | client_schedule (s->plugin, GNUNET_YES); |
@@ -189,43 +185,45 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
189 | running = 0; | 185 | running = 0; |
190 | mret = curl_multi_perform (plugin->client_mh, &running); | 186 | mret = curl_multi_perform (plugin->client_mh, &running); |
191 | 187 | ||
192 | CURLMsg * msg; | 188 | CURLMsg *msg; |
193 | int msgs_left; | 189 | int msgs_left; |
194 | while ((msg = curl_multi_info_read(plugin->client_mh, &msgs_left))) | 190 | |
191 | while ((msg = curl_multi_info_read (plugin->client_mh, &msgs_left))) | ||
195 | { | 192 | { |
196 | CURL *easy_h = msg->easy_handle; | 193 | CURL *easy_h = msg->easy_handle; |
197 | struct Session *s = NULL; | 194 | struct Session *s = NULL; |
198 | char * d = (char *) s; | 195 | char *d = (char *) s; |
199 | 196 | ||
200 | 197 | ||
201 | //GNUNET_assert (easy_h != NULL); | 198 | //GNUNET_assert (easy_h != NULL); |
202 | if (easy_h == NULL) | 199 | if (easy_h == NULL) |
203 | { | 200 | { |
204 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 201 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
205 | "Client: connection to ended with reason %i: `%s', %i handles running\n", | 202 | "Client: connection to ended with reason %i: `%s', %i handles running\n", |
206 | msg->data.result, | 203 | msg->data.result, |
207 | curl_easy_strerror(msg->data.result), | 204 | curl_easy_strerror (msg->data.result), running); |
208 | running); | 205 | continue; |
209 | continue; | 206 | } |
210 | } | 207 | |
211 | 208 | GNUNET_assert (CURLE_OK == | |
212 | GNUNET_assert (CURLE_OK == curl_easy_getinfo(easy_h, CURLINFO_PRIVATE, &d)); | 209 | curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); |
213 | s = (struct Session *) d; | 210 | s = (struct Session *) d; |
214 | GNUNET_assert (s != NULL); | 211 | GNUNET_assert (s != NULL); |
215 | 212 | ||
216 | if (msg->msg == CURLMSG_DONE) | 213 | if (msg->msg == CURLMSG_DONE) |
217 | { | 214 | { |
218 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 215 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
219 | "Client: %X connection to '%s' %s ended with reason %i: `%s'\n", | 216 | "Client: %X connection to '%s' %s ended with reason %i: `%s'\n", |
220 | msg->easy_handle, GNUNET_i2s(&s->target), | 217 | msg->easy_handle, GNUNET_i2s (&s->target), |
221 | http_plugin_address_to_string (NULL, s->addr, s->addrlen), | 218 | http_plugin_address_to_string (NULL, s->addr, |
222 | msg->data.result, | 219 | s->addrlen), |
223 | curl_easy_strerror(msg->data.result)); | 220 | msg->data.result, |
224 | 221 | curl_easy_strerror (msg->data.result)); | |
225 | client_disconnect(s); | 222 | |
226 | //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), http_plugin_address_to_string (plugin, s->addr, s->addrlen)); | 223 | client_disconnect (s); |
227 | notify_session_end (plugin, &s->target, s); | 224 | //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), http_plugin_address_to_string (plugin, s->addr, s->addrlen)); |
228 | } | 225 | notify_session_end (plugin, &s->target, s); |
226 | } | ||
229 | } | 227 | } |
230 | } | 228 | } |
231 | while (mret == CURLM_CALL_MULTI_PERFORM); | 229 | while (mret == CURLM_CALL_MULTI_PERFORM); |
@@ -238,18 +236,17 @@ client_disconnect (struct Session *s) | |||
238 | int res = GNUNET_OK; | 236 | int res = GNUNET_OK; |
239 | CURLMcode mret; | 237 | CURLMcode mret; |
240 | struct Plugin *plugin = s->plugin; | 238 | struct Plugin *plugin = s->plugin; |
241 | struct HTTP_Message * msg; | 239 | struct HTTP_Message *msg; |
242 | struct HTTP_Message * t; | 240 | struct HTTP_Message *t; |
243 | 241 | ||
244 | 242 | ||
245 | 243 | ||
246 | if (s->client_put != NULL) | 244 | if (s->client_put != NULL) |
247 | { | 245 | { |
248 | #if DEBUG_HTTP | 246 | #if DEBUG_HTTP |
249 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 247 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
250 | "Client: %X Deleting outbound PUT session to peer `%s'\n", | 248 | "Client: %X Deleting outbound PUT session to peer `%s'\n", |
251 | s->client_put, | 249 | s->client_put, GNUNET_i2s (&s->target)); |
252 | GNUNET_i2s (&s->target)); | ||
253 | #endif | 250 | #endif |
254 | 251 | ||
255 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_put); | 252 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_put); |
@@ -266,17 +263,16 @@ client_disconnect (struct Session *s) | |||
266 | 263 | ||
267 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) | 264 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) |
268 | { | 265 | { |
269 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); | 266 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); |
270 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; | 267 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; |
271 | } | 268 | } |
272 | 269 | ||
273 | if (s->client_get != NULL) | 270 | if (s->client_get != NULL) |
274 | { | 271 | { |
275 | #if DEBUG_HTTP | 272 | #if DEBUG_HTTP |
276 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 273 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
277 | "Client: %X Deleting outbound GET session to peer `%s'\n", | 274 | "Client: %X Deleting outbound GET session to peer `%s'\n", |
278 | s->client_get, | 275 | s->client_get, GNUNET_i2s (&s->target)); |
279 | GNUNET_i2s (&s->target)); | ||
280 | #endif | 276 | #endif |
281 | 277 | ||
282 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); | 278 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); |
@@ -296,7 +292,7 @@ client_disconnect (struct Session *s) | |||
296 | t = msg->next; | 292 | t = msg->next; |
297 | if (NULL != msg->transmit_cont) | 293 | if (NULL != msg->transmit_cont) |
298 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR); | 294 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR); |
299 | GNUNET_CONTAINER_DLL_remove(s->msg_head, s->msg_tail, msg); | 295 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); |
300 | GNUNET_free (msg); | 296 | GNUNET_free (msg); |
301 | msg = t; | 297 | msg = t; |
302 | } | 298 | } |
@@ -316,24 +312,28 @@ client_disconnect (struct Session *s) | |||
316 | 312 | ||
317 | static void | 313 | static void |
318 | client_receive_mst_cb (void *cls, void *client, | 314 | client_receive_mst_cb (void *cls, void *client, |
319 | const struct GNUNET_MessageHeader *message) | 315 | const struct GNUNET_MessageHeader *message) |
320 | { | 316 | { |
321 | struct Session *s = cls; | 317 | struct Session *s = cls; |
322 | struct GNUNET_TIME_Relative delay; | 318 | struct GNUNET_TIME_Relative delay; |
323 | 319 | ||
324 | delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); | 320 | delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); |
325 | s->next_receive = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay); | 321 | s->next_receive = |
322 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | ||
326 | 323 | ||
327 | if (GNUNET_TIME_absolute_get().abs_value < s->next_receive.abs_value) | 324 | if (GNUNET_TIME_absolute_get ().abs_value < s->next_receive.abs_value) |
328 | { | 325 | { |
329 | #if VERBOSE_CLIENT | 326 | #if VERBOSE_CLIENT |
330 | struct Plugin *plugin = s->plugin; | 327 | struct Plugin *plugin = s->plugin; |
328 | |||
331 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 329 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
332 | "Client: peer `%s' address `%s' next read delayed for %llu ms\n", | 330 | "Client: peer `%s' address `%s' next read delayed for %llu ms\n", |
333 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), delay); | 331 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), |
332 | delay); | ||
334 | #endif | 333 | #endif |
335 | } | 334 | } |
336 | } | 335 | } |
336 | |||
337 | static void | 337 | static void |
338 | client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 338 | client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
339 | { | 339 | { |
@@ -345,11 +345,10 @@ client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
345 | return; | 345 | return; |
346 | 346 | ||
347 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 347 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, |
348 | "Client: %X Waking up receive handle\n", | 348 | "Client: %X Waking up receive handle\n", s->client_get); |
349 | s->client_get); | ||
350 | 349 | ||
351 | if (s->client_get != NULL) | 350 | if (s->client_get != NULL) |
352 | curl_easy_pause(s->client_get, CURLPAUSE_CONT); | 351 | curl_easy_pause (s->client_get, CURLPAUSE_CONT); |
353 | 352 | ||
354 | } | 353 | } |
355 | 354 | ||
@@ -372,37 +371,38 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
372 | 371 | ||
373 | #if VERBOSE_CLIENT | 372 | #if VERBOSE_CLIENT |
374 | struct Plugin *plugin = s->plugin; | 373 | struct Plugin *plugin = s->plugin; |
374 | |||
375 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 375 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
376 | "Client: Received %Zu bytes from peer `%s'\n", | 376 | "Client: Received %Zu bytes from peer `%s'\n", len, |
377 | len, | ||
378 | GNUNET_i2s (&s->target)); | 377 | GNUNET_i2s (&s->target)); |
379 | #endif | 378 | #endif |
380 | 379 | ||
381 | now = GNUNET_TIME_absolute_get(); | 380 | now = GNUNET_TIME_absolute_get (); |
382 | if (now.abs_value < s->next_receive.abs_value) | 381 | if (now.abs_value < s->next_receive.abs_value) |
383 | { | 382 | { |
384 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); | 383 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
385 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(now, s->next_receive); | 384 | struct GNUNET_TIME_Relative delta = |
385 | GNUNET_TIME_absolute_get_difference (now, s->next_receive); | ||
386 | #if DEBUG_CLIENT | 386 | #if DEBUG_CLIENT |
387 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 387 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
388 | "Client: %X No inbound bandwidth available! Next read was delayed for %llu ms\n", | 388 | "Client: %X No inbound bandwidth available! Next read was delayed for %llu ms\n", |
389 | s->client_get, delta.rel_value); | 389 | s->client_get, delta.rel_value); |
390 | #endif | 390 | #endif |
391 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) | 391 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) |
392 | { | 392 | { |
393 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); | 393 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); |
394 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; | 394 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; |
395 | } | 395 | } |
396 | s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed (delta, &client_wake_up, s); | 396 | s->recv_wakeup_task = |
397 | GNUNET_SCHEDULER_add_delayed (delta, &client_wake_up, s); | ||
397 | return CURLPAUSE_ALL; | 398 | return CURLPAUSE_ALL; |
398 | } | 399 | } |
399 | 400 | ||
400 | 401 | ||
401 | if (s->msg_tk == NULL) | 402 | if (s->msg_tk == NULL) |
402 | s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s); | 403 | s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s); |
403 | 404 | ||
404 | GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, | 405 | GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, GNUNET_NO); |
405 | GNUNET_NO); | ||
406 | 406 | ||
407 | return len; | 407 | return len; |
408 | } | 408 | } |
@@ -420,6 +420,7 @@ static size_t | |||
420 | client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | 420 | client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) |
421 | { | 421 | { |
422 | struct Session *s = cls; | 422 | struct Session *s = cls; |
423 | |||
423 | #if VERBOSE_CLIENT | 424 | #if VERBOSE_CLIENT |
424 | struct Plugin *plugin = s->plugin; | 425 | struct Plugin *plugin = s->plugin; |
425 | #endif | 426 | #endif |
@@ -432,7 +433,8 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
432 | { | 433 | { |
433 | #if VERBOSE_CLIENT | 434 | #if VERBOSE_CLIENT |
434 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 435 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
435 | "Client: %X Nothing to send! Suspending PUT handle!\n", s->client_put); | 436 | "Client: %X Nothing to send! Suspending PUT handle!\n", |
437 | s->client_put); | ||
436 | #endif | 438 | #endif |
437 | s->client_put_paused = GNUNET_YES; | 439 | s->client_put_paused = GNUNET_YES; |
438 | return CURL_READFUNC_PAUSE; | 440 | return CURL_READFUNC_PAUSE; |
@@ -469,13 +471,13 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
469 | { | 471 | { |
470 | #if VERBOSE_CLIENT | 472 | #if VERBOSE_CLIENT |
471 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 473 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
472 | "Client: %X Message with %u bytes sent, removing message from queue\n", | 474 | "Client: %X Message with %u bytes sent, removing message from queue\n", |
473 | s->client_put, msg->size, msg->pos); | 475 | s->client_put, msg->size, msg->pos); |
474 | #endif | 476 | #endif |
475 | /* Calling transmit continuation */ | 477 | /* Calling transmit continuation */ |
476 | if (NULL != msg->transmit_cont) | 478 | if (NULL != msg->transmit_cont) |
477 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); | 479 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); |
478 | GNUNET_CONTAINER_DLL_remove(s->msg_head, s->msg_tail, msg); | 480 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); |
479 | GNUNET_free (msg); | 481 | GNUNET_free (msg); |
480 | } | 482 | } |
481 | return bytes_sent; | 483 | return bytes_sent; |
@@ -500,12 +502,11 @@ client_connect (struct Session *s) | |||
500 | plugin->last_tag++; | 502 | plugin->last_tag++; |
501 | /* create url */ | 503 | /* create url */ |
502 | GNUNET_asprintf (&url, "%s%s;%u", | 504 | GNUNET_asprintf (&url, "%s%s;%u", |
503 | http_plugin_address_to_string (plugin, s->addr, s->addrlen), | 505 | http_plugin_address_to_string (plugin, s->addr, s->addrlen), |
504 | GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey),plugin->last_tag); | 506 | GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey), |
507 | plugin->last_tag); | ||
505 | #if 0 | 508 | #if 0 |
506 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 509 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "URL `%s'\n", url); |
507 | "URL `%s'\n", | ||
508 | url); | ||
509 | #endif | 510 | #endif |
510 | /* create get connection */ | 511 | /* create get connection */ |
511 | s->client_get = curl_easy_init (); | 512 | s->client_get = curl_easy_init (); |
@@ -592,7 +593,7 @@ client_connect (struct Session *s) | |||
592 | plugin->cur_connections += 2; | 593 | plugin->cur_connections += 2; |
593 | 594 | ||
594 | /* Re-schedule since handles have changed */ | 595 | /* Re-schedule since handles have changed */ |
595 | if (plugin->client_perform_task!= GNUNET_SCHEDULER_NO_TASK) | 596 | if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) |
596 | { | 597 | { |
597 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); | 598 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); |
598 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; | 599 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; |
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index e5b20cfb4..48c8739d5 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -39,7 +39,7 @@ struct ServerConnection | |||
39 | int disconnect; | 39 | int disconnect; |
40 | 40 | ||
41 | struct Session *session; | 41 | struct Session *session; |
42 | struct MHD_Connection * mhd_conn; | 42 | struct MHD_Connection *mhd_conn; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | 45 | /** |
@@ -50,7 +50,8 @@ struct ServerConnection | |||
50 | * @return gnunet task identifier | 50 | * @return gnunet task identifier |
51 | */ | 51 | */ |
52 | static GNUNET_SCHEDULER_TaskIdentifier | 52 | static GNUNET_SCHEDULER_TaskIdentifier |
53 | server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int now); | 53 | server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, |
54 | int now); | ||
54 | 55 | ||
55 | static void | 56 | static void |
56 | server_log (void *arg, const char *fmt, va_list ap) | 57 | server_log (void *arg, const char *fmt, va_list ap) |
@@ -74,13 +75,14 @@ server_log (void *arg, const char *fmt, va_list ap) | |||
74 | static int | 75 | static int |
75 | server_accept_cb (void *cls, const struct sockaddr *addr, socklen_t addr_len) | 76 | server_accept_cb (void *cls, const struct sockaddr *addr, socklen_t addr_len) |
76 | { | 77 | { |
77 | struct Plugin * plugin = cls; | 78 | struct Plugin *plugin = cls; |
78 | 79 | ||
79 | if (plugin->cur_connections <= plugin->max_connections) | 80 | if (plugin->cur_connections <= plugin->max_connections) |
80 | return MHD_YES; | 81 | return MHD_YES; |
81 | else | 82 | else |
82 | { | 83 | { |
83 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Cannot accept new connections\n"); | 84 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
85 | "Server: Cannot accept new connections\n"); | ||
84 | return MHD_NO; | 86 | return MHD_NO; |
85 | } | 87 | } |
86 | } | 88 | } |
@@ -131,8 +133,11 @@ server_load_certificate (struct Plugin *plugin) | |||
131 | /* Get crypto init string from config | 133 | /* Get crypto init string from config |
132 | * If not present just use default values */ | 134 | * If not present just use default values */ |
133 | 135 | ||
134 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | 136 | GNUNET_assert (GNUNET_OK == |
135 | "CRYPTO_INIT", &plugin->crypto_init)); | 137 | GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, |
138 | plugin->name, | ||
139 | "CRYPTO_INIT", | ||
140 | &plugin->crypto_init)); | ||
136 | 141 | ||
137 | if (GNUNET_OK != | 142 | if (GNUNET_OK != |
138 | GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name, | 143 | GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name, |
@@ -145,7 +150,7 @@ server_load_certificate (struct Plugin *plugin) | |||
145 | GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name, | 150 | GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name, |
146 | "CERT_FILE", &cert_file)) | 151 | "CERT_FILE", &cert_file)) |
147 | { | 152 | { |
148 | GNUNET_asprintf(&cert_file, "%s", "https_cert.crt"); | 153 | GNUNET_asprintf (&cert_file, "%s", "https_cert.crt"); |
149 | } | 154 | } |
150 | 155 | ||
151 | /* read key & certificates from file */ | 156 | /* read key & certificates from file */ |
@@ -244,7 +249,7 @@ server_reschedule (struct Plugin *plugin, int now) | |||
244 | { | 249 | { |
245 | if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) | 250 | if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) |
246 | { | 251 | { |
247 | GNUNET_SCHEDULER_cancel(plugin->server_v4_task); | 252 | GNUNET_SCHEDULER_cancel (plugin->server_v4_task); |
248 | plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; | 253 | plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; |
249 | } | 254 | } |
250 | plugin->server_v4_task = server_schedule (plugin, plugin->server_v4, now); | 255 | plugin->server_v4_task = server_schedule (plugin, plugin->server_v4, now); |
@@ -252,12 +257,12 @@ server_reschedule (struct Plugin *plugin, int now) | |||
252 | 257 | ||
253 | if (plugin->server_v6 != NULL) | 258 | if (plugin->server_v6 != NULL) |
254 | { | 259 | { |
255 | if (plugin->server_v6_task != GNUNET_SCHEDULER_NO_TASK) | 260 | if (plugin->server_v6_task != GNUNET_SCHEDULER_NO_TASK) |
256 | { | 261 | { |
257 | GNUNET_SCHEDULER_cancel(plugin->server_v6_task); | 262 | GNUNET_SCHEDULER_cancel (plugin->server_v6_task); |
258 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; | 263 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; |
259 | } | 264 | } |
260 | plugin->server_v6_task = server_schedule (plugin, plugin->server_v6, now); | 265 | plugin->server_v6_task = server_schedule (plugin, plugin->server_v6, now); |
261 | } | 266 | } |
262 | } | 267 | } |
263 | 268 | ||
@@ -269,9 +274,10 @@ server_reschedule (struct Plugin *plugin, int now) | |||
269 | */ | 274 | */ |
270 | static void | 275 | static void |
271 | server_receive_mst_cb (void *cls, void *client, | 276 | server_receive_mst_cb (void *cls, void *client, |
272 | const struct GNUNET_MessageHeader *message) | 277 | const struct GNUNET_MessageHeader *message) |
273 | { | 278 | { |
274 | struct Session *s = cls; | 279 | struct Session *s = cls; |
280 | |||
275 | #if VERBOSE_SERVER | 281 | #if VERBOSE_SERVER |
276 | struct Plugin *plugin = s->plugin; | 282 | struct Plugin *plugin = s->plugin; |
277 | #endif | 283 | #endif |
@@ -279,13 +285,16 @@ server_receive_mst_cb (void *cls, void *client, | |||
279 | 285 | ||
280 | delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); | 286 | delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); |
281 | 287 | ||
282 | s->next_receive = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay); | 288 | s->next_receive = |
289 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | ||
283 | 290 | ||
284 | if (delay.rel_value > 0) | 291 | if (delay.rel_value > 0) |
285 | { | 292 | { |
286 | #if VERBOSE_CLIENT | 293 | #if VERBOSE_CLIENT |
287 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Server: peer `%s' address `%s' next read delayed for %llu ms\n", | 294 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
288 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), delay); | 295 | "Server: peer `%s' address `%s' next read delayed for %llu ms\n", |
296 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), | ||
297 | delay); | ||
289 | #endif | 298 | #endif |
290 | } | 299 | } |
291 | } | 300 | } |
@@ -305,6 +314,7 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
305 | 314 | ||
306 | struct HTTP_Message *msg; | 315 | struct HTTP_Message *msg; |
307 | int bytes_read = 0; | 316 | int bytes_read = 0; |
317 | |||
308 | //static int c = 0; | 318 | //static int c = 0; |
309 | msg = s->msg_head; | 319 | msg = s->msg_head; |
310 | if (msg != NULL) | 320 | if (msg != NULL) |
@@ -328,54 +338,58 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
328 | { | 338 | { |
329 | if (NULL != msg->transmit_cont) | 339 | if (NULL != msg->transmit_cont) |
330 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); | 340 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); |
331 | GNUNET_CONTAINER_DLL_remove(s->msg_head, s->msg_tail, msg); | 341 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); |
332 | GNUNET_free (msg); | 342 | GNUNET_free (msg); |
333 | } | 343 | } |
334 | } | 344 | } |
335 | 345 | ||
336 | #if VERBOSE_CLIENT | 346 | #if VERBOSE_CLIENT |
337 | struct Plugin *plugin = s->plugin; | 347 | struct Plugin *plugin = s->plugin; |
348 | |||
338 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 349 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
339 | "Server: %X: sent %u bytes\n", | 350 | "Server: %X: sent %u bytes\n", s, bytes_read); |
340 | s, bytes_read); | ||
341 | #endif | 351 | #endif |
342 | return bytes_read; | 352 | return bytes_read; |
343 | } | 353 | } |
344 | 354 | ||
345 | static struct ServerConnection * | 355 | static struct ServerConnection * |
346 | server_lookup_session (struct Plugin *plugin, | 356 | server_lookup_session (struct Plugin *plugin, |
347 | struct MHD_Connection *mhd_connection, | 357 | struct MHD_Connection *mhd_connection, const char *url, |
348 | const char * url, | 358 | const char *method) |
349 | const char *method) | ||
350 | { | 359 | { |
351 | struct Session *s = NULL; | 360 | struct Session *s = NULL; |
352 | struct Session * t; | 361 | struct Session *t; |
353 | struct ServerConnection *sc = NULL; | 362 | struct ServerConnection *sc = NULL; |
354 | const union MHD_ConnectionInfo *conn_info; | 363 | const union MHD_ConnectionInfo *conn_info; |
355 | 364 | ||
356 | struct IPv4HttpAddress a4; | 365 | struct IPv4HttpAddress a4; |
357 | struct IPv6HttpAddress a6; | 366 | struct IPv6HttpAddress a6; |
358 | struct sockaddr_in * s4; | 367 | struct sockaddr_in *s4; |
359 | struct sockaddr_in6 * s6; | 368 | struct sockaddr_in6 *s6; |
360 | void * a; | 369 | void *a; |
361 | size_t a_len; | 370 | size_t a_len; |
362 | struct GNUNET_PeerIdentity target; | 371 | struct GNUNET_PeerIdentity target; |
363 | int check = GNUNET_NO; | 372 | int check = GNUNET_NO; |
364 | uint32_t tag = 0; | 373 | uint32_t tag = 0; |
365 | int direction; | 374 | int direction; |
366 | 375 | ||
367 | conn_info = MHD_get_connection_info (mhd_connection, MHD_CONNECTION_INFO_CLIENT_ADDRESS); | 376 | conn_info = |
368 | if ((conn_info->client_addr->sa_family != AF_INET) && (conn_info->client_addr->sa_family != AF_INET6)) | 377 | MHD_get_connection_info (mhd_connection, |
378 | MHD_CONNECTION_INFO_CLIENT_ADDRESS); | ||
379 | if ((conn_info->client_addr->sa_family != AF_INET) && | ||
380 | (conn_info->client_addr->sa_family != AF_INET6)) | ||
369 | return MHD_NO; | 381 | return MHD_NO; |
370 | 382 | ||
371 | if ((strlen(&url[1]) >= 105) && (url[104] == ';')) | 383 | if ((strlen (&url[1]) >= 105) && (url[104] == ';')) |
372 | { | 384 | { |
373 | char hash[104]; | 385 | char hash[104]; |
374 | char * tagc = (char *) &url[105]; | 386 | char *tagc = (char *) &url[105]; |
375 | memcpy(&hash, &url[1], 103); | 387 | |
376 | hash [103] = '\0'; | 388 | memcpy (&hash, &url[1], 103); |
377 | if (GNUNET_OK == GNUNET_CRYPTO_hash_from_string ((const char *) &hash, | 389 | hash[103] = '\0'; |
378 | &(target.hashPubKey))) | 390 | if (GNUNET_OK == |
391 | GNUNET_CRYPTO_hash_from_string ((const char *) &hash, | ||
392 | &(target.hashPubKey))) | ||
379 | { | 393 | { |
380 | tag = strtoul (tagc, NULL, 10); | 394 | tag = strtoul (tagc, NULL, 10); |
381 | if (tagc > 0) | 395 | if (tagc > 0) |
@@ -395,7 +409,8 @@ server_lookup_session (struct Plugin *plugin, | |||
395 | 409 | ||
396 | #if VERBOSE_SERVER | 410 | #if VERBOSE_SERVER |
397 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 411 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
398 | "Server: New inbound connection from %s with tag %u\n", GNUNET_i2s(&target), tag); | 412 | "Server: New inbound connection from %s with tag %u\n", |
413 | GNUNET_i2s (&target), tag); | ||
399 | #endif | 414 | #endif |
400 | /* find duplicate session */ | 415 | /* find duplicate session */ |
401 | 416 | ||
@@ -403,17 +418,20 @@ server_lookup_session (struct Plugin *plugin, | |||
403 | 418 | ||
404 | while (t != NULL) | 419 | while (t != NULL) |
405 | { | 420 | { |
406 | if ((t->inbound) && (0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity))) && | 421 | if ((t->inbound) && |
422 | (0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity))) | ||
423 | && | ||
407 | /* FIXME add source address comparison */ | 424 | /* FIXME add source address comparison */ |
408 | (t->tag == tag)) | 425 | (t->tag == tag)) |
409 | break; | 426 | break; |
410 | t = t->next; | 427 | t = t->next; |
411 | } | 428 | } |
412 | if (t != NULL) | 429 | if (t != NULL) |
413 | { | 430 | { |
414 | #if VERBOSE_SERVER | 431 | #if VERBOSE_SERVER |
415 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 432 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
416 | "Server: Duplicate session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | 433 | "Server: Duplicate session, dismissing new connection from peer `%s'\n", |
434 | GNUNET_i2s (&target)); | ||
417 | #endif | 435 | #endif |
418 | goto error; | 436 | goto error; |
419 | } | 437 | } |
@@ -424,8 +442,8 @@ server_lookup_session (struct Plugin *plugin, | |||
424 | while (t != NULL) | 442 | while (t != NULL) |
425 | { | 443 | { |
426 | /* FIXME add source address comparison */ | 444 | /* FIXME add source address comparison */ |
427 | if ((0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity))) && | 445 | if ((0 == memcmp (&t->target, &target, sizeof (struct GNUNET_PeerIdentity))) |
428 | (t->tag == tag)) | 446 | && (t->tag == tag)) |
429 | { | 447 | { |
430 | break; | 448 | break; |
431 | } | 449 | } |
@@ -437,25 +455,29 @@ server_lookup_session (struct Plugin *plugin, | |||
437 | 455 | ||
438 | #if VERBOSE_SERVER | 456 | #if VERBOSE_SERVER |
439 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 457 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
440 | "Server: Found existing semi-session for `%s'\n", GNUNET_i2s (&target)); | 458 | "Server: Found existing semi-session for `%s'\n", |
459 | GNUNET_i2s (&target)); | ||
441 | #endif | 460 | #endif |
442 | 461 | ||
443 | if ((direction == _SEND) && (t->server_send != NULL)) | 462 | if ((direction == _SEND) && (t->server_send != NULL)) |
444 | { | 463 | { |
445 | #if VERBOSE_SERVER | 464 | #if VERBOSE_SERVER |
446 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 465 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
447 | "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | 466 | "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", |
467 | GNUNET_i2s (&target)); | ||
448 | #endif | 468 | #endif |
449 | goto error; | 469 | goto error; |
450 | } | 470 | } |
451 | else | 471 | else |
452 | { | 472 | { |
453 | s = t; | 473 | s = t; |
454 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); | 474 | GNUNET_CONTAINER_DLL_remove (plugin->server_semi_head, |
455 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); | 475 | plugin->server_semi_tail, s); |
476 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); | ||
456 | #if VERBOSE_SERVER | 477 | #if VERBOSE_SERVER |
457 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 478 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
458 | "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); | 479 | "Server: Found matching semi-session, merging session for peer `%s'\n", |
480 | GNUNET_i2s (&target)); | ||
459 | #endif | 481 | #endif |
460 | 482 | ||
461 | goto found; | 483 | goto found; |
@@ -464,18 +486,21 @@ server_lookup_session (struct Plugin *plugin, | |||
464 | { | 486 | { |
465 | #if VERBOSE_SERVER | 487 | #if VERBOSE_SERVER |
466 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 488 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
467 | "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | 489 | "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", |
490 | GNUNET_i2s (&target)); | ||
468 | #endif | 491 | #endif |
469 | goto error; | 492 | goto error; |
470 | } | 493 | } |
471 | else | 494 | else |
472 | { | 495 | { |
473 | s = t; | 496 | s = t; |
474 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); | 497 | GNUNET_CONTAINER_DLL_remove (plugin->server_semi_head, |
475 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); | 498 | plugin->server_semi_tail, s); |
499 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); | ||
476 | #if VERBOSE_SERVER | 500 | #if VERBOSE_SERVER |
477 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 501 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
478 | "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); | 502 | "Server: Found matching semi-session, merging session for peer `%s'\n", |
503 | GNUNET_i2s (&target)); | ||
479 | #endif | 504 | #endif |
480 | goto found; | 505 | goto found; |
481 | } | 506 | } |
@@ -484,53 +509,48 @@ create: | |||
484 | /* create new session */ | 509 | /* create new session */ |
485 | #if VERBOSE_SERVER | 510 | #if VERBOSE_SERVER |
486 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 511 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
487 | "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target)); | 512 | "Server: Creating new session for peer `%s' \n", |
513 | GNUNET_i2s (&target)); | ||
488 | #endif | 514 | #endif |
489 | 515 | ||
490 | switch (conn_info->client_addr->sa_family) | 516 | switch (conn_info->client_addr->sa_family) |
491 | { | 517 | { |
492 | case (AF_INET): | 518 | case (AF_INET): |
493 | s4 = ((struct sockaddr_in * ) conn_info->client_addr); | 519 | s4 = ((struct sockaddr_in *) conn_info->client_addr); |
494 | a4.u4_port = s4->sin_port; | 520 | a4.u4_port = s4->sin_port; |
495 | memcpy (&a4.ipv4_addr, &s4->sin_addr, | 521 | memcpy (&a4.ipv4_addr, &s4->sin_addr, sizeof (struct in_addr)); |
496 | sizeof (struct in_addr)); | 522 | a = &a4; |
497 | a = &a4; | 523 | a_len = sizeof (struct IPv4HttpAddress); |
498 | a_len = sizeof (struct IPv4HttpAddress); | 524 | break; |
499 | break; | ||
500 | case (AF_INET6): | 525 | case (AF_INET6): |
501 | s6 = ((struct sockaddr_in6 * ) conn_info->client_addr); | 526 | s6 = ((struct sockaddr_in6 *) conn_info->client_addr); |
502 | a6.u6_port = s6->sin6_port; | 527 | a6.u6_port = s6->sin6_port; |
503 | memcpy (&a6.ipv6_addr, &s6->sin6_addr, | 528 | memcpy (&a6.ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr)); |
504 | sizeof (struct in6_addr)); | 529 | a = &a6; |
505 | a = &a6; | 530 | a_len = sizeof (struct IPv6HttpAddress); |
506 | a_len = sizeof (struct IPv6HttpAddress); | 531 | break; |
507 | break; | ||
508 | default: | 532 | default: |
509 | GNUNET_break (0); | 533 | GNUNET_break (0); |
510 | goto error; | 534 | goto error; |
511 | } | 535 | } |
512 | 536 | ||
513 | s = create_session (plugin, | 537 | s = create_session (plugin, &target, a, a_len, NULL, NULL); |
514 | &target, | ||
515 | a, | ||
516 | a_len, | ||
517 | NULL, | ||
518 | NULL); | ||
519 | 538 | ||
520 | s->inbound = GNUNET_YES; | 539 | s->inbound = GNUNET_YES; |
521 | s->next_receive = GNUNET_TIME_absolute_get_zero(); | 540 | s->next_receive = GNUNET_TIME_absolute_get_zero (); |
522 | s->tag= tag; | 541 | s->tag = tag; |
523 | if (0 == strcmp (MHD_HTTP_METHOD_PUT, method)) | 542 | if (0 == strcmp (MHD_HTTP_METHOD_PUT, method)) |
524 | s->server_recv = s; | 543 | s->server_recv = s; |
525 | if (0 == strcmp (MHD_HTTP_METHOD_GET, method)) | 544 | if (0 == strcmp (MHD_HTTP_METHOD_GET, method)) |
526 | s->server_send = s; | 545 | s->server_send = s; |
527 | GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head, plugin->server_semi_tail, s); | 546 | GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head, |
547 | plugin->server_semi_tail, s); | ||
528 | goto found; | 548 | goto found; |
529 | 549 | ||
530 | error: | 550 | error: |
531 | #if VERBOSE_SERVER | 551 | #if VERBOSE_SERVER |
532 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 552 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
533 | "Server: Invalid connection request\n"); | 553 | "Server: Invalid connection request\n"); |
534 | #endif | 554 | #endif |
535 | return NULL; | 555 | return NULL; |
536 | 556 | ||
@@ -546,6 +566,7 @@ found: | |||
546 | 566 | ||
547 | #if MHD_VERSION >= 0x00090E00 | 567 | #if MHD_VERSION >= 0x00090E00 |
548 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); | 568 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); |
569 | |||
549 | #if VERBOSE_SERVER | 570 | #if VERBOSE_SERVER |
550 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 571 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
551 | "Server: Setting timeout for %X to %u sec.\n", sc, to); | 572 | "Server: Setting timeout for %X to %u sec.\n", sc, to); |
@@ -581,12 +602,14 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
581 | /* new connection */ | 602 | /* new connection */ |
582 | if (sc == NULL) | 603 | if (sc == NULL) |
583 | { | 604 | { |
584 | sc = server_lookup_session(plugin, mhd_connection, url, method); | 605 | sc = server_lookup_session (plugin, mhd_connection, url, method); |
585 | if (sc != NULL) | 606 | if (sc != NULL) |
586 | (*httpSessionCache) = sc; | 607 | (*httpSessionCache) = sc; |
587 | else | 608 | else |
588 | { | 609 | { |
589 | response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); | 610 | response = |
611 | MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE), | ||
612 | HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); | ||
590 | res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); | 613 | res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); |
591 | MHD_destroy_response (response); | 614 | MHD_destroy_response (response); |
592 | return res; | 615 | return res; |
@@ -597,10 +620,12 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
597 | sc = (*httpSessionCache); | 620 | sc = (*httpSessionCache); |
598 | s = sc->session; | 621 | s = sc->session; |
599 | 622 | ||
600 | /* connection is to be disconnected*/ | 623 | /* connection is to be disconnected */ |
601 | if (sc->disconnect == GNUNET_YES) | 624 | if (sc->disconnect == GNUNET_YES) |
602 | { | 625 | { |
603 | response = MHD_create_response_from_data (strlen ("Thank you!"), "Thank you!", MHD_NO, MHD_NO); | 626 | response = |
627 | MHD_create_response_from_data (strlen ("Thank you!"), "Thank you!", | ||
628 | MHD_NO, MHD_NO); | ||
604 | res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); | 629 | res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); |
605 | #if VERBOSE_SERVER | 630 | #if VERBOSE_SERVER |
606 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 631 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -613,7 +638,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
613 | GNUNET_assert (s != NULL); | 638 | GNUNET_assert (s != NULL); |
614 | if (sc->direction == _SEND) | 639 | if (sc->direction == _SEND) |
615 | { | 640 | { |
616 | response = MHD_create_response_from_callback (-1, 32 * 1024, &server_send_callback, | 641 | response = |
642 | MHD_create_response_from_callback (-1, 32 * 1024, &server_send_callback, | ||
617 | s, NULL); | 643 | s, NULL); |
618 | res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); | 644 | res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); |
619 | MHD_destroy_response (response); | 645 | MHD_destroy_response (response); |
@@ -624,9 +650,10 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
624 | if (*upload_data_size == 0) | 650 | if (*upload_data_size == 0) |
625 | { | 651 | { |
626 | #if VERBOSE_SERVER | 652 | #if VERBOSE_SERVER |
627 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 653 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
628 | "Server: Peer `%s' PUT on address `%s' connected\n", | 654 | "Server: Peer `%s' PUT on address `%s' connected\n", |
629 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); | 655 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, |
656 | s->addrlen)); | ||
630 | #endif | 657 | #endif |
631 | return MHD_YES; | 658 | return MHD_YES; |
632 | } | 659 | } |
@@ -635,23 +662,28 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
635 | if ((*upload_data_size > 0)) | 662 | if ((*upload_data_size > 0)) |
636 | { | 663 | { |
637 | #if VERBOSE_SERVER | 664 | #if VERBOSE_SERVER |
638 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 665 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
639 | "Server: peer `%s' PUT on address `%s' received %Zu bytes\n", | 666 | "Server: peer `%s' PUT on address `%s' received %Zu bytes\n", |
640 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), *upload_data_size); | 667 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, |
668 | s->addrlen), | ||
669 | *upload_data_size); | ||
641 | #endif | 670 | #endif |
642 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); | 671 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
643 | if (( s->next_receive.abs_value <= now.abs_value)) | 672 | |
673 | if ((s->next_receive.abs_value <= now.abs_value)) | ||
644 | { | 674 | { |
645 | #if VERBOSE_SERVER | 675 | #if VERBOSE_SERVER |
646 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 676 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
647 | "Server: %X: PUT with %u bytes forwarded to MST\n", s, | 677 | "Server: %X: PUT with %u bytes forwarded to MST\n", s, |
648 | *upload_data_size); | 678 | *upload_data_size); |
649 | #endif | 679 | #endif |
650 | if (s->msg_tk == NULL) | 680 | if (s->msg_tk == NULL) |
651 | { | 681 | { |
652 | s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s); | 682 | s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s); |
653 | } | 683 | } |
654 | res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO); | 684 | res = |
685 | GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, | ||
686 | *upload_data_size, GNUNET_NO, GNUNET_NO); | ||
655 | 687 | ||
656 | #if MHD_VERSION >= 0x00090E00 | 688 | #if MHD_VERSION >= 0x00090E00 |
657 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); | 689 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); |
@@ -668,18 +700,22 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
668 | t = s->server_recv; | 700 | t = s->server_recv; |
669 | #if VERBOSE_SERVER | 701 | #if VERBOSE_SERVER |
670 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 702 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
671 | "Server: Setting timeout for %X to %u sec.\n", t, to); | 703 | "Server: Setting timeout for %X to %u sec.\n", t, |
704 | to); | ||
672 | #endif | 705 | #endif |
673 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, to); | 706 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, |
707 | to); | ||
674 | } | 708 | } |
675 | if (s->server_send != NULL) | 709 | if (s->server_send != NULL) |
676 | { | 710 | { |
677 | t = s->server_send; | 711 | t = s->server_send; |
678 | #if VERBOSE_SERVER | 712 | #if VERBOSE_SERVER |
679 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 713 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
680 | "Server: Setting timeout for %X to %u sec.\n", t, to); | 714 | "Server: Setting timeout for %X to %u sec.\n", t, |
715 | to); | ||
681 | #endif | 716 | #endif |
682 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, to); | 717 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, |
718 | to); | ||
683 | } | 719 | } |
684 | server_reschedule (plugin, GNUNET_NO); | 720 | server_reschedule (plugin, GNUNET_NO); |
685 | #endif | 721 | #endif |
@@ -688,8 +724,9 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
688 | else | 724 | else |
689 | { | 725 | { |
690 | #if DEBUG_HTTP | 726 | #if DEBUG_HTTP |
691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
692 | "Server: %X no inbound bandwidth available! Next read was delayed by %llu ms\n", s, now.abs_value - s->next_receive.abs_value); | 728 | "Server: %X no inbound bandwidth available! Next read was delayed by %llu ms\n", |
729 | s, now.abs_value - s->next_receive.abs_value); | ||
693 | #endif | 730 | #endif |
694 | } | 731 | } |
695 | return MHD_YES; | 732 | return MHD_YES; |
@@ -706,22 +743,22 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
706 | { | 743 | { |
707 | struct ServerConnection *sc = *httpSessionCache; | 744 | struct ServerConnection *sc = *httpSessionCache; |
708 | struct ServerConnection *tc = *httpSessionCache; | 745 | struct ServerConnection *tc = *httpSessionCache; |
709 | struct Session * s = NULL; | 746 | struct Session *s = NULL; |
710 | struct Session * t = NULL; | 747 | struct Session *t = NULL; |
711 | struct Plugin * plugin = NULL; | 748 | struct Plugin *plugin = NULL; |
712 | 749 | ||
713 | if (sc == NULL) | 750 | if (sc == NULL) |
714 | return; | 751 | return; |
715 | 752 | ||
716 | s = sc->session; | 753 | s = sc->session; |
717 | plugin = s-> plugin; | 754 | plugin = s->plugin; |
718 | if (sc->direction == _SEND) | 755 | if (sc->direction == _SEND) |
719 | { | 756 | { |
720 | #if VERBOSE_SERVER | 757 | #if VERBOSE_SERVER |
721 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 758 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
722 | "Server: %X peer `%s' GET on address `%s' disconnected\n", | 759 | "Server: %X peer `%s' GET on address `%s' disconnected\n", |
723 | s->server_send, | 760 | s->server_send, GNUNET_i2s (&s->target), |
724 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); | 761 | GNUNET_a2s (s->addr, s->addrlen)); |
725 | #endif | 762 | #endif |
726 | s->server_send = NULL; | 763 | s->server_send = NULL; |
727 | 764 | ||
@@ -730,17 +767,18 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
730 | tc = s->server_recv; | 767 | tc = s->server_recv; |
731 | tc->disconnect = GNUNET_YES; | 768 | tc->disconnect = GNUNET_YES; |
732 | #if MHD_VERSION >= 0x00090E00 | 769 | #if MHD_VERSION >= 0x00090E00 |
733 | MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, 1); | 770 | MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, |
771 | 1); | ||
734 | #endif | 772 | #endif |
735 | } | 773 | } |
736 | } | 774 | } |
737 | if (sc->direction == _RECEIVE) | 775 | if (sc->direction == _RECEIVE) |
738 | { | 776 | { |
739 | #if VERBOSE_SERVER | 777 | #if VERBOSE_SERVER |
740 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 778 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
741 | "Server: %X peer `%s' PUT on address `%s' disconnected\n", | 779 | "Server: %X peer `%s' PUT on address `%s' disconnected\n", |
742 | s->server_recv, | 780 | s->server_recv, GNUNET_i2s (&s->target), |
743 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); | 781 | GNUNET_a2s (s->addr, s->addrlen)); |
744 | #endif | 782 | #endif |
745 | s->server_recv = NULL; | 783 | s->server_recv = NULL; |
746 | if (s->server_send != NULL) | 784 | if (s->server_send != NULL) |
@@ -748,13 +786,14 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
748 | tc = s->server_send; | 786 | tc = s->server_send; |
749 | tc->disconnect = GNUNET_YES; | 787 | tc->disconnect = GNUNET_YES; |
750 | #if MHD_VERSION >= 0x00090E00 | 788 | #if MHD_VERSION >= 0x00090E00 |
751 | MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, 1); | 789 | MHD_set_connection_option (sc->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, |
790 | 1); | ||
752 | #endif | 791 | #endif |
753 | } | 792 | } |
754 | if (s->msg_tk != NULL) | 793 | if (s->msg_tk != NULL) |
755 | { | 794 | { |
756 | GNUNET_SERVER_mst_destroy(s->msg_tk); | 795 | GNUNET_SERVER_mst_destroy (s->msg_tk); |
757 | s->msg_tk = NULL; | 796 | s->msg_tk = NULL; |
758 | } | 797 | } |
759 | } | 798 | } |
760 | GNUNET_free (sc); | 799 | GNUNET_free (sc); |
@@ -764,8 +803,9 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
764 | { | 803 | { |
765 | if (t == s) | 804 | if (t == s) |
766 | { | 805 | { |
767 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); | 806 | GNUNET_CONTAINER_DLL_remove (plugin->server_semi_head, |
768 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); | 807 | plugin->server_semi_tail, s); |
808 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); | ||
769 | break; | 809 | break; |
770 | } | 810 | } |
771 | t = t->next; | 811 | t = t->next; |
@@ -777,17 +817,17 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
777 | if ((s->server_send == NULL) && (s->server_recv == NULL)) | 817 | if ((s->server_send == NULL) && (s->server_recv == NULL)) |
778 | { | 818 | { |
779 | #if VERBOSE_SERVER | 819 | #if VERBOSE_SERVER |
780 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 820 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
781 | "Server: peer `%s' on address `%s' disconnected\n", | 821 | "Server: peer `%s' on address `%s' disconnected\n", |
782 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); | 822 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); |
783 | #endif | 823 | #endif |
784 | if (s->msg_tk != NULL) | 824 | if (s->msg_tk != NULL) |
785 | { | 825 | { |
786 | GNUNET_SERVER_mst_destroy(s->msg_tk); | 826 | GNUNET_SERVER_mst_destroy (s->msg_tk); |
787 | s->msg_tk = NULL; | 827 | s->msg_tk = NULL; |
788 | } | 828 | } |
789 | 829 | ||
790 | notify_session_end(s->plugin, &s->target, s); | 830 | notify_session_end (s->plugin, &s->target, s); |
791 | } | 831 | } |
792 | } | 832 | } |
793 | 833 | ||
@@ -818,7 +858,7 @@ server_disconnect (struct Session *s) | |||
818 | } | 858 | } |
819 | 859 | ||
820 | int | 860 | int |
821 | server_send (struct Session *s, struct HTTP_Message * msg) | 861 | server_send (struct Session *s, struct HTTP_Message *msg) |
822 | { | 862 | { |
823 | GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); | 863 | GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); |
824 | server_reschedule (s->plugin, GNUNET_YES); | 864 | server_reschedule (s->plugin, GNUNET_YES); |
@@ -834,10 +874,10 @@ server_send (struct Session *s, struct HTTP_Message * msg) | |||
834 | * @param tc task context | 874 | * @param tc task context |
835 | */ | 875 | */ |
836 | static void | 876 | static void |
837 | server_v4_run (void *cls, | 877 | server_v4_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
838 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
839 | { | 878 | { |
840 | struct Plugin *plugin = cls; | 879 | struct Plugin *plugin = cls; |
880 | |||
841 | GNUNET_assert (cls != NULL); | 881 | GNUNET_assert (cls != NULL); |
842 | 882 | ||
843 | plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; | 883 | plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -847,7 +887,8 @@ server_v4_run (void *cls, | |||
847 | 887 | ||
848 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); | 888 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); |
849 | if (plugin->server_v4 != NULL) | 889 | if (plugin->server_v4 != NULL) |
850 | plugin->server_v4_task = server_schedule (plugin, plugin->server_v4, GNUNET_NO); | 890 | plugin->server_v4_task = |
891 | server_schedule (plugin, plugin->server_v4, GNUNET_NO); | ||
851 | } | 892 | } |
852 | 893 | ||
853 | 894 | ||
@@ -858,10 +899,10 @@ server_v4_run (void *cls, | |||
858 | * @param tc task context | 899 | * @param tc task context |
859 | */ | 900 | */ |
860 | static void | 901 | static void |
861 | server_v6_run (void *cls, | 902 | server_v6_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
862 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
863 | { | 903 | { |
864 | struct Plugin *plugin = cls; | 904 | struct Plugin *plugin = cls; |
905 | |||
865 | GNUNET_assert (cls != NULL); | 906 | GNUNET_assert (cls != NULL); |
866 | 907 | ||
867 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; | 908 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -871,7 +912,8 @@ server_v6_run (void *cls, | |||
871 | 912 | ||
872 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); | 913 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); |
873 | if (plugin->server_v6 != NULL) | 914 | if (plugin->server_v6 != NULL) |
874 | plugin->server_v6_task = server_schedule (plugin, plugin->server_v6, GNUNET_NO); | 915 | plugin->server_v6_task = |
916 | server_schedule (plugin, plugin->server_v6, GNUNET_NO); | ||
875 | } | 917 | } |
876 | 918 | ||
877 | /** | 919 | /** |
@@ -882,7 +924,8 @@ server_v6_run (void *cls, | |||
882 | * @return gnunet task identifier | 924 | * @return gnunet task identifier |
883 | */ | 925 | */ |
884 | static GNUNET_SCHEDULER_TaskIdentifier | 926 | static GNUNET_SCHEDULER_TaskIdentifier |
885 | server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int now) | 927 | server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, |
928 | int now) | ||
886 | { | 929 | { |
887 | GNUNET_SCHEDULER_TaskIdentifier ret; | 930 | GNUNET_SCHEDULER_TaskIdentifier ret; |
888 | fd_set rs; | 931 | fd_set rs; |
@@ -909,7 +952,7 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int no | |||
909 | GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max)); | 952 | GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max)); |
910 | haveto = MHD_get_timeout (daemon_handle, &timeout); | 953 | haveto = MHD_get_timeout (daemon_handle, &timeout); |
911 | if (haveto == MHD_YES) | 954 | if (haveto == MHD_YES) |
912 | { | 955 | { |
913 | if (timeout != last_timeout) | 956 | if (timeout != last_timeout) |
914 | { | 957 | { |
915 | #if VERBOSE_SERVER | 958 | #if VERBOSE_SERVER |
@@ -920,7 +963,7 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, int no | |||
920 | last_timeout = timeout; | 963 | last_timeout = timeout; |
921 | } | 964 | } |
922 | tv.rel_value = (uint64_t) timeout; | 965 | tv.rel_value = (uint64_t) timeout; |
923 | } | 966 | } |
924 | else | 967 | else |
925 | tv = GNUNET_TIME_UNIT_SECONDS; | 968 | tv = GNUNET_TIME_UNIT_SECONDS; |
926 | /* Force immediate run, since we have outbound data to send */ | 969 | /* Force immediate run, since we have outbound data to send */ |
@@ -972,7 +1015,7 @@ server_start (struct Plugin *plugin) | |||
972 | if (res == GNUNET_SYSERR) | 1015 | if (res == GNUNET_SYSERR) |
973 | { | 1016 | { |
974 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1017 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
975 | "Could not load or create server certificate! Loading plugin failed!\n"); | 1018 | "Could not load or create server certificate! Loading plugin failed!\n"); |
976 | return res; | 1019 | return res; |
977 | } | 1020 | } |
978 | #endif | 1021 | #endif |
@@ -981,11 +1024,13 @@ server_start (struct Plugin *plugin) | |||
981 | #if MHD_VERSION >= 0x00090E00 | 1024 | #if MHD_VERSION >= 0x00090E00 |
982 | timeout = GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT.rel_value / 1000; | 1025 | timeout = GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT.rel_value / 1000; |
983 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1026 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
984 | "MHD can set timeout per connection! Default time out %u sec.\n", timeout); | 1027 | "MHD can set timeout per connection! Default time out %u sec.\n", |
1028 | timeout); | ||
985 | #else | 1029 | #else |
986 | timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000; | 1030 | timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000; |
987 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, | 1031 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, |
988 | "MHD cannot set timeout per connection! Default time out %u sec.\n", timeout); | 1032 | "MHD cannot set timeout per connection! Default time out %u sec.\n", |
1033 | timeout); | ||
989 | #endif | 1034 | #endif |
990 | plugin->server_v4 = NULL; | 1035 | plugin->server_v4 = NULL; |
991 | if (plugin->ipv4 == GNUNET_YES) | 1036 | if (plugin->ipv4 == GNUNET_YES) |
@@ -1015,7 +1060,7 @@ server_start (struct Plugin *plugin) | |||
1015 | plugin->cert, | 1060 | plugin->cert, |
1016 | #endif | 1061 | #endif |
1017 | MHD_OPTION_CONNECTION_TIMEOUT, | 1062 | MHD_OPTION_CONNECTION_TIMEOUT, |
1018 | timeout , | 1063 | timeout, |
1019 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 1064 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
1020 | (size_t) (2 * | 1065 | (size_t) (2 * |
1021 | GNUNET_SERVER_MAX_MESSAGE_SIZE), | 1066 | GNUNET_SERVER_MAX_MESSAGE_SIZE), |
@@ -1066,15 +1111,15 @@ server_start (struct Plugin *plugin) | |||
1066 | if ((plugin->ipv4 == GNUNET_YES) && (plugin->server_v4 == NULL)) | 1111 | if ((plugin->ipv4 == GNUNET_YES) && (plugin->server_v4 == NULL)) |
1067 | { | 1112 | { |
1068 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1113 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
1069 | "Failed to start %s IPv4 server component on port %u\n", plugin->name, | 1114 | "Failed to start %s IPv4 server component on port %u\n", |
1070 | plugin->port); | 1115 | plugin->name, plugin->port); |
1071 | return GNUNET_SYSERR; | 1116 | return GNUNET_SYSERR; |
1072 | } | 1117 | } |
1073 | if ((plugin->ipv6 == GNUNET_YES) && (plugin->server_v6 == NULL)) | 1118 | if ((plugin->ipv6 == GNUNET_YES) && (plugin->server_v6 == NULL)) |
1074 | { | 1119 | { |
1075 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1120 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
1076 | "Failed to start %s IPv6 server component on port %u\n", plugin->name, | 1121 | "Failed to start %s IPv6 server component on port %u\n", |
1077 | plugin->port); | 1122 | plugin->name, plugin->port); |
1078 | return GNUNET_SYSERR; | 1123 | return GNUNET_SYSERR; |
1079 | } | 1124 | } |
1080 | 1125 | ||
@@ -1095,8 +1140,10 @@ server_stop (struct Plugin *plugin) | |||
1095 | struct Session *t = NULL; | 1140 | struct Session *t = NULL; |
1096 | 1141 | ||
1097 | struct MHD_Daemon *server_v4_tmp = plugin->server_v4; | 1142 | struct MHD_Daemon *server_v4_tmp = plugin->server_v4; |
1143 | |||
1098 | plugin->server_v4 = NULL; | 1144 | plugin->server_v4 = NULL; |
1099 | struct MHD_Daemon *server_v6_tmp = plugin->server_v6; | 1145 | struct MHD_Daemon *server_v6_tmp = plugin->server_v6; |
1146 | |||
1100 | plugin->server_v6 = NULL; | 1147 | plugin->server_v6 = NULL; |
1101 | 1148 | ||
1102 | if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) | 1149 | if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) |
diff --git a/src/transport/plugin_transport_sat_constants.h b/src/transport/plugin_transport_sat_constants.h index a9ee9227c..bd64c5d2b 100644 --- a/src/transport/plugin_transport_sat_constants.h +++ b/src/transport/plugin_transport_sat_constants.h | |||
@@ -32,22 +32,26 @@ | |||
32 | 32 | ||
33 | typedef struct MacAdress | 33 | typedef struct MacAdress |
34 | { | 34 | { |
35 | uint8_t mac[6]; | 35 | uint8_t mac[6]; |
36 | }MacAdress; | 36 | } MacAdress; |
37 | 37 | ||
38 | //praeamble | 38 | //praeamble |
39 | static const struct char praeambel[56] = | 39 | static const struct char praeambel[56] = |
40 | {{1,0,1,0,10,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}}; | 40 | { {1, 0, 1, 0, 10, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, |
41 | 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, | ||
42 | 0, 1, 0, 1, 0, 1, 0} | ||
43 | }; | ||
41 | 44 | ||
42 | //start of frame | 45 | //start of frame |
43 | static const struct char sof[8]= | 46 | static const struct char sof[8] = { {1, 0, 1, 0, 1, 0, 1, 1} } |
44 | {{1,0,1,0,1,0,1,1}} | ||
45 | 47 | ||
46 | // broadcast mac | 48 | // broadcast mac |
47 | static const struct MacAddress bc_all_mac = | 49 | static const struct MacAddress bc_all_mac = |
48 | { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }; | 50 | { {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }; |
49 | 51 | ||
50 | //crc polynom | 52 | //crc polynom |
51 | static const struct char ploynom[32] = | 53 | static const struct char ploynom[32] = |
52 | {{1,1,1,0,1,1,0,1,1,0,1,1,1,0,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1}}; | 54 | { {1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, |
55 | 0, 0, 1, 0, 0, 0, 0, 1} | ||
56 | }; | ||
53 | #endif | 57 | #endif |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 04ba348b3..9c6535988 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -696,10 +696,9 @@ do_transmit (void *cls, size_t size, void *buf) | |||
696 | GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, | 696 | GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, |
697 | session->pending_messages_tail, pos); | 697 | session->pending_messages_tail, pos); |
698 | GNUNET_assert (size >= pos->message_size); | 698 | GNUNET_assert (size >= pos->message_size); |
699 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 699 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", |
700 | "tcp", | 700 | "Transmitting message of type %u\n", |
701 | "Transmitting message of type %u\n", | 701 | ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type)); |
702 | ntohs (((struct GNUNET_MessageHeader*)pos->msg)->type)); | ||
703 | /* FIXME: this memcpy can be up to 7% of our total runtime */ | 702 | /* FIXME: this memcpy can be up to 7% of our total runtime */ |
704 | memcpy (cbuf, pos->msg, pos->message_size); | 703 | memcpy (cbuf, pos->msg, pos->message_size); |
705 | cbuf += pos->message_size; | 704 | cbuf += pos->message_size; |
@@ -1002,7 +1001,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1002 | { | 1001 | { |
1003 | if (addrlen == sizeof (struct IPv6TcpAddress)) | 1002 | if (addrlen == sizeof (struct IPv6TcpAddress)) |
1004 | { | 1003 | { |
1005 | GNUNET_assert (NULL != addr); /* make static analysis happy */ | 1004 | GNUNET_assert (NULL != addr); /* make static analysis happy */ |
1006 | t6 = addr; | 1005 | t6 = addr; |
1007 | af = AF_INET6; | 1006 | af = AF_INET6; |
1008 | memset (&a6, 0, sizeof (a6)); | 1007 | memset (&a6, 0, sizeof (a6)); |
@@ -1019,7 +1018,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1019 | } | 1018 | } |
1020 | else if (addrlen == sizeof (struct IPv4TcpAddress)) | 1019 | else if (addrlen == sizeof (struct IPv4TcpAddress)) |
1021 | { | 1020 | { |
1022 | GNUNET_assert (NULL != addr); /* make static analysis happy */ | 1021 | GNUNET_assert (NULL != addr); /* make static analysis happy */ |
1023 | t4 = addr; | 1022 | t4 = addr; |
1024 | af = AF_INET; | 1023 | af = AF_INET; |
1025 | memset (&a4, 0, sizeof (a4)); | 1024 | memset (&a4, 0, sizeof (a4)); |
@@ -1073,7 +1072,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1073 | 1072 | ||
1074 | /* append pm to pending_messages list */ | 1073 | /* append pm to pending_messages list */ |
1075 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head, | 1074 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head, |
1076 | session->pending_messages_tail, pm); | 1075 | session->pending_messages_tail, pm); |
1077 | 1076 | ||
1078 | GNUNET_assert (GNUNET_CONTAINER_multihashmap_put | 1077 | GNUNET_assert (GNUNET_CONTAINER_multihashmap_put |
1079 | (plugin->nat_wait_conns, &target->hashPubKey, session, | 1078 | (plugin->nat_wait_conns, &target->hashPubKey, session, |
@@ -1129,16 +1128,14 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1129 | /* check if session is valid */ | 1128 | /* check if session is valid */ |
1130 | struct Session *ses = plugin->sessions; | 1129 | struct Session *ses = plugin->sessions; |
1131 | 1130 | ||
1132 | if (0 != memcmp (target, | 1131 | if (0 != |
1133 | &session->target, | 1132 | memcmp (target, &session->target, sizeof (struct GNUNET_PeerIdentity))) |
1134 | sizeof (struct GNUNET_PeerIdentity))) | ||
1135 | { | 1133 | { |
1136 | GNUNET_break (0); | 1134 | GNUNET_break (0); |
1137 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1135 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1138 | "Got session %p for `%s', but should be for peer `%s'!\n", | 1136 | "Got session %p for `%s', but should be for peer `%s'!\n", |
1139 | session, | 1137 | session, GNUNET_i2s (&session->target), |
1140 | GNUNET_i2s (&session->target), | 1138 | GNUNET_h2s (&target->hashPubKey)); |
1141 | GNUNET_h2s (&target->hashPubKey)); | ||
1142 | return -1; | 1139 | return -1; |
1143 | } | 1140 | } |
1144 | 1141 | ||
@@ -1170,7 +1167,7 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
1170 | 1167 | ||
1171 | /* append pm to pending_messages list */ | 1168 | /* append pm to pending_messages list */ |
1172 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head, | 1169 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head, |
1173 | session->pending_messages_tail, pm); | 1170 | session->pending_messages_tail, pm); |
1174 | #if DEBUG_TCP | 1171 | #if DEBUG_TCP |
1175 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", | 1172 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", |
1176 | "Asked to transmit %u bytes to `%s', added message to list.\n", | 1173 | "Asked to transmit %u bytes to `%s', added message to list.\n", |
@@ -1741,8 +1738,8 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
1741 | distance.value = htonl (1); | 1738 | distance.value = htonl (1); |
1742 | delay = | 1739 | delay = |
1743 | plugin->env->receive (plugin->env->cls, &session->target, message, | 1740 | plugin->env->receive (plugin->env->cls, &session->target, message, |
1744 | (const struct GNUNET_ATS_Information *) | 1741 | (const struct GNUNET_ATS_Information *) &distance, |
1745 | &distance, 1, session, | 1742 | 1, session, |
1746 | (GNUNET_YES == | 1743 | (GNUNET_YES == |
1747 | session->inbound) ? NULL : session->connect_addr, | 1744 | session->inbound) ? NULL : session->connect_addr, |
1748 | (GNUNET_YES == | 1745 | (GNUNET_YES == |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index cf6e01306..667af25be 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -120,12 +120,12 @@ struct UDP_Beacon_Message | |||
120 | /** | 120 | /** |
121 | * Message header. | 121 | * Message header. |
122 | */ | 122 | */ |
123 | struct GNUNET_MessageHeader header; | 123 | struct GNUNET_MessageHeader header; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * What is the identity of the sender | 126 | * What is the identity of the sender |
127 | */ | 127 | */ |
128 | struct GNUNET_PeerIdentity sender; | 128 | struct GNUNET_PeerIdentity sender; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | 131 | ||
@@ -396,8 +396,8 @@ struct Plugin | |||
396 | 396 | ||
397 | struct PeerSessionIteratorContext | 397 | struct PeerSessionIteratorContext |
398 | { | 398 | { |
399 | struct Session * result; | 399 | struct Session *result; |
400 | const void * addr; | 400 | const void *addr; |
401 | size_t addrlen; | 401 | size_t addrlen; |
402 | }; | 402 | }; |
403 | 403 | ||
@@ -417,13 +417,12 @@ find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer) | |||
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | static int | 420 | static int |
421 | inbound_session_iterator (void *cls, | 421 | inbound_session_iterator (void *cls, const GNUNET_HashCode * key, void *value) |
422 | const GNUNET_HashCode * key, | ||
423 | void *value) | ||
424 | { | 422 | { |
425 | struct PeerSessionIteratorContext *psc = cls; | 423 | struct PeerSessionIteratorContext *psc = cls; |
426 | struct Session *s = value; | 424 | struct Session *s = value; |
425 | |||
427 | if (s->addrlen == psc->addrlen) | 426 | if (s->addrlen == psc->addrlen) |
428 | { | 427 | { |
429 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) | 428 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) |
@@ -444,26 +443,29 @@ inbound_session_iterator (void *cls, | |||
444 | */ | 443 | */ |
445 | static struct Session * | 444 | static struct Session * |
446 | find_inbound_session (struct Plugin *plugin, | 445 | find_inbound_session (struct Plugin *plugin, |
447 | const struct GNUNET_PeerIdentity *peer, | 446 | const struct GNUNET_PeerIdentity *peer, const void *addr, |
448 | const void * addr, size_t addrlen) | 447 | size_t addrlen) |
449 | { | 448 | { |
450 | struct PeerSessionIteratorContext psc; | 449 | struct PeerSessionIteratorContext psc; |
450 | |||
451 | psc.result = NULL; | 451 | psc.result = NULL; |
452 | psc.addrlen = addrlen; | 452 | psc.addrlen = addrlen; |
453 | psc.addr = addr; | 453 | psc.addr = addr; |
454 | 454 | ||
455 | GNUNET_CONTAINER_multihashmap_get_multiple(plugin->inbound_sessions, &peer->hashPubKey, &inbound_session_iterator, &psc); | 455 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions, |
456 | &peer->hashPubKey, | ||
457 | &inbound_session_iterator, &psc); | ||
456 | return psc.result; | 458 | return psc.result; |
457 | } | 459 | } |
458 | 460 | ||
459 | 461 | ||
460 | static int | 462 | static int |
461 | inbound_session_by_addr_iterator (void *cls, | 463 | inbound_session_by_addr_iterator (void *cls, const GNUNET_HashCode * key, |
462 | const GNUNET_HashCode * key, | 464 | void *value) |
463 | void *value) | ||
464 | { | 465 | { |
465 | struct PeerSessionIteratorContext *psc = cls; | 466 | struct PeerSessionIteratorContext *psc = cls; |
466 | struct Session *s = value; | 467 | struct Session *s = value; |
468 | |||
467 | if (s->addrlen == psc->addrlen) | 469 | if (s->addrlen == psc->addrlen) |
468 | { | 470 | { |
469 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) | 471 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) |
@@ -484,14 +486,18 @@ inbound_session_by_addr_iterator (void *cls, | |||
484 | * @return NULL if we have no session | 486 | * @return NULL if we have no session |
485 | */ | 487 | */ |
486 | static struct Session * | 488 | static struct Session * |
487 | find_inbound_session_by_addr (struct Plugin *plugin, const void * addr, size_t addrlen) | 489 | find_inbound_session_by_addr (struct Plugin *plugin, const void *addr, |
490 | size_t addrlen) | ||
488 | { | 491 | { |
489 | struct PeerSessionIteratorContext psc; | 492 | struct PeerSessionIteratorContext psc; |
493 | |||
490 | psc.result = NULL; | 494 | psc.result = NULL; |
491 | psc.addrlen = addrlen; | 495 | psc.addrlen = addrlen; |
492 | psc.addr = addr; | 496 | psc.addr = addr; |
493 | 497 | ||
494 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &inbound_session_by_addr_iterator, &psc); | 498 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, |
499 | &inbound_session_by_addr_iterator, | ||
500 | &psc); | ||
495 | return psc.result; | 501 | return psc.result; |
496 | } | 502 | } |
497 | 503 | ||
@@ -531,7 +537,7 @@ destroy_inbound_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
531 | struct Session *s = value; | 537 | struct Session *s = value; |
532 | 538 | ||
533 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) | 539 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) |
534 | GNUNET_SCHEDULER_cancel(s->invalidation_task); | 540 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
535 | if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) | 541 | if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) |
536 | GNUNET_SCHEDULER_cancel (s->delayed_cont_task); | 542 | GNUNET_SCHEDULER_cancel (s->delayed_cont_task); |
537 | GNUNET_free (s); | 543 | GNUNET_free (s); |
@@ -560,11 +566,10 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
560 | session)); | 566 | session)); |
561 | 567 | ||
562 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions, | 568 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions, |
563 | &target->hashPubKey, | 569 | &target->hashPubKey, |
564 | &destroy_inbound_session, NULL); | 570 | &destroy_inbound_session, NULL); |
565 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); | 571 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
566 | LOG (GNUNET_ERROR_TYPE_ERROR, | 572 | LOG (GNUNET_ERROR_TYPE_ERROR, "UDP DISCONNECT\n"); |
567 | "UDP DISCONNECT\n"); | ||
568 | 573 | ||
569 | plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag); | 574 | plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag); |
570 | if (GNUNET_SCHEDULER_NO_TASK != session->delayed_cont_task) | 575 | if (GNUNET_SCHEDULER_NO_TASK != session->delayed_cont_task) |
@@ -614,15 +619,15 @@ udp_send (struct Plugin *plugin, const struct sockaddr *sa, | |||
614 | { | 619 | { |
615 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); | 620 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
616 | LOG (GNUNET_ERROR_TYPE_ERROR, | 621 | LOG (GNUNET_ERROR_TYPE_ERROR, |
617 | "UDP transmited %u-byte message to %s (%d: %s)\n", | 622 | "UDP transmited %u-byte message to %s (%d: %s)\n", |
618 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), | 623 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, |
619 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); | 624 | (sent < 0) ? STRERROR (errno) : "ok"); |
620 | 625 | ||
621 | } | 626 | } |
622 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 627 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
623 | "UDP transmited %u-byte message to %s (%d: %s)\n", | 628 | "UDP transmited %u-byte message to %s (%d: %s)\n", |
624 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), | 629 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, |
625 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); | 630 | (sent < 0) ? STRERROR (errno) : "ok"); |
626 | return sent; | 631 | return sent; |
627 | } | 632 | } |
628 | 633 | ||
@@ -648,10 +653,10 @@ send_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
648 | 653 | ||
649 | static struct Session * | 654 | static struct Session * |
650 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 655 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, |
651 | const void *addr, size_t addrlen, | 656 | const void *addr, size_t addrlen, |
652 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 657 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
653 | { | 658 | { |
654 | struct Session * peer_session; | 659 | struct Session *peer_session; |
655 | const struct IPv4UdpAddress *t4; | 660 | const struct IPv4UdpAddress *t4; |
656 | const struct IPv6UdpAddress *t6; | 661 | const struct IPv6UdpAddress *t6; |
657 | struct sockaddr_in *v4; | 662 | struct sockaddr_in *v4; |
@@ -667,8 +672,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
667 | } | 672 | } |
668 | t4 = addr; | 673 | t4 = addr; |
669 | peer_session = | 674 | peer_session = |
670 | GNUNET_malloc (sizeof (struct Session) + | 675 | GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in)); |
671 | sizeof (struct sockaddr_in)); | ||
672 | len = sizeof (struct sockaddr_in); | 676 | len = sizeof (struct sockaddr_in); |
673 | v4 = (struct sockaddr_in *) &peer_session[1]; | 677 | v4 = (struct sockaddr_in *) &peer_session[1]; |
674 | v4->sin_family = AF_INET; | 678 | v4->sin_family = AF_INET; |
@@ -685,8 +689,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
685 | } | 689 | } |
686 | t6 = addr; | 690 | t6 = addr; |
687 | peer_session = | 691 | peer_session = |
688 | GNUNET_malloc (sizeof (struct Session) + | 692 | GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6)); |
689 | sizeof (struct sockaddr_in6)); | ||
690 | len = sizeof (struct sockaddr_in6); | 693 | len = sizeof (struct sockaddr_in6); |
691 | v6 = (struct sockaddr_in6 *) &peer_session[1]; | 694 | v6 = (struct sockaddr_in6 *) &peer_session[1]; |
692 | v6->sin6_family = AF_INET6; | 695 | v6->sin6_family = AF_INET6; |
@@ -719,8 +722,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen); | |||
719 | 722 | ||
720 | 723 | ||
721 | static void | 724 | static void |
722 | udp_call_continuation (void *cls, | 725 | udp_call_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
723 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
724 | { | 726 | { |
725 | struct Session *s = cls; | 727 | struct Session *s = cls; |
726 | GNUNET_TRANSPORT_TransmitContinuation cont = s->cont; | 728 | GNUNET_TRANSPORT_TransmitContinuation cont = s->cont; |
@@ -779,10 +781,10 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
779 | } | 781 | } |
780 | 782 | ||
781 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 783 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
782 | "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n", | 784 | "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n", |
783 | msgbuf_size, GNUNET_i2s (target), | 785 | msgbuf_size, GNUNET_i2s (target), udp_address_to_string (NULL, addr, |
784 | udp_address_to_string (NULL, addr, addrlen), | 786 | addrlen), |
785 | session, force_address); | 787 | session, force_address); |
786 | 788 | ||
787 | if ((force_address == GNUNET_SYSERR) && (session == NULL)) | 789 | if ((force_address == GNUNET_SYSERR) && (session == NULL)) |
788 | return GNUNET_SYSERR; | 790 | return GNUNET_SYSERR; |
@@ -792,10 +794,11 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
792 | if ((session != NULL) && (addr != NULL) && (addrlen != 0)) | 794 | if ((session != NULL) && (addr != NULL) && (addrlen != 0)) |
793 | { | 795 | { |
794 | s = session; | 796 | s = session; |
795 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value ( | 797 | GNUNET_assert (GNUNET_YES == |
796 | plugin->inbound_sessions, &target->hashPubKey, s)); | 798 | GNUNET_CONTAINER_multihashmap_contains_value |
799 | (plugin->inbound_sessions, &target->hashPubKey, s)); | ||
797 | 800 | ||
798 | if (0 != memcmp (&s->target, target, sizeof (struct GNUNET_PeerIdentity))) | 801 | if (0 != memcmp (&s->target, target, sizeof (struct GNUNET_PeerIdentity))) |
799 | return GNUNET_SYSERR; | 802 | return GNUNET_SYSERR; |
800 | switch (addrlen) | 803 | switch (addrlen) |
801 | { | 804 | { |
@@ -810,10 +813,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
810 | if (s->addrlen != (sizeof (struct sockaddr_in))) | 813 | if (s->addrlen != (sizeof (struct sockaddr_in))) |
811 | return GNUNET_SYSERR; | 814 | return GNUNET_SYSERR; |
812 | struct sockaddr_in *a4 = (struct sockaddr_in *) s->sock_addr; | 815 | struct sockaddr_in *a4 = (struct sockaddr_in *) s->sock_addr; |
816 | |||
813 | GNUNET_assert (a4->sin_port == t4->u4_port); | 817 | GNUNET_assert (a4->sin_port == t4->u4_port); |
814 | GNUNET_assert (0 == memcmp(&a4->sin_addr, &t4->ipv4_addr, sizeof (struct in_addr))); | 818 | GNUNET_assert (0 == |
815 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 819 | memcmp (&a4->sin_addr, &t4->ipv4_addr, |
816 | "Session 0x%X successfully checked!\n", session); | 820 | sizeof (struct in_addr))); |
821 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Session 0x%X successfully checked!\n", | ||
822 | session); | ||
817 | break; | 823 | break; |
818 | case sizeof (struct IPv6UdpAddress): | 824 | case sizeof (struct IPv6UdpAddress): |
819 | if (NULL == plugin->sockv6) | 825 | if (NULL == plugin->sockv6) |
@@ -825,10 +831,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
825 | t6 = addr; | 831 | t6 = addr; |
826 | GNUNET_assert (s->addrlen == sizeof (struct sockaddr_in6)); | 832 | GNUNET_assert (s->addrlen == sizeof (struct sockaddr_in6)); |
827 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) s->sock_addr; | 833 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) s->sock_addr; |
834 | |||
828 | GNUNET_assert (a6->sin6_port == t6->u6_port); | 835 | GNUNET_assert (a6->sin6_port == t6->u6_port); |
829 | GNUNET_assert (0 == memcmp(&a6->sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr))); | 836 | GNUNET_assert (0 == |
830 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 837 | memcmp (&a6->sin6_addr, &t6->ipv6_addr, |
831 | "Session 0x%X successfully checked!\n", session); | 838 | sizeof (struct in6_addr))); |
839 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Session 0x%X successfully checked!\n", | ||
840 | session); | ||
832 | break; | 841 | break; |
833 | default: | 842 | default: |
834 | /* Must have a valid address to send to */ | 843 | /* Must have a valid address to send to */ |
@@ -854,7 +863,7 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
854 | udp->sender = *plugin->env->my_identity; | 863 | udp->sender = *plugin->env->my_identity; |
855 | memcpy (&udp[1], msgbuf, msgbuf_size); | 864 | memcpy (&udp[1], msgbuf, msgbuf_size); |
856 | 865 | ||
857 | if (s != NULL) | 866 | if (s != NULL) |
858 | delta = GNUNET_TIME_absolute_get_remaining (s->flow_delay_from_other_peer); | 867 | delta = GNUNET_TIME_absolute_get_remaining (s->flow_delay_from_other_peer); |
859 | else | 868 | else |
860 | delta = GNUNET_TIME_UNIT_ZERO; | 869 | delta = GNUNET_TIME_UNIT_ZERO; |
@@ -863,17 +872,15 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
863 | mlen = udp_send (plugin, peer_session->sock_addr, &udp->header); | 872 | mlen = udp_send (plugin, peer_session->sock_addr, &udp->header); |
864 | if (cont != NULL) | 873 | if (cont != NULL) |
865 | { | 874 | { |
866 | if ( (delta.rel_value > 0) && | 875 | if ((delta.rel_value > 0) && (mlen > 0)) |
867 | (mlen > 0) ) | ||
868 | { | 876 | { |
869 | s->cont = cont; | 877 | s->cont = cont; |
870 | s->cont_cls = cont_cls; | 878 | s->cont_cls = cont_cls; |
871 | s->delayed_cont_task = GNUNET_SCHEDULER_add_delayed (delta, | 879 | s->delayed_cont_task = |
872 | &udp_call_continuation, | 880 | GNUNET_SCHEDULER_add_delayed (delta, &udp_call_continuation, s); |
873 | s); | ||
874 | } | 881 | } |
875 | else | 882 | else |
876 | cont (cont_cls, target, (mlen > 0) ? GNUNET_OK : GNUNET_SYSERR); | 883 | cont (cont_cls, target, (mlen > 0) ? GNUNET_OK : GNUNET_SYSERR); |
877 | } | 884 | } |
878 | GNUNET_free_non_null (peer_session); | 885 | GNUNET_free_non_null (peer_session); |
879 | } | 886 | } |
@@ -915,7 +922,7 @@ struct SourceInformation | |||
915 | */ | 922 | */ |
916 | size_t args; | 923 | size_t args; |
917 | 924 | ||
918 | struct Session * session; | 925 | struct Session *session; |
919 | }; | 926 | }; |
920 | 927 | ||
921 | 928 | ||
@@ -940,23 +947,29 @@ process_inbound_tokenized_messages (void *cls, void *client, | |||
940 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 947 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
941 | distance.value = htonl (1); | 948 | distance.value = htonl (1); |
942 | 949 | ||
943 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 950 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving Session %X %s to transport\n", |
944 | "Giving Session %X %s to transport\n", si->session, GNUNET_i2s(&si->session->target)); | 951 | si->session, GNUNET_i2s (&si->session->target)); |
945 | delay = plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, si->session, | 952 | delay = |
946 | si->arg, si->args); | 953 | plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, |
954 | si->session, si->arg, si->args); | ||
947 | si->session->flow_delay_for_other_peer = delay; | 955 | si->session->flow_delay_for_other_peer = delay; |
948 | } | 956 | } |
949 | 957 | ||
950 | static void | 958 | static void |
951 | invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 959 | invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
952 | { | 960 | { |
953 | struct Session * s = cls; | 961 | struct Session *s = cls; |
954 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | ||
955 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
956 | "Session %X (`%s') is now invalid\n", s, GNUNET_a2s (s->sock_addr,s->addrlen)); | ||
957 | 962 | ||
958 | s->plugin->env->session_end(s->plugin->env->cls, &s->target, s); | 963 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
959 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(s->plugin->inbound_sessions, &s->target.hashPubKey, s)); | 964 | LOG (GNUNET_ERROR_TYPE_ERROR, "Session %X (`%s') is now invalid\n", s, |
965 | GNUNET_a2s (s->sock_addr, s->addrlen)); | ||
966 | |||
967 | s->plugin->env->session_end (s->plugin->env->cls, &s->target, s); | ||
968 | GNUNET_assert (GNUNET_YES == | ||
969 | GNUNET_CONTAINER_multihashmap_remove (s-> | ||
970 | plugin->inbound_sessions, | ||
971 | &s->target.hashPubKey, | ||
972 | s)); | ||
960 | GNUNET_free (s); | 973 | GNUNET_free (s); |
961 | } | 974 | } |
962 | 975 | ||
@@ -1015,54 +1028,54 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
1015 | } | 1028 | } |
1016 | #if DEBUG_UDP | 1029 | #if DEBUG_UDP |
1017 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1030 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1018 | "Received message with %u bytes from peer `%s' at `%s'\n", | 1031 | "Received message with %u bytes from peer `%s' at `%s'\n", |
1019 | (unsigned int) ntohs (msg->header.size), | 1032 | (unsigned int) ntohs (msg->header.size), GNUNET_i2s (&msg->sender), |
1020 | GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr, | 1033 | GNUNET_a2s (sender_addr, sender_addr_len)); |
1021 | sender_addr_len)); | ||
1022 | #endif | 1034 | #endif |
1023 | 1035 | ||
1024 | /* create a session for inbound connections */ | 1036 | /* create a session for inbound connections */ |
1025 | const struct UDPMessage * udp_msg = (const struct UDPMessage *) msg; | 1037 | const struct UDPMessage *udp_msg = (const struct UDPMessage *) msg; |
1038 | |||
1026 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1039 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1027 | "Lookup inbound UDP sessions for peer `%s' address `%s'\n", | 1040 | "Lookup inbound UDP sessions for peer `%s' address `%s'\n", |
1028 | GNUNET_i2s (&udp_msg->sender), | 1041 | GNUNET_i2s (&udp_msg->sender), udp_address_to_string (NULL, arg, args)); |
1029 | udp_address_to_string(NULL, arg, args)); | ||
1030 | 1042 | ||
1031 | struct Session * s = NULL; | 1043 | struct Session *s = NULL; |
1032 | s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, sender_addr_len); | 1044 | |
1045 | s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, | ||
1046 | sender_addr_len); | ||
1033 | 1047 | ||
1034 | if (s != NULL) | 1048 | if (s != NULL) |
1035 | { | 1049 | { |
1036 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1050 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1037 | "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n", | 1051 | "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n", |
1038 | s, | 1052 | s, GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args)); |
1039 | GNUNET_i2s (&s->target), | ||
1040 | udp_address_to_string(NULL, arg, args)); | ||
1041 | } | 1053 | } |
1042 | else | 1054 | else |
1043 | { | 1055 | { |
1044 | s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL); | 1056 | s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL); |
1045 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1057 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1046 | "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", | 1058 | "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", s, |
1047 | s, | 1059 | GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args)); |
1048 | GNUNET_i2s (&s->target), | 1060 | |
1049 | udp_address_to_string(NULL, arg, args)); | 1061 | GNUNET_assert (GNUNET_OK == |
1050 | 1062 | GNUNET_CONTAINER_multihashmap_put (plugin->inbound_sessions, | |
1051 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->inbound_sessions, | 1063 | &s->target.hashPubKey, s, |
1052 | &s->target.hashPubKey, | 1064 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
1053 | s, | ||
1054 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
1055 | } | 1065 | } |
1056 | s->valid_until = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 1066 | s->valid_until = |
1067 | GNUNET_TIME_relative_to_absolute | ||
1068 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
1057 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) | 1069 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) |
1058 | { | 1070 | { |
1059 | GNUNET_SCHEDULER_cancel(s->invalidation_task); | 1071 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
1060 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | 1072 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
1061 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1073 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Rescheduling %X' `%s'\n", s, |
1062 | "Rescheduling %X' `%s'\n", | 1074 | udp_address_to_string (NULL, arg, args)); |
1063 | s, udp_address_to_string(NULL, arg, args)); | ||
1064 | } | 1075 | } |
1065 | s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, s); | 1076 | s->invalidation_task = |
1077 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
1078 | &invalidation_task, s); | ||
1066 | /* iterate over all embedded messages */ | 1079 | /* iterate over all embedded messages */ |
1067 | si.sender = msg->sender; | 1080 | si.sender = msg->sender; |
1068 | si.arg = arg; | 1081 | si.arg = arg; |
@@ -1118,6 +1131,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1118 | uint32_t delay = 0; | 1131 | uint32_t delay = 0; |
1119 | 1132 | ||
1120 | struct Session *s; | 1133 | struct Session *s; |
1134 | |||
1121 | s = find_inbound_session_by_addr (rc->plugin, rc->src_addr, rc->addr_len); | 1135 | s = find_inbound_session_by_addr (rc->plugin, rc->src_addr, rc->addr_len); |
1122 | if (s != NULL) | 1136 | if (s != NULL) |
1123 | { | 1137 | { |
@@ -1129,12 +1143,13 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1129 | 1143 | ||
1130 | 1144 | ||
1131 | #if DEBUG_UDP | 1145 | #if DEBUG_UDP |
1132 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ACK to `%s' including delay of %u ms\n", | 1146 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1133 | GNUNET_a2s (rc->src_addr, | 1147 | "Sending ACK to `%s' including delay of %u ms\n", |
1134 | (rc->src_addr->sa_family == | 1148 | GNUNET_a2s (rc->src_addr, |
1135 | AF_INET) ? sizeof (struct sockaddr_in) : | 1149 | (rc->src_addr->sa_family == |
1136 | sizeof (struct sockaddr_in6)), | 1150 | AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct |
1137 | delay); | 1151 | sockaddr_in6)), |
1152 | delay); | ||
1138 | #endif | 1153 | #endif |
1139 | udp_ack = (struct UDP_ACK_Message *) buf; | 1154 | udp_ack = (struct UDP_ACK_Message *) buf; |
1140 | udp_ack->header.size = htons ((uint16_t) msize); | 1155 | udp_ack->header.size = htons ((uint16_t) msize); |
@@ -1166,7 +1181,7 @@ struct FindReceiveContext | |||
1166 | */ | 1181 | */ |
1167 | socklen_t addr_len; | 1182 | socklen_t addr_len; |
1168 | 1183 | ||
1169 | struct Session * session; | 1184 | struct Session *session; |
1170 | }; | 1185 | }; |
1171 | 1186 | ||
1172 | 1187 | ||
@@ -1217,7 +1232,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1217 | struct ReceiveContext *rc; | 1232 | struct ReceiveContext *rc; |
1218 | struct GNUNET_TIME_Absolute now; | 1233 | struct GNUNET_TIME_Absolute now; |
1219 | struct FindReceiveContext frc; | 1234 | struct FindReceiveContext frc; |
1220 | struct Session * s = NULL; | 1235 | struct Session *s = NULL; |
1221 | struct GNUNET_TIME_Relative flow_delay; | 1236 | struct GNUNET_TIME_Relative flow_delay; |
1222 | 1237 | ||
1223 | fromlen = sizeof (addr); | 1238 | fromlen = sizeof (addr); |
@@ -1233,8 +1248,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1233 | msg = (const struct GNUNET_MessageHeader *) buf; | 1248 | msg = (const struct GNUNET_MessageHeader *) buf; |
1234 | 1249 | ||
1235 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1250 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1236 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret, | 1251 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret, |
1237 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs(msg->type)); | 1252 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs (msg->type)); |
1238 | 1253 | ||
1239 | if (ret != ntohs (msg->size)) | 1254 | if (ret != ntohs (msg->size)) |
1240 | { | 1255 | { |
@@ -1261,27 +1276,29 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1261 | return; | 1276 | return; |
1262 | } | 1277 | } |
1263 | udp_ack = (const struct UDP_ACK_Message *) msg; | 1278 | udp_ack = (const struct UDP_ACK_Message *) msg; |
1264 | s = find_inbound_session(plugin, &udp_ack->sender, addr, fromlen); | 1279 | s = find_inbound_session (plugin, &udp_ack->sender, addr, fromlen); |
1265 | if (s != NULL) | 1280 | if (s != NULL) |
1266 | { | 1281 | { |
1267 | flow_delay.rel_value = (uint64_t) ntohl(udp_ack->delay); | 1282 | flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay); |
1268 | 1283 | ||
1269 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1284 | LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %llu\n", |
1270 | "We received a sending delay of %llu\n", flow_delay.rel_value); | 1285 | flow_delay.rel_value); |
1271 | 1286 | ||
1272 | s->flow_delay_from_other_peer = GNUNET_TIME_relative_to_absolute (flow_delay); | 1287 | s->flow_delay_from_other_peer = |
1288 | GNUNET_TIME_relative_to_absolute (flow_delay); | ||
1273 | } | 1289 | } |
1274 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; | 1290 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; |
1275 | if (ntohs (ack->size) != ntohs (msg->size) - sizeof (struct UDP_ACK_Message)) | 1291 | if (ntohs (ack->size) != |
1292 | ntohs (msg->size) - sizeof (struct UDP_ACK_Message)) | ||
1276 | { | 1293 | { |
1277 | GNUNET_break_op (0); | 1294 | GNUNET_break_op (0); |
1278 | return; | 1295 | return; |
1279 | } | 1296 | } |
1280 | #if DEBUG_UDP | 1297 | #if DEBUG_UDP |
1281 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1298 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1282 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | 1299 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", |
1283 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | 1300 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), |
1284 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 1301 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
1285 | #endif | 1302 | #endif |
1286 | 1303 | ||
1287 | peer_session = find_session (plugin, &udp_ack->sender); | 1304 | peer_session = find_session (plugin, &udp_ack->sender); |
@@ -1289,7 +1306,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1289 | { | 1306 | { |
1290 | #if DEBUG_UDP | 1307 | #if DEBUG_UDP |
1291 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1308 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1292 | "Session for ACK not found, dropping ACK!\n"); | 1309 | "Session for ACK not found, dropping ACK!\n"); |
1293 | #endif | 1310 | #endif |
1294 | return; | 1311 | return; |
1295 | } | 1312 | } |
@@ -1332,10 +1349,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1332 | now.abs_value); | 1349 | now.abs_value); |
1333 | } | 1350 | } |
1334 | #if DEBUG_UDP | 1351 | #if DEBUG_UDP |
1335 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1352 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n", |
1336 | "UDP processes %u-byte fragment from `%s'\n", | 1353 | (unsigned int) ntohs (msg->size), |
1337 | (unsigned int) ntohs (msg->size), | 1354 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
1338 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
1339 | #endif | 1355 | #endif |
1340 | 1356 | ||
1341 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) | 1357 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) |
@@ -1395,40 +1411,43 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1395 | 1411 | ||
1396 | struct MstContext | 1412 | struct MstContext |
1397 | { | 1413 | { |
1398 | struct Plugin * plugin; | 1414 | struct Plugin *plugin; |
1399 | 1415 | ||
1400 | struct IPv4UdpAddress addr; | 1416 | struct IPv4UdpAddress addr; |
1401 | }; | 1417 | }; |
1402 | 1418 | ||
1403 | void udp_broadcast_mst_cb (void *cls, void *client, | 1419 | void |
1404 | const struct | 1420 | udp_broadcast_mst_cb (void *cls, void *client, |
1405 | GNUNET_MessageHeader * | 1421 | const struct GNUNET_MessageHeader *message) |
1406 | message) | ||
1407 | { | 1422 | { |
1408 | struct Plugin * plugin = cls; | 1423 | struct Plugin *plugin = cls; |
1409 | struct MstContext * mc = client; | 1424 | struct MstContext *mc = client; |
1410 | const struct GNUNET_MessageHeader* hello; | 1425 | const struct GNUNET_MessageHeader *hello; |
1411 | struct UDP_Beacon_Message * msg; | 1426 | struct UDP_Beacon_Message *msg; |
1427 | |||
1412 | msg = (struct UDP_Beacon_Message *) message; | 1428 | msg = (struct UDP_Beacon_Message *) message; |
1413 | 1429 | ||
1414 | if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != ntohs(msg->header.type)) | 1430 | if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != |
1431 | ntohs (msg->header.type)) | ||
1415 | return; | 1432 | return; |
1416 | 1433 | ||
1417 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1434 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1418 | "Received beacon with %u bytes from peer `%s' via address `%s'\n", | 1435 | "Received beacon with %u bytes from peer `%s' via address `%s'\n", |
1419 | ntohs(msg->header.size), | 1436 | ntohs (msg->header.size), GNUNET_i2s (&msg->sender), |
1420 | GNUNET_i2s (&msg->sender), | 1437 | udp_address_to_string (NULL, &mc->addr, sizeof (mc->addr))); |
1421 | udp_address_to_string(NULL, &mc->addr, sizeof (mc->addr))); | ||
1422 | 1438 | ||
1423 | struct GNUNET_ATS_Information ats; | 1439 | struct GNUNET_ATS_Information ats; |
1440 | |||
1424 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 1441 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
1425 | ats.value = htonl (1); | 1442 | ats.value = htonl (1); |
1426 | 1443 | ||
1427 | hello = (struct GNUNET_MessageHeader *) &msg[1]; | 1444 | hello = (struct GNUNET_MessageHeader *) &msg[1]; |
1428 | plugin->env->receive (plugin->env->cls, &msg->sender, hello, &ats, 1, NULL, (const char *) &mc->addr, sizeof (mc->addr)); | 1445 | plugin->env->receive (plugin->env->cls, &msg->sender, hello, &ats, 1, NULL, |
1446 | (const char *) &mc->addr, sizeof (mc->addr)); | ||
1429 | 1447 | ||
1430 | GNUNET_STATISTICS_update(plugin->env->stats, | 1448 | GNUNET_STATISTICS_update (plugin->env->stats, |
1431 | _("# HELLO beacons received via udp"), 1, GNUNET_NO); | 1449 | _("# HELLO beacons received via udp"), 1, |
1450 | GNUNET_NO); | ||
1432 | GNUNET_free (mc); | 1451 | GNUNET_free (mc); |
1433 | } | 1452 | } |
1434 | 1453 | ||
@@ -1445,54 +1464,61 @@ udp_broadcast_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1445 | char addr[32]; | 1464 | char addr[32]; |
1446 | char buf[65536]; | 1465 | char buf[65536]; |
1447 | ssize_t ret; | 1466 | ssize_t ret; |
1448 | struct MstContext * mc; | 1467 | struct MstContext *mc; |
1449 | 1468 | ||
1450 | 1469 | ||
1451 | fromlen = sizeof (addr); | 1470 | fromlen = sizeof (addr); |
1452 | memset (&addr, 0, sizeof (addr)); | 1471 | memset (&addr, 0, sizeof (addr)); |
1453 | ret = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), (struct sockaddr *) &addr, &fromlen); | 1472 | ret = |
1473 | GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), | ||
1474 | (struct sockaddr *) &addr, &fromlen); | ||
1454 | if (ret < sizeof (struct GNUNET_MessageHeader)) | 1475 | if (ret < sizeof (struct GNUNET_MessageHeader)) |
1455 | { | 1476 | { |
1456 | /* malformed beacon, just throw it away */ | 1477 | /* malformed beacon, just throw it away */ |
1457 | return; | 1478 | return; |
1458 | } | 1479 | } |
1459 | 1480 | ||
1460 | mc = GNUNET_malloc(sizeof (struct MstContext)); | 1481 | mc = GNUNET_malloc (sizeof (struct MstContext)); |
1482 | |||
1483 | struct sockaddr_in *av4 = (struct sockaddr_in *) &addr; | ||
1461 | 1484 | ||
1462 | struct sockaddr_in * av4 = (struct sockaddr_in *) &addr; | ||
1463 | mc->addr.ipv4_addr = av4->sin_addr.s_addr; | 1485 | mc->addr.ipv4_addr = av4->sin_addr.s_addr; |
1464 | mc->addr.u4_port = av4->sin_port; | 1486 | mc->addr.u4_port = av4->sin_port; |
1465 | 1487 | ||
1466 | if (GNUNET_OK != GNUNET_SERVER_mst_receive(plugin->broadcast_mst, mc, buf, ret, GNUNET_NO, GNUNET_NO)) | 1488 | if (GNUNET_OK != |
1489 | GNUNET_SERVER_mst_receive (plugin->broadcast_mst, mc, buf, ret, GNUNET_NO, | ||
1490 | GNUNET_NO)) | ||
1467 | GNUNET_free (mc); | 1491 | GNUNET_free (mc); |
1468 | } | 1492 | } |
1469 | 1493 | ||
1470 | 1494 | ||
1471 | static void | 1495 | static void |
1472 | udp_broadcast_send (void *cls, | 1496 | udp_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1473 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1474 | { | 1497 | { |
1475 | struct Plugin * plugin = cls; | 1498 | struct Plugin *plugin = cls; |
1476 | int sent; | 1499 | int sent; |
1477 | uint16_t msg_size; | 1500 | uint16_t msg_size; |
1478 | uint16_t hello_size; | 1501 | uint16_t hello_size; |
1479 | char buf[65536]; | 1502 | char buf[65536]; |
1503 | |||
1480 | // /ssize_t ret; | 1504 | // /ssize_t ret; |
1481 | const struct GNUNET_MessageHeader *hello; | 1505 | const struct GNUNET_MessageHeader *hello; |
1482 | struct UDP_Beacon_Message * msg; | 1506 | struct UDP_Beacon_Message *msg; |
1483 | 1507 | ||
1484 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 1508 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
1485 | 1509 | ||
1486 | struct sockaddr_in baddr; | 1510 | struct sockaddr_in baddr; |
1511 | |||
1487 | baddr.sin_family = AF_INET; | 1512 | baddr.sin_family = AF_INET; |
1488 | baddr.sin_port = htons (plugin->broadcast_port); | 1513 | baddr.sin_port = htons (plugin->broadcast_port); |
1489 | baddr.sin_addr.s_addr=htonl(-1); /* send message to 255.255.255.255 */ | 1514 | baddr.sin_addr.s_addr = htonl (-1); /* send message to 255.255.255.255 */ |
1490 | 1515 | ||
1491 | hello = plugin->env->get_our_hello (); | 1516 | hello = plugin->env->get_our_hello (); |
1492 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 1517 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); |
1493 | msg_size = hello_size + sizeof (struct UDP_Beacon_Message); | 1518 | msg_size = hello_size + sizeof (struct UDP_Beacon_Message); |
1494 | 1519 | ||
1495 | if (hello_size < (sizeof (struct GNUNET_MessageHeader)) ||(msg_size > (UDP_MTU))) | 1520 | if (hello_size < (sizeof (struct GNUNET_MessageHeader)) || |
1521 | (msg_size > (UDP_MTU))) | ||
1496 | return; | 1522 | return; |
1497 | 1523 | ||
1498 | msg = (struct UDP_Beacon_Message *) buf; | 1524 | msg = (struct UDP_Beacon_Message *) buf; |
@@ -1501,13 +1527,17 @@ udp_broadcast_send (void *cls, | |||
1501 | msg->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON); | 1527 | msg->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON); |
1502 | memcpy (&msg[1], hello, hello_size); | 1528 | memcpy (&msg[1], hello, hello_size); |
1503 | 1529 | ||
1504 | sent = GNUNET_NETWORK_socket_sendto (plugin->sockv4_broadcast, msg, msg_size, | 1530 | sent = |
1505 | (const struct sockaddr *) &baddr, sizeof (struct sockaddr_in)); | 1531 | GNUNET_NETWORK_socket_sendto (plugin->sockv4_broadcast, msg, msg_size, |
1532 | (const struct sockaddr *) &baddr, | ||
1533 | sizeof (struct sockaddr_in)); | ||
1506 | 1534 | ||
1507 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1535 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO beacon broadcast with %i bytes\n", |
1508 | "Sent HELLO beacon broadcast with %i bytes\n", sent); | 1536 | sent); |
1509 | 1537 | ||
1510 | plugin->send_broadcast_task = GNUNET_SCHEDULER_add_delayed(plugin->broadcast_interval, &udp_broadcast_send, plugin); | 1538 | plugin->send_broadcast_task = |
1539 | GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval, | ||
1540 | &udp_broadcast_send, plugin); | ||
1511 | 1541 | ||
1512 | } | 1542 | } |
1513 | 1543 | ||
@@ -1520,7 +1550,8 @@ udp_broadcast_send (void *cls, | |||
1520 | * @param tc the scheduling context (for rescheduling this function again) | 1550 | * @param tc the scheduling context (for rescheduling this function again) |
1521 | */ | 1551 | */ |
1522 | static void | 1552 | static void |
1523 | udp_plugin_broadcast_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1553 | udp_plugin_broadcast_select (void *cls, |
1554 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1524 | { | 1555 | { |
1525 | struct Plugin *plugin = cls; | 1556 | struct Plugin *plugin = cls; |
1526 | 1557 | ||
@@ -1535,8 +1566,9 @@ udp_plugin_broadcast_select (void *cls, const struct GNUNET_SCHEDULER_TaskContex | |||
1535 | plugin->select_broadcast_task = | 1566 | plugin->select_broadcast_task = |
1536 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1567 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1537 | GNUNET_SCHEDULER_NO_TASK, | 1568 | GNUNET_SCHEDULER_NO_TASK, |
1538 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->broadcast_rs, | 1569 | GNUNET_TIME_UNIT_FOREVER_REL, |
1539 | NULL, &udp_plugin_broadcast_select, plugin); | 1570 | plugin->broadcast_rs, NULL, |
1571 | &udp_plugin_broadcast_select, plugin); | ||
1540 | } | 1572 | } |
1541 | 1573 | ||
1542 | 1574 | ||
@@ -1664,7 +1696,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
1664 | } | 1696 | } |
1665 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); | 1697 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); |
1666 | GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", | 1698 | GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", |
1667 | buf, port); | 1699 | buf, port); |
1668 | return rbuf; | 1700 | return rbuf; |
1669 | } | 1701 | } |
1670 | 1702 | ||
@@ -1868,16 +1900,20 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1868 | &port)) | 1900 | &port)) |
1869 | port = 2086; | 1901 | port = 2086; |
1870 | 1902 | ||
1871 | broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", "BROADCAST"); | 1903 | broadcast = |
1872 | if (broadcast == GNUNET_SYSERR) | 1904 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", |
1873 | broadcast = GNUNET_NO; | 1905 | "BROADCAST"); |
1906 | if (broadcast == GNUNET_SYSERR) | ||
1907 | broadcast = GNUNET_NO; | ||
1874 | 1908 | ||
1875 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-udp", "BROADCAST_INTERVAL", &interval)) | 1909 | if (GNUNET_SYSERR == |
1876 | interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10); | 1910 | GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-udp", |
1911 | "BROADCAST_INTERVAL", &interval)) | ||
1912 | interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); | ||
1877 | 1913 | ||
1878 | if (GNUNET_OK != | 1914 | if (GNUNET_OK != |
1879 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "BROADCAST_PORT", | 1915 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", |
1880 | &bport)) | 1916 | "BROADCAST_PORT", &bport)) |
1881 | bport = 20086; | 1917 | bport = 20086; |
1882 | 1918 | ||
1883 | if (GNUNET_OK != | 1919 | if (GNUNET_OK != |
@@ -1891,8 +1927,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1891 | if (port > 65535) | 1927 | if (port > 65535) |
1892 | { | 1928 | { |
1893 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1929 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1894 | _("Given `%s' option is out of range: %llu > %u\n"), "PORT", | 1930 | _("Given `%s' option is out of range: %llu > %u\n"), "PORT", port, |
1895 | port, 65535); | 1931 | 65535); |
1896 | return NULL; | 1932 | return NULL; |
1897 | } | 1933 | } |
1898 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); | 1934 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); |
@@ -1923,8 +1959,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1923 | "BINDTO", &plugin->bind4_address)) | 1959 | "BINDTO", &plugin->bind4_address)) |
1924 | { | 1960 | { |
1925 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1961 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1926 | "Binding udp plugin to specific address: `%s'\n", | 1962 | "Binding udp plugin to specific address: `%s'\n", |
1927 | plugin->bind4_address); | 1963 | plugin->bind4_address); |
1928 | if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr)) | 1964 | if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr)) |
1929 | { | 1965 | { |
1930 | GNUNET_free (plugin->bind4_address); | 1966 | GNUNET_free (plugin->bind4_address); |
@@ -1939,13 +1975,13 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1939 | "BINDTO6", &plugin->bind6_address)) | 1975 | "BINDTO6", &plugin->bind6_address)) |
1940 | { | 1976 | { |
1941 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1977 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1942 | "Binding udp plugin to specific address: `%s'\n", | 1978 | "Binding udp plugin to specific address: `%s'\n", |
1943 | plugin->bind6_address); | 1979 | plugin->bind6_address); |
1944 | if (1 != | 1980 | if (1 != |
1945 | inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) | 1981 | inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) |
1946 | { | 1982 | { |
1947 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), | 1983 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), |
1948 | plugin->bind6_address); | 1984 | plugin->bind6_address); |
1949 | GNUNET_free_non_null (plugin->bind4_address); | 1985 | GNUNET_free_non_null (plugin->bind4_address); |
1950 | GNUNET_free (plugin->bind6_address); | 1986 | GNUNET_free (plugin->bind6_address); |
1951 | GNUNET_free (plugin); | 1987 | GNUNET_free (plugin); |
@@ -1984,7 +2020,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1984 | serverAddr = (struct sockaddr *) &serverAddrv6; | 2020 | serverAddr = (struct sockaddr *) &serverAddrv6; |
1985 | #if DEBUG_UDP | 2021 | #if DEBUG_UDP |
1986 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", | 2022 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", |
1987 | ntohs (serverAddrv6.sin6_port)); | 2023 | ntohs (serverAddrv6.sin6_port)); |
1988 | #endif | 2024 | #endif |
1989 | tries = 0; | 2025 | tries = 0; |
1990 | while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != | 2026 | while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != |
@@ -1993,8 +2029,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1993 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 2029 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
1994 | #if DEBUG_UDP | 2030 | #if DEBUG_UDP |
1995 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2031 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1996 | "IPv6 Binding failed, trying new port %d\n", | 2032 | "IPv6 Binding failed, trying new port %d\n", |
1997 | ntohs (serverAddrv6.sin6_port)); | 2033 | ntohs (serverAddrv6.sin6_port)); |
1998 | #endif | 2034 | #endif |
1999 | tries++; | 2035 | tries++; |
2000 | if (tries > 10) | 2036 | if (tries > 10) |
@@ -2032,7 +2068,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2032 | serverAddr = (struct sockaddr *) &serverAddrv4; | 2068 | serverAddr = (struct sockaddr *) &serverAddrv4; |
2033 | #if DEBUG_UDP | 2069 | #if DEBUG_UDP |
2034 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", | 2070 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", |
2035 | ntohs (serverAddrv4.sin_port)); | 2071 | ntohs (serverAddrv4.sin_port)); |
2036 | #endif | 2072 | #endif |
2037 | tries = 0; | 2073 | tries = 0; |
2038 | while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != | 2074 | while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != |
@@ -2040,9 +2076,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2040 | { | 2076 | { |
2041 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 2077 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
2042 | #if DEBUG_UDP | 2078 | #if DEBUG_UDP |
2043 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2079 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Binding failed, trying new port %d\n", |
2044 | "IPv4 Binding failed, trying new port %d\n", | 2080 | ntohs (serverAddrv4.sin_port)); |
2045 | ntohs (serverAddrv4.sin_port)); | ||
2046 | #endif | 2081 | #endif |
2047 | tries++; | 2082 | tries++; |
2048 | if (tries > 10) | 2083 | if (tries > 10) |
@@ -2077,47 +2112,56 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2077 | /* create broadcast socket */ | 2112 | /* create broadcast socket */ |
2078 | if (broadcast) | 2113 | if (broadcast) |
2079 | { | 2114 | { |
2080 | plugin->sockv4_broadcast = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); | 2115 | plugin->sockv4_broadcast = |
2116 | GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); | ||
2081 | if (NULL == plugin->sockv4_broadcast) | 2117 | if (NULL == plugin->sockv4_broadcast) |
2082 | { | 2118 | { |
2083 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket"); | 2119 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket"); |
2084 | } | 2120 | } |
2085 | else | 2121 | else |
2086 | { | 2122 | { |
2087 | #if HAVE_SOCKADDR_IN_SIN_LEN | 2123 | #if HAVE_SOCKADDR_IN_SIN_LEN |
2088 | serverAddrv4.sin_len = sizeof (serverAddrv4); | 2124 | serverAddrv4.sin_len = sizeof (serverAddrv4); |
2089 | #endif | 2125 | #endif |
2090 | serverAddrv4.sin_family = AF_INET; | 2126 | serverAddrv4.sin_family = AF_INET; |
2091 | serverAddrv4.sin_addr.s_addr = INADDR_ANY; | 2127 | serverAddrv4.sin_addr.s_addr = INADDR_ANY; |
2092 | serverAddrv4.sin_port = htons (plugin->broadcast_port); | 2128 | serverAddrv4.sin_port = htons (plugin->broadcast_port); |
2093 | addrlen = sizeof (serverAddrv4); | 2129 | addrlen = sizeof (serverAddrv4); |
2094 | serverAddr = (struct sockaddr *) &serverAddrv4; | 2130 | serverAddr = (struct sockaddr *) &serverAddrv4; |
2095 | #if DEBUG_UDP | 2131 | #if DEBUG_UDP |
2096 | #endif | 2132 | #endif |
2097 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding Broadcast to IPv4 port %d\n", | 2133 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding Broadcast to IPv4 port %d\n", |
2098 | ntohs (serverAddrv4.sin_port)); | 2134 | ntohs (serverAddrv4.sin_port)); |
2099 | 2135 | ||
2100 | if (GNUNET_NETWORK_socket_bind (plugin->sockv4_broadcast, serverAddr, addrlen) != GNUNET_OK) | 2136 | if (GNUNET_NETWORK_socket_bind |
2137 | (plugin->sockv4_broadcast, serverAddr, addrlen) != GNUNET_OK) | ||
2101 | { | 2138 | { |
2102 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to create IPv4 broadcast socket on port %d\n"), | 2139 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2103 | ntohs (serverAddrv4.sin_port)); | 2140 | _("Failed to create IPv4 broadcast socket on port %d\n"), |
2104 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast); | 2141 | ntohs (serverAddrv4.sin_port)); |
2105 | plugin->sockv4_broadcast = NULL; | 2142 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast); |
2143 | plugin->sockv4_broadcast = NULL; | ||
2106 | } | 2144 | } |
2107 | if (plugin->sockv4_broadcast != NULL) | 2145 | if (plugin->sockv4_broadcast != NULL) |
2108 | { | 2146 | { |
2109 | int yes = 1; | 2147 | int yes = 1; |
2110 | if (GNUNET_NETWORK_socket_setsockopt (plugin->sockv4_broadcast, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(int)) != GNUNET_OK) | 2148 | |
2149 | if (GNUNET_NETWORK_socket_setsockopt | ||
2150 | (plugin->sockv4_broadcast, SOL_SOCKET, SO_BROADCAST, &yes, | ||
2151 | sizeof (int)) != GNUNET_OK) | ||
2111 | { | 2152 | { |
2112 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), | 2153 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2113 | ntohs (serverAddrv4.sin_port)); | 2154 | _ |
2114 | GNUNET_NETWORK_socket_close(plugin->sockv4_broadcast); | 2155 | ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), |
2156 | ntohs (serverAddrv4.sin_port)); | ||
2157 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast); | ||
2115 | plugin->sockv4_broadcast = NULL; | 2158 | plugin->sockv4_broadcast = NULL; |
2116 | } | 2159 | } |
2117 | else | 2160 | else |
2118 | { | 2161 | { |
2119 | plugin->broadcast_rs = GNUNET_NETWORK_fdset_create (); | 2162 | plugin->broadcast_rs = GNUNET_NETWORK_fdset_create (); |
2120 | GNUNET_NETWORK_fdset_set (plugin->broadcast_rs, plugin->sockv4_broadcast); | 2163 | GNUNET_NETWORK_fdset_set (plugin->broadcast_rs, |
2164 | plugin->sockv4_broadcast); | ||
2121 | } | 2165 | } |
2122 | } | 2166 | } |
2123 | } | 2167 | } |
@@ -2125,16 +2169,20 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2125 | if (plugin->sockv4_broadcast != NULL) | 2169 | if (plugin->sockv4_broadcast != NULL) |
2126 | { | 2170 | { |
2127 | plugin->broadcast = GNUNET_YES; | 2171 | plugin->broadcast = GNUNET_YES; |
2128 | plugin->broadcast_mst = GNUNET_SERVER_mst_create (udp_broadcast_mst_cb, plugin); | 2172 | plugin->broadcast_mst = |
2129 | GNUNET_STATISTICS_update(plugin->env->stats, | 2173 | GNUNET_SERVER_mst_create (udp_broadcast_mst_cb, plugin); |
2130 | _("# HELLO beacons received via udp"), 1, GNUNET_NO); | 2174 | GNUNET_STATISTICS_update (plugin->env->stats, |
2175 | _("# HELLO beacons received via udp"), 1, | ||
2176 | GNUNET_NO); | ||
2131 | plugin->select_broadcast_task = | 2177 | plugin->select_broadcast_task = |
2132 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 2178 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
2133 | GNUNET_SCHEDULER_NO_TASK, | 2179 | GNUNET_SCHEDULER_NO_TASK, |
2134 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->broadcast_rs, | 2180 | GNUNET_TIME_UNIT_FOREVER_REL, |
2135 | NULL, &udp_plugin_broadcast_select, plugin); | 2181 | plugin->broadcast_rs, NULL, |
2136 | 2182 | &udp_plugin_broadcast_select, plugin); | |
2137 | plugin->send_broadcast_task = GNUNET_SCHEDULER_add_now (&udp_broadcast_send, plugin); | 2183 | |
2184 | plugin->send_broadcast_task = | ||
2185 | GNUNET_SCHEDULER_add_now (&udp_broadcast_send, plugin); | ||
2138 | } | 2186 | } |
2139 | else | 2187 | else |
2140 | plugin->broadcast = GNUNET_NO; | 2188 | plugin->broadcast = GNUNET_NO; |
@@ -2167,8 +2215,8 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2167 | NULL); | 2215 | NULL); |
2168 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); | 2216 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); |
2169 | plugin->sessions = NULL; | 2217 | plugin->sessions = NULL; |
2170 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &destroy_inbound_session, | 2218 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, |
2171 | NULL); | 2219 | &destroy_inbound_session, NULL); |
2172 | GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions); | 2220 | GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions); |
2173 | plugin->inbound_sessions = NULL; | 2221 | plugin->inbound_sessions = NULL; |
2174 | while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) | 2222 | while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) |
@@ -2201,16 +2249,17 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2201 | GNUNET_SCHEDULER_cancel (plugin->select_broadcast_task); | 2249 | GNUNET_SCHEDULER_cancel (plugin->select_broadcast_task); |
2202 | plugin->select_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 2250 | plugin->select_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
2203 | } | 2251 | } |
2204 | if (plugin->send_broadcast_task != GNUNET_SCHEDULER_NO_TASK) | 2252 | if (plugin->send_broadcast_task != GNUNET_SCHEDULER_NO_TASK) |
2205 | { | 2253 | { |
2206 | GNUNET_SCHEDULER_cancel (plugin->send_broadcast_task ); | 2254 | GNUNET_SCHEDULER_cancel (plugin->send_broadcast_task); |
2207 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 2255 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
2208 | } | 2256 | } |
2209 | if (plugin->broadcast_mst != NULL) | 2257 | if (plugin->broadcast_mst != NULL) |
2210 | GNUNET_SERVER_mst_destroy(plugin->broadcast_mst); | 2258 | GNUNET_SERVER_mst_destroy (plugin->broadcast_mst); |
2211 | if (plugin->sockv4_broadcast != NULL) | 2259 | if (plugin->sockv4_broadcast != NULL) |
2212 | { | 2260 | { |
2213 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast)); | 2261 | GNUNET_break (GNUNET_OK == |
2262 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast)); | ||
2214 | plugin->sockv4_broadcast = NULL; | 2263 | plugin->sockv4_broadcast = NULL; |
2215 | } | 2264 | } |
2216 | GNUNET_NETWORK_fdset_destroy (plugin->broadcast_rs); | 2265 | GNUNET_NETWORK_fdset_destroy (plugin->broadcast_rs); |
diff --git a/src/transport/plugin_transport_udp_new.c b/src/transport/plugin_transport_udp_new.c index 325c5d893..7eb4cbe87 100644 --- a/src/transport/plugin_transport_udp_new.c +++ b/src/transport/plugin_transport_udp_new.c | |||
@@ -299,21 +299,22 @@ struct Plugin | |||
299 | 299 | ||
300 | }; | 300 | }; |
301 | 301 | ||
302 | int delete_session_iterator (void *cls, | 302 | int |
303 | const GNUNET_HashCode * key, | 303 | delete_session_iterator (void *cls, const GNUNET_HashCode * key, void *value) |
304 | void *value) | ||
305 | { | 304 | { |
306 | struct Session *s = (struct Session *) value; | 305 | struct Session *s = (struct Session *) value; |
306 | |||
307 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) | 307 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) |
308 | { | 308 | { |
309 | GNUNET_SCHEDULER_cancel(s->invalidation_task); | 309 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
310 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | 310 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
311 | } | 311 | } |
312 | GNUNET_CONTAINER_multihashmap_remove(s->plugin->sessions, key, s); | 312 | GNUNET_CONTAINER_multihashmap_remove (s->plugin->sessions, key, s); |
313 | 313 | ||
314 | GNUNET_free (s); | 314 | GNUNET_free (s); |
315 | return GNUNET_YES; | 315 | return GNUNET_YES; |
316 | } | 316 | } |
317 | |||
317 | /** | 318 | /** |
318 | * Disconnect from a remote node. Clean up session if we have one for this peer | 319 | * Disconnect from a remote node. Clean up session if we have one for this peer |
319 | * | 320 | * |
@@ -326,7 +327,8 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
326 | { | 327 | { |
327 | struct Plugin *plugin = cls; | 328 | struct Plugin *plugin = cls; |
328 | 329 | ||
329 | GNUNET_CONTAINER_multihashmap_get_multiple(plugin, &target->hashPubKey, &delete_session_iterator, NULL); | 330 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin, &target->hashPubKey, |
331 | &delete_session_iterator, NULL); | ||
330 | 332 | ||
331 | } | 333 | } |
332 | 334 | ||
@@ -370,25 +372,25 @@ udp_send (struct Plugin *plugin, const struct sockaddr *sa, | |||
370 | { | 372 | { |
371 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); | 373 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
372 | LOG (GNUNET_ERROR_TYPE_ERROR, | 374 | LOG (GNUNET_ERROR_TYPE_ERROR, |
373 | "UDP transmited %u-byte message to %s (%d: %s)\n", | 375 | "UDP transmited %u-byte message to %s (%d: %s)\n", |
374 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), | 376 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, |
375 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); | 377 | (sent < 0) ? STRERROR (errno) : "ok"); |
376 | 378 | ||
377 | } | 379 | } |
378 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 380 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
379 | "UDP transmited %u-byte message to %s (%d: %s)\n", | 381 | "UDP transmited %u-byte message to %s (%d: %s)\n", |
380 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), | 382 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, |
381 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); | 383 | (sent < 0) ? STRERROR (errno) : "ok"); |
382 | return sent; | 384 | return sent; |
383 | } | 385 | } |
384 | 386 | ||
385 | 387 | ||
386 | static struct Session * | 388 | static struct Session * |
387 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 389 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, |
388 | const void *addr, size_t addrlen, | 390 | const void *addr, size_t addrlen, |
389 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 391 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
390 | { | 392 | { |
391 | struct Session * s; | 393 | struct Session *s; |
392 | const struct IPv4UdpAddress *t4; | 394 | const struct IPv4UdpAddress *t4; |
393 | const struct IPv6UdpAddress *t6; | 395 | const struct IPv6UdpAddress *t6; |
394 | struct sockaddr_in *v4; | 396 | struct sockaddr_in *v4; |
@@ -403,9 +405,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
403 | return NULL; | 405 | return NULL; |
404 | } | 406 | } |
405 | t4 = addr; | 407 | t4 = addr; |
406 | s = | 408 | s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in)); |
407 | GNUNET_malloc (sizeof (struct Session) + | ||
408 | sizeof (struct sockaddr_in)); | ||
409 | len = sizeof (struct sockaddr_in); | 409 | len = sizeof (struct sockaddr_in); |
410 | v4 = (struct sockaddr_in *) &s[1]; | 410 | v4 = (struct sockaddr_in *) &s[1]; |
411 | v4->sin_family = AF_INET; | 411 | v4->sin_family = AF_INET; |
@@ -421,9 +421,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
421 | return NULL; | 421 | return NULL; |
422 | } | 422 | } |
423 | t6 = addr; | 423 | t6 = addr; |
424 | s = | 424 | s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6)); |
425 | GNUNET_malloc (sizeof (struct Session) + | ||
426 | sizeof (struct sockaddr_in6)); | ||
427 | len = sizeof (struct sockaddr_in6); | 425 | len = sizeof (struct sockaddr_in6); |
428 | v6 = (struct sockaddr_in6 *) &s[1]; | 426 | v6 = (struct sockaddr_in6 *) &s[1]; |
429 | v6->sin6_family = AF_INET6; | 427 | v6->sin6_family = AF_INET6; |
@@ -457,13 +455,17 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
457 | static void | 455 | static void |
458 | invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 456 | invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
459 | { | 457 | { |
460 | struct Session * s = cls; | 458 | struct Session *s = cls; |
461 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | ||
462 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
463 | "Session %X (`%s') is now invalid\n", s, GNUNET_a2s (s->sock_addr,s->addrlen)); | ||
464 | 459 | ||
465 | s->plugin->env->session_end(s->plugin->env->cls, &s->target, s); | 460 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
466 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(s->plugin->sessions, &s->target.hashPubKey, s)); | 461 | LOG (GNUNET_ERROR_TYPE_ERROR, "Session %X (`%s') is now invalid\n", s, |
462 | GNUNET_a2s (s->sock_addr, s->addrlen)); | ||
463 | |||
464 | s->plugin->env->session_end (s->plugin->env->cls, &s->target, s); | ||
465 | GNUNET_assert (GNUNET_YES == | ||
466 | GNUNET_CONTAINER_multihashmap_remove (s->plugin->sessions, | ||
467 | &s->target.hashPubKey, | ||
468 | s)); | ||
467 | GNUNET_free (s); | 469 | GNUNET_free (s); |
468 | } | 470 | } |
469 | 471 | ||
@@ -534,10 +536,10 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
534 | } | 536 | } |
535 | 537 | ||
536 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 538 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
537 | "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n", | 539 | "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n", |
538 | msgbuf_size, GNUNET_i2s (target), | 540 | msgbuf_size, GNUNET_i2s (target), udp_address_to_string (NULL, addr, |
539 | udp_address_to_string (NULL, addr, addrlen), | 541 | addrlen), |
540 | session, force_address); | 542 | session, force_address); |
541 | 543 | ||
542 | /* no valid address given */ | 544 | /* no valid address given */ |
543 | if ((addr = NULL) || (addrlen == 0)) | 545 | if ((addr = NULL) || (addrlen == 0)) |
@@ -562,10 +564,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
562 | if (force_address == GNUNET_SYSERR) | 564 | if (force_address == GNUNET_SYSERR) |
563 | return GNUNET_SYSERR; | 565 | return GNUNET_SYSERR; |
564 | /* create new session */ | 566 | /* create new session */ |
565 | s = create_session(plugin, target, addr, addrlen, cont, cont_cls); | 567 | s = create_session (plugin, target, addr, addrlen, cont, cont_cls); |
566 | GNUNET_CONTAINER_multihashmap_put(plugin->sessions, &target->hashPubKey, s, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 568 | GNUNET_CONTAINER_multihashmap_put (plugin->sessions, &target->hashPubKey, s, |
569 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
567 | /* schedule invalidation task */ | 570 | /* schedule invalidation task */ |
568 | s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, NULL); | 571 | s->invalidation_task = |
572 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
573 | &invalidation_task, NULL); | ||
569 | } | 574 | } |
570 | 575 | ||
571 | /* Message */ | 576 | /* Message */ |
@@ -576,12 +581,16 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
576 | udp->sender = *plugin->env->my_identity; | 581 | udp->sender = *plugin->env->my_identity; |
577 | memcpy (&udp[1], msgbuf, msgbuf_size); | 582 | memcpy (&udp[1], msgbuf, msgbuf_size); |
578 | 583 | ||
579 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); | 584 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
585 | |||
580 | if (s->flow_delay_from_other_peer.abs_value > now.abs_value) | 586 | if (s->flow_delay_from_other_peer.abs_value > now.abs_value) |
581 | { | 587 | { |
582 | struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(now, s->flow_delay_from_other_peer); | 588 | struct GNUNET_TIME_Relative delta = |
583 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 589 | GNUNET_TIME_absolute_get_difference (now, |
584 | "We try to send to early! Should in %llu!\n", delta.rel_value); | 590 | s->flow_delay_from_other_peer); |
591 | |||
592 | LOG (GNUNET_ERROR_TYPE_DEBUG, "We try to send to early! Should in %llu!\n", | ||
593 | delta.rel_value); | ||
585 | } | 594 | } |
586 | else | 595 | else |
587 | LOG (GNUNET_ERROR_TYPE_DEBUG, "We can send!\n"); | 596 | LOG (GNUNET_ERROR_TYPE_DEBUG, "We can send!\n"); |
@@ -598,11 +607,11 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
598 | /* send with fragmentation */ | 607 | /* send with fragmentation */ |
599 | else | 608 | else |
600 | { | 609 | { |
601 | s->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU, | 610 | s->frag = |
611 | GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU, | ||
602 | &plugin->tracker, | 612 | &plugin->tracker, |
603 | plugin->last_expected_delay, | 613 | plugin->last_expected_delay, |
604 | &udp->header, &send_fragment, | 614 | &udp->header, &send_fragment, s); |
605 | s); | ||
606 | } | 615 | } |
607 | return mlen; | 616 | return mlen; |
608 | } | 617 | } |
@@ -621,7 +630,7 @@ process_inbound_tokenized_messages (void *cls, void *client, | |||
621 | const struct GNUNET_MessageHeader *hdr) | 630 | const struct GNUNET_MessageHeader *hdr) |
622 | { | 631 | { |
623 | struct Plugin *plugin = cls; | 632 | struct Plugin *plugin = cls; |
624 | struct Session * s = client; | 633 | struct Session *s = client; |
625 | struct GNUNET_ATS_Information distance; | 634 | struct GNUNET_ATS_Information distance; |
626 | struct GNUNET_TIME_Relative delay; | 635 | struct GNUNET_TIME_Relative delay; |
627 | 636 | ||
@@ -629,11 +638,12 @@ process_inbound_tokenized_messages (void *cls, void *client, | |||
629 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 638 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
630 | distance.value = htonl (1); | 639 | distance.value = htonl (1); |
631 | 640 | ||
632 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 641 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving Session %X %s to transport\n", |
633 | "Giving Session %X %s to transport\n", s->session, GNUNET_i2s(&s->target)); | 642 | s->session, GNUNET_i2s (&s->target)); |
634 | delay = plugin->env->receive (plugin->env->cls, &s->target, hdr, &distance, 1, s, | 643 | delay = |
635 | // FIXME: USE UDP ADDRESSES!!!! | 644 | plugin->env->receive (plugin->env->cls, &s->target, hdr, &distance, 1, s, |
636 | s->sock_addr, s->addrlen); | 645 | // FIXME: USE UDP ADDRESSES!!!! |
646 | s->sock_addr, s->addrlen); | ||
637 | s->flow_delay_for_other_peer = delay; | 647 | s->flow_delay_for_other_peer = delay; |
638 | } | 648 | } |
639 | 649 | ||
@@ -691,54 +701,54 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
691 | } | 701 | } |
692 | #if DEBUG_UDP | 702 | #if DEBUG_UDP |
693 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 703 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
694 | "Received message with %u bytes from peer `%s' at `%s'\n", | 704 | "Received message with %u bytes from peer `%s' at `%s'\n", |
695 | (unsigned int) ntohs (msg->header.size), | 705 | (unsigned int) ntohs (msg->header.size), GNUNET_i2s (&msg->sender), |
696 | GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr, | 706 | GNUNET_a2s (sender_addr, sender_addr_len)); |
697 | sender_addr_len)); | ||
698 | #endif | 707 | #endif |
699 | 708 | ||
700 | const struct UDPMessage * udp_msg = (const struct UDPMessage *) msg; | 709 | const struct UDPMessage *udp_msg = (const struct UDPMessage *) msg; |
710 | |||
701 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 711 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
702 | "Lookup inbound UDP sessions for peer `%s' address `%s'\n", | 712 | "Lookup inbound UDP sessions for peer `%s' address `%s'\n", |
703 | GNUNET_i2s (&udp_msg->sender), | 713 | GNUNET_i2s (&udp_msg->sender), udp_address_to_string (NULL, arg, args)); |
704 | udp_address_to_string(NULL, arg, args)); | ||
705 | 714 | ||
706 | /* create a session for inbound connections */ | 715 | /* create a session for inbound connections */ |
707 | struct Session * s = NULL; | 716 | struct Session *s = NULL; |
708 | s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, sender_addr_len); | 717 | |
718 | s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, | ||
719 | sender_addr_len); | ||
709 | 720 | ||
710 | if (s != NULL) | 721 | if (s != NULL) |
711 | { | 722 | { |
712 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 723 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
713 | "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n", | 724 | "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n", |
714 | s, | 725 | s, GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args)); |
715 | GNUNET_i2s (&s->target), | ||
716 | udp_address_to_string(NULL, arg, args)); | ||
717 | } | 726 | } |
718 | else | 727 | else |
719 | { | 728 | { |
720 | s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL); | 729 | s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL); |
721 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 730 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
722 | "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", | 731 | "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", s, |
723 | s, | 732 | GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args)); |
724 | GNUNET_i2s (&s->target), | 733 | |
725 | udp_address_to_string(NULL, arg, args)); | 734 | GNUNET_assert (GNUNET_OK == |
726 | 735 | GNUNET_CONTAINER_multihashmap_put (plugin->sessions, | |
727 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->sessions, | 736 | &s->target.hashPubKey, s, |
728 | &s->target.hashPubKey, | 737 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
729 | s, | ||
730 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
731 | } | 738 | } |
732 | s->valid_until = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 739 | s->valid_until = |
740 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), | ||
741 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
733 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) | 742 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) |
734 | { | 743 | { |
735 | GNUNET_SCHEDULER_cancel(s->invalidation_task); | 744 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
736 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | 745 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
737 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 746 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Rescheduling %X' `%s'\n", s, |
738 | "Rescheduling %X' `%s'\n", | 747 | udp_address_to_string (NULL, arg, args)); |
739 | s, udp_address_to_string(NULL, arg, args)); | ||
740 | } | 748 | } |
741 | s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, s); | 749 | s->invalidation_task = |
750 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
751 | &invalidation_task, s); | ||
742 | /* we received from peer, so session is bidirectional and reliable */ | 752 | /* we received from peer, so session is bidirectional and reliable */ |
743 | s->bidirectional = GNUNET_YES; | 753 | s->bidirectional = GNUNET_YES; |
744 | 754 | ||
@@ -768,7 +778,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
768 | struct ReceiveContext *rc; | 778 | struct ReceiveContext *rc; |
769 | struct GNUNET_TIME_Absolute now; | 779 | struct GNUNET_TIME_Absolute now; |
770 | struct FindReceiveContext frc; | 780 | struct FindReceiveContext frc; |
771 | struct Session * s = NULL; | 781 | struct Session *s = NULL; |
772 | struct GNUNET_TIME_Relative flow_delay; | 782 | struct GNUNET_TIME_Relative flow_delay; |
773 | 783 | ||
774 | fromlen = sizeof (addr); | 784 | fromlen = sizeof (addr); |
@@ -784,8 +794,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
784 | msg = (const struct GNUNET_MessageHeader *) buf; | 794 | msg = (const struct GNUNET_MessageHeader *) buf; |
785 | 795 | ||
786 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 796 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
787 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret, | 797 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret, |
788 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs(msg->type)); | 798 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs (msg->type)); |
789 | 799 | ||
790 | if (ret != ntohs (msg->size)) | 800 | if (ret != ntohs (msg->size)) |
791 | { | 801 | { |
@@ -814,26 +824,25 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
814 | } | 824 | } |
815 | udp_ack = (const struct UDP_ACK_Message *) msg; | 825 | udp_ack = (const struct UDP_ACK_Message *) msg; |
816 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 826 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
817 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | 827 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", |
818 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp->sender), | 828 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp->sender), |
819 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 829 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
820 | 830 | ||
821 | // TODO Guess a session from address, give it defragmenter and check in process_udp if guess was right | 831 | // TODO Guess a session from address, give it defragmenter and check in process_udp if guess was right |
822 | s = guess_session (plugin->sessions, addr, addrlen); | 832 | s = guess_session (plugin->sessions, addr, addrlen); |
823 | if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (peer_session->frag, ack)) | 833 | if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (peer_session->frag, ack)) |
824 | // ... other stuff | 834 | // ... other stuff |
825 | return; | 835 | return; |
826 | 836 | ||
827 | case GNUNET_MESSAGE_TYPE_FRAGMENT: | 837 | case GNUNET_MESSAGE_TYPE_FRAGMENT: |
828 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 838 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n", |
829 | "UDP processes %u-byte fragment from `%s'\n", | 839 | (unsigned int) ntohs (msg->size), |
830 | (unsigned int) ntohs (msg->size), | 840 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
831 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
832 | // TODO Guess a session from address, give it defragmenter and check in process_udp if guess was right | 841 | // TODO Guess a session from address, give it defragmenter and check in process_udp if guess was right |
833 | s = guess_session (plugin->sessions, addr, addrlen); | 842 | s = guess_session (plugin->sessions, addr, addrlen); |
834 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) | 843 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) |
835 | // other stuff | 844 | // other stuff |
836 | return; | 845 | return; |
837 | default: | 846 | default: |
838 | GNUNET_break_op (0); | 847 | GNUNET_break_op (0); |
839 | return; | 848 | return; |
@@ -995,7 +1004,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
995 | } | 1004 | } |
996 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); | 1005 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); |
997 | GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", | 1006 | GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", |
998 | buf, port); | 1007 | buf, port); |
999 | return rbuf; | 1008 | return rbuf; |
1000 | } | 1009 | } |
1001 | 1010 | ||
@@ -1206,8 +1215,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1206 | if (port > 65535) | 1215 | if (port > 65535) |
1207 | { | 1216 | { |
1208 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1217 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1209 | _("Given `%s' option is out of range: %llu > %u\n"), "PORT", | 1218 | _("Given `%s' option is out of range: %llu > %u\n"), "PORT", port, |
1210 | port, 65535); | 1219 | 65535); |
1211 | return NULL; | 1220 | return NULL; |
1212 | } | 1221 | } |
1213 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); | 1222 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); |
@@ -1235,8 +1244,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1235 | "BINDTO", &plugin->bind4_address)) | 1244 | "BINDTO", &plugin->bind4_address)) |
1236 | { | 1245 | { |
1237 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1246 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1238 | "Binding udp plugin to specific address: `%s'\n", | 1247 | "Binding udp plugin to specific address: `%s'\n", |
1239 | plugin->bind4_address); | 1248 | plugin->bind4_address); |
1240 | if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr)) | 1249 | if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr)) |
1241 | { | 1250 | { |
1242 | GNUNET_free (plugin->bind4_address); | 1251 | GNUNET_free (plugin->bind4_address); |
@@ -1251,13 +1260,13 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1251 | "BINDTO6", &plugin->bind6_address)) | 1260 | "BINDTO6", &plugin->bind6_address)) |
1252 | { | 1261 | { |
1253 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1262 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1254 | "Binding udp plugin to specific address: `%s'\n", | 1263 | "Binding udp plugin to specific address: `%s'\n", |
1255 | plugin->bind6_address); | 1264 | plugin->bind6_address); |
1256 | if (1 != | 1265 | if (1 != |
1257 | inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) | 1266 | inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) |
1258 | { | 1267 | { |
1259 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), | 1268 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), |
1260 | plugin->bind6_address); | 1269 | plugin->bind6_address); |
1261 | GNUNET_free_non_null (plugin->bind4_address); | 1270 | GNUNET_free_non_null (plugin->bind4_address); |
1262 | GNUNET_free (plugin->bind6_address); | 1271 | GNUNET_free (plugin->bind6_address); |
1263 | GNUNET_free (plugin); | 1272 | GNUNET_free (plugin); |
@@ -1296,7 +1305,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1296 | serverAddr = (struct sockaddr *) &serverAddrv6; | 1305 | serverAddr = (struct sockaddr *) &serverAddrv6; |
1297 | #if DEBUG_UDP | 1306 | #if DEBUG_UDP |
1298 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", | 1307 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", |
1299 | ntohs (serverAddrv6.sin6_port)); | 1308 | ntohs (serverAddrv6.sin6_port)); |
1300 | #endif | 1309 | #endif |
1301 | tries = 0; | 1310 | tries = 0; |
1302 | while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != | 1311 | while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != |
@@ -1305,8 +1314,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1305 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 1314 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
1306 | #if DEBUG_UDP | 1315 | #if DEBUG_UDP |
1307 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1316 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1308 | "IPv6 Binding failed, trying new port %d\n", | 1317 | "IPv6 Binding failed, trying new port %d\n", |
1309 | ntohs (serverAddrv6.sin6_port)); | 1318 | ntohs (serverAddrv6.sin6_port)); |
1310 | #endif | 1319 | #endif |
1311 | tries++; | 1320 | tries++; |
1312 | if (tries > 10) | 1321 | if (tries > 10) |
@@ -1344,7 +1353,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1344 | serverAddr = (struct sockaddr *) &serverAddrv4; | 1353 | serverAddr = (struct sockaddr *) &serverAddrv4; |
1345 | #if DEBUG_UDP | 1354 | #if DEBUG_UDP |
1346 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", | 1355 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", |
1347 | ntohs (serverAddrv4.sin_port)); | 1356 | ntohs (serverAddrv4.sin_port)); |
1348 | #endif | 1357 | #endif |
1349 | tries = 0; | 1358 | tries = 0; |
1350 | while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != | 1359 | while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != |
@@ -1352,9 +1361,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1352 | { | 1361 | { |
1353 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 1362 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
1354 | #if DEBUG_UDP | 1363 | #if DEBUG_UDP |
1355 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1364 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Binding failed, trying new port %d\n", |
1356 | "IPv4 Binding failed, trying new port %d\n", | 1365 | ntohs (serverAddrv4.sin_port)); |
1357 | ntohs (serverAddrv4.sin_port)); | ||
1358 | #endif | 1366 | #endif |
1359 | tries++; | 1367 | tries++; |
1360 | if (tries > 10) | 1368 | if (tries > 10) |
@@ -1411,8 +1419,8 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
1411 | NULL); | 1419 | NULL); |
1412 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); | 1420 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); |
1413 | plugin->sessions = NULL; | 1421 | plugin->sessions = NULL; |
1414 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &destroy_inbound_session, | 1422 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, |
1415 | NULL); | 1423 | &destroy_inbound_session, NULL); |
1416 | GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions); | 1424 | GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions); |
1417 | plugin->inbound_sessions = NULL; | 1425 | plugin->inbound_sessions = NULL; |
1418 | while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) | 1426 | while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 32f047d65..270829e68 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -731,9 +731,8 @@ unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
731 | un->sun_path); | 731 | un->sun_path); |
732 | #endif | 732 | #endif |
733 | plugin->env->receive (plugin->env->cls, sender, currhdr, | 733 | plugin->env->receive (plugin->env->cls, sender, currhdr, |
734 | (const struct GNUNET_ATS_Information *) | 734 | (const struct GNUNET_ATS_Information *) &distance, 1, |
735 | &distance, 1, NULL, un->sun_path, | 735 | NULL, un->sun_path, strlen (un->sun_path) + 1); |
736 | strlen (un->sun_path) + 1); | ||
737 | } | 736 | } |
738 | 737 | ||
739 | 738 | ||
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 041e80f86..cbab8cb0f 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -862,7 +862,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
862 | struct Sessionqueue *queue = cls; | 862 | struct Sessionqueue *queue = cls; |
863 | 863 | ||
864 | GNUNET_assert (queue != NULL); | 864 | GNUNET_assert (queue != NULL); |
865 | GNUNET_assert(queue->content != NULL); | 865 | GNUNET_assert (queue->content != NULL); |
866 | queue->content->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 866 | queue->content->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
867 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | 867 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) |
868 | { | 868 | { |
@@ -873,9 +873,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
873 | (queue->content->last_activity, SESSION_TIMEOUT)).rel_value == 0) | 873 | (queue->content->last_activity, SESSION_TIMEOUT)).rel_value == 0) |
874 | { | 874 | { |
875 | 875 | ||
876 | GNUNET_assert(queue->content->mac != NULL); | 876 | GNUNET_assert (queue->content->mac != NULL); |
877 | GNUNET_assert(queue->content->mac->plugin != NULL); | 877 | GNUNET_assert (queue->content->mac->plugin != NULL); |
878 | GNUNET_STATISTICS_update (queue->content->mac->plugin->env->stats, _("# wlan session timeouts"), 1, GNUNET_NO); | 878 | GNUNET_STATISTICS_update (queue->content->mac->plugin->env->stats, |
879 | _("# wlan session timeouts"), 1, GNUNET_NO); | ||
879 | free_session (queue->content->mac->plugin, queue, GNUNET_YES); | 880 | free_session (queue->content->mac->plugin, queue, GNUNET_YES); |
880 | } | 881 | } |
881 | else | 882 | else |
@@ -900,7 +901,8 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint, | |||
900 | { | 901 | { |
901 | GNUNET_assert (endpoint != NULL); | 902 | GNUNET_assert (endpoint != NULL); |
902 | GNUNET_assert (plugin != NULL); | 903 | GNUNET_assert (plugin != NULL); |
903 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan session created"), 1, GNUNET_NO); | 904 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan session created"), 1, |
905 | GNUNET_NO); | ||
904 | struct Sessionqueue *queue = | 906 | struct Sessionqueue *queue = |
905 | GNUNET_malloc (sizeof (struct Sessionqueue) + sizeof (struct Session)); | 907 | GNUNET_malloc (sizeof (struct Sessionqueue) + sizeof (struct Session)); |
906 | 908 | ||
@@ -983,7 +985,8 @@ queue_session (struct Plugin *plugin, struct Session *session) | |||
983 | GNUNET_CONTAINER_DLL_insert_tail (plugin->pending_Sessions_head, | 985 | GNUNET_CONTAINER_DLL_insert_tail (plugin->pending_Sessions_head, |
984 | plugin->pending_Sessions_tail, queue); | 986 | plugin->pending_Sessions_tail, queue); |
985 | plugin->pendingsessions++; | 987 | plugin->pendingsessions++; |
986 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO); | 988 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"), |
989 | plugin->pendingsessions, GNUNET_NO); | ||
987 | } | 990 | } |
988 | 991 | ||
989 | } | 992 | } |
@@ -1132,24 +1135,25 @@ get_next_queue_session (struct Plugin *plugin) | |||
1132 | pm = session->pending_message_head; | 1135 | pm = session->pending_message_head; |
1133 | 1136 | ||
1134 | if (pm == NULL) | 1137 | if (pm == NULL) |
1135 | { | 1138 | { |
1136 | #if DEBUG_wlan | 1139 | #if DEBUG_wlan |
1137 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1140 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1138 | "pending message is empty, should not happen. session %p\n", | 1141 | "pending message is empty, should not happen. session %p\n", |
1139 | session); | 1142 | session); |
1140 | #endif | 1143 | #endif |
1141 | sessionqueue_alt = sessionqueue; | 1144 | sessionqueue_alt = sessionqueue; |
1142 | sessionqueue = sessionqueue->next; | 1145 | sessionqueue = sessionqueue->next; |
1143 | plugin->pendingsessions--; | 1146 | plugin->pendingsessions--; |
1144 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO); | 1147 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"), |
1145 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, | 1148 | plugin->pendingsessions, GNUNET_NO); |
1146 | plugin->pending_Sessions_tail, | 1149 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, |
1147 | sessionqueue_alt); | 1150 | plugin->pending_Sessions_tail, |
1151 | sessionqueue_alt); | ||
1148 | 1152 | ||
1149 | GNUNET_free (sessionqueue_alt); | 1153 | GNUNET_free (sessionqueue_alt); |
1150 | continue; | 1154 | continue; |
1151 | 1155 | ||
1152 | } | 1156 | } |
1153 | 1157 | ||
1154 | //check for message timeout | 1158 | //check for message timeout |
1155 | if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0) | 1159 | if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0) |
@@ -1161,7 +1165,8 @@ get_next_queue_session (struct Plugin *plugin) | |||
1161 | FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION)) | 1165 | FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION)) |
1162 | { | 1166 | { |
1163 | plugin->pendingsessions--; | 1167 | plugin->pendingsessions--; |
1164 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO); | 1168 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"), |
1169 | plugin->pendingsessions, GNUNET_NO); | ||
1165 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, | 1170 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, |
1166 | plugin->pending_Sessions_tail, | 1171 | plugin->pending_Sessions_tail, |
1167 | sessionqueue); | 1172 | sessionqueue); |
@@ -1191,7 +1196,8 @@ get_next_queue_session (struct Plugin *plugin) | |||
1191 | sessionqueue_alt = sessionqueue; | 1196 | sessionqueue_alt = sessionqueue; |
1192 | sessionqueue = sessionqueue->next; | 1197 | sessionqueue = sessionqueue->next; |
1193 | plugin->pendingsessions--; | 1198 | plugin->pendingsessions--; |
1194 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO); | 1199 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"), |
1200 | plugin->pendingsessions, GNUNET_NO); | ||
1195 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, | 1201 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, |
1196 | plugin->pending_Sessions_tail, | 1202 | plugin->pending_Sessions_tail, |
1197 | sessionqueue_alt); | 1203 | sessionqueue_alt); |
@@ -1217,38 +1223,40 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm) | |||
1217 | struct FragmentMessage_queue *fmq; | 1223 | struct FragmentMessage_queue *fmq; |
1218 | struct FragmentMessage_queue *fmq_next; | 1224 | struct FragmentMessage_queue *fmq_next; |
1219 | 1225 | ||
1220 | fmq = plugin->sending_messages_head; | 1226 | fmq = plugin->sending_messages_head; |
1221 | while (fmq != NULL) | 1227 | while (fmq != NULL) |
1228 | { | ||
1229 | fmq_next = fmq->next; | ||
1230 | if (fmq->content == fm) | ||
1222 | { | 1231 | { |
1223 | fmq_next = fmq->next; | 1232 | GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head, |
1224 | if (fmq->content == fm) | 1233 | plugin->sending_messages_tail, fmq); |
1225 | { | 1234 | GNUNET_free (fmq); |
1226 | GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head, | ||
1227 | plugin->sending_messages_tail, fmq); | ||
1228 | GNUNET_free (fmq); | ||
1229 | } | ||
1230 | fmq = fmq_next; | ||
1231 | } | 1235 | } |
1236 | fmq = fmq_next; | ||
1237 | } | ||
1232 | 1238 | ||
1233 | (session->mac->fragment_messages_out_count)--; | 1239 | (session->mac->fragment_messages_out_count)--; |
1234 | session->fragment_messages_out_count--; | 1240 | session->fragment_messages_out_count--; |
1235 | plugin->pending_Fragment_Messages--; | 1241 | plugin->pending_Fragment_Messages--; |
1236 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending fragments"), plugin->pending_Fragment_Messages, GNUNET_NO); | 1242 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"), |
1237 | GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, | 1243 | plugin->pending_Fragment_Messages, GNUNET_NO); |
1238 | endpoint->sending_messages_tail, fm); | 1244 | GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, |
1239 | GNUNET_FRAGMENT_context_destroy (fm->fragcontext); | 1245 | endpoint->sending_messages_tail, fm); |
1240 | if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK){ | 1246 | GNUNET_FRAGMENT_context_destroy (fm->fragcontext); |
1241 | GNUNET_SCHEDULER_cancel (fm->timeout_task); | 1247 | if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
1242 | fm->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1248 | { |
1243 | } | 1249 | GNUNET_SCHEDULER_cancel (fm->timeout_task); |
1250 | fm->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
1251 | } | ||
1244 | 1252 | ||
1245 | GNUNET_free (fm); | 1253 | GNUNET_free (fm); |
1246 | 1254 | ||
1247 | queue_session (plugin, session); | 1255 | queue_session (plugin, session); |
1248 | #if DEBUG_wlan | 1256 | #if DEBUG_wlan |
1249 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1257 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1250 | "Free pending fragment messages %p, session %p\n", fm, | 1258 | "Free pending fragment messages %p, session %p\n", fm, |
1251 | session); | 1259 | session); |
1252 | #endif | 1260 | #endif |
1253 | } | 1261 | } |
1254 | 1262 | ||
@@ -1499,15 +1507,17 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1499 | else | 1507 | else |
1500 | { | 1508 | { |
1501 | char cwd[FILENAME_MAX]; | 1509 | char cwd[FILENAME_MAX]; |
1502 | GNUNET_assert (getcwd(cwd, sizeof(cwd)) != NULL); | ||
1503 | 1510 | ||
1504 | GNUNET_asprintf (&absolute_filename, "%s%s%s", cwd, DIR_SEPARATOR_STR, filenameloopback); | 1511 | GNUNET_assert (getcwd (cwd, sizeof (cwd)) != NULL); |
1512 | |||
1513 | GNUNET_asprintf (&absolute_filename, "%s%s%s", cwd, DIR_SEPARATOR_STR, | ||
1514 | filenameloopback); | ||
1505 | 1515 | ||
1506 | if (GNUNET_DISK_file_test (filenameloopback) != GNUNET_YES) | 1516 | if (GNUNET_DISK_file_test (filenameloopback) != GNUNET_YES) |
1507 | { | 1517 | { |
1508 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1518 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1509 | "Helper `%s' not found! %i\n", absolute_filename); | 1519 | "Helper `%s' not found! %i\n", absolute_filename); |
1510 | GNUNET_break(0); | 1520 | GNUNET_break (0); |
1511 | } | 1521 | } |
1512 | } | 1522 | } |
1513 | } | 1523 | } |
@@ -1552,14 +1562,16 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1552 | "Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n", | 1562 | "Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n", |
1553 | absolute_filename, plugin->interface, plugin->testmode); | 1563 | absolute_filename, plugin->interface, plugin->testmode); |
1554 | #endif | 1564 | #endif |
1555 | plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, | 1565 | plugin->server_proc = |
1556 | absolute_filename, absolute_filename, "1", | 1566 | GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, |
1557 | NULL); | 1567 | absolute_filename, absolute_filename, "1", |
1568 | NULL); | ||
1558 | if (plugin->server_proc == NULL) | 1569 | if (plugin->server_proc == NULL) |
1559 | { | 1570 | { |
1560 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1571 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1561 | "`%s' not found, please look if it exists and is in the $PATH variable!\n", absolute_filename); | 1572 | "`%s' not found, please look if it exists and is in the $PATH variable!\n", |
1562 | GNUNET_break (0); | 1573 | absolute_filename); |
1574 | GNUNET_break (0); | ||
1563 | } | 1575 | } |
1564 | } | 1576 | } |
1565 | else if (plugin->testmode == 2) | 1577 | else if (plugin->testmode == 2) |
@@ -1570,18 +1582,20 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin) | |||
1570 | absolute_filename, plugin->interface, plugin->testmode); | 1582 | absolute_filename, plugin->interface, plugin->testmode); |
1571 | #endif | 1583 | #endif |
1572 | 1584 | ||
1573 | plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, | 1585 | plugin->server_proc = |
1574 | absolute_filename, absolute_filename, "2", | 1586 | GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, |
1575 | NULL); | 1587 | absolute_filename, absolute_filename, "2", |
1576 | if (plugin->server_proc == NULL) | 1588 | NULL); |
1577 | { | 1589 | if (plugin->server_proc == NULL) |
1578 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1590 | { |
1579 | "`%s' not found, please look if it exists and is in the $PATH variable!\n", absolute_filename); | 1591 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1592 | "`%s' not found, please look if it exists and is in the $PATH variable!\n", | ||
1593 | absolute_filename); | ||
1580 | GNUNET_break (0); | 1594 | GNUNET_break (0); |
1581 | } | 1595 | } |
1582 | } | 1596 | } |
1583 | if (absolute_filename != NULL) | 1597 | if (absolute_filename != NULL) |
1584 | GNUNET_free(absolute_filename); | 1598 | GNUNET_free (absolute_filename); |
1585 | if (plugin->server_proc == NULL) | 1599 | if (plugin->server_proc == NULL) |
1586 | { | 1600 | { |
1587 | #if DEBUG_wlan | 1601 | #if DEBUG_wlan |
@@ -1632,8 +1646,8 @@ static int | |||
1632 | wlan_transport_stop_wlan_helper (struct Plugin *plugin) | 1646 | wlan_transport_stop_wlan_helper (struct Plugin *plugin) |
1633 | { | 1647 | { |
1634 | #if DEBUG_wlan | 1648 | #if DEBUG_wlan |
1635 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1649 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1636 | "Stoping WLAN helper process\n"); | 1650 | "Stoping WLAN helper process\n"); |
1637 | #endif | 1651 | #endif |
1638 | 1652 | ||
1639 | if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK) | 1653 | if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -1657,7 +1671,7 @@ wlan_transport_stop_wlan_helper (struct Plugin *plugin) | |||
1657 | GNUNET_DISK_pipe_close (plugin->server_stdout); | 1671 | GNUNET_DISK_pipe_close (plugin->server_stdout); |
1658 | GNUNET_DISK_pipe_close (plugin->server_stdin); | 1672 | GNUNET_DISK_pipe_close (plugin->server_stdin); |
1659 | GNUNET_OS_process_kill (plugin->server_proc, SIGKILL); | 1673 | GNUNET_OS_process_kill (plugin->server_proc, SIGKILL); |
1660 | GNUNET_OS_process_wait(plugin->server_proc); | 1674 | GNUNET_OS_process_wait (plugin->server_proc); |
1661 | GNUNET_OS_process_close (plugin->server_proc); | 1675 | GNUNET_OS_process_close (plugin->server_proc); |
1662 | 1676 | ||
1663 | return GNUNET_YES; | 1677 | return GNUNET_YES; |
@@ -1673,31 +1687,32 @@ delay_restart_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1673 | { | 1687 | { |
1674 | struct Finish_send *finish = cls; | 1688 | struct Finish_send *finish = cls; |
1675 | struct Plugin *plugin; | 1689 | struct Plugin *plugin; |
1690 | |||
1676 | plugin = finish->plugin; | 1691 | plugin = finish->plugin; |
1677 | 1692 | ||
1678 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; | 1693 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; |
1679 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 1694 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) |
1680 | { | 1695 | { |
1681 | GNUNET_free_non_null(finish->msgstart); | 1696 | GNUNET_free_non_null (finish->msgstart); |
1682 | GNUNET_free (finish); | 1697 | GNUNET_free (finish); |
1683 | return; | 1698 | return; |
1684 | } | 1699 | } |
1685 | 1700 | ||
1686 | wlan_transport_start_wlan_helper(plugin); | 1701 | wlan_transport_start_wlan_helper (plugin); |
1687 | 1702 | ||
1688 | if (finish->size != 0) | 1703 | if (finish->size != 0) |
1689 | { | 1704 | { |
1690 | plugin->server_write_task = | 1705 | plugin->server_write_task = |
1691 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1706 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1692 | plugin->server_stdin_handle, | 1707 | plugin->server_stdin_handle, |
1693 | &finish_sending, finish); | 1708 | &finish_sending, finish); |
1694 | } | 1709 | } |
1695 | else | 1710 | else |
1696 | { | 1711 | { |
1697 | set_next_send (plugin); | 1712 | set_next_send (plugin); |
1698 | GNUNET_free_non_null(finish->msgstart); | 1713 | GNUNET_free_non_null (finish->msgstart); |
1699 | GNUNET_free (finish); | 1714 | GNUNET_free (finish); |
1700 | } | 1715 | } |
1701 | 1716 | ||
1702 | } | 1717 | } |
1703 | 1718 | ||
@@ -1707,14 +1722,15 @@ delay_restart_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1707 | * @param finish pointer to the Finish_send struct to finish | 1722 | * @param finish pointer to the Finish_send struct to finish |
1708 | */ | 1723 | */ |
1709 | static void | 1724 | static void |
1710 | restart_helper(struct Plugin *plugin, struct Finish_send *finish) | 1725 | restart_helper (struct Plugin *plugin, struct Finish_send *finish) |
1711 | { | 1726 | { |
1712 | static struct GNUNET_TIME_Relative next_try = {1000}; | 1727 | static struct GNUNET_TIME_Relative next_try = { 1000 }; |
1713 | GNUNET_assert(finish != NULL); | 1728 | GNUNET_assert (finish != NULL); |
1714 | 1729 | ||
1715 | wlan_transport_stop_wlan_helper(plugin); | 1730 | wlan_transport_stop_wlan_helper (plugin); |
1716 | plugin->server_write_task = GNUNET_SCHEDULER_add_delayed (next_try, &delay_restart_helper, finish); | 1731 | plugin->server_write_task = |
1717 | GNUNET_TIME_relative_multiply(next_try, HELPER_RESTART_SCALING_FACTOR); | 1732 | GNUNET_SCHEDULER_add_delayed (next_try, &delay_restart_helper, finish); |
1733 | GNUNET_TIME_relative_multiply (next_try, HELPER_RESTART_SCALING_FACTOR); | ||
1718 | 1734 | ||
1719 | } | 1735 | } |
1720 | 1736 | ||
@@ -1740,24 +1756,24 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1740 | return; | 1756 | return; |
1741 | } | 1757 | } |
1742 | bytes = | 1758 | bytes = |
1743 | GNUNET_DISK_file_write (plugin->server_stdin_handle, finish->head_of_next_write, | 1759 | GNUNET_DISK_file_write (plugin->server_stdin_handle, |
1744 | finish->size); | 1760 | finish->head_of_next_write, finish->size); |
1745 | 1761 | ||
1746 | if (bytes != finish->size) | 1762 | if (bytes != finish->size) |
1747 | { | 1763 | { |
1748 | if (bytes != GNUNET_SYSERR) | 1764 | if (bytes != GNUNET_SYSERR) |
1749 | { | 1765 | { |
1750 | finish->head_of_next_write += bytes; | 1766 | finish->head_of_next_write += bytes; |
1751 | finish->size -= bytes; | 1767 | finish->size -= bytes; |
1752 | plugin->server_write_task = | 1768 | plugin->server_write_task = |
1753 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1769 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1754 | plugin->server_stdin_handle, | 1770 | plugin->server_stdin_handle, |
1755 | &finish_sending, finish); | 1771 | &finish_sending, finish); |
1756 | } | 1772 | } |
1757 | else | 1773 | else |
1758 | { | 1774 | { |
1759 | restart_helper(plugin, finish); | 1775 | restart_helper (plugin, finish); |
1760 | } | 1776 | } |
1761 | } | 1777 | } |
1762 | else | 1778 | else |
1763 | { | 1779 | { |
@@ -1788,11 +1804,12 @@ send_hello_beacon (struct Plugin *plugin) | |||
1788 | struct Radiotap_Send *radioHeader; | 1804 | struct Radiotap_Send *radioHeader; |
1789 | struct GNUNET_MessageHeader *msgheader2; | 1805 | struct GNUNET_MessageHeader *msgheader2; |
1790 | const struct GNUNET_MessageHeader *hello; | 1806 | const struct GNUNET_MessageHeader *hello; |
1791 | struct Finish_send * finish; | 1807 | struct Finish_send *finish; |
1792 | 1808 | ||
1793 | GNUNET_assert (plugin != NULL); | 1809 | GNUNET_assert (plugin != NULL); |
1794 | 1810 | ||
1795 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), 1, GNUNET_NO); | 1811 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), |
1812 | 1, GNUNET_NO); | ||
1796 | 1813 | ||
1797 | hello = plugin->env->get_our_hello (); | 1814 | hello = plugin->env->get_our_hello (); |
1798 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 1815 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); |
@@ -1812,10 +1829,10 @@ send_hello_beacon (struct Plugin *plugin) | |||
1812 | 1829 | ||
1813 | msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1]; | 1830 | msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1]; |
1814 | /*msgheader2->size = | 1831 | /*msgheader2->size = |
1815 | htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) + | 1832 | * htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) + |
1816 | sizeof (struct GNUNET_MessageHeader)); | 1833 | * sizeof (struct GNUNET_MessageHeader)); |
1817 | 1834 | * | |
1818 | msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT);*/ | 1835 | * msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT); */ |
1819 | memcpy (msgheader2, hello, hello_size); | 1836 | memcpy (msgheader2, hello, hello_size); |
1820 | 1837 | ||
1821 | bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size); | 1838 | bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size); |
@@ -1831,17 +1848,17 @@ send_hello_beacon (struct Plugin *plugin) | |||
1831 | finish->head_of_next_write = NULL; | 1848 | finish->head_of_next_write = NULL; |
1832 | finish->size = 0; | 1849 | finish->size = 0; |
1833 | finish->msgstart = NULL; | 1850 | finish->msgstart = NULL; |
1834 | restart_helper(plugin, finish); | 1851 | restart_helper (plugin, finish); |
1835 | 1852 | ||
1836 | set_next_beacon_time (plugin); | 1853 | set_next_beacon_time (plugin); |
1837 | 1854 | ||
1838 | } | 1855 | } |
1839 | else | 1856 | else |
1840 | { | 1857 | { |
1841 | GNUNET_assert (bytes == size); | 1858 | GNUNET_assert (bytes == size); |
1842 | set_next_beacon_time (plugin); | 1859 | set_next_beacon_time (plugin); |
1843 | set_next_send (plugin); | 1860 | set_next_send (plugin); |
1844 | } | 1861 | } |
1845 | GNUNET_free (msgheader); | 1862 | GNUNET_free (msgheader); |
1846 | 1863 | ||
1847 | 1864 | ||
@@ -1951,7 +1968,8 @@ check_fragment_queue (struct Plugin *plugin) | |||
1951 | session->mac->fragment_messages_out_count++; | 1968 | session->mac->fragment_messages_out_count++; |
1952 | session->fragment_messages_out_count++; | 1969 | session->fragment_messages_out_count++; |
1953 | plugin->pending_Fragment_Messages++; | 1970 | plugin->pending_Fragment_Messages++; |
1954 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending fragments"), plugin->pending_Fragment_Messages, GNUNET_NO); | 1971 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"), |
1972 | plugin->pending_Fragment_Messages, GNUNET_NO); | ||
1955 | 1973 | ||
1956 | fm = GNUNET_malloc (sizeof (struct FragmentMessage)); | 1974 | fm = GNUNET_malloc (sizeof (struct FragmentMessage)); |
1957 | fm->session = session; | 1975 | fm->session = session; |
@@ -2012,7 +2030,7 @@ send_ack (struct Plugin *plugin) | |||
2012 | 2030 | ||
2013 | ssize_t bytes; | 2031 | ssize_t bytes; |
2014 | struct AckSendQueue *ack; | 2032 | struct AckSendQueue *ack; |
2015 | struct Finish_send * finish; | 2033 | struct Finish_send *finish; |
2016 | 2034 | ||
2017 | ack = plugin->ack_send_queue_head; | 2035 | ack = plugin->ack_send_queue_head; |
2018 | 2036 | ||
@@ -2025,7 +2043,8 @@ send_ack (struct Plugin *plugin) | |||
2025 | #endif | 2043 | #endif |
2026 | 2044 | ||
2027 | GNUNET_assert (plugin != NULL); | 2045 | GNUNET_assert (plugin != NULL); |
2028 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, GNUNET_NO); | 2046 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, |
2047 | GNUNET_NO); | ||
2029 | 2048 | ||
2030 | getRadiotapHeader (plugin, ack->endpoint, ack->radioHeader); | 2049 | getRadiotapHeader (plugin, ack->endpoint, ack->radioHeader); |
2031 | getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin, | 2050 | getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin, |
@@ -2045,7 +2064,7 @@ send_ack (struct Plugin *plugin) | |||
2045 | finish->head_of_next_write = NULL; | 2064 | finish->head_of_next_write = NULL; |
2046 | finish->size = 0; | 2065 | finish->size = 0; |
2047 | finish->msgstart = NULL; | 2066 | finish->msgstart = NULL; |
2048 | restart_helper(plugin, finish); | 2067 | restart_helper (plugin, finish); |
2049 | } | 2068 | } |
2050 | else | 2069 | else |
2051 | { | 2070 | { |
@@ -2067,6 +2086,7 @@ static void | |||
2067 | do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 2086 | do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
2068 | { | 2087 | { |
2069 | struct Plugin *plugin = cls; | 2088 | struct Plugin *plugin = cls; |
2089 | |||
2070 | GNUNET_assert (plugin != NULL); | 2090 | GNUNET_assert (plugin != NULL); |
2071 | 2091 | ||
2072 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; | 2092 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -2094,7 +2114,8 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2094 | 2114 | ||
2095 | if (plugin->sending_messages_head != NULL) | 2115 | if (plugin->sending_messages_head != NULL) |
2096 | { | 2116 | { |
2097 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1, GNUNET_NO); | 2117 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1, |
2118 | GNUNET_NO); | ||
2098 | 2119 | ||
2099 | fmq = plugin->sending_messages_head; | 2120 | fmq = plugin->sending_messages_head; |
2100 | fm = fmq->content; | 2121 | fm = fmq->content; |
@@ -2136,16 +2157,16 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2136 | 2157 | ||
2137 | finish->head_of_next_write = fm->frag; | 2158 | finish->head_of_next_write = fm->frag; |
2138 | finish->size = fm->size; | 2159 | finish->size = fm->size; |
2139 | restart_helper(plugin, finish); | 2160 | restart_helper (plugin, finish); |
2140 | } | 2161 | } |
2141 | else | 2162 | else |
2142 | { | 2163 | { |
2143 | finish->head_of_next_write = fm->frag + bytes; | 2164 | finish->head_of_next_write = fm->frag + bytes; |
2144 | finish->size = fm->size - bytes; | 2165 | finish->size = fm->size - bytes; |
2145 | plugin->server_write_task = | 2166 | plugin->server_write_task = |
2146 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | 2167 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
2147 | plugin->server_stdin_handle, | 2168 | plugin->server_stdin_handle, |
2148 | &finish_sending, finish); | 2169 | &finish_sending, finish); |
2149 | } | 2170 | } |
2150 | 2171 | ||
2151 | fm->frag = NULL; | 2172 | fm->frag = NULL; |
@@ -2192,13 +2213,15 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
2192 | /* TODO check for bad addresses like multicast, broadcast, etc */ | 2213 | /* TODO check for bad addresses like multicast, broadcast, etc */ |
2193 | #if DEBUG_wlan | 2214 | #if DEBUG_wlan |
2194 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2215 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2195 | "wlan_plugin_address_suggested got good address, size %u!\n", addrlen); | 2216 | "wlan_plugin_address_suggested got good address, size %u!\n", |
2217 | addrlen); | ||
2196 | #endif | 2218 | #endif |
2197 | return GNUNET_OK; | 2219 | return GNUNET_OK; |
2198 | } | 2220 | } |
2199 | #if DEBUG_wlan | 2221 | #if DEBUG_wlan |
2200 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2222 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2201 | "wlan_plugin_address_suggested got bad address, size %u!\n", addrlen); | 2223 | "wlan_plugin_address_suggested got bad address, size %u!\n", |
2224 | addrlen); | ||
2202 | #endif | 2225 | #endif |
2203 | return GNUNET_SYSERR; | 2226 | return GNUNET_SYSERR; |
2204 | } | 2227 | } |
@@ -2239,6 +2262,7 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
2239 | struct Plugin *plugin = cls; | 2262 | struct Plugin *plugin = cls; |
2240 | struct PendingMessage *newmsg; | 2263 | struct PendingMessage *newmsg; |
2241 | struct WlanHeader *wlanheader; | 2264 | struct WlanHeader *wlanheader; |
2265 | |||
2242 | GNUNET_assert (plugin != NULL); | 2266 | GNUNET_assert (plugin != NULL); |
2243 | //check if msglen > 0 | 2267 | //check if msglen > 0 |
2244 | GNUNET_assert (msgbuf_size > 0); | 2268 | GNUNET_assert (msgbuf_size > 0); |
@@ -2258,7 +2282,8 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
2258 | } | 2282 | } |
2259 | } | 2283 | } |
2260 | 2284 | ||
2261 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1, GNUNET_NO); | 2285 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1, |
2286 | GNUNET_NO); | ||
2262 | 2287 | ||
2263 | //queue message: | 2288 | //queue message: |
2264 | 2289 | ||
@@ -2348,7 +2373,8 @@ free_macendpoint (struct Plugin *plugin, struct MacEndpoint *endpoint) | |||
2348 | endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 2373 | endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
2349 | } | 2374 | } |
2350 | plugin->mac_count--; | 2375 | plugin->mac_count--; |
2351 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan mac endpoints"), plugin->mac_count, GNUNET_NO); | 2376 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"), |
2377 | plugin->mac_count, GNUNET_NO); | ||
2352 | GNUNET_free (endpoint); | 2378 | GNUNET_free (endpoint); |
2353 | 2379 | ||
2354 | } | 2380 | } |
@@ -2386,7 +2412,8 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue, | |||
2386 | if (pendingsession_tmp->content == queue->content) | 2412 | if (pendingsession_tmp->content == queue->content) |
2387 | { | 2413 | { |
2388 | plugin->pendingsessions--; | 2414 | plugin->pendingsessions--; |
2389 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO); | 2415 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"), |
2416 | plugin->pendingsessions, GNUNET_NO); | ||
2390 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, | 2417 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, |
2391 | plugin->pending_Sessions_tail, | 2418 | plugin->pending_Sessions_tail, |
2392 | pendingsession_tmp); | 2419 | pendingsession_tmp); |
@@ -2423,12 +2450,14 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue, | |||
2423 | GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail, | 2450 | GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail, |
2424 | queue); | 2451 | queue); |
2425 | //Check that no ohter session on this endpoint for this session exits | 2452 | //Check that no ohter session on this endpoint for this session exits |
2426 | GNUNET_assert(search_session(plugin, endpoint, &queue->content->target) == NULL); | 2453 | GNUNET_assert (search_session (plugin, endpoint, &queue->content->target) == |
2454 | NULL); | ||
2427 | if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES) | 2455 | if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES) |
2428 | { | 2456 | { |
2429 | free_macendpoint (plugin, endpoint); | 2457 | free_macendpoint (plugin, endpoint); |
2430 | //check if no endpoint with the same address exists | 2458 | //check if no endpoint with the same address exists |
2431 | GNUNET_assert(get_macendpoint(plugin, &endpoint->addr, GNUNET_NO) == NULL); | 2459 | GNUNET_assert (get_macendpoint (plugin, &endpoint->addr, GNUNET_NO) == |
2460 | NULL); | ||
2432 | } | 2461 | } |
2433 | 2462 | ||
2434 | if (queue->content->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 2463 | if (queue->content->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -2507,31 +2536,31 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type, | |||
2507 | const unsigned char *input; | 2536 | const unsigned char *input; |
2508 | 2537 | ||
2509 | //GNUNET_assert(cls !=NULL); | 2538 | //GNUNET_assert(cls !=NULL); |
2510 | if (addrlen != sizeof(struct MacAddress)) | 2539 | if (addrlen != sizeof (struct MacAddress)) |
2511 | { | 2540 | { |
2512 | /* invalid address (MAC addresses have 6 bytes) */ | 2541 | /* invalid address (MAC addresses have 6 bytes) */ |
2513 | //GNUNET_break (0); | 2542 | //GNUNET_break (0); |
2514 | #if DEBUG_wlan | 2543 | #if DEBUG_wlan |
2515 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2544 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2516 | "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n", | 2545 | "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n", |
2517 | addrlen); | 2546 | addrlen); |
2518 | #endif | 2547 | #endif |
2519 | asc(asc_cls, NULL); | 2548 | asc (asc_cls, NULL); |
2520 | return; | 2549 | return; |
2521 | } | 2550 | } |
2522 | input = (const unsigned char *) addr; | 2551 | input = (const unsigned char *) addr; |
2523 | GNUNET_asprintf (&ret, | 2552 | GNUNET_asprintf (&ret, |
2524 | "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",type, | 2553 | "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
2525 | PROTOCOL_PREFIX, input[0], input[1], input[2], input[3], | 2554 | type, PROTOCOL_PREFIX, input[0], input[1], input[2], |
2526 | input[4], input[5]); | 2555 | input[3], input[4], input[5]); |
2527 | #if DEBUG_wlan | 2556 | #if DEBUG_wlan |
2528 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2557 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2529 | "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n", | 2558 | "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n", |
2530 | addrlen, numeric, type, ret); | 2559 | addrlen, numeric, type, ret); |
2531 | #endif | 2560 | #endif |
2532 | asc ( asc_cls, ret); | 2561 | asc (asc_cls, ret); |
2533 | //only one mac address per plugin | 2562 | //only one mac address per plugin |
2534 | asc ( asc_cls, NULL); | 2563 | asc (asc_cls, NULL); |
2535 | } | 2564 | } |
2536 | 2565 | ||
2537 | 2566 | ||
@@ -2571,7 +2600,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2571 | return; | 2600 | return; |
2572 | } | 2601 | } |
2573 | 2602 | ||
2574 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan whole messages received"), 1, GNUNET_NO); | 2603 | GNUNET_STATISTICS_update (plugin->env->stats, |
2604 | _("# wlan whole messages received"), 1, | ||
2605 | GNUNET_NO); | ||
2575 | wlanheader = (struct WlanHeader *) hdr; | 2606 | wlanheader = (struct WlanHeader *) hdr; |
2576 | 2607 | ||
2577 | session = search_session (plugin, endpoint, &wlanheader->source); | 2608 | session = search_session (plugin, endpoint, &wlanheader->source); |
@@ -2711,9 +2742,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
2711 | #endif | 2742 | #endif |
2712 | 2743 | ||
2713 | plugin->env->receive (plugin->env->cls, &(session->target), hdr, | 2744 | plugin->env->receive (plugin->env->cls, &(session->target), hdr, |
2714 | (const struct GNUNET_ATS_Information *) | 2745 | (const struct GNUNET_ATS_Information *) &distance, 1, |
2715 | &distance, 1, session, | 2746 | session, (const char *) &session->mac->addr, |
2716 | (const char *) &session->mac->addr, | ||
2717 | sizeof (session->mac->addr)); | 2747 | sizeof (session->mac->addr)); |
2718 | } | 2748 | } |
2719 | 2749 | ||
@@ -2735,7 +2765,7 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2735 | struct FragmentMessage *fm2; | 2765 | struct FragmentMessage *fm2; |
2736 | struct GNUNET_PeerIdentity tmpsource; | 2766 | struct GNUNET_PeerIdentity tmpsource; |
2737 | 2767 | ||
2738 | GNUNET_assert(plugin != NULL); | 2768 | GNUNET_assert (plugin != NULL); |
2739 | 2769 | ||
2740 | //ADVERTISEMENT | 2770 | //ADVERTISEMENT |
2741 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) | 2771 | if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) |
@@ -2761,18 +2791,22 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2761 | 2791 | ||
2762 | 2792 | ||
2763 | if (GNUNET_HELLO_get_id | 2793 | if (GNUNET_HELLO_get_id |
2764 | ((const struct GNUNET_HELLO_Message *) hdr, | 2794 | ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource) == GNUNET_OK) |
2765 | &tmpsource) == GNUNET_OK) | ||
2766 | { | 2795 | { |
2767 | session_light->session = search_session (plugin, session_light->macendpoint, &tmpsource); | 2796 | session_light->session = |
2797 | search_session (plugin, session_light->macendpoint, &tmpsource); | ||
2768 | if (session_light->session == NULL) | 2798 | if (session_light->session == NULL) |
2769 | { | 2799 | { |
2770 | session_light->session = create_session (plugin, session_light->macendpoint, &tmpsource); | 2800 | session_light->session = |
2771 | } | 2801 | create_session (plugin, session_light->macendpoint, &tmpsource); |
2772 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello messages received"), 1, GNUNET_NO); | 2802 | } |
2773 | plugin->env->receive(plugin->env->cls,&session_light->session->target,hdr, NULL, 0, session_light->session, | 2803 | GNUNET_STATISTICS_update (plugin->env->stats, |
2774 | (const char *) &session_light->session->mac->addr, | 2804 | _("# wlan hello messages received"), 1, |
2775 | sizeof (session_light->session->mac->addr)); | 2805 | GNUNET_NO); |
2806 | plugin->env->receive (plugin->env->cls, &session_light->session->target, | ||
2807 | hdr, NULL, 0, session_light->session, | ||
2808 | (const char *) &session_light->session->mac->addr, | ||
2809 | sizeof (session_light->session->mac->addr)); | ||
2776 | } | 2810 | } |
2777 | else | 2811 | else |
2778 | { | 2812 | { |
@@ -2803,7 +2837,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2803 | 6)); | 2837 | 6)); |
2804 | #endif | 2838 | #endif |
2805 | 2839 | ||
2806 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments received"), 1, GNUNET_NO); | 2840 | GNUNET_STATISTICS_update (plugin->env->stats, |
2841 | _("# wlan fragments received"), 1, GNUNET_NO); | ||
2807 | int ret = | 2842 | int ret = |
2808 | GNUNET_DEFRAGMENT_process_fragment (session_light->macendpoint->defrag, | 2843 | GNUNET_DEFRAGMENT_process_fragment (session_light->macendpoint->defrag, |
2809 | hdr); | 2844 | hdr); |
@@ -2855,7 +2890,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2855 | while (fm != NULL) | 2890 | while (fm != NULL) |
2856 | { | 2891 | { |
2857 | fm2 = fm->next; | 2892 | fm2 = fm->next; |
2858 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks received"), 1, GNUNET_NO); | 2893 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks received"), |
2894 | 1, GNUNET_NO); | ||
2859 | int ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); | 2895 | int ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); |
2860 | 2896 | ||
2861 | if (ret == GNUNET_OK) | 2897 | if (ret == GNUNET_OK) |
@@ -2947,8 +2983,9 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2947 | (GNUNET_TIME_absolute_add | 2983 | (GNUNET_TIME_absolute_add |
2948 | (endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value == 0) | 2984 | (endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value == 0) |
2949 | { | 2985 | { |
2950 | GNUNET_assert(endpoint->plugin != NULL); | 2986 | GNUNET_assert (endpoint->plugin != NULL); |
2951 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# wlan mac endpoints timeouts"), 1, GNUNET_NO); | 2987 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, |
2988 | _("# wlan mac endpoints timeouts"), 1, GNUNET_NO); | ||
2952 | free_macendpoint (endpoint->plugin, endpoint); | 2989 | free_macendpoint (endpoint->plugin, endpoint); |
2953 | } | 2990 | } |
2954 | else | 2991 | else |
@@ -2970,8 +3007,9 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr) | |||
2970 | { | 3007 | { |
2971 | struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint)); | 3008 | struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint)); |
2972 | 3009 | ||
2973 | GNUNET_assert(plugin != NULL); | 3010 | GNUNET_assert (plugin != NULL); |
2974 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan mac endpoints created"), 1, GNUNET_NO); | 3011 | GNUNET_STATISTICS_update (plugin->env->stats, |
3012 | _("# wlan mac endpoints created"), 1, GNUNET_NO); | ||
2975 | newend->addr = *addr; | 3013 | newend->addr = *addr; |
2976 | newend->plugin = plugin; | 3014 | newend->plugin = plugin; |
2977 | newend->addr = *addr; | 3015 | newend->addr = *addr; |
@@ -2987,7 +3025,8 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr) | |||
2987 | newend); | 3025 | newend); |
2988 | 3026 | ||
2989 | plugin->mac_count++; | 3027 | plugin->mac_count++; |
2990 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan mac endpoints"), plugin->mac_count, GNUNET_NO); | 3028 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"), |
3029 | plugin->mac_count, GNUNET_NO); | ||
2991 | GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); | 3030 | GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); |
2992 | #if DEBUG_wlan | 3031 | #if DEBUG_wlan |
2993 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3032 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
@@ -3017,7 +3056,7 @@ wlan_process_helper (void *cls, void *client, | |||
3017 | int datasize = 0; | 3056 | int datasize = 0; |
3018 | int pos; | 3057 | int pos; |
3019 | 3058 | ||
3020 | GNUNET_assert(plugin != NULL); | 3059 | GNUNET_assert (plugin != NULL); |
3021 | switch (ntohs (hdr->type)) | 3060 | switch (ntohs (hdr->type)) |
3022 | { | 3061 | { |
3023 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: | 3062 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: |
@@ -3027,11 +3066,13 @@ wlan_process_helper (void *cls, void *client, | |||
3027 | ntohs (hdr->size)); | 3066 | ntohs (hdr->size)); |
3028 | #endif | 3067 | #endif |
3029 | 3068 | ||
3030 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan WLAN_HELPER_DATA received"), 1, GNUNET_NO); | 3069 | GNUNET_STATISTICS_update (plugin->env->stats, |
3070 | _("# wlan WLAN_HELPER_DATA received"), 1, | ||
3071 | GNUNET_NO); | ||
3031 | //call wlan_process_helper with the message inside, later with wlan: analyze signal | 3072 | //call wlan_process_helper with the message inside, later with wlan: analyze signal |
3032 | if (ntohs (hdr->size) < | 3073 | if (ntohs (hdr->size) < |
3033 | sizeof (struct ieee80211_frame) + 2*sizeof (struct GNUNET_MessageHeader) + | 3074 | sizeof (struct ieee80211_frame) + |
3034 | sizeof (struct Radiotap_rx)) | 3075 | 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) |
3035 | { | 3076 | { |
3036 | #if DEBUG_wlan | 3077 | #if DEBUG_wlan |
3037 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3078 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
@@ -3057,16 +3098,19 @@ wlan_process_helper (void *cls, void *client, | |||
3057 | { | 3098 | { |
3058 | //check for broadcast or mac | 3099 | //check for broadcast or mac |
3059 | if ((memcmp | 3100 | if ((memcmp |
3060 | (&(wlanIeeeHeader->i_addr1), &bc_all_mac, | 3101 | (&(wlanIeeeHeader->i_addr1), &bc_all_mac, |
3061 | sizeof (struct MacAddress)) == 0) || | 3102 | sizeof (struct MacAddress)) == 0) || |
3062 | (memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), | 3103 | (memcmp |
3063 | sizeof (struct MacAddress)) == 0)) | 3104 | (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), |
3105 | sizeof (struct MacAddress)) == 0)) | ||
3064 | { | 3106 | { |
3065 | //if packet is from us return | 3107 | //if packet is from us return |
3066 | if ((memcmp (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), | 3108 | if ((memcmp |
3067 | sizeof (struct MacAddress)) == 0)){ | 3109 | (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), |
3068 | return; | 3110 | sizeof (struct MacAddress)) == 0)) |
3069 | } | 3111 | { |
3112 | return; | ||
3113 | } | ||
3070 | // process the inner data | 3114 | // process the inner data |
3071 | 3115 | ||
3072 | 3116 | ||
@@ -3078,25 +3122,30 @@ wlan_process_helper (void *cls, void *client, | |||
3078 | memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), | 3122 | memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), |
3079 | sizeof (struct MacAddress)); | 3123 | sizeof (struct MacAddress)); |
3080 | //session_light->session = search_session(plugin,session_light->addr); | 3124 | //session_light->session = search_session(plugin,session_light->addr); |
3081 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages for this client received"), 1, GNUNET_NO); | 3125 | GNUNET_STATISTICS_update (plugin->env->stats, |
3126 | _("# wlan messages for this client received"), | ||
3127 | 1, GNUNET_NO); | ||
3082 | 3128 | ||
3083 | pos = 0; | 3129 | pos = 0; |
3084 | while (pos < datasize) | 3130 | while (pos < datasize) |
3085 | { | 3131 | { |
3086 | temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1] + pos; | 3132 | temp_hdr = (struct GNUNET_MessageHeader *) &wlanIeeeHeader[1] + pos; |
3087 | if (ntohs(temp_hdr->size) <= datasize + pos) | 3133 | if (ntohs (temp_hdr->size) <= datasize + pos) |
3088 | { | 3134 | { |
3089 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages inside WLAN_HELPER_DATA received"), 1, GNUNET_NO); | 3135 | GNUNET_STATISTICS_update (plugin->env->stats, |
3090 | wlan_data_helper (plugin, session_light, temp_hdr, rxinfo); | 3136 | _ |
3091 | } | 3137 | ("# wlan messages inside WLAN_HELPER_DATA received"), |
3138 | 1, GNUNET_NO); | ||
3139 | wlan_data_helper (plugin, session_light, temp_hdr, rxinfo); | ||
3140 | } | ||
3092 | else | 3141 | else |
3093 | { | 3142 | { |
3094 | #if DEBUG_wlan | 3143 | #if DEBUG_wlan |
3095 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3144 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3096 | "Size of packet is too small; size: %u > size of packet: %u\n", | 3145 | "Size of packet is too small; size: %u > size of packet: %u\n", |
3097 | ntohs(temp_hdr->size),datasize + pos); | 3146 | ntohs (temp_hdr->size), datasize + pos); |
3098 | #endif | 3147 | #endif |
3099 | } | 3148 | } |
3100 | pos += ntohs (temp_hdr->size); | 3149 | pos += ntohs (temp_hdr->size); |
3101 | 3150 | ||
3102 | } | 3151 | } |
@@ -3176,7 +3225,7 @@ libgnunet_plugin_transport_wlan_done (void *cls) | |||
3176 | "libgnunet_plugin_transport_wlan_done started\n"); | 3225 | "libgnunet_plugin_transport_wlan_done started\n"); |
3177 | #endif | 3226 | #endif |
3178 | 3227 | ||
3179 | wlan_transport_stop_wlan_helper(plugin); | 3228 | wlan_transport_stop_wlan_helper (plugin); |
3180 | 3229 | ||
3181 | GNUNET_assert (cls != NULL); | 3230 | GNUNET_assert (cls != NULL); |
3182 | //free sessions | 3231 | //free sessions |
@@ -3220,9 +3269,11 @@ libgnunet_plugin_transport_wlan_init (void *cls) | |||
3220 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 3269 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
3221 | plugin->env = env; | 3270 | plugin->env = env; |
3222 | plugin->pendingsessions = 0; | 3271 | plugin->pendingsessions = 0; |
3223 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan pending sessions"), plugin->pendingsessions, GNUNET_NO); | 3272 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending sessions"), |
3273 | plugin->pendingsessions, GNUNET_NO); | ||
3224 | plugin->mac_count = 0; | 3274 | plugin->mac_count = 0; |
3225 | GNUNET_STATISTICS_set(plugin->env->stats, _("# wlan mac endpoints"), plugin->mac_count, GNUNET_NO); | 3275 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"), |
3276 | plugin->mac_count, GNUNET_NO); | ||
3226 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; | 3277 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; |
3227 | plugin->server_read_task = GNUNET_SCHEDULER_NO_TASK; | 3278 | plugin->server_read_task = GNUNET_SCHEDULER_NO_TASK; |
3228 | plugin->server_write_delay_task = GNUNET_SCHEDULER_NO_TASK; | 3279 | plugin->server_write_delay_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -3253,7 +3304,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) | |||
3253 | if (GNUNET_SYSERR == | 3304 | if (GNUNET_SYSERR == |
3254 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan", | 3305 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan", |
3255 | "TESTMODE", &(plugin->testmode))) | 3306 | "TESTMODE", &(plugin->testmode))) |
3256 | plugin->testmode = 0; //default value | 3307 | plugin->testmode = 0; //default value |
3257 | } | 3308 | } |
3258 | 3309 | ||
3259 | if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE")) | 3310 | if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE")) |
@@ -3270,7 +3321,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) | |||
3270 | //start the plugin | 3321 | //start the plugin |
3271 | wlan_transport_start_wlan_helper (plugin); | 3322 | wlan_transport_start_wlan_helper (plugin); |
3272 | set_next_beacon_time (plugin); | 3323 | set_next_beacon_time (plugin); |
3273 | set_next_send(plugin); | 3324 | set_next_send (plugin); |
3274 | #if DEBUG_wlan | 3325 | #if DEBUG_wlan |
3275 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 3326 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3276 | "wlan init finished\n"); | 3327 | "wlan init finished\n"); |
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 1c6bba0d5..7d28820cb 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -70,9 +70,9 @@ struct PeerContext *p1; | |||
70 | 70 | ||
71 | struct PeerContext *p2; | 71 | struct PeerContext *p2; |
72 | 72 | ||
73 | struct PeerContext * sender; | 73 | struct PeerContext *sender; |
74 | 74 | ||
75 | struct PeerContext * receiver; | 75 | struct PeerContext *receiver; |
76 | 76 | ||
77 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 77 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
78 | 78 | ||
@@ -86,7 +86,7 @@ char *gen_cfg_p1; | |||
86 | unsigned long long quota_in_p2; | 86 | unsigned long long quota_in_p2; |
87 | unsigned long long quota_out_p2; | 87 | unsigned long long quota_out_p2; |
88 | 88 | ||
89 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 89 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
90 | 90 | ||
91 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 91 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
92 | 92 | ||
@@ -144,26 +144,28 @@ end () | |||
144 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 144 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
145 | datarate = (total_bytes_sent * 1000) / delta; | 145 | datarate = (total_bytes_sent * 1000) / delta; |
146 | 146 | ||
147 | fprintf (stderr, "Throughput was %llu b/s\n", | 147 | fprintf (stderr, "Throughput was %llu b/s\n", datarate); |
148 | datarate); | ||
149 | 148 | ||
150 | test_failed = GNUNET_NO; | 149 | test_failed = GNUNET_NO; |
151 | if (datarate > quota_in_p2) | 150 | if (datarate > quota_in_p2) |
152 | { | 151 | { |
153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 152 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
154 | "Datarate of %llu b/s higher than allowed inbound quota of %llu b/s\n", datarate, quota_in_p2); | 153 | "Datarate of %llu b/s higher than allowed inbound quota of %llu b/s\n", |
154 | datarate, quota_in_p2); | ||
155 | test_failed = GNUNET_YES; | 155 | test_failed = GNUNET_YES; |
156 | } | 156 | } |
157 | if (datarate > quota_out_p1) | 157 | if (datarate > quota_out_p1) |
158 | { | 158 | { |
159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
160 | "Datarate of %llu b/s higher than allowed outbound quota of %llu b/s\n", datarate, quota_out_p1); | 160 | "Datarate of %llu b/s higher than allowed outbound quota of %llu b/s\n", |
161 | datarate, quota_out_p1); | ||
161 | test_failed = GNUNET_YES; | 162 | test_failed = GNUNET_YES; |
162 | } | 163 | } |
163 | if (test_failed == GNUNET_NO) | 164 | if (test_failed == GNUNET_NO) |
164 | { | 165 | { |
165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
166 | "Datarate of %llu b/s complied to allowed outbound quota of %llu b/s and inbound quota of %llu b/s\n", datarate, quota_out_p1, quota_in_p2); | 167 | "Datarate of %llu b/s complied to allowed outbound quota of %llu b/s and inbound quota of %llu b/s\n", |
168 | datarate, quota_out_p1, quota_in_p2); | ||
167 | } | 169 | } |
168 | 170 | ||
169 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 171 | if (die_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -174,7 +176,7 @@ end () | |||
174 | th = NULL; | 176 | th = NULL; |
175 | 177 | ||
176 | if (cc != NULL) | 178 | if (cc != NULL) |
177 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 179 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
178 | 180 | ||
179 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 181 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
180 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 182 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
@@ -200,7 +202,7 @@ end_badly () | |||
200 | th = NULL; | 202 | th = NULL; |
201 | 203 | ||
202 | if (cc != NULL) | 204 | if (cc != NULL) |
203 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 205 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
204 | 206 | ||
205 | if (p1 != NULL) | 207 | if (p1 != NULL) |
206 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 208 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
@@ -224,8 +226,7 @@ get_size (unsigned int iter) | |||
224 | static void | 226 | static void |
225 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 227 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
226 | const struct GNUNET_MessageHeader *message, | 228 | const struct GNUNET_MessageHeader *message, |
227 | const struct GNUNET_ATS_Information *ats, | 229 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
228 | uint32_t ats_count) | ||
229 | { | 230 | { |
230 | static int n; | 231 | static int n; |
231 | unsigned int s; | 232 | unsigned int s; |
@@ -269,17 +270,19 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
269 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 270 | if (die_task != GNUNET_SCHEDULER_NO_TASK) |
270 | GNUNET_SCHEDULER_cancel (die_task); | 271 | GNUNET_SCHEDULER_cancel (die_task); |
271 | test_failed = GNUNET_YES; | 272 | test_failed = GNUNET_YES; |
272 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, | 273 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
273 | NULL); | ||
274 | return; | 274 | return; |
275 | } | 275 | } |
276 | #if VERBOSE | 276 | #if VERBOSE |
277 | if (ntohl (hdr->num) % 5000 == 0) | 277 | if (ntohl (hdr->num) % 5000 == 0) |
278 | { | 278 | { |
279 | struct PeerContext *p = cls; | 279 | struct PeerContext *p = cls; |
280 | char * ps = strdup(GNUNET_i2s(&p->id)); | 280 | char *ps = strdup (GNUNET_i2s (&p->id)); |
281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", | 281 | |
282 | p->no, ps, ntohl (hdr->num), ntohs (message->size), GNUNET_i2s(peer)); | 282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
283 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", | ||
284 | p->no, ps, ntohl (hdr->num), ntohs (message->size), | ||
285 | GNUNET_i2s (peer)); | ||
283 | GNUNET_free (ps); | 286 | GNUNET_free (ps); |
284 | } | 287 | } |
285 | #endif | 288 | #endif |
@@ -300,7 +303,8 @@ notify_ready (void *cls, size_t size, void *buf) | |||
300 | if (buf == NULL) | 303 | if (buf == NULL) |
301 | { | 304 | { |
302 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 305 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
303 | "Timeout occurred while waiting for transmit_ready for message %u of %u\n", msg_scheduled, TOTAL_MSGS); | 306 | "Timeout occurred while waiting for transmit_ready for message %u of %u\n", |
307 | msg_scheduled, TOTAL_MSGS); | ||
304 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 308 | if (GNUNET_SCHEDULER_NO_TASK != die_task) |
305 | GNUNET_SCHEDULER_cancel (die_task); | 309 | GNUNET_SCHEDULER_cancel (die_task); |
306 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 310 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
@@ -327,12 +331,12 @@ notify_ready (void *cls, size_t size, void *buf) | |||
327 | if (n % 5000 == 0) | 331 | if (n % 5000 == 0) |
328 | { | 332 | { |
329 | 333 | ||
330 | char * receiver_s = strdup(GNUNET_i2s (&receiver->id)); | 334 | char *receiver_s = strdup (GNUNET_i2s (&receiver->id)); |
335 | |||
331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
332 | "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", | 337 | "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", |
333 | n, | 338 | n, sender->no, GNUNET_i2s (&sender->id), receiver->no, |
334 | sender->no, | 339 | receiver_s); |
335 | GNUNET_i2s (&sender->id), receiver->no, receiver_s); | ||
336 | GNUNET_free (receiver_s); | 340 | GNUNET_free (receiver_s); |
337 | } | 341 | } |
338 | #endif | 342 | #endif |
@@ -367,11 +371,11 @@ notify_ready (void *cls, size_t size, void *buf) | |||
367 | 371 | ||
368 | static void | 372 | static void |
369 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 373 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
370 | const struct GNUNET_ATS_Information *ats, | 374 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
371 | uint32_t ats_count) | ||
372 | { | 375 | { |
373 | 376 | ||
374 | struct PeerContext *p = cls; | 377 | struct PeerContext *p = cls; |
378 | |||
375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", | 379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", |
376 | p->no, GNUNET_i2s (peer)); | 380 | p->no, GNUNET_i2s (peer)); |
377 | } | 381 | } |
@@ -381,8 +385,9 @@ static void | |||
381 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 385 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
382 | { | 386 | { |
383 | struct PeerContext *p = cls; | 387 | struct PeerContext *p = cls; |
384 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", | 388 | |
385 | p->no, GNUNET_i2s (peer)); | 389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no, |
390 | GNUNET_i2s (peer)); | ||
386 | if (th != NULL) | 391 | if (th != NULL) |
387 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 392 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
388 | th = NULL; | 393 | th = NULL; |
@@ -403,10 +408,11 @@ static void | |||
403 | measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 408 | measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
404 | { | 409 | { |
405 | static int counter; | 410 | static int counter; |
411 | |||
406 | measure_task = GNUNET_SCHEDULER_NO_TASK; | 412 | measure_task = GNUNET_SCHEDULER_NO_TASK; |
407 | 413 | ||
408 | counter++; | 414 | counter++; |
409 | if ((DURATION.rel_value / 1000) < counter ) | 415 | if ((DURATION.rel_value / 1000) < counter) |
410 | { | 416 | { |
411 | fprintf (stderr, ".\n"); | 417 | fprintf (stderr, ".\n"); |
412 | GNUNET_SCHEDULER_add_now (&end, NULL); | 418 | GNUNET_SCHEDULER_add_now (&end, NULL); |
@@ -414,7 +420,8 @@ measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
414 | else | 420 | else |
415 | { | 421 | { |
416 | fprintf (stderr, "."); | 422 | fprintf (stderr, "."); |
417 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL); | 423 | measure_task = |
424 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL); | ||
418 | } | 425 | } |
419 | } | 426 | } |
420 | 427 | ||
@@ -423,28 +430,29 @@ static void | |||
423 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 430 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
424 | { | 431 | { |
425 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 432 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
433 | |||
426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", |
427 | p1->no, p1_c, | 435 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); |
428 | p2->no, GNUNET_i2s (&p2->id)); | ||
429 | GNUNET_free (p1_c); | 436 | GNUNET_free (p1_c); |
430 | 437 | ||
431 | cc = NULL; | 438 | cc = NULL; |
432 | test_connected = GNUNET_YES; | 439 | test_connected = GNUNET_YES; |
433 | 440 | ||
434 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL); | 441 | measure_task = |
442 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL); | ||
435 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 443 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
436 | 444 | ||
437 | } | 445 | } |
438 | 446 | ||
439 | void start_cb (struct PeerContext * p, | 447 | void |
440 | void *cls) | 448 | start_cb (struct PeerContext *p, void *cls) |
441 | { | 449 | { |
442 | static int started; | 450 | static int started; |
451 | |||
443 | started++; | 452 | started++; |
444 | 453 | ||
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
446 | p->no, | 455 | GNUNET_i2s (&p->id)); |
447 | GNUNET_i2s (&p->id)); | ||
448 | 456 | ||
449 | if (started != 2) | 457 | if (started != 2) |
450 | return; | 458 | return; |
@@ -455,61 +463,66 @@ void start_cb (struct PeerContext * p, | |||
455 | receiver = p1; | 463 | receiver = p1; |
456 | 464 | ||
457 | char *sender_c = strdup (GNUNET_i2s (&sender->id)); | 465 | char *sender_c = strdup (GNUNET_i2s (&sender->id)); |
458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to send from %u (%s) -> peer %u (%s)\n", | ||
459 | sender->no, sender_c, | ||
460 | receiver->no, GNUNET_i2s (&receiver->id)); | ||
461 | 466 | ||
462 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL); | 467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
468 | "Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no, | ||
469 | sender_c, receiver->no, GNUNET_i2s (&receiver->id)); | ||
470 | |||
471 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | ||
472 | NULL); | ||
463 | 473 | ||
464 | } | 474 | } |
465 | 475 | ||
466 | static char * | 476 | static char * |
467 | generate_config (char * cfg_file, unsigned long long quota_in, unsigned long long quota_out) | 477 | generate_config (char *cfg_file, unsigned long long quota_in, |
478 | unsigned long long quota_out) | ||
468 | { | 479 | { |
469 | char * fname = NULL; | 480 | char *fname = NULL; |
470 | struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create(); | 481 | struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create (); |
482 | |||
471 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_file)); | 483 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_file)); |
472 | GNUNET_asprintf (&fname, "q_in_%llu_q_out_%llu_%s", quota_in, quota_out, cfg_file); | 484 | GNUNET_asprintf (&fname, "q_in_%llu_q_out_%llu_%s", quota_in, quota_out, |
473 | GNUNET_CONFIGURATION_set_value_string(cfg, "PATHS", "DEFAULTCONFIG", fname); | 485 | cfg_file); |
474 | GNUNET_CONFIGURATION_set_value_number(cfg, "core", "TOTAL_QUOTA_OUT", quota_out); | 486 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", fname); |
475 | GNUNET_CONFIGURATION_set_value_number(cfg, "core", "TOTAL_QUOTA_IN", quota_in); | 487 | GNUNET_CONFIGURATION_set_value_number (cfg, "core", "TOTAL_QUOTA_OUT", |
476 | GNUNET_CONFIGURATION_set_value_number(cfg, "ats", "TOTAL_QUOTA_IN", quota_in); | 488 | quota_out); |
477 | GNUNET_CONFIGURATION_set_value_number(cfg, "ats", "TOTAL_QUOTA_OUT", quota_out); | 489 | GNUNET_CONFIGURATION_set_value_number (cfg, "core", "TOTAL_QUOTA_IN", |
478 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write(cfg, fname)); | 490 | quota_in); |
479 | GNUNET_CONFIGURATION_destroy(cfg); | 491 | GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "TOTAL_QUOTA_IN", |
492 | quota_in); | ||
493 | GNUNET_CONFIGURATION_set_value_number (cfg, "ats", "TOTAL_QUOTA_OUT", | ||
494 | quota_out); | ||
495 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write (cfg, fname)); | ||
496 | GNUNET_CONFIGURATION_destroy (cfg); | ||
480 | return fname; | 497 | return fname; |
481 | } | 498 | } |
482 | 499 | ||
483 | static void | 500 | static void |
484 | run_measurement (unsigned long long p1_quota_in, unsigned long long p1_quota_out, | 501 | run_measurement (unsigned long long p1_quota_in, |
485 | unsigned long long p2_quota_in, unsigned long long p2_quota_out) | 502 | unsigned long long p1_quota_out, |
503 | unsigned long long p2_quota_in, | ||
504 | unsigned long long p2_quota_out) | ||
486 | { | 505 | { |
487 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 506 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
488 | 507 | ||
489 | /* setting ATS quota */ | 508 | /* setting ATS quota */ |
490 | quota_out_p1 = p1_quota_out; | 509 | quota_out_p1 = p1_quota_out; |
491 | gen_cfg_p1 = generate_config(cfg_file_p1, p1_quota_in, p1_quota_out); | 510 | gen_cfg_p1 = generate_config (cfg_file_p1, p1_quota_in, p1_quota_out); |
492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Generated config file `%s'\n", |
493 | "Generated config file `%s'\n", | 512 | gen_cfg_p1); |
494 | gen_cfg_p1); | ||
495 | 513 | ||
496 | quota_in_p2 = p2_quota_in; | 514 | quota_in_p2 = p2_quota_in; |
497 | gen_cfg_p2 = generate_config(cfg_file_p2, p2_quota_in, p2_quota_out); | 515 | gen_cfg_p2 = generate_config (cfg_file_p2, p2_quota_in, p2_quota_out); |
498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Generated config file `%s'\n", |
499 | "Generated config file `%s'\n", | 517 | gen_cfg_p2); |
500 | gen_cfg_p2); | ||
501 | 518 | ||
502 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p1, 1, | 519 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p1, 1, ¬ify_receive, |
503 | ¬ify_receive, | ||
504 | ¬ify_connect, ¬ify_disconnect, | 520 | ¬ify_connect, ¬ify_disconnect, |
505 | &start_cb, | 521 | &start_cb, NULL); |
506 | NULL); | ||
507 | 522 | ||
508 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p2, 2, | 523 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, gen_cfg_p2, 2, ¬ify_receive, |
509 | ¬ify_receive, | ||
510 | ¬ify_connect, ¬ify_disconnect, | 524 | ¬ify_connect, ¬ify_disconnect, |
511 | &start_cb, | 525 | &start_cb, NULL); |
512 | NULL); | ||
513 | 526 | ||
514 | if ((p1 == NULL) || (p2 == NULL)) | 527 | if ((p1 == NULL) || (p2 == NULL)) |
515 | { | 528 | { |
@@ -530,19 +543,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
530 | unsigned long long p2_quota_in = 10000; | 543 | unsigned long long p2_quota_in = 10000; |
531 | unsigned long long p2_quota_out = 10000; | 544 | unsigned long long p2_quota_out = 10000; |
532 | 545 | ||
533 | if (NULL != strstr (test_name,"asymmetric")) | 546 | if (NULL != strstr (test_name, "asymmetric")) |
534 | { | 547 | { |
535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
536 | "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n", | 549 | "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n", |
537 | p2_quota_in, p2_quota_out); | 550 | p2_quota_in, p2_quota_out); |
538 | p1_quota_out = 1024 * 1024 * 1024; | 551 | p1_quota_out = 1024 * 1024 * 1024; |
539 | p1_quota_in = 1024 * 1024 * 1024; | 552 | p1_quota_in = 1024 * 1024 * 1024; |
540 | } | 553 | } |
541 | else | 554 | else |
542 | { | 555 | { |
543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
544 | "Running symmetric test with (in/out) %llu/%llu b/s \n", | 557 | "Running symmetric test with (in/out) %llu/%llu b/s \n", |
545 | p2_quota_in, p2_quota_out); | 558 | p2_quota_in, p2_quota_out); |
546 | } | 559 | } |
547 | run_measurement (p1_quota_in, p1_quota_out, p2_quota_in, p2_quota_out); | 560 | run_measurement (p1_quota_in, p1_quota_out, p2_quota_in, p2_quota_out); |
548 | } | 561 | } |
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 6b6cc0c0e..47686f8d9 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -74,7 +74,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | |||
74 | 74 | ||
75 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 75 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
76 | 76 | ||
77 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 77 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
78 | 78 | ||
79 | char *cfg_file_p1; | 79 | char *cfg_file_p1; |
80 | 80 | ||
@@ -140,10 +140,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
140 | static void | 140 | static void |
141 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 141 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
142 | const struct GNUNET_MessageHeader *message, | 142 | const struct GNUNET_MessageHeader *message, |
143 | const struct GNUNET_ATS_Information *ats, | 143 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
144 | uint32_t ats_count) | ||
145 | { | 144 | { |
146 | struct PeerContext * p = cls; | 145 | struct PeerContext *p = cls; |
147 | struct PeerContext *t = NULL; | 146 | struct PeerContext *t = NULL; |
148 | 147 | ||
149 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 148 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
@@ -152,11 +151,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
152 | t = p2; | 151 | t = p2; |
153 | GNUNET_assert (t != NULL); | 152 | GNUNET_assert (t != NULL); |
154 | 153 | ||
155 | char * ps = strdup (GNUNET_i2s(&p->id)); | 154 | char *ps = strdup (GNUNET_i2s (&p->id)); |
156 | 155 | ||
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
158 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 157 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
159 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, GNUNET_i2s (&t->id)); | 158 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, |
159 | GNUNET_i2s (&t->id)); | ||
160 | 160 | ||
161 | if ((MTYPE == ntohs (message->type)) && | 161 | if ((MTYPE == ntohs (message->type)) && |
162 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) | 162 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) |
@@ -200,13 +200,12 @@ notify_ready (void *cls, size_t size, void *buf) | |||
200 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 200 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); |
201 | hdr->type = htons (MTYPE); | 201 | hdr->type = htons (MTYPE); |
202 | } | 202 | } |
203 | char * ps = strdup (GNUNET_i2s(&p2->id)); | 203 | char *ps = strdup (GNUNET_i2s (&p2->id)); |
204 | |||
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
205 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | 206 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
206 | p2->no, | 207 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, |
207 | ps, | 208 | GNUNET_i2s (&p->id)); |
208 | ntohs (hdr->type), | ||
209 | ntohs (hdr->size), p->no, GNUNET_i2s (&p->id)); | ||
210 | GNUNET_free (ps); | 209 | GNUNET_free (ps); |
211 | return sizeof (struct GNUNET_MessageHeader); | 210 | return sizeof (struct GNUNET_MessageHeader); |
212 | } | 211 | } |
@@ -219,11 +218,11 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
219 | 218 | ||
220 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 219 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
221 | return; | 220 | return; |
222 | char * receiver_s = strdup(GNUNET_i2s (&p1->id)); | 221 | char *receiver_s = strdup (GNUNET_i2s (&p1->id)); |
222 | |||
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
224 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 224 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", |
225 | p2->no, | 225 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); |
226 | GNUNET_i2s (&p2->id), p1->no, receiver_s); | ||
227 | GNUNET_free (receiver_s); | 226 | GNUNET_free (receiver_s); |
228 | 227 | ||
229 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, | 228 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, |
@@ -234,10 +233,10 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
234 | 233 | ||
235 | static void | 234 | static void |
236 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 235 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
237 | const struct GNUNET_ATS_Information *ats, | 236 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
238 | uint32_t ats_count) | ||
239 | { | 237 | { |
240 | static int c; | 238 | static int c; |
239 | |||
241 | c++; | 240 | c++; |
242 | struct PeerContext *p = cls; | 241 | struct PeerContext *p = cls; |
243 | struct PeerContext *t = NULL; | 242 | struct PeerContext *t = NULL; |
@@ -246,11 +245,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
246 | t = p1; | 245 | t = p1; |
247 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 246 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) |
248 | t = p2; | 247 | t = p2; |
249 | GNUNET_assert (t!=NULL); | 248 | GNUNET_assert (t != NULL); |
249 | |||
250 | char *ps = strdup (GNUNET_i2s (&p->id)); | ||
250 | 251 | ||
251 | char * ps = strdup (GNUNET_i2s(&p->id)); | 252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", | 253 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, |
253 | p->no, ps, | ||
254 | t->no, GNUNET_i2s (peer)); | 254 | t->no, GNUNET_i2s (peer)); |
255 | GNUNET_free (ps); | 255 | GNUNET_free (ps); |
256 | } | 256 | } |
@@ -260,9 +260,11 @@ static void | |||
260 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 260 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
261 | { | 261 | { |
262 | struct PeerContext *p = cls; | 262 | struct PeerContext *p = cls; |
263 | char * ps = strdup (GNUNET_i2s(&p->id)); | 263 | char *ps = strdup (GNUNET_i2s (&p->id)); |
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | 264 | |
265 | p->no, ps, GNUNET_i2s (peer)); | 265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
266 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | ||
267 | GNUNET_i2s (peer)); | ||
266 | 268 | ||
267 | if (th != NULL) | 269 | if (th != NULL) |
268 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 270 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
@@ -276,8 +278,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
276 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 278 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
277 | 279 | ||
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", |
279 | p1->no, p1_c, | 281 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); |
280 | p2->no, GNUNET_i2s (&p2->id)); | ||
281 | GNUNET_free (p1_c); | 282 | GNUNET_free (p1_c); |
282 | 283 | ||
283 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 284 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
@@ -285,23 +286,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
285 | 286 | ||
286 | 287 | ||
287 | 288 | ||
288 | void start_cb (struct PeerContext * p, | 289 | void |
289 | void *cls) | 290 | start_cb (struct PeerContext *p, void *cls) |
290 | { | 291 | { |
291 | static int started; | 292 | static int started; |
293 | |||
292 | started++; | 294 | started++; |
293 | 295 | ||
294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
295 | p->no, | 297 | GNUNET_i2s (&p->id)); |
296 | GNUNET_i2s (&p->id)); | ||
297 | 298 | ||
298 | if (started != 2) | 299 | if (started != 2) |
299 | return; | 300 | return; |
300 | 301 | ||
301 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 302 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 303 | |
303 | p1->no, sender_c, | 304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
304 | p2->no, GNUNET_i2s (&p2->id)); | 305 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
306 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
305 | 307 | ||
306 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 308 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
307 | NULL); | 309 | NULL); |
@@ -315,17 +317,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
315 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 317 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
316 | 318 | ||
317 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 319 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
318 | ¬ify_receive, | 320 | ¬ify_receive, ¬ify_connect, |
319 | ¬ify_connect, | 321 | ¬ify_disconnect, &start_cb, |
320 | ¬ify_disconnect, | 322 | NULL); |
321 | &start_cb, | ||
322 | NULL); | ||
323 | 323 | ||
324 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 324 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
325 | ¬ify_receive, | 325 | ¬ify_receive, ¬ify_connect, |
326 | ¬ify_connect, | 326 | ¬ify_disconnect, &start_cb, |
327 | ¬ify_disconnect, | ||
328 | &start_cb, | ||
329 | NULL); | 327 | NULL); |
330 | 328 | ||
331 | if ((p1 == NULL) || (p2 == NULL)) | 329 | if ((p1 == NULL) || (p2 == NULL)) |
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c index 0be922e93..f97c449fc 100644 --- a/src/transport/test_transport_api_disconnect.c +++ b/src/transport/test_transport_api_disconnect.c | |||
@@ -71,7 +71,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | |||
71 | 71 | ||
72 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 72 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 73 | ||
74 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 74 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
75 | 75 | ||
76 | int shutdown_; | 76 | int shutdown_; |
77 | 77 | ||
@@ -148,9 +148,11 @@ static void | |||
148 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 148 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
149 | { | 149 | { |
150 | struct PeerContext *p = cls; | 150 | struct PeerContext *p = cls; |
151 | char * ps = strdup (GNUNET_i2s(&p->id)); | 151 | char *ps = strdup (GNUNET_i2s (&p->id)); |
152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | 152 | |
153 | p->no, ps, GNUNET_i2s (peer)); | 153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
154 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | ||
155 | GNUNET_i2s (peer)); | ||
154 | 156 | ||
155 | if (th != NULL) | 157 | if (th != NULL) |
156 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 158 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
@@ -158,8 +160,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
158 | 160 | ||
159 | if (shutdown_ == GNUNET_YES) | 161 | if (shutdown_ == GNUNET_YES) |
160 | { | 162 | { |
161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Complete, shutting down...\n"); | 163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Complete, shutting down...\n"); |
162 | GNUNET_SCHEDULER_add_now (&end, NULL); | 164 | GNUNET_SCHEDULER_add_now (&end, NULL); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | 167 | ||
@@ -170,12 +172,12 @@ stop_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
170 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 172 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
171 | return; | 173 | return; |
172 | 174 | ||
173 | struct PeerContext * p = cls; | 175 | struct PeerContext *p = cls; |
174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", | 176 | |
175 | p->no, | 177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no, |
176 | GNUNET_i2s (&p->id)); | 178 | GNUNET_i2s (&p->id)); |
177 | shutdown_ = GNUNET_YES; | 179 | shutdown_ = GNUNET_YES; |
178 | GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2); | 180 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
179 | p2 = NULL; | 181 | p2 = NULL; |
180 | GNUNET_assert (p2 == NULL); | 182 | GNUNET_assert (p2 == NULL); |
181 | } | 183 | } |
@@ -183,10 +185,9 @@ stop_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
183 | static void | 185 | static void |
184 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 186 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
185 | const struct GNUNET_MessageHeader *message, | 187 | const struct GNUNET_MessageHeader *message, |
186 | const struct GNUNET_ATS_Information *ats, | 188 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
187 | uint32_t ats_count) | ||
188 | { | 189 | { |
189 | struct PeerContext * p = cls; | 190 | struct PeerContext *p = cls; |
190 | struct PeerContext *t = NULL; | 191 | struct PeerContext *t = NULL; |
191 | 192 | ||
192 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 193 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
@@ -195,17 +196,18 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
195 | t = p2; | 196 | t = p2; |
196 | GNUNET_assert (t != NULL); | 197 | GNUNET_assert (t != NULL); |
197 | 198 | ||
198 | char * ps = strdup (GNUNET_i2s(&p->id)); | 199 | char *ps = strdup (GNUNET_i2s (&p->id)); |
199 | 200 | ||
200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
201 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 202 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
202 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, GNUNET_i2s (&t->id)); | 203 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, |
204 | GNUNET_i2s (&t->id)); | ||
203 | 205 | ||
204 | if ((MTYPE == ntohs (message->type)) && | 206 | if ((MTYPE == ntohs (message->type)) && |
205 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) | 207 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) |
206 | { | 208 | { |
207 | ok = 1; | 209 | ok = 1; |
208 | GNUNET_SCHEDULER_add_now(stop_peer, p2); | 210 | GNUNET_SCHEDULER_add_now (stop_peer, p2); |
209 | return; | 211 | return; |
210 | } | 212 | } |
211 | } | 213 | } |
@@ -238,13 +240,12 @@ notify_ready (void *cls, size_t size, void *buf) | |||
238 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 240 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); |
239 | hdr->type = htons (MTYPE); | 241 | hdr->type = htons (MTYPE); |
240 | } | 242 | } |
241 | char * ps = strdup (GNUNET_i2s(&p2->id)); | 243 | char *ps = strdup (GNUNET_i2s (&p2->id)); |
244 | |||
242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
243 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | 246 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
244 | p2->no, | 247 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, |
245 | ps, | 248 | GNUNET_i2s (&p->id)); |
246 | ntohs (hdr->type), | ||
247 | ntohs (hdr->size), p->no, GNUNET_i2s (&p->id)); | ||
248 | GNUNET_free (ps); | 249 | GNUNET_free (ps); |
249 | return sizeof (struct GNUNET_MessageHeader); | 250 | return sizeof (struct GNUNET_MessageHeader); |
250 | } | 251 | } |
@@ -257,11 +258,11 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
257 | 258 | ||
258 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 259 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
259 | return; | 260 | return; |
260 | char * receiver_s = strdup(GNUNET_i2s (&p1->id)); | 261 | char *receiver_s = strdup (GNUNET_i2s (&p1->id)); |
262 | |||
261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
262 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 264 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", |
263 | p2->no, | 265 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); |
264 | GNUNET_i2s (&p2->id), p1->no, receiver_s); | ||
265 | GNUNET_free (receiver_s); | 266 | GNUNET_free (receiver_s); |
266 | 267 | ||
267 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, | 268 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, |
@@ -272,10 +273,10 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
272 | 273 | ||
273 | static void | 274 | static void |
274 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 275 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
275 | const struct GNUNET_ATS_Information *ats, | 276 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
276 | uint32_t ats_count) | ||
277 | { | 277 | { |
278 | static int c; | 278 | static int c; |
279 | |||
279 | c++; | 280 | c++; |
280 | struct PeerContext *p = cls; | 281 | struct PeerContext *p = cls; |
281 | struct PeerContext *t = NULL; | 282 | struct PeerContext *t = NULL; |
@@ -284,11 +285,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
284 | t = p1; | 285 | t = p1; |
285 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 286 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) |
286 | t = p2; | 287 | t = p2; |
287 | GNUNET_assert (t!=NULL); | 288 | GNUNET_assert (t != NULL); |
289 | |||
290 | char *ps = strdup (GNUNET_i2s (&p->id)); | ||
288 | 291 | ||
289 | char * ps = strdup (GNUNET_i2s(&p->id)); | 292 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", | 293 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, |
291 | p->no, ps, | ||
292 | t->no, GNUNET_i2s (peer)); | 294 | t->no, GNUNET_i2s (peer)); |
293 | GNUNET_free (ps); | 295 | GNUNET_free (ps); |
294 | } | 296 | } |
@@ -301,8 +303,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
301 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 303 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
302 | 304 | ||
303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", |
304 | p1->no, p1_c, | 306 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); |
305 | p2->no, GNUNET_i2s (&p2->id)); | ||
306 | GNUNET_free (p1_c); | 307 | GNUNET_free (p1_c); |
307 | 308 | ||
308 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 309 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
@@ -310,23 +311,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
310 | 311 | ||
311 | 312 | ||
312 | 313 | ||
313 | void start_cb (struct PeerContext * p, | 314 | void |
314 | void *cls) | 315 | start_cb (struct PeerContext *p, void *cls) |
315 | { | 316 | { |
316 | static int started; | 317 | static int started; |
318 | |||
317 | started++; | 319 | started++; |
318 | 320 | ||
319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
320 | p->no, | 322 | GNUNET_i2s (&p->id)); |
321 | GNUNET_i2s (&p->id)); | ||
322 | 323 | ||
323 | if (started != 2) | 324 | if (started != 2) |
324 | return; | 325 | return; |
325 | 326 | ||
326 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 327 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 328 | |
328 | p1->no, sender_c, | 329 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
329 | p2->no, GNUNET_i2s (&p2->id)); | 330 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
331 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
330 | 332 | ||
331 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 333 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
332 | NULL); | 334 | NULL); |
@@ -340,17 +342,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
340 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 342 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
341 | 343 | ||
342 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 344 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
343 | ¬ify_receive, | 345 | ¬ify_receive, ¬ify_connect, |
344 | ¬ify_connect, | 346 | ¬ify_disconnect, &start_cb, |
345 | ¬ify_disconnect, | 347 | NULL); |
346 | &start_cb, | ||
347 | NULL); | ||
348 | 348 | ||
349 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 349 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
350 | ¬ify_receive, | 350 | ¬ify_receive, ¬ify_connect, |
351 | ¬ify_connect, | 351 | ¬ify_disconnect, &start_cb, |
352 | ¬ify_disconnect, | ||
353 | &start_cb, | ||
354 | NULL); | 352 | NULL); |
355 | 353 | ||
356 | if ((p1 == NULL) || (p2 == NULL)) | 354 | if ((p1 == NULL) || (p2 == NULL)) |
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c index 20dc3ed2e..f165a5771 100644 --- a/src/transport/test_transport_api_limited_sockets.c +++ b/src/transport/test_transport_api_limited_sockets.c | |||
@@ -77,7 +77,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | |||
77 | 77 | ||
78 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 78 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
79 | 79 | ||
80 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 80 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
81 | 81 | ||
82 | char *cfg_file_p1; | 82 | char *cfg_file_p1; |
83 | 83 | ||
@@ -138,8 +138,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
138 | static void | 138 | static void |
139 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 139 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
140 | const struct GNUNET_MessageHeader *message, | 140 | const struct GNUNET_MessageHeader *message, |
141 | const struct GNUNET_ATS_Information *ats, | 141 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
142 | uint32_t ats_count) | ||
143 | { | 142 | { |
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 143 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
145 | "Received message of type %d from peer %s!\n", | 144 | "Received message of type %d from peer %s!\n", |
@@ -185,8 +184,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
185 | 184 | ||
186 | static void | 185 | static void |
187 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 186 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
188 | const struct GNUNET_ATS_Information *ats, | 187 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
189 | uint32_t ats_count) | ||
190 | { | 188 | { |
191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
192 | GNUNET_i2s (peer), cls); | 190 | GNUNET_i2s (peer), cls); |
@@ -230,15 +228,15 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
230 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL); | 228 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL); |
231 | } | 229 | } |
232 | 230 | ||
233 | void start_cb (struct PeerContext * p, | 231 | void |
234 | void *cls) | 232 | start_cb (struct PeerContext *p, void *cls) |
235 | { | 233 | { |
236 | static int started; | 234 | static int started; |
235 | |||
237 | started++; | 236 | started++; |
238 | 237 | ||
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
240 | p->no, | 239 | GNUNET_i2s (&p->id)); |
241 | GNUNET_i2s (&p->id)); | ||
242 | 240 | ||
243 | if (started != 2) | 241 | if (started != 2) |
244 | return; | 242 | return; |
@@ -257,14 +255,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
257 | tth = GNUNET_TRANSPORT_TESTING_init (); | 255 | tth = GNUNET_TRANSPORT_TESTING_init (); |
258 | 256 | ||
259 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 257 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
260 | ¬ify_receive, | 258 | ¬ify_receive, ¬ify_connect, |
261 | ¬ify_connect, ¬ify_disconnect, | 259 | ¬ify_disconnect, &start_cb, |
262 | &start_cb, | ||
263 | NULL); | 260 | NULL); |
264 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 261 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
265 | ¬ify_receive, | 262 | ¬ify_receive, ¬ify_connect, |
266 | ¬ify_connect, ¬ify_disconnect, | 263 | ¬ify_disconnect, &start_cb, |
267 | &start_cb, | ||
268 | NULL); | 264 | NULL); |
269 | if ((p1 == NULL) || (p2 == NULL)) | 265 | if ((p1 == NULL) || (p2 == NULL)) |
270 | { | 266 | { |
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index e4b635905..5bbff2550 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -69,9 +69,9 @@ struct PeerContext *p1; | |||
69 | 69 | ||
70 | struct PeerContext *p2; | 70 | struct PeerContext *p2; |
71 | 71 | ||
72 | struct PeerContext * sender; | 72 | struct PeerContext *sender; |
73 | 73 | ||
74 | struct PeerContext * receiver; | 74 | struct PeerContext *receiver; |
75 | 75 | ||
76 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 76 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
77 | 77 | ||
@@ -79,7 +79,7 @@ char *cfg_file_p1; | |||
79 | 79 | ||
80 | char *cfg_file_p2; | 80 | char *cfg_file_p2; |
81 | 81 | ||
82 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 82 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
83 | 83 | ||
84 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 84 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
85 | 85 | ||
@@ -151,7 +151,7 @@ end () | |||
151 | th = NULL; | 151 | th = NULL; |
152 | 152 | ||
153 | if (cc != NULL) | 153 | if (cc != NULL) |
154 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 154 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
155 | 155 | ||
156 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 156 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
157 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 157 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
@@ -175,7 +175,7 @@ end_badly () | |||
175 | th = NULL; | 175 | th = NULL; |
176 | 176 | ||
177 | if (cc != NULL) | 177 | if (cc != NULL) |
178 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 178 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
179 | 179 | ||
180 | if (p1 != NULL) | 180 | if (p1 != NULL) |
181 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 181 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
@@ -201,8 +201,7 @@ get_size (unsigned int iter) | |||
201 | static void | 201 | static void |
202 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 202 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
203 | const struct GNUNET_MessageHeader *message, | 203 | const struct GNUNET_MessageHeader *message, |
204 | const struct GNUNET_ATS_Information *ats, | 204 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
205 | uint32_t ats_count) | ||
206 | { | 205 | { |
207 | static int n; | 206 | static int n; |
208 | unsigned int s; | 207 | unsigned int s; |
@@ -253,9 +252,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
253 | if (ntohl (hdr->num) % 5000 == 0) | 252 | if (ntohl (hdr->num) % 5000 == 0) |
254 | { | 253 | { |
255 | struct PeerContext *p = cls; | 254 | struct PeerContext *p = cls; |
256 | char * ps = strdup(GNUNET_i2s(&p->id)); | 255 | char *ps = strdup (GNUNET_i2s (&p->id)); |
257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", | 256 | |
258 | p->no, ps, ntohl (hdr->num), ntohs (message->size), GNUNET_i2s(peer)); | 257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
258 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", | ||
259 | p->no, ps, ntohl (hdr->num), ntohs (message->size), | ||
260 | GNUNET_i2s (peer)); | ||
259 | GNUNET_free (ps); | 261 | GNUNET_free (ps); |
260 | } | 262 | } |
261 | #endif | 263 | #endif |
@@ -289,7 +291,8 @@ notify_ready (void *cls, size_t size, void *buf) | |||
289 | if (buf == NULL) | 291 | if (buf == NULL) |
290 | { | 292 | { |
291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 293 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
292 | "Timeout occurred while waiting for transmit_ready for message %u of %u\n", msg_scheduled, TOTAL_MSGS); | 294 | "Timeout occurred while waiting for transmit_ready for message %u of %u\n", |
295 | msg_scheduled, TOTAL_MSGS); | ||
293 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 296 | if (GNUNET_SCHEDULER_NO_TASK != die_task) |
294 | GNUNET_SCHEDULER_cancel (die_task); | 297 | GNUNET_SCHEDULER_cancel (die_task); |
295 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 298 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
@@ -316,12 +319,12 @@ notify_ready (void *cls, size_t size, void *buf) | |||
316 | if (n % 5000 == 0) | 319 | if (n % 5000 == 0) |
317 | { | 320 | { |
318 | 321 | ||
319 | char * receiver_s = strdup(GNUNET_i2s (&receiver->id)); | 322 | char *receiver_s = strdup (GNUNET_i2s (&receiver->id)); |
323 | |||
320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
321 | "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", | 325 | "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", |
322 | n, | 326 | n, sender->no, GNUNET_i2s (&sender->id), receiver->no, |
323 | sender->no, | 327 | receiver_s); |
324 | GNUNET_i2s (&sender->id), receiver->no, receiver_s); | ||
325 | GNUNET_free (receiver_s); | 328 | GNUNET_free (receiver_s); |
326 | } | 329 | } |
327 | #endif | 330 | #endif |
@@ -356,11 +359,11 @@ notify_ready (void *cls, size_t size, void *buf) | |||
356 | 359 | ||
357 | static void | 360 | static void |
358 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 361 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
359 | const struct GNUNET_ATS_Information *ats, | 362 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
360 | uint32_t ats_count) | ||
361 | { | 363 | { |
362 | 364 | ||
363 | struct PeerContext *p = cls; | 365 | struct PeerContext *p = cls; |
366 | |||
364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", | 367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", |
365 | p->no, GNUNET_i2s (peer)); | 368 | p->no, GNUNET_i2s (peer)); |
366 | } | 369 | } |
@@ -370,8 +373,9 @@ static void | |||
370 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 373 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
371 | { | 374 | { |
372 | struct PeerContext *p = cls; | 375 | struct PeerContext *p = cls; |
373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", | 376 | |
374 | p->no, GNUNET_i2s (peer)); | 377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no, |
378 | GNUNET_i2s (peer)); | ||
375 | if (th != NULL) | 379 | if (th != NULL) |
376 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 380 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
377 | th = NULL; | 381 | th = NULL; |
@@ -391,9 +395,9 @@ static void | |||
391 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 395 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
392 | { | 396 | { |
393 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 397 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
398 | |||
394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", |
395 | p1->no, p1_c, | 400 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); |
396 | p2->no, GNUNET_i2s (&p2->id)); | ||
397 | GNUNET_free (p1_c); | 401 | GNUNET_free (p1_c); |
398 | 402 | ||
399 | cc = NULL; | 403 | cc = NULL; |
@@ -402,37 +406,39 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
402 | 406 | ||
403 | } | 407 | } |
404 | 408 | ||
405 | void start_cb (struct PeerContext * p, | 409 | void |
406 | void *cls) | 410 | start_cb (struct PeerContext *p, void *cls) |
407 | { | 411 | { |
408 | static int started; | 412 | static int started; |
413 | |||
409 | started++; | 414 | started++; |
410 | 415 | ||
411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 416 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
412 | p->no, | 417 | GNUNET_i2s (&p->id)); |
413 | GNUNET_i2s (&p->id)); | ||
414 | 418 | ||
415 | if (started != 2) | 419 | if (started != 2) |
416 | return; | 420 | return; |
417 | 421 | ||
418 | test_connected = GNUNET_NO; | 422 | test_connected = GNUNET_NO; |
419 | 423 | ||
420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", | 424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
421 | p1->no, | 425 | "Peer %u: `%s' using configuration file `%s'\n", p1->no, |
422 | GNUNET_i2s (&p1->id), cfg_file_p1); | 426 | GNUNET_i2s (&p1->id), cfg_file_p1); |
423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
424 | p2->no, | 428 | "Peer %u: `%s' using configuration file `%s'\n", p2->no, |
425 | GNUNET_i2s (&p2->id), cfg_file_p2); | 429 | GNUNET_i2s (&p2->id), cfg_file_p2); |
426 | 430 | ||
427 | sender = p2; | 431 | sender = p2; |
428 | receiver = p1; | 432 | receiver = p1; |
429 | 433 | ||
430 | char *sender_c = strdup (GNUNET_i2s (&sender->id)); | 434 | char *sender_c = strdup (GNUNET_i2s (&sender->id)); |
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test triest to send from %u (%s) -> peer %u (%s)\n", | ||
432 | sender->no, sender_c, | ||
433 | receiver->no, GNUNET_i2s (&receiver->id)); | ||
434 | 435 | ||
435 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL); | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
437 | "Test triest to send from %u (%s) -> peer %u (%s)\n", sender->no, | ||
438 | sender_c, receiver->no, GNUNET_i2s (&receiver->id)); | ||
439 | |||
440 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | ||
441 | NULL); | ||
436 | 442 | ||
437 | } | 443 | } |
438 | 444 | ||
@@ -444,14 +450,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
444 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 450 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
445 | 451 | ||
446 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 452 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
447 | ¬ify_receive, | 453 | ¬ify_receive, ¬ify_connect, |
448 | ¬ify_connect, ¬ify_disconnect, | 454 | ¬ify_disconnect, &start_cb, |
449 | &start_cb, | ||
450 | NULL); | 455 | NULL); |
451 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 456 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
452 | ¬ify_receive, | 457 | ¬ify_receive, ¬ify_connect, |
453 | ¬ify_connect, ¬ify_disconnect, | 458 | ¬ify_disconnect, &start_cb, |
454 | &start_cb, | ||
455 | NULL); | 459 | NULL); |
456 | 460 | ||
457 | if ((p1 == NULL) || (p2 == NULL)) | 461 | if ((p1 == NULL) || (p2 == NULL)) |
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c index aff36853a..79a90ba0e 100644 --- a/src/transport/test_transport_api_timeout.c +++ b/src/transport/test_transport_api_timeout.c | |||
@@ -65,7 +65,7 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task; | |||
65 | 65 | ||
66 | static GNUNET_SCHEDULER_TaskIdentifier timer_task; | 66 | static GNUNET_SCHEDULER_TaskIdentifier timer_task; |
67 | 67 | ||
68 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 68 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
69 | 69 | ||
70 | struct PeerContext *p1; | 70 | struct PeerContext *p1; |
71 | 71 | ||
@@ -161,8 +161,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
161 | static void | 161 | static void |
162 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 162 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
163 | const struct GNUNET_MessageHeader *message, | 163 | const struct GNUNET_MessageHeader *message, |
164 | const struct GNUNET_ATS_Information *ats, | 164 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
165 | uint32_t ats_count) | ||
166 | { | 165 | { |
167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
168 | "Received message of type %d from peer %s!\n", | 167 | "Received message of type %d from peer %s!\n", |
@@ -171,8 +170,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
171 | 170 | ||
172 | static void | 171 | static void |
173 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 172 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
174 | const struct GNUNET_ATS_Information *ats, | 173 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
175 | uint32_t ats_count) | ||
176 | { | 174 | { |
177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
178 | GNUNET_i2s (peer), cls); | 176 | GNUNET_i2s (peer), cls); |
@@ -240,23 +238,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
240 | timer_task = GNUNET_SCHEDULER_add_now (&timer, NULL); | 238 | timer_task = GNUNET_SCHEDULER_add_now (&timer, NULL); |
241 | } | 239 | } |
242 | 240 | ||
243 | void start_cb (struct PeerContext * p, | 241 | void |
244 | void *cls) | 242 | start_cb (struct PeerContext *p, void *cls) |
245 | { | 243 | { |
246 | static int started; | 244 | static int started; |
245 | |||
247 | started++; | 246 | started++; |
248 | 247 | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 248 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
250 | p->no, | 249 | GNUNET_i2s (&p->id)); |
251 | GNUNET_i2s (&p->id)); | ||
252 | 250 | ||
253 | if (started != 2) | 251 | if (started != 2) |
254 | return; | 252 | return; |
255 | 253 | ||
256 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 254 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 255 | |
258 | p1->no, sender_c, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | p2->no, GNUNET_i2s (&p2->id)); | 257 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
258 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
260 | 259 | ||
261 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 260 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
262 | NULL); | 261 | NULL); |
@@ -269,17 +268,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
269 | { | 268 | { |
270 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 269 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
271 | 270 | ||
272 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 271 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
273 | ¬ify_receive, | 272 | ¬ify_receive, ¬ify_connect, |
274 | ¬ify_connect, | 273 | ¬ify_disconnect, &start_cb, |
275 | ¬ify_disconnect, | ||
276 | &start_cb, | ||
277 | NULL); | 274 | NULL); |
278 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 275 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
279 | ¬ify_receive, | 276 | ¬ify_receive, ¬ify_connect, |
280 | ¬ify_connect, | 277 | ¬ify_disconnect, &start_cb, |
281 | ¬ify_disconnect, | ||
282 | &start_cb, | ||
283 | NULL); | 278 | NULL); |
284 | 279 | ||
285 | if ((p1 == NULL) || (p2 == NULL)) | 280 | if ((p1 == NULL) || (p2 == NULL)) |
@@ -314,8 +309,8 @@ check () | |||
314 | 309 | ||
315 | ok = 1; | 310 | ok = 1; |
316 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | 311 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
317 | "test-transport-api-timeout", "nohelp", options, | 312 | "test-transport-api-timeout", "nohelp", options, &run, |
318 | &run, &ok); | 313 | &ok); |
319 | 314 | ||
320 | return ok; | 315 | return ok; |
321 | } | 316 | } |
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index 90b5280ce..3077eaae6 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c | |||
@@ -78,7 +78,7 @@ char *cfg_file_p2; | |||
78 | uint32_t max_bps_p1; | 78 | uint32_t max_bps_p1; |
79 | uint32_t max_bps_p2; | 79 | uint32_t max_bps_p2; |
80 | 80 | ||
81 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 81 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
82 | 82 | ||
83 | /* | 83 | /* |
84 | * Testcase specific declarations | 84 | * Testcase specific declarations |
@@ -156,7 +156,7 @@ end () | |||
156 | th = NULL; | 156 | th = NULL; |
157 | 157 | ||
158 | if (cc != NULL) | 158 | if (cc != NULL) |
159 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 159 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
160 | cc = NULL; | 160 | cc = NULL; |
161 | 161 | ||
162 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 162 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
@@ -190,13 +190,15 @@ end_badly () | |||
190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers got NOT connected\n"); | 190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers got NOT connected\n"); |
191 | 191 | ||
192 | if (test_sending == GNUNET_NO) | 192 | if (test_sending == GNUNET_NO) |
193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testcase did not send any messages timeout\n"); | 193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
194 | "Testcase did not send any messages timeout\n"); | ||
194 | else | 195 | else |
195 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 196 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
196 | "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n", | 197 | "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n", |
197 | msg_sent, msg_scheduled, msg_recv, msg_recv_expected); | 198 | msg_sent, msg_scheduled, msg_recv, msg_recv_expected); |
198 | if (test_send_timeout == GNUNET_YES) | 199 | if (test_send_timeout == GNUNET_YES) |
199 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test had timeout while waiting to send data\n"); | 200 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
201 | "Test had timeout while waiting to send data\n"); | ||
200 | 202 | ||
201 | 203 | ||
202 | if (th != NULL) | 204 | if (th != NULL) |
@@ -204,7 +206,7 @@ end_badly () | |||
204 | th = NULL; | 206 | th = NULL; |
205 | 207 | ||
206 | if (cc != NULL) | 208 | if (cc != NULL) |
207 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 209 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
208 | cc = NULL; | 210 | cc = NULL; |
209 | 211 | ||
210 | if (p1 != NULL) | 212 | if (p1 != NULL) |
@@ -273,8 +275,7 @@ get_bit (const char *map, unsigned int bit) | |||
273 | static void | 275 | static void |
274 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 276 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
275 | const struct GNUNET_MessageHeader *message, | 277 | const struct GNUNET_MessageHeader *message, |
276 | const struct GNUNET_ATS_Information *ats, | 278 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
277 | uint32_t ats_count) | ||
278 | { | 279 | { |
279 | static int n; | 280 | static int n; |
280 | 281 | ||
@@ -400,8 +401,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
400 | else | 401 | else |
401 | { | 402 | { |
402 | fprintf (stderr, "\n"); | 403 | fprintf (stderr, "\n"); |
403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All messages scheduled to be sent\n"); |
404 | "All messages scheduled to be sent\n"); | ||
405 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 405 | if (GNUNET_SCHEDULER_NO_TASK != die_task) |
406 | GNUNET_SCHEDULER_cancel (die_task); | 406 | GNUNET_SCHEDULER_cancel (die_task); |
407 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 407 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
@@ -418,8 +418,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
418 | 418 | ||
419 | static void | 419 | static void |
420 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 420 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
421 | const struct GNUNET_ATS_Information *ats, | 421 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
422 | uint32_t ats_count) | ||
423 | { | 422 | { |
424 | 423 | ||
425 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
@@ -450,6 +449,7 @@ static void | |||
450 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 449 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
451 | { | 450 | { |
452 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 451 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
452 | |||
453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, | 453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, |
454 | GNUNET_i2s (&p2->id)); | 454 | GNUNET_i2s (&p2->id)); |
455 | GNUNET_free (p1_c); | 455 | GNUNET_free (p1_c); |
@@ -460,21 +460,22 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
460 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 460 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
461 | } | 461 | } |
462 | 462 | ||
463 | void start_cb (struct PeerContext * p, | 463 | void |
464 | void *cls) | 464 | start_cb (struct PeerContext *p, void *cls) |
465 | { | 465 | { |
466 | static int started; | 466 | static int started; |
467 | |||
467 | started++; | 468 | started++; |
468 | 469 | ||
469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
470 | p->no, | 471 | GNUNET_i2s (&p->id)); |
471 | GNUNET_i2s (&p->id)); | ||
472 | 472 | ||
473 | if (started != 2) | 473 | if (started != 2) |
474 | return; | 474 | return; |
475 | 475 | ||
476 | test_connected = GNUNET_NO; | 476 | test_connected = GNUNET_NO; |
477 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL); | 477 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
478 | NULL); | ||
478 | 479 | ||
479 | } | 480 | } |
480 | 481 | ||
@@ -487,14 +488,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
487 | 488 | ||
488 | 489 | ||
489 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 490 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
490 | ¬ify_receive, | 491 | ¬ify_receive, ¬ify_connect, |
491 | ¬ify_connect, ¬ify_disconnect, | 492 | ¬ify_disconnect, &start_cb, |
492 | &start_cb, | ||
493 | NULL); | 493 | NULL); |
494 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 494 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
495 | ¬ify_receive, | 495 | ¬ify_receive, ¬ify_connect, |
496 | ¬ify_connect, ¬ify_disconnect, | 496 | ¬ify_disconnect, &start_cb, |
497 | &start_cb, | ||
498 | NULL); | 497 | NULL); |
499 | 498 | ||
500 | 499 | ||
diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c index c8638cd23..3ce256017 100644 --- a/src/transport/test_transport_api_unreliability_constant.c +++ b/src/transport/test_transport_api_unreliability_constant.c | |||
@@ -71,7 +71,7 @@ struct PeerContext *p2; | |||
71 | 71 | ||
72 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 72 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 73 | ||
74 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 74 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
75 | 75 | ||
76 | char *cfg_file_p1; | 76 | char *cfg_file_p1; |
77 | 77 | ||
@@ -154,7 +154,7 @@ end () | |||
154 | th = NULL; | 154 | th = NULL; |
155 | 155 | ||
156 | if (cc != NULL) | 156 | if (cc != NULL) |
157 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 157 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
158 | cc = NULL; | 158 | cc = NULL; |
159 | 159 | ||
160 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 160 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
@@ -165,7 +165,8 @@ end () | |||
165 | ok = 0; | 165 | ok = 0; |
166 | if (test_failed == GNUNET_NO) | 166 | if (test_failed == GNUNET_NO) |
167 | ok = GNUNET_SYSERR; | 167 | ok = GNUNET_SYSERR; |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GOT %u of %u messages\n", msg_recv, TOTAL_MSGS); | 168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GOT %u of %u messages\n", msg_recv, |
169 | TOTAL_MSGS); | ||
169 | } | 170 | } |
170 | 171 | ||
171 | static void | 172 | static void |
@@ -186,7 +187,7 @@ end_badly () | |||
186 | th = NULL; | 187 | th = NULL; |
187 | 188 | ||
188 | if (cc != NULL) | 189 | if (cc != NULL) |
189 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 190 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
190 | cc = NULL; | 191 | cc = NULL; |
191 | 192 | ||
192 | if (p1 != NULL) | 193 | if (p1 != NULL) |
@@ -217,8 +218,7 @@ get_size (unsigned int iter) | |||
217 | static void | 218 | static void |
218 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 219 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
219 | const struct GNUNET_MessageHeader *message, | 220 | const struct GNUNET_MessageHeader *message, |
220 | const struct GNUNET_ATS_Information *ats, | 221 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
221 | uint32_t ats_count) | ||
222 | { | 222 | { |
223 | static int n; | 223 | static int n; |
224 | 224 | ||
@@ -234,8 +234,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
234 | msg_recv = ntohl (hdr->num); | 234 | msg_recv = ntohl (hdr->num); |
235 | if (msg_recv_expected != msg_recv) | 235 | if (msg_recv_expected != msg_recv) |
236 | { | 236 | { |
237 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 237 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected message no %u, got %u\n", |
238 | "Expected message no %u, got %u\n", | ||
239 | msg_recv_expected, msg_recv); | 238 | msg_recv_expected, msg_recv); |
240 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 239 | if (GNUNET_SCHEDULER_NO_TASK != die_task) |
241 | GNUNET_SCHEDULER_cancel (die_task); | 240 | GNUNET_SCHEDULER_cancel (die_task); |
@@ -373,8 +372,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
373 | 372 | ||
374 | static void | 373 | static void |
375 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 374 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
376 | const struct GNUNET_ATS_Information *ats, | 375 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
377 | uint32_t ats_count) | ||
378 | { | 376 | { |
379 | 377 | ||
380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 378 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
@@ -415,20 +413,21 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
415 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 413 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
416 | } | 414 | } |
417 | 415 | ||
418 | void start_cb (struct PeerContext * p, | 416 | void |
419 | void *cls) | 417 | start_cb (struct PeerContext *p, void *cls) |
420 | { | 418 | { |
421 | static int started; | 419 | static int started; |
420 | |||
422 | started++; | 421 | started++; |
423 | 422 | ||
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
425 | p->no, | 424 | GNUNET_i2s (&p->id)); |
426 | GNUNET_i2s (&p->id)); | ||
427 | 425 | ||
428 | if (started != 2) | 426 | if (started != 2) |
429 | return; | 427 | return; |
430 | 428 | ||
431 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL); | 429 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
430 | NULL); | ||
432 | } | 431 | } |
433 | 432 | ||
434 | static void | 433 | static void |
@@ -438,14 +437,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
438 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 437 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
439 | 438 | ||
440 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 439 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
441 | ¬ify_receive, | 440 | ¬ify_receive, ¬ify_connect, |
442 | ¬ify_connect, ¬ify_disconnect, | 441 | ¬ify_disconnect, &start_cb, |
443 | &start_cb, | ||
444 | NULL); | 442 | NULL); |
445 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 443 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
446 | ¬ify_receive, | 444 | ¬ify_receive, ¬ify_connect, |
447 | ¬ify_connect, ¬ify_disconnect, | 445 | ¬ify_disconnect, &start_cb, |
448 | &start_cb, | ||
449 | NULL); | 446 | NULL); |
450 | 447 | ||
451 | if ((p1 == NULL) || (p2 == NULL)) | 448 | if ((p1 == NULL) || (p2 == NULL)) |
diff --git a/src/transport/test_transport_startonly.c b/src/transport/test_transport_startonly.c index 1349a0c4d..c6215c9bc 100644 --- a/src/transport/test_transport_startonly.c +++ b/src/transport/test_transport_startonly.c | |||
@@ -54,7 +54,7 @@ GNUNET_SCHEDULER_TaskIdentifier timeout_task; | |||
54 | 54 | ||
55 | static struct PeerContext *p1; | 55 | static struct PeerContext *p1; |
56 | 56 | ||
57 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 57 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
58 | 58 | ||
59 | static int connected = GNUNET_NO; | 59 | static int connected = GNUNET_NO; |
60 | 60 | ||
@@ -92,8 +92,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
92 | 92 | ||
93 | static void | 93 | static void |
94 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 94 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
95 | const struct GNUNET_ATS_Information *ats, | 95 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
96 | uint32_t ats_count) | ||
97 | { | 96 | { |
98 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n", | 97 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n", |
99 | GNUNET_i2s (peer)); | 98 | GNUNET_i2s (peer)); |
@@ -110,8 +109,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
110 | static void | 109 | static void |
111 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 110 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
112 | const struct GNUNET_MessageHeader *message, | 111 | const struct GNUNET_MessageHeader *message, |
113 | const struct GNUNET_ATS_Information *ats, | 112 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
114 | uint32_t ats_count) | ||
115 | { | 113 | { |
116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n"); | 114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n"); |
117 | } | 115 | } |
@@ -130,8 +128,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
130 | while (i <= ITERATIONS) | 128 | while (i <= ITERATIONS) |
131 | { | 129 | { |
132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); | 130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); |
133 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_startonly.conf", 1, | 131 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
134 | ¬ify_receive, ¬ify_connect, | 132 | "test_transport_startonly.conf", |
133 | 1, ¬ify_receive, | ||
134 | ¬ify_connect, | ||
135 | ¬ify_disconnect, NULL, p1); | 135 | ¬ify_disconnect, NULL, p1); |
136 | 136 | ||
137 | 137 | ||
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c index 266933580..996ea0543 100644 --- a/src/transport/test_transport_testing.c +++ b/src/transport/test_transport_testing.c | |||
@@ -55,7 +55,7 @@ static struct PeerContext *p2; | |||
55 | 55 | ||
56 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 56 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
57 | 57 | ||
58 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 58 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
59 | 59 | ||
60 | static int connected = GNUNET_NO; | 60 | static int connected = GNUNET_NO; |
61 | 61 | ||
@@ -94,9 +94,10 @@ end_badly () | |||
94 | static void | 94 | static void |
95 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 95 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
96 | { | 96 | { |
97 | char * ps = strdup (GNUNET_i2s(&p1->id)); | 97 | char *ps = strdup (GNUNET_i2s (&p1->id)); |
98 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to peer %u (`%s')!\n", | 98 | |
99 | p1->no, ps, | 99 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
100 | "Peer %u (`%4s') connected to peer %u (`%s')!\n", p1->no, ps, | ||
100 | p2->no, GNUNET_i2s (&p2->id)); | 101 | p2->no, GNUNET_i2s (&p2->id)); |
101 | GNUNET_free (ps); | 102 | GNUNET_free (ps); |
102 | GNUNET_SCHEDULER_add_now (&end, NULL); | 103 | GNUNET_SCHEDULER_add_now (&end, NULL); |
@@ -104,8 +105,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
104 | 105 | ||
105 | static void | 106 | static void |
106 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 107 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
107 | const struct GNUNET_ATS_Information *ats, | 108 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
108 | uint32_t ats_count) | ||
109 | { | 109 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n", | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n", |
111 | GNUNET_i2s (peer)); | 111 | GNUNET_i2s (peer)); |
@@ -122,29 +122,29 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
122 | static void | 122 | static void |
123 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 123 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
124 | const struct GNUNET_MessageHeader *message, | 124 | const struct GNUNET_MessageHeader *message, |
125 | const struct GNUNET_ATS_Information *ats, | 125 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
126 | uint32_t ats_count) | ||
127 | { | 126 | { |
128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n"); | 127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n"); |
129 | } | 128 | } |
130 | 129 | ||
131 | void start_cb (struct PeerContext * p, | 130 | void |
132 | void *cls) | 131 | start_cb (struct PeerContext *p, void *cls) |
133 | { | 132 | { |
134 | static int started; | 133 | static int started; |
134 | |||
135 | started++; | 135 | started++; |
136 | 136 | ||
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
138 | p->no, | 138 | GNUNET_i2s (&p->id)); |
139 | GNUNET_i2s (&p->id)); | ||
140 | 139 | ||
141 | if (started != 2) | 140 | if (started != 2) |
142 | return; | 141 | return; |
143 | 142 | ||
144 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 143 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 144 | |
146 | p1->no, sender_c, | 145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
147 | p2->no, GNUNET_i2s (&p2->id)); | 146 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
147 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
148 | 148 | ||
149 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 149 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
150 | NULL); | 150 | NULL); |
@@ -161,34 +161,30 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); | 161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); |
162 | 162 | ||
163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); | 163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); |
164 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer1.conf", | 164 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
165 | 1, | 165 | "test_transport_api_tcp_peer1.conf", |
166 | ¬ify_receive, ¬ify_connect, | 166 | 1, ¬ify_receive, ¬ify_connect, |
167 | ¬ify_disconnect, | 167 | ¬ify_disconnect, &start_cb, p1); |
168 | &start_cb, | 168 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
169 | p1); | 169 | "test_transport_api_tcp_peer2.conf", |
170 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer2.conf", | 170 | 2, ¬ify_receive, ¬ify_connect, |
171 | 2, | 171 | ¬ify_disconnect, &start_cb, p2); |
172 | ¬ify_receive, ¬ify_connect, | ||
173 | ¬ify_disconnect, | ||
174 | &start_cb, | ||
175 | p2); | ||
176 | 172 | ||
177 | if (p1 == NULL) | 173 | if (p1 == NULL) |
178 | { | 174 | { |
179 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer1 was not started successfully\n"); | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
176 | "Peer1 was not started successfully\n"); | ||
180 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) | 177 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) |
181 | GNUNET_SCHEDULER_cancel(timeout_task); | 178 | GNUNET_SCHEDULER_cancel (timeout_task); |
182 | timeout_task = | 179 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
183 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
184 | } | 180 | } |
185 | if (p2 == NULL) | 181 | if (p2 == NULL) |
186 | { | 182 | { |
187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer2 was not started successfully\n"); | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
184 | "Peer2 was not started successfully\n"); | ||
188 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) | 185 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) |
189 | GNUNET_SCHEDULER_cancel(timeout_task); | 186 | GNUNET_SCHEDULER_cancel (timeout_task); |
190 | timeout_task = | 187 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
191 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
192 | } | 188 | } |
193 | } | 189 | } |
194 | 190 | ||
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index a4eba609d..b23879032 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -31,11 +31,11 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | static struct PeerContext * | 33 | static struct PeerContext * |
34 | find_peer_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth, | 34 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
35 | const struct GNUNET_PeerIdentity *peer) | 35 | const struct GNUNET_PeerIdentity *peer) |
36 | { | 36 | { |
37 | GNUNET_assert (tth != NULL); | 37 | GNUNET_assert (tth != NULL); |
38 | struct PeerContext * t = tth->p_head; | 38 | struct PeerContext *t = tth->p_head; |
39 | 39 | ||
40 | while (t != NULL) | 40 | while (t != NULL) |
41 | { | 41 | { |
@@ -48,17 +48,16 @@ find_peer_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
48 | } | 48 | } |
49 | 49 | ||
50 | struct ConnectingContext * | 50 | struct ConnectingContext * |
51 | find_connecting_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth, | 51 | find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
52 | struct PeerContext *p1, | 52 | struct PeerContext *p1, struct PeerContext *p2) |
53 | struct PeerContext * p2) | ||
54 | { | 53 | { |
55 | GNUNET_assert (tth != NULL); | 54 | GNUNET_assert (tth != NULL); |
56 | struct ConnectingContext * cc = tth->cc_head; | 55 | struct ConnectingContext *cc = tth->cc_head; |
57 | 56 | ||
58 | while (cc != NULL) | 57 | while (cc != NULL) |
59 | { | 58 | { |
60 | if ((cc->p1 == p1) && (cc->p2 == p2)) | 59 | if ((cc->p1 == p1) && (cc->p2 == p2)) |
61 | break; | 60 | break; |
62 | if ((cc->p1 == p2) && (cc->p2 == p1)) | 61 | if ((cc->p1 == p2) && (cc->p2 == p1)) |
63 | break; | 62 | break; |
64 | cc = cc->next; | 63 | cc = cc->next; |
@@ -69,14 +68,14 @@ find_connecting_context ( struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
69 | 68 | ||
70 | static void | 69 | static void |
71 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 70 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
72 | const struct GNUNET_ATS_Information *ats, | 71 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
73 | uint32_t ats_count) | ||
74 | { | 72 | { |
75 | struct PeerContext *p = cls; | 73 | struct PeerContext *p = cls; |
74 | |||
76 | /* Find PeerContext */ | 75 | /* Find PeerContext */ |
77 | GNUNET_assert (p != 0); | 76 | GNUNET_assert (p != 0); |
78 | GNUNET_assert (p->tth != NULL); | 77 | GNUNET_assert (p->tth != NULL); |
79 | struct PeerContext * p2 = find_peer_context (p->tth, peer); | 78 | struct PeerContext *p2 = find_peer_context (p->tth, peer); |
80 | 79 | ||
81 | if (p == NULL) | 80 | if (p == NULL) |
82 | return; | 81 | return; |
@@ -84,21 +83,22 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
84 | p->nc (p->cb_cls, peer, ats, ats_count); | 83 | p->nc (p->cb_cls, peer, ats, ats_count); |
85 | 84 | ||
86 | #if VERBOSE | 85 | #if VERBOSE |
87 | char * p2_s; | 86 | char *p2_s; |
87 | |||
88 | if (p2 != NULL) | 88 | if (p2 != NULL) |
89 | GNUNET_asprintf(&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); | 89 | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); |
90 | else | 90 | else |
91 | GNUNET_asprintf(&p2_s, "`%s'", GNUNET_i2s (peer)); | 91 | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); |
92 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 92 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
93 | "Peers %s connected to peer %u (`%s')\n", | 93 | "Peers %s connected to peer %u (`%s')\n", p2_s, p->no, |
94 | p2_s, | 94 | GNUNET_i2s (&p->id)); |
95 | p->no, GNUNET_i2s (&p->id)); | ||
96 | GNUNET_free (p2_s); | 95 | GNUNET_free (p2_s); |
97 | #endif | 96 | #endif |
98 | 97 | ||
99 | 98 | ||
100 | /* Find ConnectingContext */ | 99 | /* Find ConnectingContext */ |
101 | struct ConnectingContext * cc = find_connecting_context(p->tth, p, p2); | 100 | struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2); |
101 | |||
102 | if (cc == NULL) | 102 | if (cc == NULL) |
103 | return; | 103 | return; |
104 | 104 | ||
@@ -106,12 +106,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
106 | cc->p1_c = GNUNET_YES; | 106 | cc->p1_c = GNUNET_YES; |
107 | 107 | ||
108 | if (p == cc->p2) | 108 | if (p == cc->p2) |
109 | cc->p2_c = GNUNET_YES; | 109 | cc->p2_c = GNUNET_YES; |
110 | 110 | ||
111 | if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES)) | 111 | if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES)) |
112 | { | 112 | { |
113 | cc->cb (cc->p1, cc->p2, cc->cb_cls); | 113 | cc->cb (cc->p1, cc->p2, cc->cb_cls); |
114 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(p->tth, cc); | 114 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (p->tth, cc); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
@@ -119,9 +119,10 @@ static void | |||
119 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 119 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
120 | { | 120 | { |
121 | struct PeerContext *p = cls; | 121 | struct PeerContext *p = cls; |
122 | |||
122 | /* Find PeerContext */ | 123 | /* Find PeerContext */ |
123 | int no = 0; | 124 | int no = 0; |
124 | struct PeerContext * p2 = NULL; | 125 | struct PeerContext *p2 = NULL; |
125 | 126 | ||
126 | if (p != NULL) | 127 | if (p != NULL) |
127 | { | 128 | { |
@@ -130,15 +131,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
130 | no = p->no; | 131 | no = p->no; |
131 | } | 132 | } |
132 | 133 | ||
133 | char * p2_s; | 134 | char *p2_s; |
135 | |||
134 | if (p2 != NULL) | 136 | if (p2 != NULL) |
135 | GNUNET_asprintf(&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); | 137 | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); |
136 | else | 138 | else |
137 | GNUNET_asprintf(&p2_s, "`%s'", GNUNET_i2s (peer)); | 139 | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); |
138 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 140 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
139 | "Peers %s disconnected from peer %u (`%s')\n", | 141 | "Peers %s disconnected from peer %u (`%s')\n", p2_s, no, |
140 | p2_s, | 142 | GNUNET_i2s (&p->id)); |
141 | no , GNUNET_i2s (&p->id)); | ||
142 | GNUNET_free (p2_s); | 143 | GNUNET_free (p2_s); |
143 | 144 | ||
144 | if (p == NULL) | 145 | if (p == NULL) |
@@ -150,8 +151,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
150 | static void | 151 | static void |
151 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 152 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
152 | const struct GNUNET_MessageHeader *message, | 153 | const struct GNUNET_MessageHeader *message, |
153 | const struct GNUNET_ATS_Information *ats, | 154 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
154 | uint32_t ats_count) | ||
155 | { | 155 | { |
156 | struct PeerContext *p = cls; | 156 | struct PeerContext *p = cls; |
157 | 157 | ||
@@ -170,25 +170,25 @@ get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) | |||
170 | GNUNET_assert (GNUNET_OK == | 170 | GNUNET_assert (GNUNET_OK == |
171 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | 171 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) |
172 | message, &p->id)); | 172 | message, &p->id)); |
173 | size_t size = GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *) message); | 173 | size_t size = |
174 | GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) message); | ||
174 | GNUNET_free_non_null (p->hello); | 175 | GNUNET_free_non_null (p->hello); |
175 | p->hello = (struct GNUNET_HELLO_Message*) GNUNET_copy_message (message); | 176 | p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message); |
176 | 177 | ||
177 | #if VERBOSE | 178 | #if VERBOSE |
178 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 179 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
179 | "transport-testing", | 180 | "New HELLO for peer %u (`%s') with size %u\n", p->no, |
180 | "New HELLO for peer %u (`%s') with size %u\n", | 181 | GNUNET_i2s (&p->id), size); |
181 | p->no, GNUNET_i2s (&p->id), size); | ||
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | if (p->start_cb != NULL) | 184 | if (p->start_cb != NULL) |
185 | { | 185 | { |
186 | #if VERBOSE | 186 | #if VERBOSE |
187 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 187 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
188 | "Peer %u (`%s') successfully started\n", | 188 | "Peer %u (`%s') successfully started\n", p->no, |
189 | p->no, GNUNET_i2s (&p->id)); | 189 | GNUNET_i2s (&p->id)); |
190 | #endif | 190 | #endif |
191 | p->start_cb(p, p->cb_cls); | 191 | p->start_cb (p, p->cb_cls); |
192 | p->start_cb = NULL; | 192 | p->start_cb = NULL; |
193 | } | 193 | } |
194 | } | 194 | } |
@@ -205,15 +205,17 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
205 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 205 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
206 | return; | 206 | return; |
207 | 207 | ||
208 | char * p2_s = GNUNET_strdup(GNUNET_i2s (&p2->id)); | 208 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
209 | |||
209 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 210 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
210 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", | 211 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", |
211 | p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, | 212 | p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, |
212 | GNUNET_HELLO_size (cc->p2->hello)); | 213 | GNUNET_HELLO_size (cc->p2->hello)); |
213 | GNUNET_free (p2_s); | 214 | GNUNET_free (p2_s); |
214 | 215 | ||
215 | GNUNET_TRANSPORT_offer_hello (cc->th_p1, | 216 | GNUNET_TRANSPORT_offer_hello (cc->th_p1, |
216 | (const struct GNUNET_MessageHeader *) cc->p2->hello, NULL, NULL); | 217 | (const struct GNUNET_MessageHeader *) cc-> |
218 | p2->hello, NULL, NULL); | ||
217 | GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id); | 219 | GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id); |
218 | 220 | ||
219 | cc->tct = | 221 | cc->tct = |
@@ -230,9 +232,8 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
230 | * @return the peer context | 232 | * @return the peer context |
231 | */ | 233 | */ |
232 | struct PeerContext * | 234 | struct PeerContext * |
233 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 235 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle |
234 | const char *cfgname, | 236 | *tth, const char *cfgname, int peer_id, |
235 | int peer_id, | ||
236 | GNUNET_TRANSPORT_ReceiveCallback rec, | 237 | GNUNET_TRANSPORT_ReceiveCallback rec, |
237 | GNUNET_TRANSPORT_NotifyConnect nc, | 238 | GNUNET_TRANSPORT_NotifyConnect nc, |
238 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 239 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
@@ -243,7 +244,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt | |||
243 | if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) | 244 | if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) |
244 | { | 245 | { |
245 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 246 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", |
246 | "File not found: `%s' \n", cfgname); | 247 | "File not found: `%s' \n", cfgname); |
247 | return NULL; | 248 | return NULL; |
248 | } | 249 | } |
249 | 250 | ||
@@ -253,8 +254,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt | |||
253 | 254 | ||
254 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 255 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
255 | if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) | 256 | if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) |
256 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", | 257 | GNUNET_assert (GNUNET_OK == |
257 | &p->servicehome)); | 258 | GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", |
259 | "SERVICEHOME", | ||
260 | &p->servicehome)); | ||
258 | if (NULL != p->servicehome) | 261 | if (NULL != p->servicehome) |
259 | GNUNET_DISK_directory_remove (p->servicehome); | 262 | GNUNET_DISK_directory_remove (p->servicehome); |
260 | p->arm_proc = | 263 | p->arm_proc = |
@@ -286,7 +289,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt | |||
286 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | 289 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); |
287 | GNUNET_assert (p->ghh != NULL); | 290 | GNUNET_assert (p->ghh != NULL); |
288 | 291 | ||
289 | GNUNET_CONTAINER_DLL_insert(tth->p_head, tth->p_tail, p); | 292 | GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p); |
290 | 293 | ||
291 | return p; | 294 | return p; |
292 | } | 295 | } |
@@ -296,7 +299,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt | |||
296 | * @param p the peer | 299 | * @param p the peer |
297 | */ | 300 | */ |
298 | void | 301 | void |
299 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 302 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
300 | struct PeerContext *p) | 303 | struct PeerContext *p) |
301 | { | 304 | { |
302 | GNUNET_assert (p != NULL); | 305 | GNUNET_assert (p != NULL); |
@@ -346,12 +349,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth | |||
346 | * @return connect context | 349 | * @return connect context |
347 | */ | 350 | */ |
348 | GNUNET_TRANSPORT_TESTING_ConnectRequest | 351 | GNUNET_TRANSPORT_TESTING_ConnectRequest |
349 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 352 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle |
350 | struct PeerContext *p1, | 353 | *tth, struct PeerContext *p1, |
351 | struct PeerContext *p2, | 354 | struct PeerContext *p2, |
352 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 355 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
353 | void *cb_cls) | 356 | void *cb_cls) |
354 | |||
355 | { | 357 | { |
356 | GNUNET_assert (tth != NULL); | 358 | GNUNET_assert (tth != NULL); |
357 | 359 | ||
@@ -377,7 +379,7 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
377 | 379 | ||
378 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); | 380 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); |
379 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 381 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
380 | "New connect request %X\n", cc); | 382 | "New connect request %X\n", cc); |
381 | 383 | ||
382 | return cc; | 384 | return cc; |
383 | } | 385 | } |
@@ -387,16 +389,19 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
387 | * Tou MUST cancel the request if you stop the peers before the peers connected succesfully | 389 | * Tou MUST cancel the request if you stop the peers before the peers connected succesfully |
388 | * @param cc a connect request handle | 390 | * @param cc a connect request handle |
389 | */ | 391 | */ |
390 | void GNUNET_TRANSPORT_TESTING_connect_peers_cancel | 392 | void |
391 | (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 393 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct |
392 | GNUNET_TRANSPORT_TESTING_ConnectRequest ccr) | 394 | GNUNET_TRANSPORT_TESTING_handle |
395 | *tth, | ||
396 | GNUNET_TRANSPORT_TESTING_ConnectRequest | ||
397 | ccr) | ||
393 | { | 398 | { |
394 | struct ConnectingContext *cc = ccr; | 399 | struct ConnectingContext *cc = ccr; |
395 | 400 | ||
396 | GNUNET_assert (tth != NULL); | 401 | GNUNET_assert (tth != NULL); |
397 | 402 | ||
398 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 403 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
399 | "Canceling connect request %X!\n", cc); | 404 | "Canceling connect request %X!\n", cc); |
400 | if (cc->tct != GNUNET_SCHEDULER_NO_TASK) | 405 | if (cc->tct != GNUNET_SCHEDULER_NO_TASK) |
401 | GNUNET_SCHEDULER_cancel (cc->tct); | 406 | GNUNET_SCHEDULER_cancel (cc->tct); |
402 | 407 | ||
@@ -412,7 +417,7 @@ void GNUNET_TRANSPORT_TESTING_connect_peers_cancel | |||
412 | * @param tth transport testing handle | 417 | * @param tth transport testing handle |
413 | */ | 418 | */ |
414 | void | 419 | void |
415 | GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth) | 420 | GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) |
416 | { | 421 | { |
417 | struct ConnectingContext *cc = tth->cc_head; | 422 | struct ConnectingContext *cc = tth->cc_head; |
418 | struct ConnectingContext *ct = NULL; | 423 | struct ConnectingContext *ct = NULL; |
@@ -425,8 +430,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth) | |||
425 | { | 430 | { |
426 | ct = cc->next; | 431 | ct = cc->next; |
427 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 432 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", |
428 | "Developer forgot to cancel connect request %X!\n", cc); | 433 | "Developer forgot to cancel connect request %X!\n", cc); |
429 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); | 434 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
430 | cc = ct; | 435 | cc = ct; |
431 | } | 436 | } |
432 | 437 | ||
@@ -434,7 +439,7 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth) | |||
434 | { | 439 | { |
435 | t = p->next; | 440 | t = p->next; |
436 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 441 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", |
437 | "Developer forgot to stop peer!\n"); | 442 | "Developer forgot to stop peer!\n"); |
438 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 443 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
439 | p = t; | 444 | p = t; |
440 | } | 445 | } |
@@ -450,7 +455,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth) | |||
450 | struct GNUNET_TRANSPORT_TESTING_handle * | 455 | struct GNUNET_TRANSPORT_TESTING_handle * |
451 | GNUNET_TRANSPORT_TESTING_init () | 456 | GNUNET_TRANSPORT_TESTING_init () |
452 | { | 457 | { |
453 | struct GNUNET_TRANSPORT_TESTING_handle * tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); | 458 | struct GNUNET_TRANSPORT_TESTING_handle *tth = |
459 | GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); | ||
454 | 460 | ||
455 | return tth; | 461 | return tth; |
456 | } | 462 | } |
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h index ed9238ecb..8e5d55dcd 100644 --- a/src/transport/transport-testing.h +++ b/src/transport/transport-testing.h | |||
@@ -65,10 +65,10 @@ struct GNUNET_TRANSPORT_TESTING_handle; | |||
65 | */ | 65 | */ |
66 | struct PeerContext | 66 | struct PeerContext |
67 | { | 67 | { |
68 | struct PeerContext * next; | 68 | struct PeerContext *next; |
69 | struct PeerContext * prev; | 69 | struct PeerContext *prev; |
70 | 70 | ||
71 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 71 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
72 | 72 | ||
73 | struct GNUNET_CONFIGURATION_Handle *cfg; | 73 | struct GNUNET_CONFIGURATION_Handle *cfg; |
74 | 74 | ||
@@ -100,8 +100,8 @@ struct PeerContext | |||
100 | 100 | ||
101 | struct ConnectingContext | 101 | struct ConnectingContext |
102 | { | 102 | { |
103 | struct ConnectingContext * next; | 103 | struct ConnectingContext *next; |
104 | struct ConnectingContext * prev; | 104 | struct ConnectingContext *prev; |
105 | struct PeerContext *p1; | 105 | struct PeerContext *p1; |
106 | struct PeerContext *p2; | 106 | struct PeerContext *p2; |
107 | GNUNET_SCHEDULER_TaskIdentifier tct; | 107 | GNUNET_SCHEDULER_TaskIdentifier tct; |
@@ -115,11 +115,11 @@ struct ConnectingContext | |||
115 | 115 | ||
116 | struct GNUNET_TRANSPORT_TESTING_handle | 116 | struct GNUNET_TRANSPORT_TESTING_handle |
117 | { | 117 | { |
118 | struct ConnectingContext * cc_head; | 118 | struct ConnectingContext *cc_head; |
119 | struct ConnectingContext * cc_tail; | 119 | struct ConnectingContext *cc_tail; |
120 | 120 | ||
121 | struct PeerContext * p_head; | 121 | struct PeerContext *p_head; |
122 | struct PeerContext * p_tail; | 122 | struct PeerContext *p_tail; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | 125 | ||
@@ -134,9 +134,8 @@ struct GNUNET_TRANSPORT_TESTING_handle | |||
134 | * @return the peer context | 134 | * @return the peer context |
135 | */ | 135 | */ |
136 | struct PeerContext * | 136 | struct PeerContext * |
137 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 137 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle |
138 | const char *cfgname, | 138 | *tth, const char *cfgname, int peer_id, |
139 | int peer_id, | ||
140 | GNUNET_TRANSPORT_ReceiveCallback rec, | 139 | GNUNET_TRANSPORT_ReceiveCallback rec, |
141 | GNUNET_TRANSPORT_NotifyConnect nc, | 140 | GNUNET_TRANSPORT_NotifyConnect nc, |
142 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 141 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
@@ -150,7 +149,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle * tt | |||
150 | */ | 149 | */ |
151 | 150 | ||
152 | void | 151 | void |
153 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 152 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
154 | struct PeerContext *pc); | 153 | struct PeerContext *pc); |
155 | 154 | ||
156 | 155 | ||
@@ -165,8 +164,8 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle * tth | |||
165 | * @return a connect request handle | 164 | * @return a connect request handle |
166 | */ | 165 | */ |
167 | GNUNET_TRANSPORT_TESTING_ConnectRequest | 166 | GNUNET_TRANSPORT_TESTING_ConnectRequest |
168 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * tth, | 167 | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle |
169 | struct PeerContext *p1, | 168 | *tth, struct PeerContext *p1, |
170 | struct PeerContext *p2, | 169 | struct PeerContext *p2, |
171 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 170 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
172 | void *cls); | 171 | void *cls); |
@@ -177,15 +176,16 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
177 | * @param cc a connect request handle | 176 | * @param cc a connect request handle |
178 | */ | 177 | */ |
179 | void | 178 | void |
180 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *, | 179 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct |
181 | void *cc); | 180 | GNUNET_TRANSPORT_TESTING_handle |
181 | *, void *cc); | ||
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Clean up the transport testing | 184 | * Clean up the transport testing |
185 | * @param tth transport testing handle | 185 | * @param tth transport testing handle |
186 | */ | 186 | */ |
187 | void | 187 | void |
188 | GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle * tth); | 188 | GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth); |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Initialize the transport testing | 191 | * Initialize the transport testing |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index cff967b19..b7704e512 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -473,7 +473,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
473 | GNUNET_break (0); | 473 | GNUNET_break (0); |
474 | break; | 474 | break; |
475 | } | 475 | } |
476 | ats = (const struct GNUNET_ATS_Information*) &cim[1]; | 476 | ats = (const struct GNUNET_ATS_Information *) &cim[1]; |
477 | #if DEBUG_TRANSPORT_API | 477 | #if DEBUG_TRANSPORT_API |
478 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n", | 478 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n", |
479 | "CONNECT", GNUNET_i2s (&cim->id)); | 479 | "CONNECT", GNUNET_i2s (&cim->id)); |
@@ -547,7 +547,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
547 | } | 547 | } |
548 | im = (const struct InboundMessage *) msg; | 548 | im = (const struct InboundMessage *) msg; |
549 | ats_count = ntohl (im->ats_count); | 549 | ats_count = ntohl (im->ats_count); |
550 | ats = (const struct GNUNET_ATS_Information*) &im[1]; | 550 | ats = (const struct GNUNET_ATS_Information *) &im[1]; |
551 | imm = (const struct GNUNET_MessageHeader *) &ats[ats_count]; | 551 | imm = (const struct GNUNET_MessageHeader *) &ats[ats_count]; |
552 | if (ntohs (imm->size) + sizeof (struct InboundMessage) + | 552 | if (ntohs (imm->size) + sizeof (struct InboundMessage) + |
553 | ats_count * sizeof (struct GNUNET_ATS_Information) != size) | 553 | ats_count * sizeof (struct GNUNET_ATS_Information) != size) |
diff --git a/src/transport/transport_api_address_iterate.c b/src/transport/transport_api_address_iterate.c index 2ffe1ada8..3c3f97c28 100644 --- a/src/transport/transport_api_address_iterate.c +++ b/src/transport/transport_api_address_iterate.c | |||
@@ -80,7 +80,8 @@ peer_address_response_processor (void *cls, | |||
80 | struct AddressLookupCtx *alucb = cls; | 80 | struct AddressLookupCtx *alucb = cls; |
81 | struct AddressIterateResponseMessage *address; | 81 | struct AddressIterateResponseMessage *address; |
82 | uint16_t size; | 82 | uint16_t size; |
83 | char * transport; | 83 | char *transport; |
84 | |||
84 | //size_t transport_len; | 85 | //size_t transport_len; |
85 | //void * addr; | 86 | //void * addr; |
86 | size_t addrlen; | 87 | size_t addrlen; |
@@ -120,7 +121,7 @@ peer_address_response_processor (void *cls, | |||
120 | 121 | ||
121 | transport = (char *) &address[0]; | 122 | transport = (char *) &address[0]; |
122 | //transport_len = ntohs(address->pluginlen); | 123 | //transport_len = ntohs(address->pluginlen); |
123 | addrlen = ntohs(address->addrlen); | 124 | addrlen = ntohs (address->addrlen); |
124 | 125 | ||
125 | /* expect more replies */ | 126 | /* expect more replies */ |
126 | GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb, | 127 | GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb, |