aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-02 14:04:21 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-02 14:04:21 +0000
commit82c4c89493dcbfc6ee7fd1232a9088d02e2cd0a2 (patch)
treec7d6b5a6c20540045ecc52d85c006a9104b3350f /src/nat
parent82894f45a92d4df70b8e038109a318f2489c4cfe (diff)
downloadgnunet-82c4c89493dcbfc6ee7fd1232a9088d02e2cd0a2.tar.gz
gnunet-82c4c89493dcbfc6ee7fd1232a9088d02e2cd0a2.zip
- LRN's patch
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/nat.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 5117f5da7..725bbe952 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -1308,32 +1308,34 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h)
1308 * gnunet-helper-nat-client to send dummy ICMP responses to cause 1308 * gnunet-helper-nat-client to send dummy ICMP responses to cause
1309 * that peer to connect to us (connection reversal). 1309 * that peer to connect to us (connection reversal).
1310 * 1310 *
1311 * @param h NAT handle for us (largely used for configuration) 1311 * @return GNUNET_SYSERR on error, GNUNET_NO if nat client is disabled,
1312 * @param sa the address of the peer (IPv4-only) 1312 * GNUNET_OK otherwise
1313 */ 1313 */
1314void 1314int
1315GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, 1315GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
1316 const struct sockaddr_in *sa) 1316 const struct sockaddr_in *sa)
1317
1318
1317{ 1319{
1318 char inet4[INET_ADDRSTRLEN]; 1320 char inet4[INET_ADDRSTRLEN];
1319 char port_as_string[6]; 1321 char port_as_string[6];
1320 struct GNUNET_OS_Process *proc; 1322 struct GNUNET_OS_Process *proc;
1321 1323
1322 if (GNUNET_YES != h->enable_nat_client) 1324 if (GNUNET_YES != h->enable_nat_client)
1323 return; /* not permitted / possible */ 1325 return GNUNET_NO; /* not permitted / possible */
1324 1326
1325 if (h->internal_address == NULL) 1327 if (h->internal_address == NULL)
1326 { 1328 {
1327 LOG (GNUNET_ERROR_TYPE_WARNING, "nat", 1329 LOG (GNUNET_ERROR_TYPE_WARNING, "nat",
1328 _ 1330 _
1329 ("Internal IP address not known, cannot use ICMP NAT traversal method\n")); 1331 ("Internal IP address not known, cannot use ICMP NAT traversal method\n"));
1330 return; 1332 return GNUNET_SYSERR;
1331 } 1333 }
1332 GNUNET_assert (sa->sin_family == AF_INET); 1334 GNUNET_assert (sa->sin_family == AF_INET);
1333 if (NULL == inet_ntop (AF_INET, &sa->sin_addr, inet4, INET_ADDRSTRLEN)) 1335 if (NULL == inet_ntop (AF_INET, &sa->sin_addr, inet4, INET_ADDRSTRLEN))
1334 { 1336 {
1335 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "inet_ntop"); 1337 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "inet_ntop");
1336 return; 1338 return GNUNET_SYSERR;
1337 } 1339 }
1338 GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port); 1340 GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port);
1339#if DEBUG_NAT 1341#if DEBUG_NAT
@@ -1347,11 +1349,12 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
1347 "gnunet-helper-nat-client", h->internal_address, 1349 "gnunet-helper-nat-client", h->internal_address,
1348 inet4, port_as_string, NULL); 1350 inet4, port_as_string, NULL);
1349 if (NULL == proc) 1351 if (NULL == proc)
1350 return; 1352 return GNUNET_SYSERR;
1351 /* we know that the gnunet-helper-nat-client will terminate virtually 1353 /* we know that the gnunet-helper-nat-client will terminate virtually
1352 * instantly */ 1354 * instantly */
1353 GNUNET_OS_process_wait (proc); 1355 GNUNET_OS_process_wait (proc);
1354 GNUNET_OS_process_close (proc); 1356 GNUNET_OS_process_close (proc);
1357 return GNUNET_OK;
1355} 1358}
1356 1359
1357 1360