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