diff options
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-nat-server.c | 4 | ||||
-rw-r--r-- | src/nat/nat.c | 24 | ||||
-rw-r--r-- | src/nat/nat_auto.c | 75 | ||||
-rw-r--r-- | src/nat/nat_mini.c | 16 | ||||
-rw-r--r-- | src/nat/nat_test.c | 34 | ||||
-rw-r--r-- | src/nat/test_nat.c | 3 |
6 files changed, 78 insertions, 78 deletions
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 0069303ca..db51ef89a 100644 --- a/src/nat/gnunet-nat-server.c +++ b/src/nat/gnunet-nat-server.c | |||
@@ -294,8 +294,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
294 | GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen, | 294 | GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen, |
295 | GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); | 295 | GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); |
296 | GNUNET_SERVER_add_handlers (server, handlers); | 296 | GNUNET_SERVER_add_handlers (server, handlers); |
297 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 297 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
298 | NULL); | 298 | NULL); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
diff --git a/src/nat/nat.c b/src/nat/nat.c index 1c60e4e0d..042a0f686 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -603,7 +603,8 @@ add_to_address_list (struct GNUNET_NAT_Handle *h, | |||
603 | */ | 603 | */ |
604 | static void | 604 | static void |
605 | add_ip_to_address_list (struct GNUNET_NAT_Handle *h, | 605 | add_ip_to_address_list (struct GNUNET_NAT_Handle *h, |
606 | enum LocalAddressSource src, const void *addr, | 606 | enum LocalAddressSource src, |
607 | const void *addr, | ||
607 | socklen_t addrlen) | 608 | socklen_t addrlen) |
608 | { | 609 | { |
609 | struct sockaddr_in s4; | 610 | struct sockaddr_in s4; |
@@ -913,10 +914,12 @@ process_interfaces (void *cls, | |||
913 | GNUNET_break (0); | 914 | GNUNET_break (0); |
914 | return GNUNET_OK; | 915 | return GNUNET_OK; |
915 | } | 916 | } |
916 | if ((h->internal_address == NULL) && (h->server_proc == NULL) && | 917 | if ( (h->internal_address == NULL) && |
917 | (h->server_read_task == NULL) && | 918 | (h->server_proc == NULL) && |
918 | (GNUNET_YES == isDefault) && ((addr->sa_family == AF_INET) || | 919 | (h->server_read_task == NULL) && |
919 | (addr->sa_family == AF_INET6))) | 920 | (GNUNET_YES == isDefault) && |
921 | ( (addr->sa_family == AF_INET) || | ||
922 | (addr->sa_family == AF_INET6) ) ) | ||
920 | { | 923 | { |
921 | /* no internal address configured, but we found a "default" | 924 | /* no internal address configured, but we found a "default" |
922 | * interface, try using that as our 'internal' address */ | 925 | * interface, try using that as our 'internal' address */ |
@@ -938,12 +941,8 @@ static void | |||
938 | restart_nat_server (void *cls) | 941 | restart_nat_server (void *cls) |
939 | { | 942 | { |
940 | struct GNUNET_NAT_Handle *h = cls; | 943 | struct GNUNET_NAT_Handle *h = cls; |
941 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
942 | 944 | ||
943 | h->server_read_task = NULL; | 945 | h->server_read_task = NULL; |
944 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
945 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
946 | return; | ||
947 | start_gnunet_nat_server (h); | 946 | start_gnunet_nat_server (h); |
948 | } | 947 | } |
949 | 948 | ||
@@ -965,12 +964,8 @@ nat_server_read (void *cls) | |||
965 | int port; | 964 | int port; |
966 | const char *port_start; | 965 | const char *port_start; |
967 | struct sockaddr_in sin_addr; | 966 | struct sockaddr_in sin_addr; |
968 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
969 | 967 | ||
970 | h->server_read_task = NULL; | 968 | h->server_read_task = NULL; |
971 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
972 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
973 | return; | ||
974 | memset (mybuf, 0, sizeof (mybuf)); | 969 | memset (mybuf, 0, sizeof (mybuf)); |
975 | bytes = | 970 | bytes = |
976 | GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); | 971 | GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); |
@@ -1036,7 +1031,8 @@ nat_server_read (void *cls) | |||
1036 | sizeof (sin_addr)); | 1031 | sizeof (sin_addr)); |
1037 | h->server_read_task = | 1032 | h->server_read_task = |
1038 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1033 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1039 | h->server_stdout_handle, &nat_server_read, | 1034 | h->server_stdout_handle, |
1035 | &nat_server_read, | ||
1040 | h); | 1036 | h); |
1041 | } | 1037 | } |
1042 | 1038 | ||
diff --git a/src/nat/nat_auto.c b/src/nat/nat_auto.c index 82e067f73..4611edc62 100644 --- a/src/nat/nat_auto.c +++ b/src/nat/nat_auto.c | |||
@@ -273,7 +273,9 @@ do_udp_read (void *cls) | |||
273 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 273 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
274 | lsock4))) | 274 | lsock4))) |
275 | { | 275 | { |
276 | rlen = GNUNET_NETWORK_socket_recv (lsock4, reply_buf, sizeof (reply_buf)); | 276 | rlen = GNUNET_NETWORK_socket_recv (lsock4, |
277 | reply_buf, | ||
278 | sizeof (reply_buf)); | ||
277 | 279 | ||
278 | //Lets handle the packet | 280 | //Lets handle the packet |
279 | memset(&answer, 0, sizeof(struct sockaddr_in)); | 281 | memset(&answer, 0, sizeof(struct sockaddr_in)); |
@@ -288,7 +290,8 @@ do_udp_read (void *cls) | |||
288 | } | 290 | } |
289 | else | 291 | else |
290 | { | 292 | { |
291 | if (GNUNET_OK == GNUNET_NAT_stun_handle_packet (reply_buf, rlen, &answer)) | 293 | if (GNUNET_OK == |
294 | GNUNET_NAT_stun_handle_packet (reply_buf, rlen, &answer)) | ||
292 | { | 295 | { |
293 | //Process the answer | 296 | //Process the answer |
294 | process_stun_reply (&answer, ah); | 297 | process_stun_reply (&answer, ah); |
@@ -310,9 +313,6 @@ do_udp_read (void *cls) | |||
310 | 313 | ||
311 | next_phase (ah); | 314 | next_phase (ah); |
312 | } | 315 | } |
313 | |||
314 | |||
315 | |||
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
@@ -352,10 +352,9 @@ bind_v4 () | |||
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | 355 | static void | |
356 | 356 | request_callback (void *cls, | |
357 | static void request_callback (void *cls, | 357 | enum GNUNET_NAT_StatusCode result) |
358 | enum GNUNET_NAT_StatusCode result) | ||
359 | { | 358 | { |
360 | // struct GNUNET_NAT_AutoHandle *ah = cls; | 359 | // struct GNUNET_NAT_AutoHandle *ah = cls; |
361 | 360 | ||
@@ -363,10 +362,7 @@ static void request_callback (void *cls, | |||
363 | stop_stun (); | 362 | stop_stun (); |
364 | 363 | ||
365 | // next_phase (ah); FIXME this always will be NULL, as called in test_stun() | 364 | // next_phase (ah); FIXME this always will be NULL, as called in test_stun() |
366 | }; | 365 | } |
367 | |||
368 | |||
369 | |||
370 | 366 | ||
371 | 367 | ||
372 | /** | 368 | /** |
@@ -518,17 +514,20 @@ test_stun (struct GNUNET_NAT_AutoHandle *ah) | |||
518 | { | 514 | { |
519 | //Lets call our function now when it accepts | 515 | //Lets call our function now when it accepts |
520 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, | 516 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, |
521 | lsock4, &do_udp_read, ah); | 517 | lsock4, |
522 | 518 | &do_udp_read, | |
519 | ah); | ||
523 | } | 520 | } |
524 | 521 | ||
525 | 522 | ||
526 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
527 | "STUN service listens on port %u\n", | 524 | "STUN service listens on port %u\n", |
528 | port); | 525 | port); |
529 | if (GNUNET_NO == GNUNET_NAT_stun_make_request (stun_server, stun_port, | 526 | if (GNUNET_NO == |
530 | lsock4, &request_callback, | 527 | GNUNET_NAT_stun_make_request (stun_server, stun_port, |
531 | NULL)) | 528 | lsock4, |
529 | &request_callback, | ||
530 | NULL)) | ||
532 | { | 531 | { |
533 | /*An error happened*/ | 532 | /*An error happened*/ |
534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STUN error, stopping\n"); | 533 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STUN error, stopping\n"); |
@@ -538,7 +537,6 @@ test_stun (struct GNUNET_NAT_AutoHandle *ah) | |||
538 | } | 537 | } |
539 | 538 | ||
540 | 539 | ||
541 | |||
542 | /** | 540 | /** |
543 | * Process list of local IP addresses. Find and set the | 541 | * Process list of local IP addresses. Find and set the |
544 | * one of the default interface. | 542 | * one of the default interface. |
@@ -550,16 +548,16 @@ test_stun (struct GNUNET_NAT_AutoHandle *ah) | |||
550 | * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) | 548 | * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) |
551 | * @param netmask the network mask (can be NULL for unknown or unassigned)) | 549 | * @param netmask the network mask (can be NULL for unknown or unassigned)) |
552 | * @param addrlen length of the @a addr and @a broadcast_addr | 550 | * @param addrlen length of the @a addr and @a broadcast_addr |
553 | * @return GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort | 551 | * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort |
554 | */ | 552 | */ |
555 | static int | 553 | static int |
556 | process_if (void *cls, | 554 | process_if (void *cls, |
557 | const char *name, | 555 | const char *name, |
558 | int isDefault, | 556 | int isDefault, |
559 | const struct sockaddr *addr, | 557 | const struct sockaddr *addr, |
560 | const struct sockaddr *broadcast_addr, | 558 | const struct sockaddr *broadcast_addr, |
561 | const struct sockaddr *netmask, | 559 | const struct sockaddr *netmask, |
562 | socklen_t addrlen) | 560 | socklen_t addrlen) |
563 | { | 561 | { |
564 | struct GNUNET_NAT_AutoHandle *ah = cls; | 562 | struct GNUNET_NAT_AutoHandle *ah = cls; |
565 | const struct sockaddr_in *in; | 563 | const struct sockaddr_in *in; |
@@ -640,11 +638,9 @@ test_local_ip (struct GNUNET_NAT_AutoHandle *ah) | |||
640 | static void | 638 | static void |
641 | test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) | 639 | test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) |
642 | { | 640 | { |
643 | |||
644 | struct GNUNET_CLIENT_Connection *client; | 641 | struct GNUNET_CLIENT_Connection *client; |
645 | struct GNUNET_NAT_TestMessage msg; | 642 | struct GNUNET_NAT_TestMessage msg; |
646 | 643 | ||
647 | |||
648 | if (ah->stun_ip) | 644 | if (ah->stun_ip) |
649 | { | 645 | { |
650 | LOG (GNUNET_ERROR_TYPE_INFO, | 646 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -676,9 +672,10 @@ test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) | |||
676 | { | 672 | { |
677 | GNUNET_SCHEDULER_cancel (ltask4); | 673 | GNUNET_SCHEDULER_cancel (ltask4); |
678 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, | 674 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, |
679 | lsock4, &do_udp_read, ah); | 675 | lsock4, |
676 | &do_udp_read, | ||
677 | ah); | ||
680 | } | 678 | } |
681 | |||
682 | } | 679 | } |
683 | else | 680 | else |
684 | { | 681 | { |
@@ -686,13 +683,9 @@ test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) | |||
686 | "We don't have a STUN IP"); | 683 | "We don't have a STUN IP"); |
687 | next_phase(ah); | 684 | next_phase(ah); |
688 | } | 685 | } |
689 | |||
690 | |||
691 | } | 686 | } |
692 | 687 | ||
693 | 688 | ||
694 | |||
695 | |||
696 | /** | 689 | /** |
697 | * Test if UPnPC works. | 690 | * Test if UPnPC works. |
698 | * | 691 | * |
@@ -772,7 +765,6 @@ err: | |||
772 | ah->task = GNUNET_SCHEDULER_add_now (&reversal_test, ah); | 765 | ah->task = GNUNET_SCHEDULER_add_now (&reversal_test, ah); |
773 | else | 766 | else |
774 | next_phase (ah); | 767 | next_phase (ah); |
775 | |||
776 | } | 768 | } |
777 | 769 | ||
778 | 770 | ||
@@ -784,8 +776,6 @@ err: | |||
784 | static void | 776 | static void |
785 | test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) | 777 | test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) |
786 | { | 778 | { |
787 | |||
788 | |||
789 | char *tmp; | 779 | char *tmp; |
790 | char *helper; | 780 | char *helper; |
791 | 781 | ||
@@ -802,7 +792,8 @@ test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) | |||
802 | 792 | ||
803 | if (GNUNET_YES != | 793 | if (GNUNET_YES != |
804 | GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){ | 794 | GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){ |
805 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("test_icmp_server not possible, as we are not behind NAT\n")); | 795 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
796 | _("test_icmp_server not possible, as we are not behind NAT\n")); | ||
806 | } | 797 | } |
807 | else | 798 | else |
808 | goto err; | 799 | goto err; |
@@ -810,14 +801,14 @@ test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) | |||
810 | if (GNUNET_YES == | 801 | if (GNUNET_YES == |
811 | GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){ | 802 | GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){ |
812 | // none of these parameters are actually used in privilege testing mode | 803 | // none of these parameters are actually used in privilege testing mode |
813 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("No working gnunet-helper-nat-server found\n")); | 804 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
805 | _("No working gnunet-helper-nat-server found\n")); | ||
814 | } | 806 | } |
815 | err: | 807 | err: |
816 | GNUNET_free_non_null (tmp); | 808 | GNUNET_free_non_null (tmp); |
817 | GNUNET_free (helper); | 809 | GNUNET_free (helper); |
818 | 810 | ||
819 | next_phase (ah); | 811 | next_phase (ah); |
820 | |||
821 | } | 812 | } |
822 | 813 | ||
823 | 814 | ||
@@ -940,11 +931,7 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah) | |||
940 | GNUNET_CONFIGURATION_destroy (diff); | 931 | GNUNET_CONFIGURATION_destroy (diff); |
941 | GNUNET_NAT_autoconfig_cancel (ah); | 932 | GNUNET_NAT_autoconfig_cancel (ah); |
942 | return; | 933 | return; |
943 | |||
944 | } | 934 | } |
945 | |||
946 | |||
947 | |||
948 | } | 935 | } |
949 | 936 | ||
950 | 937 | ||
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index d310b3e14..915bcbdb6 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c | |||
@@ -121,11 +121,15 @@ read_external_ipv4 (void *cls) | |||
121 | 121 | ||
122 | eh->task = NULL; | 122 | eh->task = NULL; |
123 | tc = GNUNET_SCHEDULER_get_task_context (); | 123 | tc = GNUNET_SCHEDULER_get_task_context (); |
124 | if (GNUNET_YES == GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, eh->r)) | 124 | if (GNUNET_YES == |
125 | GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, eh->r)) | ||
126 | { | ||
125 | ret = | 127 | ret = |
126 | GNUNET_DISK_file_read (eh->r, &eh->buf[eh->off], | 128 | GNUNET_DISK_file_read (eh->r, &eh->buf[eh->off], |
127 | sizeof (eh->buf) - eh->off); | 129 | sizeof (eh->buf) - eh->off); |
128 | else { | 130 | } |
131 | else | ||
132 | { | ||
129 | eh->ret = GNUNET_NAT_ERROR_IPC_FAILURE; | 133 | eh->ret = GNUNET_NAT_ERROR_IPC_FAILURE; |
130 | ret = -1; /* error reading, timeout, etc. */ | 134 | ret = -1; /* error reading, timeout, etc. */ |
131 | } | 135 | } |
@@ -541,7 +545,9 @@ process_map_output (void *cls, | |||
541 | GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED); | 545 | GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED); |
542 | if (NULL == mini->refresh_task) | 546 | if (NULL == mini->refresh_task) |
543 | mini->refresh_task = | 547 | mini->refresh_task = |
544 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, mini); | 548 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, |
549 | &do_refresh, | ||
550 | mini); | ||
545 | return; | 551 | return; |
546 | } | 552 | } |
547 | /* | 553 | /* |
@@ -617,7 +623,9 @@ GNUNET_NAT_mini_map_start (uint16_t port, | |||
617 | ret->is_tcp = is_tcp; | 623 | ret->is_tcp = is_tcp; |
618 | ret->port = port; | 624 | ret->port = port; |
619 | ret->refresh_task = | 625 | ret->refresh_task = |
620 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, ret); | 626 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, |
627 | &do_refresh, | ||
628 | ret); | ||
621 | run_upnpc_r (ret); | 629 | run_upnpc_r (ret); |
622 | return ret; | 630 | return ret; |
623 | } | 631 | } |
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 33f81d800..b2f22781e 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c | |||
@@ -252,7 +252,9 @@ do_read (void *cls) | |||
252 | tc = GNUNET_SCHEDULER_get_task_context (); | 252 | tc = GNUNET_SCHEDULER_get_task_context (); |
253 | na->rtask = NULL; | 253 | na->rtask = NULL; |
254 | tst = na->h; | 254 | tst = na->h; |
255 | GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na); | 255 | GNUNET_CONTAINER_DLL_remove (tst->na_head, |
256 | tst->na_tail, | ||
257 | na); | ||
256 | if ((NULL != tc->write_ready) && | 258 | if ((NULL != tc->write_ready) && |
257 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, na->sock)) && | 259 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, na->sock)) && |
258 | (sizeof (data) == | 260 | (sizeof (data) == |
@@ -284,14 +286,10 @@ do_accept (void *cls) | |||
284 | struct GNUNET_NAT_Test *tst = cls; | 286 | struct GNUNET_NAT_Test *tst = cls; |
285 | struct GNUNET_NETWORK_Handle *s; | 287 | struct GNUNET_NETWORK_Handle *s; |
286 | struct NatActivity *wl; | 288 | struct NatActivity *wl; |
287 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
288 | 289 | ||
289 | tst->ltask = NULL; | ||
290 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
291 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
292 | return; | ||
293 | tst->ltask = | 290 | tst->ltask = |
294 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, tst->lsock, | 291 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
292 | tst->lsock, | ||
295 | &do_accept, tst); | 293 | &do_accept, tst); |
296 | s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); | 294 | s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); |
297 | if (NULL == s) | 295 | if (NULL == s) |
@@ -308,7 +306,9 @@ do_accept (void *cls) | |||
308 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 306 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
309 | wl->sock, | 307 | wl->sock, |
310 | &do_read, wl); | 308 | &do_read, wl); |
311 | GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl); | 309 | GNUNET_CONTAINER_DLL_insert (tst->na_head, |
310 | tst->na_tail, | ||
311 | wl); | ||
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
@@ -474,13 +474,15 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
474 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (nh->lsock, 5)); | 474 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (nh->lsock, 5)); |
475 | nh->ltask = | 475 | nh->ltask = |
476 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 476 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
477 | nh->lsock, &do_accept, nh); | 477 | nh->lsock, |
478 | &do_accept, nh); | ||
478 | } | 479 | } |
479 | else | 480 | else |
480 | { | 481 | { |
481 | nh->ltask = | 482 | nh->ltask = |
482 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 483 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
483 | nh->lsock, &do_udp_read, nh); | 484 | nh->lsock, |
485 | &do_udp_read, nh); | ||
484 | } | 486 | } |
485 | LOG (GNUNET_ERROR_TYPE_INFO, | 487 | LOG (GNUNET_ERROR_TYPE_INFO, |
486 | "NAT test listens on port %u (%s)\n", | 488 | "NAT test listens on port %u (%s)\n", |
@@ -508,7 +510,9 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
508 | return nh; | 510 | return nh; |
509 | } | 511 | } |
510 | } | 512 | } |
511 | nh->ttask = GNUNET_SCHEDULER_add_delayed (timeout, &do_timeout, nh); | 513 | nh->ttask = GNUNET_SCHEDULER_add_delayed (timeout, |
514 | &do_timeout, | ||
515 | nh); | ||
512 | return nh; | 516 | return nh; |
513 | } | 517 | } |
514 | 518 | ||
@@ -528,13 +532,17 @@ GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst) | |||
528 | "Stopping NAT test\n"); | 532 | "Stopping NAT test\n"); |
529 | while (NULL != (cpos = tst->ca_head)) | 533 | while (NULL != (cpos = tst->ca_head)) |
530 | { | 534 | { |
531 | GNUNET_CONTAINER_DLL_remove (tst->ca_head, tst->ca_tail, cpos); | 535 | GNUNET_CONTAINER_DLL_remove (tst->ca_head, |
536 | tst->ca_tail, | ||
537 | cpos); | ||
532 | GNUNET_CLIENT_disconnect (cpos->client); | 538 | GNUNET_CLIENT_disconnect (cpos->client); |
533 | GNUNET_free (cpos); | 539 | GNUNET_free (cpos); |
534 | } | 540 | } |
535 | while (NULL != (pos = tst->na_head)) | 541 | while (NULL != (pos = tst->na_head)) |
536 | { | 542 | { |
537 | GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, pos); | 543 | GNUNET_CONTAINER_DLL_remove (tst->na_head, |
544 | tst->na_tail, | ||
545 | pos); | ||
538 | GNUNET_SCHEDULER_cancel (pos->rtask); | 546 | GNUNET_SCHEDULER_cancel (pos->rtask); |
539 | GNUNET_NETWORK_socket_close (pos->sock); | 547 | GNUNET_NETWORK_socket_close (pos->sock); |
540 | GNUNET_free (pos); | 548 | GNUNET_free (pos); |
diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c index a840f3ef9..fd67473ee 100644 --- a/src/nat/test_nat.c +++ b/src/nat/test_nat.c | |||
@@ -69,7 +69,8 @@ stop (void *cls) | |||
69 | { | 69 | { |
70 | struct GNUNET_NAT_Handle *nat = cls; | 70 | struct GNUNET_NAT_Handle *nat = cls; |
71 | 71 | ||
72 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n"); | 72 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
73 | "Stopping NAT and quitting...\n"); | ||
73 | GNUNET_NAT_unregister (nat); | 74 | GNUNET_NAT_unregister (nat); |
74 | } | 75 | } |
75 | 76 | ||