diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-05 12:40:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-05 12:40:38 +0000 |
commit | 3ff6963c5c3d1c5eba14417b42cd0ed8448aa2de (patch) | |
tree | 3db84c8f4ecacf7264ac91a42bca371033ca8ae3 /src/transport | |
parent | 18855c3cfcf73985f9caeff78050f462a9c03d45 (diff) | |
download | gnunet-3ff6963c5c3d1c5eba14417b42cd0ed8448aa2de.tar.gz gnunet-3ff6963c5c3d1c5eba14417b42cd0ed8448aa2de.zip |
-make cryogenic code Linux-only
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_udp_broadcasting.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index 153259382..a289118f1 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) | 42 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
43 | 43 | ||
44 | /* *********** Cryogenic ********** */ | 44 | /* *********** Cryogenic ********** */ |
45 | 45 | #if LINUX | |
46 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | 48 | ||
@@ -57,7 +57,8 @@ struct pm_times { | |||
57 | unsigned long delay_msecs; | 57 | unsigned long delay_msecs; |
58 | unsigned long timeout_msecs; | 58 | unsigned long timeout_msecs; |
59 | }; | 59 | }; |
60 | /************************************/ | 60 | #endif |
61 | /************************************/ | ||
61 | 62 | ||
62 | 63 | ||
63 | struct UDP_Beacon_Message | 64 | struct UDP_Beacon_Message |
@@ -90,13 +91,18 @@ struct BroadcastAddress | |||
90 | void *addr; | 91 | void *addr; |
91 | 92 | ||
92 | socklen_t addrlen; | 93 | socklen_t addrlen; |
93 | 94 | ||
94 | /* | 95 | #if LINUX |
95 | * Cryogenic fields | 96 | /** |
97 | * Cryogenic handle. | ||
96 | */ | 98 | */ |
97 | struct GNUNET_DISK_FileHandle *cryogenic_fd; | 99 | struct GNUNET_DISK_FileHandle *cryogenic_fd; |
98 | 100 | ||
101 | /** | ||
102 | * Time out for cryogenic. | ||
103 | */ | ||
99 | struct pm_times cryogenic_times; | 104 | struct pm_times cryogenic_times; |
105 | #endif | ||
100 | }; | 106 | }; |
101 | 107 | ||
102 | 108 | ||
@@ -340,7 +346,8 @@ udp_ipv4_broadcast_send (void *cls, | |||
340 | GNUNET_a2s (baddr->addr, baddr->addrlen)); | 346 | GNUNET_a2s (baddr->addr, baddr->addrlen)); |
341 | } | 347 | } |
342 | } | 348 | } |
343 | 349 | ||
350 | #if LINUX | ||
344 | /* | 351 | /* |
345 | * Cryogenic | 352 | * Cryogenic |
346 | */ | 353 | */ |
@@ -348,7 +355,7 @@ udp_ipv4_broadcast_send (void *cls, | |||
348 | { | 355 | { |
349 | baddr->cryogenic_times.delay_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*0.5; | 356 | baddr->cryogenic_times.delay_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*0.5; |
350 | baddr->cryogenic_times.timeout_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*1.5; | 357 | baddr->cryogenic_times.timeout_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*1.5; |
351 | 358 | ||
352 | if (ioctl(baddr->cryogenic_fd->fd, | 359 | if (ioctl(baddr->cryogenic_fd->fd, |
353 | PM_SET_DELAY_AND_TIMEOUT, | 360 | PM_SET_DELAY_AND_TIMEOUT, |
354 | &baddr->cryogenic_times) < 0) | 361 | &baddr->cryogenic_times) < 0) |
@@ -363,9 +370,10 @@ udp_ipv4_broadcast_send (void *cls, | |||
363 | baddr->cryogenic_fd, | 370 | baddr->cryogenic_fd, |
364 | &udp_ipv4_broadcast_send, | 371 | &udp_ipv4_broadcast_send, |
365 | baddr); | 372 | baddr); |
366 | 373 | ||
367 | } | 374 | } |
368 | else | 375 | else |
376 | #endif | ||
369 | baddr->broadcast_task = | 377 | baddr->broadcast_task = |
370 | GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval, | 378 | GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval, |
371 | &udp_ipv4_broadcast_send, baddr); | 379 | &udp_ipv4_broadcast_send, baddr); |
@@ -423,6 +431,7 @@ udp_ipv6_broadcast_send (void *cls, | |||
423 | GNUNET_a2s ((const struct sockaddr *) &plugin->ipv6_multicast_address, | 431 | GNUNET_a2s ((const struct sockaddr *) &plugin->ipv6_multicast_address, |
424 | sizeof (struct sockaddr_in6))); | 432 | sizeof (struct sockaddr_in6))); |
425 | } | 433 | } |
434 | #if LINUX | ||
426 | /* | 435 | /* |
427 | * Cryogenic | 436 | * Cryogenic |
428 | */ | 437 | */ |
@@ -430,7 +439,7 @@ udp_ipv6_broadcast_send (void *cls, | |||
430 | { | 439 | { |
431 | baddr->cryogenic_times.delay_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*0.5; | 440 | baddr->cryogenic_times.delay_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*0.5; |
432 | baddr->cryogenic_times.timeout_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*1.5; | 441 | baddr->cryogenic_times.timeout_msecs = (plugin->broadcast_interval.rel_value_us/1000.0)*1.5; |
433 | 442 | ||
434 | if (ioctl(baddr->cryogenic_fd->fd, | 443 | if (ioctl(baddr->cryogenic_fd->fd, |
435 | PM_SET_DELAY_AND_TIMEOUT, | 444 | PM_SET_DELAY_AND_TIMEOUT, |
436 | &baddr->cryogenic_times) < 0) | 445 | &baddr->cryogenic_times) < 0) |
@@ -447,6 +456,7 @@ udp_ipv6_broadcast_send (void *cls, | |||
447 | baddr); | 456 | baddr); |
448 | } | 457 | } |
449 | else | 458 | else |
459 | #endif | ||
450 | baddr->broadcast_task = | 460 | baddr->broadcast_task = |
451 | GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval, | 461 | GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval, |
452 | &udp_ipv6_broadcast_send, baddr); | 462 | &udp_ipv6_broadcast_send, baddr); |
@@ -498,11 +508,12 @@ iface_proc (void *cls, | |||
498 | (NULL != plugin->sockv4) && | 508 | (NULL != plugin->sockv4) && |
499 | (addrlen == sizeof (struct sockaddr_in)) ) | 509 | (addrlen == sizeof (struct sockaddr_in)) ) |
500 | { | 510 | { |
501 | 511 | #if LINUX | |
502 | /* | 512 | /* |
503 | * setup Cryogenic FD for ipv4 broadcasting | 513 | * setup Cryogenic FD for ipv4 broadcasting |
504 | */ | 514 | */ |
505 | char *filename; | 515 | char *filename; |
516 | |||
506 | GNUNET_asprintf (&filename, | 517 | GNUNET_asprintf (&filename, |
507 | "/dev/power/%s", | 518 | "/dev/power/%s", |
508 | name); | 519 | name); |
@@ -511,7 +522,7 @@ iface_proc (void *cls, | |||
511 | GNUNET_DISK_OPEN_WRITE, | 522 | GNUNET_DISK_OPEN_WRITE, |
512 | GNUNET_DISK_PERM_NONE); | 523 | GNUNET_DISK_PERM_NONE); |
513 | GNUNET_free (filename); | 524 | GNUNET_free (filename); |
514 | 525 | #endif | |
515 | ba->broadcast_task = | 526 | ba->broadcast_task = |
516 | GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, ba); | 527 | GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, ba); |
517 | } | 528 | } |
@@ -549,13 +560,12 @@ iface_proc (void *cls, | |||
549 | } | 560 | } |
550 | else | 561 | else |
551 | { | 562 | { |
552 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 563 | #if LINUX |
553 | "IPv6 multicasting running\n"); | ||
554 | |||
555 | /* | 564 | /* |
556 | * setup Cryogenic FD for ipv6 broadcasting | 565 | * setup Cryogenic FD for ipv6 broadcasting |
557 | */ | 566 | */ |
558 | char *filename; | 567 | char *filename; |
568 | |||
559 | GNUNET_asprintf (&filename, | 569 | GNUNET_asprintf (&filename, |
560 | "/dev/power/%s", | 570 | "/dev/power/%s", |
561 | name); | 571 | name); |
@@ -564,8 +574,7 @@ iface_proc (void *cls, | |||
564 | GNUNET_DISK_OPEN_WRITE, | 574 | GNUNET_DISK_OPEN_WRITE, |
565 | GNUNET_DISK_PERM_NONE); | 575 | GNUNET_DISK_PERM_NONE); |
566 | GNUNET_free (filename); | 576 | GNUNET_free (filename); |
567 | 577 | #endif | |
568 | |||
569 | ba->broadcast_task = | 578 | ba->broadcast_task = |
570 | GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, ba); | 579 | GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, ba); |
571 | } | 580 | } |
@@ -664,11 +673,9 @@ stop_broadcast (struct Plugin *plugin) | |||
664 | } | 673 | } |
665 | } | 674 | } |
666 | 675 | ||
667 | /* | 676 | #if LINUX |
668 | * Close Cryogenic FD | ||
669 | */ | ||
670 | GNUNET_DISK_file_close(p->cryogenic_fd); | 677 | GNUNET_DISK_file_close(p->cryogenic_fd); |
671 | 678 | #endif | |
672 | GNUNET_CONTAINER_DLL_remove (plugin->broadcast_head, | 679 | GNUNET_CONTAINER_DLL_remove (plugin->broadcast_head, |
673 | plugin->broadcast_tail, p); | 680 | plugin->broadcast_tail, p); |
674 | GNUNET_free (p->addr); | 681 | GNUNET_free (p->addr); |