aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-19 13:57:34 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-19 13:57:34 +0100
commit360d7afad50d1af425a20e89419d2063a6a0e220 (patch)
tree1597e6257a3f5eedecac8c30ed41e81d366168ae /src/nat
parentaf4e2e306bd703958ab0b8de1ab25fcc0a528eea (diff)
downloadgnunet-360d7afad50d1af425a20e89419d2063a6a0e220.tar.gz
gnunet-360d7afad50d1af425a20e89419d2063a6a0e220.zip
fix zombie-fest
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/gnunet-service-nat_externalip.c17
-rw-r--r--src/nat/gnunet-service-nat_mini.c16
2 files changed, 16 insertions, 17 deletions
diff --git a/src/nat/gnunet-service-nat_externalip.c b/src/nat/gnunet-service-nat_externalip.c
index 979d2f0f5..8df6f48a5 100644
--- a/src/nat/gnunet-service-nat_externalip.c
+++ b/src/nat/gnunet-service-nat_externalip.c
@@ -23,15 +23,12 @@
23 * 23 *
24 * This can be implemented using different methods, and we allow 24 * This can be implemented using different methods, and we allow
25 * the main service to be notified about changes to what we believe 25 * the main service to be notified about changes to what we believe
26 * is our external IPv4 address. 26 * is our external IPv4 address.
27 * 27 *
28 * Note that this is explicitly only about NATed systems; if one 28 * Note that this is explicitly only about NATed systems; if one
29 * of our network interfaces has a global IP address this does 29 * of our network interfaces has a global IP address this does
30 * not count as "external". 30 * not count as "external".
31 * 31 *
32 * TODO:
33 * - implement NEW logic for external IP detection based on traceroute!
34 *
35 * @file nat/gnunet-service-nat_externalip.c 32 * @file nat/gnunet-service-nat_externalip.c
36 * @brief Functions for monitoring external IPv4 addresses 33 * @brief Functions for monitoring external IPv4 addresses
37 * @author Christian Grothoff 34 * @author Christian Grothoff
@@ -86,7 +83,7 @@ struct GN_ExternalIPMonitor
86 * Kept in DLL. 83 * Kept in DLL.
87 */ 84 */
88 struct GN_ExternalIPMonitor *prev; 85 struct GN_ExternalIPMonitor *prev;
89 86
90 /** 87 /**
91 * Function to call when we believe our external IPv4 address changed. 88 * Function to call when we believe our external IPv4 address changed.
92 */ 89 */
@@ -131,7 +128,7 @@ static struct in_addr mini_external_ipv4;
131/** 128/**
132 * Tell relevant clients about a change in our external 129 * Tell relevant clients about a change in our external
133 * IPv4 address. 130 * IPv4 address.
134 * 131 *
135 * @param add #GNUNET_YES to add, #GNUNET_NO to remove 132 * @param add #GNUNET_YES to add, #GNUNET_NO to remove
136 * @param v4 the external address that changed 133 * @param v4 the external address that changed
137 */ 134 */
@@ -162,7 +159,7 @@ run_external_ip (void *cls);
162 * We learn our current external IP address. If it changed, 159 * We learn our current external IP address. If it changed,
163 * notify all of our applicable clients. Also re-schedule 160 * notify all of our applicable clients. Also re-schedule
164 * #run_external_ip with an appropriate timeout. 161 * #run_external_ip with an appropriate timeout.
165 * 162 *
166 * @param cls NULL 163 * @param cls NULL
167 * @param addr the address, NULL on errors 164 * @param addr the address, NULL on errors
168 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code 165 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
@@ -173,7 +170,7 @@ handle_external_ip (void *cls,
173 enum GNUNET_NAT_StatusCode result) 170 enum GNUNET_NAT_StatusCode result)
174{ 171{
175 char buf[INET_ADDRSTRLEN]; 172 char buf[INET_ADDRSTRLEN];
176 173
177 probe_external_ip_op = NULL; 174 probe_external_ip_op = NULL;
178 GNUNET_SCHEDULER_cancel (probe_external_ip_task); 175 GNUNET_SCHEDULER_cancel (probe_external_ip_task);
179 probe_external_ip_task 176 probe_external_ip_task
@@ -204,7 +201,7 @@ handle_external_ip (void *cls,
204 if (0 != mini_external_ipv4.s_addr) 201 if (0 != mini_external_ipv4.s_addr)
205 notify_monitors_external_ipv4_change (GNUNET_NO, 202 notify_monitors_external_ipv4_change (GNUNET_NO,
206 &mini_external_ipv4); 203 &mini_external_ipv4);
207 mini_external_ipv4.s_addr = 0; 204 mini_external_ipv4.s_addr = 0;
208 break; 205 break;
209 } 206 }
210} 207}
@@ -254,7 +251,7 @@ GN_nat_status_changed (int have_nat)
254 NULL); 251 NULL);
255 return; 252 return;
256 } 253 }
257 if (GNUNET_NO == have_nat) 254 if (GNUNET_NO == have_nat)
258 { 255 {
259 if (NULL != probe_external_ip_task) 256 if (NULL != probe_external_ip_task)
260 { 257 {
diff --git a/src/nat/gnunet-service-nat_mini.c b/src/nat/gnunet-service-nat_mini.c
index e5b9d021b..8f1229be1 100644
--- a/src/nat/gnunet-service-nat_mini.c
+++ b/src/nat/gnunet-service-nat_mini.c
@@ -123,7 +123,7 @@ read_external_ipv4 (void *cls)
123 { 123 {
124 /* try to read more */ 124 /* try to read more */
125 eh->off += ret; 125 eh->off += ret;
126 eh->task 126 eh->task
127 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 127 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
128 eh->r, 128 eh->r,
129 &read_external_ipv4, 129 &read_external_ipv4,
@@ -233,7 +233,7 @@ GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb,
233 GNUNET_DISK_PIPE_END_WRITE); 233 GNUNET_DISK_PIPE_END_WRITE);
234 eh->r = GNUNET_DISK_pipe_handle (eh->opipe, 234 eh->r = GNUNET_DISK_pipe_handle (eh->opipe,
235 GNUNET_DISK_PIPE_END_READ); 235 GNUNET_DISK_PIPE_END_READ);
236 eh->task 236 eh->task
237 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 237 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
238 eh->r, 238 eh->r,
239 &read_external_ipv4, 239 &read_external_ipv4,
@@ -254,6 +254,8 @@ GNUNET_NAT_mini_get_external_ipv4_cancel_ (struct GNUNET_NAT_ExternalHandle *eh)
254 { 254 {
255 (void) GNUNET_OS_process_kill (eh->eip, 255 (void) GNUNET_OS_process_kill (eh->eip,
256 SIGKILL); 256 SIGKILL);
257 GNUNET_break (GNUNET_OK ==
258 GNUNET_OS_process_wait (eh->eip));
257 GNUNET_OS_process_destroy (eh->eip); 259 GNUNET_OS_process_destroy (eh->eip);
258 } 260 }
259 if (NULL != eh->opipe) 261 if (NULL != eh->opipe)
@@ -372,7 +374,7 @@ run_upnpc_r (struct GNUNET_NAT_MiniHandle *mini)
372 sizeof (pstr), 374 sizeof (pstr),
373 "%u", 375 "%u",
374 (unsigned int) mini->port); 376 (unsigned int) mini->port);
375 mini->map_cmd 377 mini->map_cmd
376 = GNUNET_OS_command_run (&process_map_output, 378 = GNUNET_OS_command_run (&process_map_output,
377 mini, 379 mini,
378 MAP_TIMEOUT, 380 MAP_TIMEOUT,
@@ -516,7 +518,7 @@ do_refresh (void *cls)
516 struct GNUNET_NAT_MiniHandle *mini = cls; 518 struct GNUNET_NAT_MiniHandle *mini = cls;
517 int ac; 519 int ac;
518 520
519 mini->refresh_task 521 mini->refresh_task
520 = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, 522 = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
521 &do_refresh, 523 &do_refresh,
522 mini); 524 mini);
@@ -538,7 +540,7 @@ do_refresh (void *cls)
538 mini->refresh_cmd = NULL; 540 mini->refresh_cmd = NULL;
539 ac = GNUNET_YES; 541 ac = GNUNET_YES;
540 } 542 }
541 mini->refresh_cmd 543 mini->refresh_cmd
542 = GNUNET_OS_command_run (&process_refresh_output, 544 = GNUNET_OS_command_run (&process_refresh_output,
543 mini, 545 mini,
544 MAP_TIMEOUT, 546 MAP_TIMEOUT,
@@ -582,7 +584,7 @@ process_map_output (void *cls,
582 0, 584 0,
583 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED); 585 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED);
584 if (NULL == mini->refresh_task) 586 if (NULL == mini->refresh_task)
585 mini->refresh_task 587 mini->refresh_task
586 = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, 588 = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
587 &do_refresh, 589 &do_refresh,
588 mini); 590 mini);
@@ -747,7 +749,7 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
747 LOG (GNUNET_ERROR_TYPE_DEBUG, 749 LOG (GNUNET_ERROR_TYPE_DEBUG,
748 "Unmapping port %u with UPnP\n", 750 "Unmapping port %u with UPnP\n",
749 ntohs (mini->current_addr.sin_port)); 751 ntohs (mini->current_addr.sin_port));
750 mini->unmap_cmd 752 mini->unmap_cmd
751 = GNUNET_OS_command_run (&process_unmap_output, 753 = GNUNET_OS_command_run (&process_unmap_output,
752 mini, 754 mini,
753 UNMAP_TIMEOUT, 755 UNMAP_TIMEOUT,