diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet.c | 1174 |
1 files changed, 586 insertions, 588 deletions
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index 209f7d392..a06cd184f 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file cadet/gnunet-service-cadet.c | 22 | * @file cadet/gnunet-service-cadet.c |
@@ -46,14 +46,13 @@ | |||
46 | #include "gnunet-service-cadet_peer.h" | 46 | #include "gnunet-service-cadet_peer.h" |
47 | #include "gnunet-service-cadet_paths.h" | 47 | #include "gnunet-service-cadet_paths.h" |
48 | 48 | ||
49 | #define LOG(level, ...) GNUNET_log (level,__VA_ARGS__) | 49 | #define LOG(level, ...) GNUNET_log(level, __VA_ARGS__) |
50 | 50 | ||
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Struct containing information about a client of the service | 53 | * Struct containing information about a client of the service |
54 | */ | 54 | */ |
55 | struct CadetClient | 55 | struct CadetClient { |
56 | { | ||
57 | /** | 56 | /** |
58 | * Linked list next | 57 | * Linked list next |
59 | */ | 58 | */ |
@@ -202,11 +201,11 @@ unsigned long long drop_percent; | |||
202 | * @param env envelope with the message | 201 | * @param env envelope with the message |
203 | */ | 202 | */ |
204 | void | 203 | void |
205 | GSC_send_to_client (struct CadetClient *c, | 204 | GSC_send_to_client(struct CadetClient *c, |
206 | struct GNUNET_MQ_Envelope *env) | 205 | struct GNUNET_MQ_Envelope *env) |
207 | { | 206 | { |
208 | GNUNET_MQ_send (c->mq, | 207 | GNUNET_MQ_send(c->mq, |
209 | env); | 208 | env); |
210 | } | 209 | } |
211 | 210 | ||
212 | 211 | ||
@@ -217,14 +216,14 @@ GSC_send_to_client (struct CadetClient *c, | |||
217 | * @return string for debugging | 216 | * @return string for debugging |
218 | */ | 217 | */ |
219 | const char * | 218 | const char * |
220 | GSC_2s (struct CadetClient *c) | 219 | GSC_2s(struct CadetClient *c) |
221 | { | 220 | { |
222 | static char buf[32]; | 221 | static char buf[32]; |
223 | 222 | ||
224 | GNUNET_snprintf (buf, | 223 | GNUNET_snprintf(buf, |
225 | sizeof (buf), | 224 | sizeof(buf), |
226 | "Client(%u)", | 225 | "Client(%u)", |
227 | c->id); | 226 | c->id); |
228 | return buf; | 227 | return buf; |
229 | } | 228 | } |
230 | 229 | ||
@@ -237,11 +236,11 @@ GSC_2s (struct CadetClient *c) | |||
237 | * @return NULL if no such channel exists | 236 | * @return NULL if no such channel exists |
238 | */ | 237 | */ |
239 | static struct CadetChannel * | 238 | static struct CadetChannel * |
240 | lookup_channel (struct CadetClient *c, | 239 | lookup_channel(struct CadetClient *c, |
241 | struct GNUNET_CADET_ClientChannelNumber ccn) | 240 | struct GNUNET_CADET_ClientChannelNumber ccn) |
242 | { | 241 | { |
243 | return GNUNET_CONTAINER_multihashmap32_get (c->channels, | 242 | return GNUNET_CONTAINER_multihashmap32_get(c->channels, |
244 | ntohl (ccn.channel_of_client)); | 243 | ntohl(ccn.channel_of_client)); |
245 | } | 244 | } |
246 | 245 | ||
247 | 246 | ||
@@ -252,23 +251,23 @@ lookup_channel (struct CadetClient *c, | |||
252 | * @param c client handle | 251 | * @param c client handle |
253 | */ | 252 | */ |
254 | static struct GNUNET_CADET_ClientChannelNumber | 253 | static struct GNUNET_CADET_ClientChannelNumber |
255 | client_get_next_ccn (struct CadetClient *c) | 254 | client_get_next_ccn(struct CadetClient *c) |
256 | { | 255 | { |
257 | struct GNUNET_CADET_ClientChannelNumber ccn = c->next_ccn; | 256 | struct GNUNET_CADET_ClientChannelNumber ccn = c->next_ccn; |
258 | 257 | ||
259 | /* increment until we have a free one... */ | 258 | /* increment until we have a free one... */ |
260 | while (NULL != | 259 | while (NULL != |
261 | lookup_channel (c, | 260 | lookup_channel(c, |
262 | ccn)) | 261 | ccn)) |
263 | { | 262 | { |
264 | ccn.channel_of_client | 263 | ccn.channel_of_client |
265 | = htonl (1 + (ntohl (ccn.channel_of_client))); | 264 | = htonl(1 + (ntohl(ccn.channel_of_client))); |
266 | if (ntohl (ccn.channel_of_client) >= | 265 | if (ntohl(ccn.channel_of_client) >= |
267 | GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) | 266 | GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) |
268 | ccn.channel_of_client = htonl (0); | 267 | ccn.channel_of_client = htonl(0); |
269 | } | 268 | } |
270 | c->next_ccn.channel_of_client | 269 | c->next_ccn.channel_of_client |
271 | = htonl (1 + (ntohl (ccn.channel_of_client))); | 270 | = htonl(1 + (ntohl(ccn.channel_of_client))); |
272 | return ccn; | 271 | return ccn; |
273 | } | 272 | } |
274 | 273 | ||
@@ -286,38 +285,38 @@ client_get_next_ccn (struct CadetClient *c) | |||
286 | * @return local channel number assigned to the new client | 285 | * @return local channel number assigned to the new client |
287 | */ | 286 | */ |
288 | struct GNUNET_CADET_ClientChannelNumber | 287 | struct GNUNET_CADET_ClientChannelNumber |
289 | GSC_bind (struct CadetClient *c, | 288 | GSC_bind(struct CadetClient *c, |
290 | struct CadetChannel *ch, | 289 | struct CadetChannel *ch, |
291 | struct CadetPeer *dest, | 290 | struct CadetPeer *dest, |
292 | const struct GNUNET_HashCode *port, | 291 | const struct GNUNET_HashCode *port, |
293 | uint32_t options) | 292 | uint32_t options) |
294 | { | 293 | { |
295 | struct GNUNET_MQ_Envelope *env; | 294 | struct GNUNET_MQ_Envelope *env; |
296 | struct GNUNET_CADET_LocalChannelCreateMessage *cm; | 295 | struct GNUNET_CADET_LocalChannelCreateMessage *cm; |
297 | struct GNUNET_CADET_ClientChannelNumber ccn; | 296 | struct GNUNET_CADET_ClientChannelNumber ccn; |
298 | 297 | ||
299 | ccn = client_get_next_ccn (c); | 298 | ccn = client_get_next_ccn(c); |
300 | GNUNET_assert (GNUNET_YES == | 299 | GNUNET_assert(GNUNET_YES == |
301 | GNUNET_CONTAINER_multihashmap32_put (c->channels, | 300 | GNUNET_CONTAINER_multihashmap32_put(c->channels, |
302 | ntohl (ccn.channel_of_client), | 301 | ntohl(ccn.channel_of_client), |
303 | ch, | 302 | ch, |
304 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 303 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
305 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 304 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
306 | "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n", | 305 | "Accepting incoming %s from %s on open port %s (%u), assigning ccn %X\n", |
307 | GCCH_2s (ch), | 306 | GCCH_2s(ch), |
308 | GCP_2s (dest), | 307 | GCP_2s(dest), |
309 | GNUNET_h2s (port), | 308 | GNUNET_h2s(port), |
310 | (uint32_t) ntohl (options), | 309 | (uint32_t)ntohl(options), |
311 | (uint32_t) ntohl (ccn.channel_of_client)); | 310 | (uint32_t)ntohl(ccn.channel_of_client)); |
312 | /* notify local client about incoming connection! */ | 311 | /* notify local client about incoming connection! */ |
313 | env = GNUNET_MQ_msg (cm, | 312 | env = GNUNET_MQ_msg(cm, |
314 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE); | 313 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE); |
315 | cm->ccn = ccn; | 314 | cm->ccn = ccn; |
316 | cm->port = *port; | 315 | cm->port = *port; |
317 | cm->opt = htonl (options); | 316 | cm->opt = htonl(options); |
318 | cm->peer = *GCP_get_id (dest); | 317 | cm->peer = *GCP_get_id(dest); |
319 | GSC_send_to_client (c, | 318 | GSC_send_to_client(c, |
320 | env); | 319 | env); |
321 | return ccn; | 320 | return ccn; |
322 | } | 321 | } |
323 | 322 | ||
@@ -332,16 +331,16 @@ GSC_bind (struct CadetClient *c, | |||
332 | * @return #GNUNET_OK (iterate over all entries) | 331 | * @return #GNUNET_OK (iterate over all entries) |
333 | */ | 332 | */ |
334 | static int | 333 | static int |
335 | destroy_tunnels_now (void *cls, | 334 | destroy_tunnels_now(void *cls, |
336 | const struct GNUNET_PeerIdentity *pid, | 335 | const struct GNUNET_PeerIdentity *pid, |
337 | void *value) | 336 | void *value) |
338 | { | 337 | { |
339 | struct CadetPeer *cp = value; | 338 | struct CadetPeer *cp = value; |
340 | struct CadetTunnel *t = GCP_get_tunnel (cp, | 339 | struct CadetTunnel *t = GCP_get_tunnel(cp, |
341 | GNUNET_NO); | 340 | GNUNET_NO); |
342 | 341 | ||
343 | if (NULL != t) | 342 | if (NULL != t) |
344 | GCT_destroy_tunnel_now (t); | 343 | GCT_destroy_tunnel_now(t); |
345 | return GNUNET_OK; | 344 | return GNUNET_OK; |
346 | } | 345 | } |
347 | 346 | ||
@@ -356,13 +355,13 @@ destroy_tunnels_now (void *cls, | |||
356 | * @return #GNUNET_OK (iterate over all entries) | 355 | * @return #GNUNET_OK (iterate over all entries) |
357 | */ | 356 | */ |
358 | static int | 357 | static int |
359 | destroy_paths_now (void *cls, | 358 | destroy_paths_now(void *cls, |
360 | const struct GNUNET_PeerIdentity *pid, | 359 | const struct GNUNET_PeerIdentity *pid, |
361 | void *value) | 360 | void *value) |
362 | { | 361 | { |
363 | struct CadetPeer *cp = value; | 362 | struct CadetPeer *cp = value; |
364 | 363 | ||
365 | GCP_drop_owned_paths (cp); | 364 | GCP_drop_owned_paths(cp); |
366 | return GNUNET_OK; | 365 | return GNUNET_OK; |
367 | } | 366 | } |
368 | 367 | ||
@@ -371,50 +370,50 @@ destroy_paths_now (void *cls, | |||
371 | * Shutdown everything once the clients have disconnected. | 370 | * Shutdown everything once the clients have disconnected. |
372 | */ | 371 | */ |
373 | static void | 372 | static void |
374 | shutdown_rest () | 373 | shutdown_rest() |
375 | { | 374 | { |
376 | if (NULL != stats) | 375 | if (NULL != stats) |
377 | { | 376 | { |
378 | GNUNET_STATISTICS_destroy (stats, | 377 | GNUNET_STATISTICS_destroy(stats, |
379 | GNUNET_NO); | 378 | GNUNET_NO); |
380 | stats = NULL; | 379 | stats = NULL; |
381 | } | 380 | } |
382 | /* Destroy tunnels. Note that all channels must be destroyed first! */ | 381 | /* Destroy tunnels. Note that all channels must be destroyed first! */ |
383 | GCP_iterate_all (&destroy_tunnels_now, | 382 | GCP_iterate_all(&destroy_tunnels_now, |
384 | NULL); | 383 | NULL); |
385 | /* All tunnels, channels, connections and CORE must be down before this point. */ | 384 | /* All tunnels, channels, connections and CORE must be down before this point. */ |
386 | GCP_iterate_all (&destroy_paths_now, | 385 | GCP_iterate_all(&destroy_paths_now, |
387 | NULL); | 386 | NULL); |
388 | /* All paths, tunnels, channels, connections and CORE must be down before this point. */ | 387 | /* All paths, tunnels, channels, connections and CORE must be down before this point. */ |
389 | GCP_destroy_all_peers (); | 388 | GCP_destroy_all_peers(); |
390 | if (NULL != open_ports) | 389 | if (NULL != open_ports) |
391 | { | 390 | { |
392 | GNUNET_CONTAINER_multihashmap_destroy (open_ports); | 391 | GNUNET_CONTAINER_multihashmap_destroy(open_ports); |
393 | open_ports = NULL; | 392 | open_ports = NULL; |
394 | } | 393 | } |
395 | if (NULL != loose_channels) | 394 | if (NULL != loose_channels) |
396 | { | 395 | { |
397 | GNUNET_CONTAINER_multihashmap_destroy (loose_channels); | 396 | GNUNET_CONTAINER_multihashmap_destroy(loose_channels); |
398 | loose_channels = NULL; | 397 | loose_channels = NULL; |
399 | } | 398 | } |
400 | if (NULL != peers) | 399 | if (NULL != peers) |
401 | { | 400 | { |
402 | GNUNET_CONTAINER_multipeermap_destroy (peers); | 401 | GNUNET_CONTAINER_multipeermap_destroy(peers); |
403 | peers = NULL; | 402 | peers = NULL; |
404 | } | 403 | } |
405 | if (NULL != connections) | 404 | if (NULL != connections) |
406 | { | 405 | { |
407 | GNUNET_CONTAINER_multishortmap_destroy (connections); | 406 | GNUNET_CONTAINER_multishortmap_destroy(connections); |
408 | connections = NULL; | 407 | connections = NULL; |
409 | } | 408 | } |
410 | if (NULL != ats_ch) | 409 | if (NULL != ats_ch) |
411 | { | 410 | { |
412 | GNUNET_ATS_connectivity_done (ats_ch); | 411 | GNUNET_ATS_connectivity_done(ats_ch); |
413 | ats_ch = NULL; | 412 | ats_ch = NULL; |
414 | } | 413 | } |
415 | GCD_shutdown (); | 414 | GCD_shutdown(); |
416 | GCH_shutdown (); | 415 | GCH_shutdown(); |
417 | GNUNET_free_non_null (my_private_key); | 416 | GNUNET_free_non_null(my_private_key); |
418 | my_private_key = NULL; | 417 | my_private_key = NULL; |
419 | } | 418 | } |
420 | 419 | ||
@@ -425,14 +424,14 @@ shutdown_rest () | |||
425 | * @param cls unused | 424 | * @param cls unused |
426 | */ | 425 | */ |
427 | static void | 426 | static void |
428 | shutdown_task (void *cls) | 427 | shutdown_task(void *cls) |
429 | { | 428 | { |
430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 429 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
431 | "Shutting down\n"); | 430 | "Shutting down\n"); |
432 | shutting_down = GNUNET_YES; | 431 | shutting_down = GNUNET_YES; |
433 | GCO_shutdown (); | 432 | GCO_shutdown(); |
434 | if (NULL == clients_head) | 433 | if (NULL == clients_head) |
435 | shutdown_rest (); | 434 | shutdown_rest(); |
436 | } | 435 | } |
437 | 436 | ||
438 | 437 | ||
@@ -446,20 +445,20 @@ shutdown_task (void *cls) | |||
446 | * @return #GNUNET_YES (iterate over all such channels) | 445 | * @return #GNUNET_YES (iterate over all such channels) |
447 | */ | 446 | */ |
448 | static int | 447 | static int |
449 | bind_loose_channel (void *cls, | 448 | bind_loose_channel(void *cls, |
450 | const struct GNUNET_HashCode *port, | 449 | const struct GNUNET_HashCode *port, |
451 | void *value) | 450 | void *value) |
452 | { | 451 | { |
453 | struct OpenPort *op = cls; | 452 | struct OpenPort *op = cls; |
454 | struct CadetChannel *ch = value; | 453 | struct CadetChannel *ch = value; |
455 | 454 | ||
456 | GCCH_bind (ch, | 455 | GCCH_bind(ch, |
457 | op->c, | 456 | op->c, |
458 | &op->port); | 457 | &op->port); |
459 | GNUNET_assert (GNUNET_YES == | 458 | GNUNET_assert(GNUNET_YES == |
460 | GNUNET_CONTAINER_multihashmap_remove (loose_channels, | 459 | GNUNET_CONTAINER_multihashmap_remove(loose_channels, |
461 | &op->h_port, | 460 | &op->h_port, |
462 | ch)); | 461 | ch)); |
463 | return GNUNET_YES; | 462 | return GNUNET_YES; |
464 | } | 463 | } |
465 | 464 | ||
@@ -474,44 +473,44 @@ bind_loose_channel (void *cls, | |||
474 | * @param pmsg The actual message. | 473 | * @param pmsg The actual message. |
475 | */ | 474 | */ |
476 | static void | 475 | static void |
477 | handle_port_open (void *cls, | 476 | handle_port_open(void *cls, |
478 | const struct GNUNET_CADET_PortMessage *pmsg) | 477 | const struct GNUNET_CADET_PortMessage *pmsg) |
479 | { | 478 | { |
480 | struct CadetClient *c = cls; | 479 | struct CadetClient *c = cls; |
481 | struct OpenPort *op; | 480 | struct OpenPort *op; |
482 | 481 | ||
483 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 482 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
484 | "Open port %s requested by %s\n", | 483 | "Open port %s requested by %s\n", |
485 | GNUNET_h2s (&pmsg->port), | 484 | GNUNET_h2s(&pmsg->port), |
486 | GSC_2s (c)); | 485 | GSC_2s(c)); |
487 | if (NULL == c->ports) | 486 | if (NULL == c->ports) |
488 | c->ports = GNUNET_CONTAINER_multihashmap_create (4, | 487 | c->ports = GNUNET_CONTAINER_multihashmap_create(4, |
489 | GNUNET_NO); | 488 | GNUNET_NO); |
490 | op = GNUNET_new (struct OpenPort); | 489 | op = GNUNET_new(struct OpenPort); |
491 | op->c = c; | 490 | op->c = c; |
492 | op->port = pmsg->port; | 491 | op->port = pmsg->port; |
493 | GCCH_hash_port (&op->h_port, | 492 | GCCH_hash_port(&op->h_port, |
494 | &pmsg->port, | 493 | &pmsg->port, |
495 | &my_full_id); | 494 | &my_full_id); |
496 | if (GNUNET_OK != | 495 | if (GNUNET_OK != |
497 | GNUNET_CONTAINER_multihashmap_put (c->ports, | 496 | GNUNET_CONTAINER_multihashmap_put(c->ports, |
498 | &op->port, | 497 | &op->port, |
499 | op, | 498 | op, |
500 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 499 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
501 | { | 500 | { |
502 | GNUNET_break (0); | 501 | GNUNET_break(0); |
503 | GNUNET_SERVICE_client_drop (c->client); | 502 | GNUNET_SERVICE_client_drop(c->client); |
504 | return; | 503 | return; |
505 | } | 504 | } |
506 | (void) GNUNET_CONTAINER_multihashmap_put (open_ports, | 505 | (void)GNUNET_CONTAINER_multihashmap_put(open_ports, |
507 | &op->h_port, | 506 | &op->h_port, |
508 | op, | 507 | op, |
509 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 508 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
510 | GNUNET_CONTAINER_multihashmap_get_multiple (loose_channels, | 509 | GNUNET_CONTAINER_multihashmap_get_multiple(loose_channels, |
511 | &op->h_port, | 510 | &op->h_port, |
512 | &bind_loose_channel, | 511 | &bind_loose_channel, |
513 | op); | 512 | op); |
514 | GNUNET_SERVICE_client_continue (c->client); | 513 | GNUNET_SERVICE_client_continue(c->client); |
515 | } | 514 | } |
516 | 515 | ||
517 | 516 | ||
@@ -525,41 +524,41 @@ handle_port_open (void *cls, | |||
525 | * @param pmsg The actual message. | 524 | * @param pmsg The actual message. |
526 | */ | 525 | */ |
527 | static void | 526 | static void |
528 | handle_port_close (void *cls, | 527 | handle_port_close(void *cls, |
529 | const struct GNUNET_CADET_PortMessage *pmsg) | 528 | const struct GNUNET_CADET_PortMessage *pmsg) |
530 | { | 529 | { |
531 | struct CadetClient *c = cls; | 530 | struct CadetClient *c = cls; |
532 | struct OpenPort *op; | 531 | struct OpenPort *op; |
533 | 532 | ||
534 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 533 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
535 | "Closing port %s as requested by %s\n", | 534 | "Closing port %s as requested by %s\n", |
536 | GNUNET_h2s (&pmsg->port), | 535 | GNUNET_h2s(&pmsg->port), |
537 | GSC_2s (c)); | 536 | GSC_2s(c)); |
538 | if (NULL == c->ports) | 537 | if (NULL == c->ports) |
539 | { | 538 | { |
540 | /* Client closed a port despite _never_ having opened one? */ | 539 | /* Client closed a port despite _never_ having opened one? */ |
541 | GNUNET_break (0); | 540 | GNUNET_break(0); |
542 | GNUNET_SERVICE_client_drop (c->client); | 541 | GNUNET_SERVICE_client_drop(c->client); |
543 | return; | 542 | return; |
544 | } | 543 | } |
545 | op = GNUNET_CONTAINER_multihashmap_get (c->ports, | 544 | op = GNUNET_CONTAINER_multihashmap_get(c->ports, |
546 | &pmsg->port); | 545 | &pmsg->port); |
547 | if (NULL == op) | 546 | if (NULL == op) |
548 | { | 547 | { |
549 | GNUNET_break (0); | 548 | GNUNET_break(0); |
550 | GNUNET_SERVICE_client_drop (c->client); | 549 | GNUNET_SERVICE_client_drop(c->client); |
551 | return; | 550 | return; |
552 | } | 551 | } |
553 | GNUNET_assert (GNUNET_YES == | 552 | GNUNET_assert(GNUNET_YES == |
554 | GNUNET_CONTAINER_multihashmap_remove (c->ports, | 553 | GNUNET_CONTAINER_multihashmap_remove(c->ports, |
555 | &op->port, | 554 | &op->port, |
556 | op)); | 555 | op)); |
557 | GNUNET_assert (GNUNET_YES == | 556 | GNUNET_assert(GNUNET_YES == |
558 | GNUNET_CONTAINER_multihashmap_remove (open_ports, | 557 | GNUNET_CONTAINER_multihashmap_remove(open_ports, |
559 | &op->h_port, | 558 | &op->h_port, |
560 | op)); | 559 | op)); |
561 | GNUNET_free (op); | 560 | GNUNET_free(op); |
562 | GNUNET_SERVICE_client_continue (c->client); | 561 | GNUNET_SERVICE_client_continue(c->client); |
563 | } | 562 | } |
564 | 563 | ||
565 | 564 | ||
@@ -570,54 +569,54 @@ handle_port_close (void *cls, | |||
570 | * @param tcm The actual message. | 569 | * @param tcm The actual message. |
571 | */ | 570 | */ |
572 | static void | 571 | static void |
573 | handle_channel_create (void *cls, | 572 | handle_channel_create(void *cls, |
574 | const struct GNUNET_CADET_LocalChannelCreateMessage *tcm) | 573 | const struct GNUNET_CADET_LocalChannelCreateMessage *tcm) |
575 | { | 574 | { |
576 | struct CadetClient *c = cls; | 575 | struct CadetClient *c = cls; |
577 | struct CadetChannel *ch; | 576 | struct CadetChannel *ch; |
578 | 577 | ||
579 | if (ntohl (tcm->ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) | 578 | if (ntohl(tcm->ccn.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) |
580 | { | 579 | { |
581 | /* Channel ID not in allowed range. */ | 580 | /* Channel ID not in allowed range. */ |
582 | GNUNET_break (0); | 581 | GNUNET_break(0); |
583 | GNUNET_SERVICE_client_drop (c->client); | 582 | GNUNET_SERVICE_client_drop(c->client); |
584 | return; | 583 | return; |
585 | } | 584 | } |
586 | ch = lookup_channel (c, | 585 | ch = lookup_channel(c, |
587 | tcm->ccn); | 586 | tcm->ccn); |
588 | if (NULL != ch) | 587 | if (NULL != ch) |
589 | { | 588 | { |
590 | /* Channel ID already in use. Not allowed. */ | 589 | /* Channel ID already in use. Not allowed. */ |
591 | GNUNET_break (0); | 590 | GNUNET_break(0); |
592 | GNUNET_SERVICE_client_drop (c->client); | 591 | GNUNET_SERVICE_client_drop(c->client); |
593 | return; | 592 | return; |
594 | } | 593 | } |
595 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 594 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
596 | "New channel to %s at port %s requested by %s\n", | 595 | "New channel to %s at port %s requested by %s\n", |
597 | GNUNET_i2s (&tcm->peer), | 596 | GNUNET_i2s(&tcm->peer), |
598 | GNUNET_h2s (&tcm->port), | 597 | GNUNET_h2s(&tcm->port), |
599 | GSC_2s (c)); | 598 | GSC_2s(c)); |
600 | 599 | ||
601 | /* Create channel */ | 600 | /* Create channel */ |
602 | ch = GCCH_channel_local_new (c, | 601 | ch = GCCH_channel_local_new(c, |
603 | tcm->ccn, | 602 | tcm->ccn, |
604 | GCP_get (&tcm->peer, | 603 | GCP_get(&tcm->peer, |
605 | GNUNET_YES), | 604 | GNUNET_YES), |
606 | &tcm->port, | 605 | &tcm->port, |
607 | ntohl (tcm->opt)); | 606 | ntohl(tcm->opt)); |
608 | if (NULL == ch) | 607 | if (NULL == ch) |
609 | { | 608 | { |
610 | GNUNET_break (0); | 609 | GNUNET_break(0); |
611 | GNUNET_SERVICE_client_drop (c->client); | 610 | GNUNET_SERVICE_client_drop(c->client); |
612 | return; | 611 | return; |
613 | } | 612 | } |
614 | GNUNET_assert (GNUNET_YES == | 613 | GNUNET_assert(GNUNET_YES == |
615 | GNUNET_CONTAINER_multihashmap32_put (c->channels, | 614 | GNUNET_CONTAINER_multihashmap32_put(c->channels, |
616 | ntohl (tcm->ccn.channel_of_client), | 615 | ntohl(tcm->ccn.channel_of_client), |
617 | ch, | 616 | ch, |
618 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 617 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
619 | 618 | ||
620 | GNUNET_SERVICE_client_continue (c->client); | 619 | GNUNET_SERVICE_client_continue(c->client); |
621 | } | 620 | } |
622 | 621 | ||
623 | 622 | ||
@@ -628,37 +627,37 @@ handle_channel_create (void *cls, | |||
628 | * @param msg the actual message | 627 | * @param msg the actual message |
629 | */ | 628 | */ |
630 | static void | 629 | static void |
631 | handle_channel_destroy (void *cls, | 630 | handle_channel_destroy(void *cls, |
632 | const struct GNUNET_CADET_LocalChannelDestroyMessage *msg) | 631 | const struct GNUNET_CADET_LocalChannelDestroyMessage *msg) |
633 | { | 632 | { |
634 | struct CadetClient *c = cls; | 633 | struct CadetClient *c = cls; |
635 | struct CadetChannel *ch; | 634 | struct CadetChannel *ch; |
636 | 635 | ||
637 | ch = lookup_channel (c, | 636 | ch = lookup_channel(c, |
638 | msg->ccn); | 637 | msg->ccn); |
639 | if (NULL == ch) | 638 | if (NULL == ch) |
640 | { | 639 | { |
641 | /* Client attempted to destroy unknown channel. | 640 | /* Client attempted to destroy unknown channel. |
642 | Can happen if the other side went down at the same time.*/ | 641 | Can happen if the other side went down at the same time.*/ |
643 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 642 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
644 | "%s tried to destroy unknown channel %X\n", | 643 | "%s tried to destroy unknown channel %X\n", |
645 | GSC_2s(c), | 644 | GSC_2s(c), |
646 | (uint32_t) ntohl (msg->ccn.channel_of_client)); | 645 | (uint32_t)ntohl(msg->ccn.channel_of_client)); |
647 | GNUNET_SERVICE_client_continue (c->client); | 646 | GNUNET_SERVICE_client_continue(c->client); |
648 | return; | 647 | return; |
649 | } | 648 | } |
650 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 649 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
651 | "%s is destroying %s\n", | 650 | "%s is destroying %s\n", |
652 | GSC_2s(c), | 651 | GSC_2s(c), |
653 | GCCH_2s (ch)); | 652 | GCCH_2s(ch)); |
654 | GNUNET_assert (GNUNET_YES == | 653 | GNUNET_assert(GNUNET_YES == |
655 | GNUNET_CONTAINER_multihashmap32_remove (c->channels, | 654 | GNUNET_CONTAINER_multihashmap32_remove(c->channels, |
656 | ntohl (msg->ccn.channel_of_client), | 655 | ntohl(msg->ccn.channel_of_client), |
657 | ch)); | 656 | ch)); |
658 | GCCH_channel_local_destroy (ch, | 657 | GCCH_channel_local_destroy(ch, |
659 | c, | 658 | c, |
660 | msg->ccn); | 659 | msg->ccn); |
661 | GNUNET_SERVICE_client_continue (c->client); | 660 | GNUNET_SERVICE_client_continue(c->client); |
662 | } | 661 | } |
663 | 662 | ||
664 | 663 | ||
@@ -670,8 +669,8 @@ handle_channel_destroy (void *cls, | |||
670 | * @return #GNUNET_OK if @a msg is OK, #GNUNET_SYSERR if not | 669 | * @return #GNUNET_OK if @a msg is OK, #GNUNET_SYSERR if not |
671 | */ | 670 | */ |
672 | static int | 671 | static int |
673 | check_local_data (void *cls, | 672 | check_local_data(void *cls, |
674 | const struct GNUNET_CADET_LocalData *msg) | 673 | const struct GNUNET_CADET_LocalData *msg) |
675 | { | 674 | { |
676 | size_t payload_size; | 675 | size_t payload_size; |
677 | size_t payload_claimed_size; | 676 | size_t payload_claimed_size; |
@@ -684,36 +683,36 @@ check_local_data (void *cls, | |||
684 | cadet_api will likely no more, so we could then | 683 | cadet_api will likely no more, so we could then |
685 | simplify this mess again. */ | 684 | simplify this mess again. */ |
686 | /* Sanity check for message size */ | 685 | /* Sanity check for message size */ |
687 | payload_size = ntohs (msg->header.size) - sizeof (*msg); | 686 | payload_size = ntohs(msg->header.size) - sizeof(*msg); |
688 | buf = (const char *) &msg[1]; | 687 | buf = (const char *)&msg[1]; |
689 | while (payload_size >= sizeof (struct GNUNET_MessageHeader)) | 688 | while (payload_size >= sizeof(struct GNUNET_MessageHeader)) |
690 | { | ||
691 | /* need to memcpy() for alignment */ | ||
692 | GNUNET_memcpy (&pa, | ||
693 | buf, | ||
694 | sizeof (pa)); | ||
695 | payload_claimed_size = ntohs (pa.size); | ||
696 | if ( (payload_size < payload_claimed_size) || | ||
697 | (payload_claimed_size < sizeof (struct GNUNET_MessageHeader)) || | ||
698 | (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size) ) | ||
699 | { | 689 | { |
700 | GNUNET_break (0); | 690 | /* need to memcpy() for alignment */ |
701 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 691 | GNUNET_memcpy(&pa, |
702 | "Local data of %u total size had sub-message %u at %u with %u bytes\n", | 692 | buf, |
703 | ntohs (msg->header.size), | 693 | sizeof(pa)); |
704 | ntohs (pa.type), | 694 | payload_claimed_size = ntohs(pa.size); |
705 | (unsigned int) (buf - (const char *) &msg[1]), | 695 | if ((payload_size < payload_claimed_size) || |
706 | (unsigned int) payload_claimed_size); | 696 | (payload_claimed_size < sizeof(struct GNUNET_MessageHeader)) || |
707 | return GNUNET_SYSERR; | 697 | (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size)) |
698 | { | ||
699 | GNUNET_break(0); | ||
700 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
701 | "Local data of %u total size had sub-message %u at %u with %u bytes\n", | ||
702 | ntohs(msg->header.size), | ||
703 | ntohs(pa.type), | ||
704 | (unsigned int)(buf - (const char *)&msg[1]), | ||
705 | (unsigned int)payload_claimed_size); | ||
706 | return GNUNET_SYSERR; | ||
707 | } | ||
708 | payload_size -= payload_claimed_size; | ||
709 | buf += payload_claimed_size; | ||
708 | } | 710 | } |
709 | payload_size -= payload_claimed_size; | ||
710 | buf += payload_claimed_size; | ||
711 | } | ||
712 | if (0 != payload_size) | 711 | if (0 != payload_size) |
713 | { | 712 | { |
714 | GNUNET_break_op (0); | 713 | GNUNET_break_op(0); |
715 | return GNUNET_SYSERR; | 714 | return GNUNET_SYSERR; |
716 | } | 715 | } |
717 | return GNUNET_OK; | 716 | return GNUNET_OK; |
718 | } | 717 | } |
719 | 718 | ||
@@ -726,47 +725,47 @@ check_local_data (void *cls, | |||
726 | * @param msg the actual message | 725 | * @param msg the actual message |
727 | */ | 726 | */ |
728 | static void | 727 | static void |
729 | handle_local_data (void *cls, | 728 | handle_local_data(void *cls, |
730 | const struct GNUNET_CADET_LocalData *msg) | 729 | const struct GNUNET_CADET_LocalData *msg) |
731 | { | 730 | { |
732 | struct CadetClient *c = cls; | 731 | struct CadetClient *c = cls; |
733 | struct CadetChannel *ch; | 732 | struct CadetChannel *ch; |
734 | size_t payload_size; | 733 | size_t payload_size; |
735 | const char *buf; | 734 | const char *buf; |
736 | 735 | ||
737 | ch = lookup_channel (c, | 736 | ch = lookup_channel(c, |
738 | msg->ccn); | 737 | msg->ccn); |
739 | if (NULL == ch) | 738 | if (NULL == ch) |
740 | { | 739 | { |
741 | /* Channel does not exist (anymore) */ | 740 | /* Channel does not exist (anymore) */ |
742 | LOG (GNUNET_ERROR_TYPE_WARNING, | 741 | LOG(GNUNET_ERROR_TYPE_WARNING, |
743 | "Dropping payload for channel %u from client (channel unknown, other endpoint may have disconnected)\n", | 742 | "Dropping payload for channel %u from client (channel unknown, other endpoint may have disconnected)\n", |
744 | (unsigned int) ntohl (msg->ccn.channel_of_client)); | 743 | (unsigned int)ntohl(msg->ccn.channel_of_client)); |
745 | GNUNET_SERVICE_client_continue (c->client); | 744 | GNUNET_SERVICE_client_continue(c->client); |
746 | return; | 745 | return; |
747 | } | 746 | } |
748 | payload_size = ntohs (msg->header.size) - sizeof (*msg); | 747 | payload_size = ntohs(msg->header.size) - sizeof(*msg); |
749 | GNUNET_STATISTICS_update (stats, | 748 | GNUNET_STATISTICS_update(stats, |
750 | "# payload received from clients", | 749 | "# payload received from clients", |
751 | payload_size, | 750 | payload_size, |
752 | GNUNET_NO); | 751 | GNUNET_NO); |
753 | buf = (const char *) &msg[1]; | 752 | buf = (const char *)&msg[1]; |
754 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 753 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
755 | "Received %u bytes payload from %s for %s\n", | 754 | "Received %u bytes payload from %s for %s\n", |
756 | (unsigned int) payload_size, | 755 | (unsigned int)payload_size, |
757 | GSC_2s (c), | 756 | GSC_2s(c), |
758 | GCCH_2s (ch)); | 757 | GCCH_2s(ch)); |
759 | if (GNUNET_OK != | 758 | if (GNUNET_OK != |
760 | GCCH_handle_local_data (ch, | 759 | GCCH_handle_local_data(ch, |
761 | msg->ccn, | 760 | msg->ccn, |
762 | buf, | 761 | buf, |
763 | payload_size)) | 762 | payload_size)) |
764 | { | 763 | { |
765 | GNUNET_break (0); | 764 | GNUNET_break(0); |
766 | GNUNET_SERVICE_client_drop (c->client); | 765 | GNUNET_SERVICE_client_drop(c->client); |
767 | return; | 766 | return; |
768 | } | 767 | } |
769 | GNUNET_SERVICE_client_continue (c->client); | 768 | GNUNET_SERVICE_client_continue(c->client); |
770 | } | 769 | } |
771 | 770 | ||
772 | 771 | ||
@@ -777,30 +776,30 @@ handle_local_data (void *cls, | |||
777 | * @param msg The actual message. | 776 | * @param msg The actual message. |
778 | */ | 777 | */ |
779 | static void | 778 | static void |
780 | handle_local_ack (void *cls, | 779 | handle_local_ack(void *cls, |
781 | const struct GNUNET_CADET_LocalAck *msg) | 780 | const struct GNUNET_CADET_LocalAck *msg) |
782 | { | 781 | { |
783 | struct CadetClient *c = cls; | 782 | struct CadetClient *c = cls; |
784 | struct CadetChannel *ch; | 783 | struct CadetChannel *ch; |
785 | 784 | ||
786 | ch = lookup_channel (c, | 785 | ch = lookup_channel(c, |
787 | msg->ccn); | 786 | msg->ccn); |
788 | if (NULL == ch) | 787 | if (NULL == ch) |
789 | { | 788 | { |
790 | /* Channel does not exist (anymore) */ | 789 | /* Channel does not exist (anymore) */ |
791 | LOG (GNUNET_ERROR_TYPE_WARNING, | 790 | LOG(GNUNET_ERROR_TYPE_WARNING, |
792 | "Ignoring local ACK for channel %u from client (channel unknown, other endpoint may have disconnected)\n", | 791 | "Ignoring local ACK for channel %u from client (channel unknown, other endpoint may have disconnected)\n", |
793 | (unsigned int) ntohl (msg->ccn.channel_of_client)); | 792 | (unsigned int)ntohl(msg->ccn.channel_of_client)); |
794 | GNUNET_SERVICE_client_continue (c->client); | 793 | GNUNET_SERVICE_client_continue(c->client); |
795 | return; | 794 | return; |
796 | } | 795 | } |
797 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 796 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
798 | "Got a local ACK from %s for %s\n", | 797 | "Got a local ACK from %s for %s\n", |
799 | GSC_2s(c), | 798 | GSC_2s(c), |
800 | GCCH_2s (ch)); | 799 | GCCH_2s(ch)); |
801 | GCCH_handle_local_ack (ch, | 800 | GCCH_handle_local_ack(ch, |
802 | msg->ccn); | 801 | msg->ccn); |
803 | GNUNET_SERVICE_client_continue (c->client); | 802 | GNUNET_SERVICE_client_continue(c->client); |
804 | } | 803 | } |
805 | 804 | ||
806 | 805 | ||
@@ -813,24 +812,24 @@ handle_local_ack (void *cls, | |||
813 | * @return #GNUNET_YES, to keep iterating. | 812 | * @return #GNUNET_YES, to keep iterating. |
814 | */ | 813 | */ |
815 | static int | 814 | static int |
816 | get_all_peers_iterator (void *cls, | 815 | get_all_peers_iterator(void *cls, |
817 | const struct GNUNET_PeerIdentity *peer, | 816 | const struct GNUNET_PeerIdentity *peer, |
818 | void *value) | 817 | void *value) |
819 | { | 818 | { |
820 | struct CadetClient *c = cls; | 819 | struct CadetClient *c = cls; |
821 | struct CadetPeer *p = value; | 820 | struct CadetPeer *p = value; |
822 | struct GNUNET_MQ_Envelope *env; | 821 | struct GNUNET_MQ_Envelope *env; |
823 | struct GNUNET_CADET_LocalInfoPeers *msg; | 822 | struct GNUNET_CADET_LocalInfoPeers *msg; |
824 | 823 | ||
825 | env = GNUNET_MQ_msg (msg, | 824 | env = GNUNET_MQ_msg(msg, |
826 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); | 825 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS); |
827 | msg->destination = *peer; | 826 | msg->destination = *peer; |
828 | msg->paths = htons (GCP_count_paths (p)); | 827 | msg->paths = htons(GCP_count_paths(p)); |
829 | msg->tunnel = htons (NULL != GCP_get_tunnel (p, | 828 | msg->tunnel = htons(NULL != GCP_get_tunnel(p, |
830 | GNUNET_NO)); | 829 | GNUNET_NO)); |
831 | msg->best_path_length = htonl (0); // FIXME: get length of shortest known path! | 830 | msg->best_path_length = htonl(0); // FIXME: get length of shortest known path! |
832 | GNUNET_MQ_send (c->mq, | 831 | GNUNET_MQ_send(c->mq, |
833 | env); | 832 | env); |
834 | return GNUNET_YES; | 833 | return GNUNET_YES; |
835 | } | 834 | } |
836 | 835 | ||
@@ -842,20 +841,20 @@ get_all_peers_iterator (void *cls, | |||
842 | * @param message The actual message. | 841 | * @param message The actual message. |
843 | */ | 842 | */ |
844 | static void | 843 | static void |
845 | handle_get_peers (void *cls, | 844 | handle_get_peers(void *cls, |
846 | const struct GNUNET_MessageHeader *message) | 845 | const struct GNUNET_MessageHeader *message) |
847 | { | 846 | { |
848 | struct CadetClient *c = cls; | 847 | struct CadetClient *c = cls; |
849 | struct GNUNET_MQ_Envelope *env; | 848 | struct GNUNET_MQ_Envelope *env; |
850 | struct GNUNET_MessageHeader *reply; | 849 | struct GNUNET_MessageHeader *reply; |
851 | 850 | ||
852 | GCP_iterate_all (&get_all_peers_iterator, | 851 | GCP_iterate_all(&get_all_peers_iterator, |
853 | c); | 852 | c); |
854 | env = GNUNET_MQ_msg (reply, | 853 | env = GNUNET_MQ_msg(reply, |
855 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END); | 854 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS_END); |
856 | GNUNET_MQ_send (c->mq, | 855 | GNUNET_MQ_send(c->mq, |
857 | env); | 856 | env); |
858 | GNUNET_SERVICE_client_continue (c->client); | 857 | GNUNET_SERVICE_client_continue(c->client); |
859 | } | 858 | } |
860 | 859 | ||
861 | 860 | ||
@@ -870,9 +869,9 @@ handle_get_peers (void *cls, | |||
870 | * #GNUNET_NO otherwise. | 869 | * #GNUNET_NO otherwise. |
871 | */ | 870 | */ |
872 | static int | 871 | static int |
873 | path_info_iterator (void *cls, | 872 | path_info_iterator(void *cls, |
874 | struct CadetPeerPath *path, | 873 | struct CadetPeerPath *path, |
875 | unsigned int off) | 874 | unsigned int off) |
876 | { | 875 | { |
877 | struct GNUNET_MQ_Handle *mq = cls; | 876 | struct GNUNET_MQ_Handle *mq = cls; |
878 | struct GNUNET_MQ_Envelope *env; | 877 | struct GNUNET_MQ_Envelope *env; |
@@ -881,36 +880,36 @@ path_info_iterator (void *cls, | |||
881 | size_t path_size; | 880 | size_t path_size; |
882 | unsigned int path_length; | 881 | unsigned int path_length; |
883 | 882 | ||
884 | path_length = GCPP_get_length (path); | 883 | path_length = GCPP_get_length(path); |
885 | path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; | 884 | path_size = sizeof(struct GNUNET_PeerIdentity) * path_length; |
886 | if (sizeof (*resp) + path_size > UINT16_MAX) | 885 | if (sizeof(*resp) + path_size > UINT16_MAX) |
887 | { | 886 | { |
888 | /* try just giving the relevant path */ | 887 | /* try just giving the relevant path */ |
889 | path_length = GNUNET_MIN ((UINT16_MAX - sizeof (*resp)) / sizeof (struct GNUNET_PeerIdentity), | 888 | path_length = GNUNET_MIN((UINT16_MAX - sizeof(*resp)) / sizeof(struct GNUNET_PeerIdentity), |
890 | off); | 889 | off); |
891 | path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; | 890 | path_size = sizeof(struct GNUNET_PeerIdentity) * path_length; |
892 | } | 891 | } |
893 | if (sizeof (*resp) + path_size > UINT16_MAX) | 892 | if (sizeof(*resp) + path_size > UINT16_MAX) |
894 | { | 893 | { |
895 | LOG (GNUNET_ERROR_TYPE_WARNING, | 894 | LOG(GNUNET_ERROR_TYPE_WARNING, |
896 | "Path of %u entries is too long for info message\n", | 895 | "Path of %u entries is too long for info message\n", |
897 | path_length); | 896 | path_length); |
898 | return GNUNET_YES; | 897 | return GNUNET_YES; |
899 | } | 898 | } |
900 | env = GNUNET_MQ_msg_extra (resp, | 899 | env = GNUNET_MQ_msg_extra(resp, |
901 | path_size, | 900 | path_size, |
902 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH); | 901 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH); |
903 | id = (struct GNUNET_PeerIdentity *) &resp[1]; | 902 | id = (struct GNUNET_PeerIdentity *)&resp[1]; |
904 | 903 | ||
905 | /* Don't copy first peer. First peer is always the local one. Last | 904 | /* Don't copy first peer. First peer is always the local one. Last |
906 | * peer is always the destination (leave as 0, EOL). | 905 | * peer is always the destination (leave as 0, EOL). |
907 | */ | 906 | */ |
908 | for (unsigned int i = 0; i < path_length; i++) | 907 | for (unsigned int i = 0; i < path_length; i++) |
909 | id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path, | 908 | id[i] = *GCP_get_id(GCPP_get_peer_at_offset(path, |
910 | i)); | 909 | i)); |
911 | resp->off = htonl (off); | 910 | resp->off = htonl(off); |
912 | GNUNET_MQ_send (mq, | 911 | GNUNET_MQ_send(mq, |
913 | env); | 912 | env); |
914 | return GNUNET_YES; | 913 | return GNUNET_YES; |
915 | } | 914 | } |
916 | 915 | ||
@@ -922,25 +921,25 @@ path_info_iterator (void *cls, | |||
922 | * @param msg The actual message. | 921 | * @param msg The actual message. |
923 | */ | 922 | */ |
924 | static void | 923 | static void |
925 | handle_show_path (void *cls, | 924 | handle_show_path(void *cls, |
926 | const struct GNUNET_CADET_RequestPathInfoMessage *msg) | 925 | const struct GNUNET_CADET_RequestPathInfoMessage *msg) |
927 | { | 926 | { |
928 | struct CadetClient *c = cls; | 927 | struct CadetClient *c = cls; |
929 | struct CadetPeer *p; | 928 | struct CadetPeer *p; |
930 | struct GNUNET_MQ_Envelope *env; | 929 | struct GNUNET_MQ_Envelope *env; |
931 | struct GNUNET_MessageHeader *resp; | 930 | struct GNUNET_MessageHeader *resp; |
932 | 931 | ||
933 | p = GCP_get (&msg->peer, | 932 | p = GCP_get(&msg->peer, |
934 | GNUNET_NO); | 933 | GNUNET_NO); |
935 | if (NULL != p) | 934 | if (NULL != p) |
936 | GCP_iterate_indirect_paths (p, | 935 | GCP_iterate_indirect_paths(p, |
937 | &path_info_iterator, | 936 | &path_info_iterator, |
938 | c->mq); | 937 | c->mq); |
939 | env = GNUNET_MQ_msg (resp, | 938 | env = GNUNET_MQ_msg(resp, |
940 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END); | 939 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH_END); |
941 | GNUNET_MQ_send (c->mq, | 940 | GNUNET_MQ_send(c->mq, |
942 | env); | 941 | env); |
943 | GNUNET_SERVICE_client_continue (c->client); | 942 | GNUNET_SERVICE_client_continue(c->client); |
944 | } | 943 | } |
945 | 944 | ||
946 | 945 | ||
@@ -953,9 +952,9 @@ handle_show_path (void *cls, | |||
953 | * @return #GNUNET_YES, to keep iterating. | 952 | * @return #GNUNET_YES, to keep iterating. |
954 | */ | 953 | */ |
955 | static int | 954 | static int |
956 | get_all_tunnels_iterator (void *cls, | 955 | get_all_tunnels_iterator(void *cls, |
957 | const struct GNUNET_PeerIdentity *peer, | 956 | const struct GNUNET_PeerIdentity *peer, |
958 | void *value) | 957 | void *value) |
959 | { | 958 | { |
960 | struct CadetClient *c = cls; | 959 | struct CadetClient *c = cls; |
961 | struct CadetPeer *p = value; | 960 | struct CadetPeer *p = value; |
@@ -963,19 +962,19 @@ get_all_tunnels_iterator (void *cls, | |||
963 | struct GNUNET_CADET_LocalInfoTunnel *msg; | 962 | struct GNUNET_CADET_LocalInfoTunnel *msg; |
964 | struct CadetTunnel *t; | 963 | struct CadetTunnel *t; |
965 | 964 | ||
966 | t = GCP_get_tunnel (p, | 965 | t = GCP_get_tunnel(p, |
967 | GNUNET_NO); | 966 | GNUNET_NO); |
968 | if (NULL == t) | 967 | if (NULL == t) |
969 | return GNUNET_YES; | 968 | return GNUNET_YES; |
970 | env = GNUNET_MQ_msg (msg, | 969 | env = GNUNET_MQ_msg(msg, |
971 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS); | 970 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS); |
972 | msg->destination = *peer; | 971 | msg->destination = *peer; |
973 | msg->channels = htonl (GCT_count_channels (t)); | 972 | msg->channels = htonl(GCT_count_channels(t)); |
974 | msg->connections = htonl (GCT_count_any_connections (t)); | 973 | msg->connections = htonl(GCT_count_any_connections(t)); |
975 | msg->cstate = htons (0); | 974 | msg->cstate = htons(0); |
976 | msg->estate = htons ((uint16_t) GCT_get_estate (t)); | 975 | msg->estate = htons((uint16_t)GCT_get_estate(t)); |
977 | GNUNET_MQ_send (c->mq, | 976 | GNUNET_MQ_send(c->mq, |
978 | env); | 977 | env); |
979 | return GNUNET_YES; | 978 | return GNUNET_YES; |
980 | } | 979 | } |
981 | 980 | ||
@@ -987,20 +986,20 @@ get_all_tunnels_iterator (void *cls, | |||
987 | * @param message The actual message. | 986 | * @param message The actual message. |
988 | */ | 987 | */ |
989 | static void | 988 | static void |
990 | handle_info_tunnels (void *cls, | 989 | handle_info_tunnels(void *cls, |
991 | const struct GNUNET_MessageHeader *message) | 990 | const struct GNUNET_MessageHeader *message) |
992 | { | 991 | { |
993 | struct CadetClient *c = cls; | 992 | struct CadetClient *c = cls; |
994 | struct GNUNET_MQ_Envelope *env; | 993 | struct GNUNET_MQ_Envelope *env; |
995 | struct GNUNET_MessageHeader *reply; | 994 | struct GNUNET_MessageHeader *reply; |
996 | 995 | ||
997 | GCP_iterate_all (&get_all_tunnels_iterator, | 996 | GCP_iterate_all(&get_all_tunnels_iterator, |
998 | c); | 997 | c); |
999 | env = GNUNET_MQ_msg (reply, | 998 | env = GNUNET_MQ_msg(reply, |
1000 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END); | 999 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END); |
1001 | GNUNET_MQ_send (c->mq, | 1000 | GNUNET_MQ_send(c->mq, |
1002 | env); | 1001 | env); |
1003 | GNUNET_SERVICE_client_continue (c->client); | 1002 | GNUNET_SERVICE_client_continue(c->client); |
1004 | } | 1003 | } |
1005 | 1004 | ||
1006 | 1005 | ||
@@ -1013,28 +1012,28 @@ handle_info_tunnels (void *cls, | |||
1013 | * @return @a c | 1012 | * @return @a c |
1014 | */ | 1013 | */ |
1015 | static void * | 1014 | static void * |
1016 | client_connect_cb (void *cls, | 1015 | client_connect_cb(void *cls, |
1017 | struct GNUNET_SERVICE_Client *client, | 1016 | struct GNUNET_SERVICE_Client *client, |
1018 | struct GNUNET_MQ_Handle *mq) | 1017 | struct GNUNET_MQ_Handle *mq) |
1019 | { | 1018 | { |
1020 | struct CadetClient *c; | 1019 | struct CadetClient *c; |
1021 | 1020 | ||
1022 | c = GNUNET_new (struct CadetClient); | 1021 | c = GNUNET_new(struct CadetClient); |
1023 | c->client = client; | 1022 | c->client = client; |
1024 | c->mq = mq; | 1023 | c->mq = mq; |
1025 | c->id = next_client_id++; /* overflow not important: just for debug */ | 1024 | c->id = next_client_id++; /* overflow not important: just for debug */ |
1026 | c->channels | 1025 | c->channels |
1027 | = GNUNET_CONTAINER_multihashmap32_create (32); | 1026 | = GNUNET_CONTAINER_multihashmap32_create(32); |
1028 | GNUNET_CONTAINER_DLL_insert (clients_head, | 1027 | GNUNET_CONTAINER_DLL_insert(clients_head, |
1029 | clients_tail, | 1028 | clients_tail, |
1030 | c); | 1029 | c); |
1031 | GNUNET_STATISTICS_update (stats, | 1030 | GNUNET_STATISTICS_update(stats, |
1032 | "# clients", | 1031 | "# clients", |
1033 | +1, | 1032 | +1, |
1034 | GNUNET_NO); | 1033 | GNUNET_NO); |
1035 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1034 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1036 | "%s connected\n", | 1035 | "%s connected\n", |
1037 | GSC_2s (c)); | 1036 | GSC_2s(c)); |
1038 | return c; | 1037 | return c; |
1039 | } | 1038 | } |
1040 | 1039 | ||
@@ -1047,22 +1046,22 @@ client_connect_cb (void *cls, | |||
1047 | * @param ch the channel object | 1046 | * @param ch the channel object |
1048 | */ | 1047 | */ |
1049 | void | 1048 | void |
1050 | GSC_handle_remote_channel_destroy (struct CadetClient *c, | 1049 | GSC_handle_remote_channel_destroy(struct CadetClient *c, |
1051 | struct GNUNET_CADET_ClientChannelNumber ccn, | 1050 | struct GNUNET_CADET_ClientChannelNumber ccn, |
1052 | struct CadetChannel *ch) | 1051 | struct CadetChannel *ch) |
1053 | { | 1052 | { |
1054 | struct GNUNET_MQ_Envelope *env; | 1053 | struct GNUNET_MQ_Envelope *env; |
1055 | struct GNUNET_CADET_LocalChannelDestroyMessage *tdm; | 1054 | struct GNUNET_CADET_LocalChannelDestroyMessage *tdm; |
1056 | 1055 | ||
1057 | env = GNUNET_MQ_msg (tdm, | 1056 | env = GNUNET_MQ_msg(tdm, |
1058 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY); | 1057 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY); |
1059 | tdm->ccn = ccn; | 1058 | tdm->ccn = ccn; |
1060 | GSC_send_to_client (c, | 1059 | GSC_send_to_client(c, |
1061 | env); | 1060 | env); |
1062 | GNUNET_assert (GNUNET_YES == | 1061 | GNUNET_assert(GNUNET_YES == |
1063 | GNUNET_CONTAINER_multihashmap32_remove (c->channels, | 1062 | GNUNET_CONTAINER_multihashmap32_remove(c->channels, |
1064 | ntohl (ccn.channel_of_client), | 1063 | ntohl(ccn.channel_of_client), |
1065 | ch)); | 1064 | ch)); |
1066 | } | 1065 | } |
1067 | 1066 | ||
1068 | 1067 | ||
@@ -1074,13 +1073,13 @@ GSC_handle_remote_channel_destroy (struct CadetClient *c, | |||
1074 | * @param ch the channel that was lost | 1073 | * @param ch the channel that was lost |
1075 | */ | 1074 | */ |
1076 | void | 1075 | void |
1077 | GSC_drop_loose_channel (const struct GNUNET_HashCode *h_port, | 1076 | GSC_drop_loose_channel(const struct GNUNET_HashCode *h_port, |
1078 | struct CadetChannel *ch) | 1077 | struct CadetChannel *ch) |
1079 | { | 1078 | { |
1080 | GNUNET_assert (GNUNET_YES == | 1079 | GNUNET_assert(GNUNET_YES == |
1081 | GNUNET_CONTAINER_multihashmap_remove (loose_channels, | 1080 | GNUNET_CONTAINER_multihashmap_remove(loose_channels, |
1082 | h_port, | 1081 | h_port, |
1083 | ch)); | 1082 | ch)); |
1084 | } | 1083 | } |
1085 | 1084 | ||
1086 | 1085 | ||
@@ -1093,26 +1092,26 @@ GSC_drop_loose_channel (const struct GNUNET_HashCode *h_port, | |||
1093 | * @return #GNUNET_OK, keep iterating. | 1092 | * @return #GNUNET_OK, keep iterating. |
1094 | */ | 1093 | */ |
1095 | static int | 1094 | static int |
1096 | channel_destroy_iterator (void *cls, | 1095 | channel_destroy_iterator(void *cls, |
1097 | uint32_t key, | 1096 | uint32_t key, |
1098 | void *value) | 1097 | void *value) |
1099 | { | 1098 | { |
1100 | struct CadetClient *c = cls; | 1099 | struct CadetClient *c = cls; |
1101 | struct GNUNET_CADET_ClientChannelNumber ccn; | 1100 | struct GNUNET_CADET_ClientChannelNumber ccn; |
1102 | struct CadetChannel *ch = value; | 1101 | struct CadetChannel *ch = value; |
1103 | 1102 | ||
1104 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1103 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1105 | "Destroying %s, due to %s disconnecting.\n", | 1104 | "Destroying %s, due to %s disconnecting.\n", |
1106 | GCCH_2s (ch), | 1105 | GCCH_2s(ch), |
1107 | GSC_2s (c)); | 1106 | GSC_2s(c)); |
1108 | ccn.channel_of_client = htonl (key); | 1107 | ccn.channel_of_client = htonl(key); |
1109 | GCCH_channel_local_destroy (ch, | 1108 | GCCH_channel_local_destroy(ch, |
1110 | c, | 1109 | c, |
1111 | ccn); | 1110 | ccn); |
1112 | GNUNET_assert (GNUNET_YES == | 1111 | GNUNET_assert(GNUNET_YES == |
1113 | GNUNET_CONTAINER_multihashmap32_remove (c->channels, | 1112 | GNUNET_CONTAINER_multihashmap32_remove(c->channels, |
1114 | key, | 1113 | key, |
1115 | ch)); | 1114 | ch)); |
1116 | return GNUNET_OK; | 1115 | return GNUNET_OK; |
1117 | } | 1116 | } |
1118 | 1117 | ||
@@ -1126,27 +1125,27 @@ channel_destroy_iterator (void *cls, | |||
1126 | * @return #GNUNET_OK, keep iterating. | 1125 | * @return #GNUNET_OK, keep iterating. |
1127 | */ | 1126 | */ |
1128 | static int | 1127 | static int |
1129 | client_release_ports (void *cls, | 1128 | client_release_ports(void *cls, |
1130 | const struct GNUNET_HashCode *port, | 1129 | const struct GNUNET_HashCode *port, |
1131 | void *value) | 1130 | void *value) |
1132 | { | 1131 | { |
1133 | struct CadetClient *c = cls; | 1132 | struct CadetClient *c = cls; |
1134 | struct OpenPort *op = value; | 1133 | struct OpenPort *op = value; |
1135 | 1134 | ||
1136 | GNUNET_assert (c == op->c); | 1135 | GNUNET_assert(c == op->c); |
1137 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1136 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1138 | "Closing port %s due to %s disconnect.\n", | 1137 | "Closing port %s due to %s disconnect.\n", |
1139 | GNUNET_h2s (port), | 1138 | GNUNET_h2s(port), |
1140 | GSC_2s (c)); | 1139 | GSC_2s(c)); |
1141 | GNUNET_assert (GNUNET_YES == | 1140 | GNUNET_assert(GNUNET_YES == |
1142 | GNUNET_CONTAINER_multihashmap_remove (open_ports, | 1141 | GNUNET_CONTAINER_multihashmap_remove(open_ports, |
1143 | &op->h_port, | 1142 | &op->h_port, |
1144 | op)); | 1143 | op)); |
1145 | GNUNET_assert (GNUNET_YES == | 1144 | GNUNET_assert(GNUNET_YES == |
1146 | GNUNET_CONTAINER_multihashmap_remove (c->ports, | 1145 | GNUNET_CONTAINER_multihashmap_remove(c->ports, |
1147 | port, | 1146 | port, |
1148 | op)); | 1147 | op)); |
1149 | GNUNET_free (op); | 1148 | GNUNET_free(op); |
1150 | return GNUNET_OK; | 1149 | return GNUNET_OK; |
1151 | } | 1150 | } |
1152 | 1151 | ||
@@ -1159,42 +1158,42 @@ client_release_ports (void *cls, | |||
1159 | * @param internal_cls should be equal to @a c | 1158 | * @param internal_cls should be equal to @a c |
1160 | */ | 1159 | */ |
1161 | static void | 1160 | static void |
1162 | client_disconnect_cb (void *cls, | 1161 | client_disconnect_cb(void *cls, |
1163 | struct GNUNET_SERVICE_Client *client, | 1162 | struct GNUNET_SERVICE_Client *client, |
1164 | void *internal_cls) | 1163 | void *internal_cls) |
1165 | { | 1164 | { |
1166 | struct CadetClient *c = internal_cls; | 1165 | struct CadetClient *c = internal_cls; |
1167 | 1166 | ||
1168 | GNUNET_assert (c->client == client); | 1167 | GNUNET_assert(c->client == client); |
1169 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1168 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1170 | "%s is disconnecting.\n", | 1169 | "%s is disconnecting.\n", |
1171 | GSC_2s (c)); | 1170 | GSC_2s(c)); |
1172 | if (NULL != c->channels) | 1171 | if (NULL != c->channels) |
1173 | { | 1172 | { |
1174 | GNUNET_CONTAINER_multihashmap32_iterate (c->channels, | 1173 | GNUNET_CONTAINER_multihashmap32_iterate(c->channels, |
1175 | &channel_destroy_iterator, | 1174 | &channel_destroy_iterator, |
1176 | c); | 1175 | c); |
1177 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (c->channels)); | 1176 | GNUNET_assert(0 == GNUNET_CONTAINER_multihashmap32_size(c->channels)); |
1178 | GNUNET_CONTAINER_multihashmap32_destroy (c->channels); | 1177 | GNUNET_CONTAINER_multihashmap32_destroy(c->channels); |
1179 | } | 1178 | } |
1180 | if (NULL != c->ports) | 1179 | if (NULL != c->ports) |
1181 | { | 1180 | { |
1182 | GNUNET_CONTAINER_multihashmap_iterate (c->ports, | 1181 | GNUNET_CONTAINER_multihashmap_iterate(c->ports, |
1183 | &client_release_ports, | 1182 | &client_release_ports, |
1184 | c); | 1183 | c); |
1185 | GNUNET_CONTAINER_multihashmap_destroy (c->ports); | 1184 | GNUNET_CONTAINER_multihashmap_destroy(c->ports); |
1186 | } | 1185 | } |
1187 | GNUNET_CONTAINER_DLL_remove (clients_head, | 1186 | GNUNET_CONTAINER_DLL_remove(clients_head, |
1188 | clients_tail, | 1187 | clients_tail, |
1189 | c); | 1188 | c); |
1190 | GNUNET_STATISTICS_update (stats, | 1189 | GNUNET_STATISTICS_update(stats, |
1191 | "# clients", | 1190 | "# clients", |
1192 | -1, | 1191 | -1, |
1193 | GNUNET_NO); | 1192 | GNUNET_NO); |
1194 | GNUNET_free (c); | 1193 | GNUNET_free(c); |
1195 | if ( (NULL == clients_head) && | 1194 | if ((NULL == clients_head) && |
1196 | (GNUNET_YES == shutting_down) ) | 1195 | (GNUNET_YES == shutting_down)) |
1197 | shutdown_rest (); | 1196 | shutdown_rest(); |
1198 | } | 1197 | } |
1199 | 1198 | ||
1200 | 1199 | ||
@@ -1206,93 +1205,92 @@ client_disconnect_cb (void *cls, | |||
1206 | * @param c configuration to use | 1205 | * @param c configuration to use |
1207 | */ | 1206 | */ |
1208 | static void | 1207 | static void |
1209 | run (void *cls, | 1208 | run(void *cls, |
1210 | const struct GNUNET_CONFIGURATION_Handle *c, | 1209 | const struct GNUNET_CONFIGURATION_Handle *c, |
1211 | struct GNUNET_SERVICE_Handle *service) | 1210 | struct GNUNET_SERVICE_Handle *service) |
1212 | { | 1211 | { |
1213 | cfg = c; | 1212 | cfg = c; |
1214 | if (GNUNET_OK != | 1213 | if (GNUNET_OK != |
1215 | GNUNET_CONFIGURATION_get_value_number (c, | 1214 | GNUNET_CONFIGURATION_get_value_number(c, |
1216 | "CADET", | 1215 | "CADET", |
1217 | "RATCHET_MESSAGES", | 1216 | "RATCHET_MESSAGES", |
1218 | &ratchet_messages)) | 1217 | &ratchet_messages)) |
1219 | { | 1218 | { |
1220 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, | 1219 | GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_WARNING, |
1221 | "CADET", | 1220 | "CADET", |
1222 | "RATCHET_MESSAGES", | 1221 | "RATCHET_MESSAGES", |
1223 | "needs to be a number"); | 1222 | "needs to be a number"); |
1224 | ratchet_messages = 64; | 1223 | ratchet_messages = 64; |
1225 | } | 1224 | } |
1226 | if (GNUNET_OK != | 1225 | if (GNUNET_OK != |
1227 | GNUNET_CONFIGURATION_get_value_time (c, | 1226 | GNUNET_CONFIGURATION_get_value_time(c, |
1228 | "CADET", | 1227 | "CADET", |
1229 | "RATCHET_TIME", | 1228 | "RATCHET_TIME", |
1230 | &ratchet_time)) | 1229 | &ratchet_time)) |
1231 | { | 1230 | { |
1232 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, | 1231 | GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_WARNING, |
1233 | "CADET", | 1232 | "CADET", |
1234 | "RATCHET_TIME", | 1233 | "RATCHET_TIME", |
1235 | "need delay value"); | 1234 | "need delay value"); |
1236 | ratchet_time = GNUNET_TIME_UNIT_HOURS; | 1235 | ratchet_time = GNUNET_TIME_UNIT_HOURS; |
1237 | } | 1236 | } |
1238 | if (GNUNET_OK != | 1237 | if (GNUNET_OK != |
1239 | GNUNET_CONFIGURATION_get_value_time (c, | 1238 | GNUNET_CONFIGURATION_get_value_time(c, |
1240 | "CADET", | 1239 | "CADET", |
1241 | "REFRESH_CONNECTION_TIME", | 1240 | "REFRESH_CONNECTION_TIME", |
1242 | &keepalive_period)) | 1241 | &keepalive_period)) |
1243 | { | 1242 | { |
1244 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, | 1243 | GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_WARNING, |
1245 | "CADET", | 1244 | "CADET", |
1246 | "REFRESH_CONNECTION_TIME", | 1245 | "REFRESH_CONNECTION_TIME", |
1247 | "need delay value"); | 1246 | "need delay value"); |
1248 | keepalive_period = GNUNET_TIME_UNIT_MINUTES; | 1247 | keepalive_period = GNUNET_TIME_UNIT_MINUTES; |
1249 | } | 1248 | } |
1250 | if (GNUNET_OK != | 1249 | if (GNUNET_OK != |
1251 | GNUNET_CONFIGURATION_get_value_number (c, | 1250 | GNUNET_CONFIGURATION_get_value_number(c, |
1252 | "CADET", | 1251 | "CADET", |
1253 | "DROP_PERCENT", | 1252 | "DROP_PERCENT", |
1254 | &drop_percent)) | 1253 | &drop_percent)) |
1255 | { | 1254 | { |
1256 | drop_percent = 0; | 1255 | drop_percent = 0; |
1257 | } | 1256 | } |
1258 | else | 1257 | else |
1259 | { | 1258 | { |
1260 | LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n"); | 1259 | LOG(GNUNET_ERROR_TYPE_WARNING, "**************************************\n"); |
1261 | LOG (GNUNET_ERROR_TYPE_WARNING, "Cadet is running with DROP enabled.\n"); | 1260 | LOG(GNUNET_ERROR_TYPE_WARNING, "Cadet is running with DROP enabled.\n"); |
1262 | LOG (GNUNET_ERROR_TYPE_WARNING, "This is NOT a good idea!\n"); | 1261 | LOG(GNUNET_ERROR_TYPE_WARNING, "This is NOT a good idea!\n"); |
1263 | LOG (GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n"); | 1262 | LOG(GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n"); |
1264 | LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n"); | 1263 | LOG(GNUNET_ERROR_TYPE_WARNING, "**************************************\n"); |
1265 | } | 1264 | } |
1266 | my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (c); | 1265 | my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration(c); |
1267 | if (NULL == my_private_key) | 1266 | if (NULL == my_private_key) |
1268 | { | 1267 | { |
1269 | GNUNET_break (0); | 1268 | GNUNET_break(0); |
1270 | GNUNET_SCHEDULER_shutdown (); | 1269 | GNUNET_SCHEDULER_shutdown(); |
1271 | return; | 1270 | return; |
1272 | } | 1271 | } |
1273 | GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, | 1272 | GNUNET_CRYPTO_eddsa_key_get_public(my_private_key, |
1274 | &my_full_id.public_key); | 1273 | &my_full_id.public_key); |
1275 | stats = GNUNET_STATISTICS_create ("cadet", | 1274 | stats = GNUNET_STATISTICS_create("cadet", |
1276 | c); | 1275 | c); |
1277 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1276 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, |
1278 | NULL); | 1277 | NULL); |
1279 | ats_ch = GNUNET_ATS_connectivity_init (c); | 1278 | ats_ch = GNUNET_ATS_connectivity_init(c); |
1280 | /* FIXME: optimize code to allow GNUNET_YES here! */ | 1279 | /* FIXME: optimize code to allow GNUNET_YES here! */ |
1281 | open_ports = GNUNET_CONTAINER_multihashmap_create (16, | 1280 | open_ports = GNUNET_CONTAINER_multihashmap_create(16, |
1282 | GNUNET_NO); | 1281 | GNUNET_NO); |
1283 | loose_channels = GNUNET_CONTAINER_multihashmap_create (16, | 1282 | loose_channels = GNUNET_CONTAINER_multihashmap_create(16, |
1284 | GNUNET_NO); | 1283 | GNUNET_NO); |
1285 | peers = GNUNET_CONTAINER_multipeermap_create (16, | 1284 | peers = GNUNET_CONTAINER_multipeermap_create(16, |
1286 | GNUNET_YES); | 1285 | GNUNET_YES); |
1287 | connections = GNUNET_CONTAINER_multishortmap_create (256, | 1286 | connections = GNUNET_CONTAINER_multishortmap_create(256, |
1288 | GNUNET_YES); | 1287 | GNUNET_YES); |
1289 | GCH_init (c); | 1288 | GCH_init(c); |
1290 | GCD_init (c); | 1289 | GCD_init(c); |
1291 | GCO_init (c); | 1290 | GCO_init(c); |
1292 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1291 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1293 | "CADET started for peer %s\n", | 1292 | "CADET started for peer %s\n", |
1294 | GNUNET_i2s (&my_full_id)); | 1293 | GNUNET_i2s(&my_full_id)); |
1295 | |||
1296 | } | 1294 | } |
1297 | 1295 | ||
1298 | 1296 | ||
@@ -1300,48 +1298,48 @@ run (void *cls, | |||
1300 | * Define "main" method using service macro. | 1298 | * Define "main" method using service macro. |
1301 | */ | 1299 | */ |
1302 | GNUNET_SERVICE_MAIN | 1300 | GNUNET_SERVICE_MAIN |
1303 | ("cadet", | 1301 | ("cadet", |
1304 | GNUNET_SERVICE_OPTION_NONE, | 1302 | GNUNET_SERVICE_OPTION_NONE, |
1305 | &run, | 1303 | &run, |
1306 | &client_connect_cb, | 1304 | &client_connect_cb, |
1307 | &client_disconnect_cb, | 1305 | &client_disconnect_cb, |
1308 | NULL, | 1306 | NULL, |
1309 | GNUNET_MQ_hd_fixed_size (port_open, | 1307 | GNUNET_MQ_hd_fixed_size(port_open, |
1310 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN, | 1308 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN, |
1311 | struct GNUNET_CADET_PortMessage, | 1309 | struct GNUNET_CADET_PortMessage, |
1312 | NULL), | 1310 | NULL), |
1313 | GNUNET_MQ_hd_fixed_size (port_close, | 1311 | GNUNET_MQ_hd_fixed_size(port_close, |
1314 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE, | 1312 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE, |
1315 | struct GNUNET_CADET_PortMessage, | 1313 | struct GNUNET_CADET_PortMessage, |
1316 | NULL), | 1314 | NULL), |
1317 | GNUNET_MQ_hd_fixed_size (channel_create, | 1315 | GNUNET_MQ_hd_fixed_size(channel_create, |
1318 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, | 1316 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, |
1319 | struct GNUNET_CADET_LocalChannelCreateMessage, | 1317 | struct GNUNET_CADET_LocalChannelCreateMessage, |
1320 | NULL), | 1318 | NULL), |
1321 | GNUNET_MQ_hd_fixed_size (channel_destroy, | 1319 | GNUNET_MQ_hd_fixed_size(channel_destroy, |
1322 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, | 1320 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, |
1323 | struct GNUNET_CADET_LocalChannelDestroyMessage, | 1321 | struct GNUNET_CADET_LocalChannelDestroyMessage, |
1324 | NULL), | 1322 | NULL), |
1325 | GNUNET_MQ_hd_var_size (local_data, | 1323 | GNUNET_MQ_hd_var_size(local_data, |
1326 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, | 1324 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, |
1327 | struct GNUNET_CADET_LocalData, | 1325 | struct GNUNET_CADET_LocalData, |
1328 | NULL), | 1326 | NULL), |
1329 | GNUNET_MQ_hd_fixed_size (local_ack, | 1327 | GNUNET_MQ_hd_fixed_size(local_ack, |
1330 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, | 1328 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, |
1331 | struct GNUNET_CADET_LocalAck, | 1329 | struct GNUNET_CADET_LocalAck, |
1332 | NULL), | 1330 | NULL), |
1333 | GNUNET_MQ_hd_fixed_size (get_peers, | 1331 | GNUNET_MQ_hd_fixed_size(get_peers, |
1334 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS, | 1332 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PEERS, |
1335 | struct GNUNET_MessageHeader, | 1333 | struct GNUNET_MessageHeader, |
1336 | NULL), | 1334 | NULL), |
1337 | GNUNET_MQ_hd_fixed_size (show_path, | 1335 | GNUNET_MQ_hd_fixed_size(show_path, |
1338 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH, | 1336 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH, |
1339 | struct GNUNET_CADET_RequestPathInfoMessage, | 1337 | struct GNUNET_CADET_RequestPathInfoMessage, |
1340 | NULL), | 1338 | NULL), |
1341 | GNUNET_MQ_hd_fixed_size (info_tunnels, | 1339 | GNUNET_MQ_hd_fixed_size(info_tunnels, |
1342 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, | 1340 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, |
1343 | struct GNUNET_MessageHeader, | 1341 | struct GNUNET_MessageHeader, |
1344 | NULL), | 1342 | NULL), |
1345 | GNUNET_MQ_handler_end ()); | 1343 | GNUNET_MQ_handler_end()); |
1346 | 1344 | ||
1347 | /* end of gnunet-service-cadet-new.c */ | 1345 | /* end of gnunet-service-cadet-new.c */ |