diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-05 15:28:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-05 15:28:21 +0000 |
commit | ef76e090bf279f25038c03eec4eac96bbfbe952e (patch) | |
tree | 9e70dd991daefef65cd85dbcdc4bc4d19b7fedb0 /src/nat/nat.c | |
parent | 8c85bda93a8ece52f02af7f20fb797ad6ac79337 (diff) | |
download | gnunet-ef76e090bf279f25038c03eec4eac96bbfbe952e.tar.gz gnunet-ef76e090bf279f25038c03eec4eac96bbfbe952e.zip |
fix #3986
Diffstat (limited to 'src/nat/nat.c')
-rw-r--r-- | src/nat/nat.c | 225 |
1 files changed, 129 insertions, 96 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c index e51c001f2..709a13f03 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -454,18 +454,15 @@ static void | |||
454 | start_gnunet_nat_server (struct GNUNET_NAT_Handle *h); | 454 | start_gnunet_nat_server (struct GNUNET_NAT_Handle *h); |
455 | 455 | ||
456 | 456 | ||
457 | |||
458 | |||
459 | /** | 457 | /** |
460 | * Call task to process STUN | 458 | * Call task to process STUN |
461 | * | 459 | * |
462 | * @param cls handle to NAT | 460 | * @param cls handle to NAT |
463 | * @param tc TaskContext | 461 | * @param tc TaskContext |
464 | */ | 462 | */ |
465 | |||
466 | static void | 463 | static void |
467 | process_stun (void *cls, | 464 | process_stun (void *cls, |
468 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 465 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
469 | 466 | ||
470 | 467 | ||
471 | /** | 468 | /** |
@@ -488,10 +485,14 @@ remove_from_address_list_by_source (struct GNUNET_NAT_Handle *h, | |||
488 | next = pos->next; | 485 | next = pos->next; |
489 | if (pos->source != src) | 486 | if (pos->source != src) |
490 | continue; | 487 | continue; |
491 | GNUNET_CONTAINER_DLL_remove (h->lal_head, h->lal_tail, pos); | 488 | GNUNET_CONTAINER_DLL_remove (h->lal_head, |
489 | h->lal_tail, | ||
490 | pos); | ||
492 | if (NULL != h->address_callback) | 491 | if (NULL != h->address_callback) |
493 | h->address_callback (h->callback_cls, GNUNET_NO, | 492 | h->address_callback (h->callback_cls, |
494 | (const struct sockaddr *) &pos[1], pos->addrlen); | 493 | GNUNET_NO, |
494 | (const struct sockaddr *) &pos[1], | ||
495 | pos->addrlen); | ||
495 | GNUNET_free (pos); | 496 | GNUNET_free (pos); |
496 | } | 497 | } |
497 | } | 498 | } |
@@ -509,7 +510,8 @@ remove_from_address_list_by_source (struct GNUNET_NAT_Handle *h, | |||
509 | static void | 510 | static void |
510 | add_to_address_list_as_is (struct GNUNET_NAT_Handle *h, | 511 | add_to_address_list_as_is (struct GNUNET_NAT_Handle *h, |
511 | enum LocalAddressSource src, | 512 | enum LocalAddressSource src, |
512 | const struct sockaddr *arg, socklen_t arg_size) | 513 | const struct sockaddr *arg, |
514 | socklen_t arg_size) | ||
513 | { | 515 | { |
514 | struct LocalAddressList *lal; | 516 | struct LocalAddressList *lal; |
515 | 517 | ||
@@ -517,13 +519,18 @@ add_to_address_list_as_is (struct GNUNET_NAT_Handle *h, | |||
517 | memcpy (&lal[1], arg, arg_size); | 519 | memcpy (&lal[1], arg, arg_size); |
518 | lal->addrlen = arg_size; | 520 | lal->addrlen = arg_size; |
519 | lal->source = src; | 521 | lal->source = src; |
520 | GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal); | 522 | GNUNET_CONTAINER_DLL_insert (h->lal_head, |
523 | h->lal_tail, | ||
524 | lal); | ||
521 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 525 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
522 | "Adding address `%s' from source %d\n", | 526 | "Adding address `%s' from source %d\n", |
523 | GNUNET_a2s (arg, arg_size), | 527 | GNUNET_a2s (arg, arg_size), |
524 | src); | 528 | src); |
525 | if (NULL != h->address_callback) | 529 | if (NULL != h->address_callback) |
526 | h->address_callback (h->callback_cls, GNUNET_YES, arg, arg_size); | 530 | h->address_callback (h->callback_cls, |
531 | GNUNET_YES, | ||
532 | arg, | ||
533 | arg_size); | ||
527 | } | 534 | } |
528 | 535 | ||
529 | 536 | ||
@@ -1110,15 +1117,13 @@ list_interfaces (void *cls, | |||
1110 | * @param result , the status | 1117 | * @param result , the status |
1111 | */ | 1118 | */ |
1112 | static void | 1119 | static void |
1113 | stun_request_callback(void *cls, | 1120 | stun_request_callback (void *cls, |
1114 | enum GNUNET_NAT_StatusCode result) | 1121 | enum GNUNET_NAT_StatusCode result) |
1115 | { | 1122 | { |
1116 | |||
1117 | struct GNUNET_NAT_Handle *h = cls; | 1123 | struct GNUNET_NAT_Handle *h = cls; |
1118 | 1124 | ||
1119 | if(NULL == cls) | 1125 | if (NULL == h) |
1120 | return; | 1126 | return; |
1121 | |||
1122 | h->waiting_stun = GNUNET_NO; | 1127 | h->waiting_stun = GNUNET_NO; |
1123 | 1128 | ||
1124 | if(result != GNUNET_OK) | 1129 | if(result != GNUNET_OK) |
@@ -1126,58 +1131,64 @@ stun_request_callback(void *cls, | |||
1126 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1131 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1127 | "Error processing a STUN request"); | 1132 | "Error processing a STUN request"); |
1128 | } | 1133 | } |
1134 | } | ||
1129 | 1135 | ||
1130 | }; | ||
1131 | 1136 | ||
1132 | /** | 1137 | /** |
1133 | * CHECK if is a valid STUN packet sending to GNUNET_NAT_stun_handle_packet. | 1138 | * CHECK if is a valid STUN packet sending to GNUNET_NAT_stun_handle_packet(). |
1134 | * It also check if it can handle the packet based on the NAT handler. | 1139 | * It also check if it can handle the packet based on the NAT handler. |
1135 | * You don't need to call anything else to check if the packet is valid, | 1140 | * You don't need to call anything else to check if the packet is valid, |
1136 | * | 1141 | * |
1137 | * @param cls the NAT handle | 1142 | * @param cls the NAT handle |
1138 | * @param data, packet | 1143 | * @param data packet |
1139 | * @param len, packet length | 1144 | * @param len packet length |
1140 | * | ||
1141 | * @return #GNUNET_NO if it can't decode, #GNUNET_YES if is a packet | 1145 | * @return #GNUNET_NO if it can't decode, #GNUNET_YES if is a packet |
1142 | */ | 1146 | */ |
1143 | int | 1147 | int |
1144 | GNUNET_NAT_is_valid_stun_packet(void *cls, const void *data, size_t len) | 1148 | GNUNET_NAT_is_valid_stun_packet (void *cls, |
1149 | const void *data, | ||
1150 | size_t len) | ||
1145 | { | 1151 | { |
1146 | struct GNUNET_NAT_Handle *h = cls; | 1152 | struct GNUNET_NAT_Handle *h = cls; |
1147 | struct sockaddr_in answer; | 1153 | struct sockaddr_in answer; |
1148 | 1154 | ||
1149 | /* We are not expecting a STUN message*/ | 1155 | /* We are not expecting a STUN message */ |
1150 | if(!h->waiting_stun) | 1156 | if (! h->waiting_stun) |
1151 | return GNUNET_NO; | 1157 | return GNUNET_NO; |
1152 | 1158 | ||
1153 | /*We dont have STUN installed*/ | 1159 | /* We dont have STUN installed */ |
1154 | if(!h->use_stun) | 1160 | if (! h->use_stun) |
1155 | return GNUNET_NO; | 1161 | return GNUNET_NO; |
1156 | 1162 | ||
1157 | /* Empty the answer structure */ | 1163 | /* Empty the answer structure */ |
1158 | memset(&answer, 0, sizeof(struct sockaddr_in)); | 1164 | memset (&answer, |
1165 | 0, | ||
1166 | sizeof(struct sockaddr_in)); | ||
1159 | 1167 | ||
1160 | /*Lets handle the packet*/ | 1168 | /*Lets handle the packet*/ |
1161 | int valid = GNUNET_NAT_stun_handle_packet(data,len, &answer); | 1169 | int valid = GNUNET_NAT_stun_handle_packet (data, |
1162 | if(valid) | 1170 | len, |
1163 | { | 1171 | &answer); |
1164 | LOG (GNUNET_ERROR_TYPE_INFO, | 1172 | if (! valid) |
1165 | "Stun server returned IP %s , with port %d \n", inet_ntoa(answer.sin_addr), ntohs(answer.sin_port)); | ||
1166 | /* ADD IP AS VALID*/ | ||
1167 | add_to_address_list (h, LAL_EXTERNAL_IP, (const struct sockaddr *) &answer, | ||
1168 | sizeof (struct sockaddr_in)); | ||
1169 | h->waiting_stun = GNUNET_NO; | ||
1170 | return GNUNET_YES; | ||
1171 | } | ||
1172 | else | ||
1173 | { | ||
1174 | return GNUNET_NO; | 1173 | return GNUNET_NO; |
1175 | } | ||
1176 | |||
1177 | |||
1178 | 1174 | ||
1175 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
1176 | "Stun server returned %s:%d\n", | ||
1177 | inet_ntoa (answer.sin_addr), | ||
1178 | ntohs (answer.sin_port)); | ||
1179 | /* Remove old IPs from previous STUN calls */ | ||
1180 | remove_from_address_list_by_source (h, | ||
1181 | LAL_EXTERNAL_STUN_IP); | ||
1182 | /* Add new IP from STUN packet */ | ||
1183 | add_to_address_list (h, | ||
1184 | LAL_EXTERNAL_STUN_IP, | ||
1185 | (const struct sockaddr *) &answer, | ||
1186 | sizeof (struct sockaddr_in)); | ||
1187 | h->waiting_stun = GNUNET_NO; | ||
1188 | return GNUNET_YES; | ||
1179 | } | 1189 | } |
1180 | 1190 | ||
1191 | |||
1181 | /** | 1192 | /** |
1182 | * Task to do a STUN request | 1193 | * Task to do a STUN request |
1183 | * | 1194 | * |
@@ -1186,36 +1197,39 @@ GNUNET_NAT_is_valid_stun_packet(void *cls, const void *data, size_t len) | |||
1186 | */ | 1197 | */ |
1187 | static void | 1198 | static void |
1188 | process_stun (void *cls, | 1199 | process_stun (void *cls, |
1189 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1200 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1190 | { | 1201 | { |
1191 | struct GNUNET_NAT_Handle *h = cls; | 1202 | struct GNUNET_NAT_Handle *h = cls; |
1192 | |||
1193 | h->stun_task = NULL; | ||
1194 | |||
1195 | |||
1196 | |||
1197 | struct StunServerList* elem = h->actual_stun_server; | 1203 | struct StunServerList* elem = h->actual_stun_server; |
1198 | 1204 | ||
1205 | h->stun_task = NULL; | ||
1199 | /* Make the request */ | 1206 | /* Make the request */ |
1200 | LOG (GNUNET_ERROR_TYPE_INFO, | 1207 | LOG (GNUNET_ERROR_TYPE_INFO, |
1201 | "I will request the stun server %s:%i !\n", elem->address, elem->port); | 1208 | "I will request the stun server %s:%i\n", |
1202 | 1209 | elem->address, | |
1203 | if(GNUNET_OK == GNUNET_NAT_stun_make_request(elem->address, elem->port, h->socket, &stun_request_callback, NULL)) | 1210 | elem->port); |
1211 | if (GNUNET_OK == | ||
1212 | GNUNET_NAT_stun_make_request (elem->address, | ||
1213 | elem->port, | ||
1214 | h->socket, | ||
1215 | &stun_request_callback, | ||
1216 | NULL)) | ||
1204 | { | 1217 | { |
1205 | h->waiting_stun = GNUNET_YES; | 1218 | h->waiting_stun = GNUNET_YES; |
1206 | } | 1219 | } |
1207 | else | 1220 | else |
1208 | { | 1221 | { |
1209 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1222 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1210 | "STUN request failed %s:%i !\n", elem->address, elem->port); | 1223 | "STUN request to %s:%i failed\n", |
1224 | elem->address, | ||
1225 | elem->port); | ||
1211 | } | 1226 | } |
1212 | |||
1213 | h->stun_task = | 1227 | h->stun_task = |
1214 | GNUNET_SCHEDULER_add_delayed (h->stun_frequency, | 1228 | GNUNET_SCHEDULER_add_delayed (h->stun_frequency, |
1215 | &process_stun, h); | 1229 | &process_stun, h); |
1216 | 1230 | ||
1217 | /* Set actual Server*/ | 1231 | /* Set actual Server*/ |
1218 | if(elem->next) | 1232 | if (NULL != elem->next) |
1219 | { | 1233 | { |
1220 | h->actual_stun_server = elem->next; | 1234 | h->actual_stun_server = elem->next; |
1221 | } | 1235 | } |
@@ -1223,11 +1237,9 @@ process_stun (void *cls, | |||
1223 | { | 1237 | { |
1224 | h->actual_stun_server = h->stun_servers_head; | 1238 | h->actual_stun_server = h->stun_servers_head; |
1225 | } | 1239 | } |
1226 | |||
1227 | } | 1240 | } |
1228 | 1241 | ||
1229 | 1242 | ||
1230 | |||
1231 | /** | 1243 | /** |
1232 | * Task to do a lookup on our hostname for IP addresses. | 1244 | * Task to do a lookup on our hostname for IP addresses. |
1233 | * | 1245 | * |
@@ -1303,15 +1315,16 @@ upnp_add (void *cls, | |||
1303 | /* Error while running upnp client */ | 1315 | /* Error while running upnp client */ |
1304 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1316 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1305 | _("Error while running upnp client:\n")); | 1317 | _("Error while running upnp client:\n")); |
1306 | |||
1307 | //FIXME: convert error code to string | 1318 | //FIXME: convert error code to string |
1308 | |||
1309 | return; | 1319 | return; |
1310 | } | 1320 | } |
1311 | 1321 | ||
1312 | if (GNUNET_YES == add_remove) | 1322 | if (GNUNET_YES == add_remove) |
1313 | { | 1323 | { |
1314 | add_to_address_list (h, LAL_UPNP, addr, addrlen); | 1324 | add_to_address_list (h, |
1325 | LAL_UPNP, | ||
1326 | addr, | ||
1327 | addrlen); | ||
1315 | return; | 1328 | return; |
1316 | } | 1329 | } |
1317 | else if (GNUNET_NO == add_remove) | 1330 | else if (GNUNET_NO == add_remove) |
@@ -1324,10 +1337,14 @@ upnp_add (void *cls, | |||
1324 | if ((pos->source != LAL_UPNP) || (pos->addrlen != addrlen) || | 1337 | if ((pos->source != LAL_UPNP) || (pos->addrlen != addrlen) || |
1325 | (0 != memcmp (&pos[1], addr, addrlen))) | 1338 | (0 != memcmp (&pos[1], addr, addrlen))) |
1326 | continue; | 1339 | continue; |
1327 | GNUNET_CONTAINER_DLL_remove (h->lal_head, h->lal_tail, pos); | 1340 | GNUNET_CONTAINER_DLL_remove (h->lal_head, |
1341 | h->lal_tail, | ||
1342 | pos); | ||
1328 | if (NULL != h->address_callback) | 1343 | if (NULL != h->address_callback) |
1329 | h->address_callback (h->callback_cls, GNUNET_NO, | 1344 | h->address_callback (h->callback_cls, |
1330 | (const struct sockaddr *) &pos[1], pos->addrlen); | 1345 | GNUNET_NO, |
1346 | (const struct sockaddr *) &pos[1], | ||
1347 | pos->addrlen); | ||
1331 | GNUNET_free (pos); | 1348 | GNUNET_free (pos); |
1332 | return; /* only remove once */ | 1349 | return; /* only remove once */ |
1333 | } | 1350 | } |
@@ -1377,7 +1394,9 @@ add_minis (struct GNUNET_NAT_Handle *h, | |||
1377 | return; | 1394 | return; |
1378 | } | 1395 | } |
1379 | 1396 | ||
1380 | GNUNET_CONTAINER_DLL_insert (h->mini_head, h->mini_tail, ml); | 1397 | GNUNET_CONTAINER_DLL_insert (h->mini_head, |
1398 | h->mini_tail, | ||
1399 | ml); | ||
1381 | } | 1400 | } |
1382 | 1401 | ||
1383 | 1402 | ||
@@ -1470,7 +1489,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1470 | GNUNET_NAT_AddressCallback address_callback, | 1489 | GNUNET_NAT_AddressCallback address_callback, |
1471 | GNUNET_NAT_ReversalCallback reversal_callback, | 1490 | GNUNET_NAT_ReversalCallback reversal_callback, |
1472 | void *callback_cls, | 1491 | void *callback_cls, |
1473 | struct GNUNET_NETWORK_Handle* sock ) | 1492 | struct GNUNET_NETWORK_Handle *sock) |
1474 | { | 1493 | { |
1475 | struct GNUNET_NAT_Handle *h; | 1494 | struct GNUNET_NAT_Handle *h; |
1476 | struct in_addr in_addr; | 1495 | struct in_addr in_addr; |
@@ -1489,7 +1508,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1489 | h->callback_cls = callback_cls; | 1508 | h->callback_cls = callback_cls; |
1490 | h->num_local_addrs = num_addrs; | 1509 | h->num_local_addrs = num_addrs; |
1491 | h->adv_port = adv_port; | 1510 | h->adv_port = adv_port; |
1492 | if (num_addrs != 0) | 1511 | if (0 != num_addrs) |
1493 | { | 1512 | { |
1494 | h->local_addrs = GNUNET_malloc (num_addrs * sizeof (struct sockaddr *)); | 1513 | h->local_addrs = GNUNET_malloc (num_addrs * sizeof (struct sockaddr *)); |
1495 | h->local_addrlens = GNUNET_malloc (num_addrs * sizeof (socklen_t)); | 1514 | h->local_addrlens = GNUNET_malloc (num_addrs * sizeof (socklen_t)); |
@@ -1574,11 +1593,14 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1574 | 1593 | ||
1575 | /* STUN */ | 1594 | /* STUN */ |
1576 | h->use_stun = | 1595 | h->use_stun = |
1577 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", | 1596 | GNUNET_CONFIGURATION_get_value_yesno (cfg, |
1578 | "USE_STUN"); | 1597 | "nat", |
1598 | "USE_STUN"); | ||
1579 | 1599 | ||
1580 | if (GNUNET_OK != | 1600 | if (GNUNET_OK != |
1581 | GNUNET_CONFIGURATION_get_value_time (cfg, "nat", "STUN_FREQUENCY", | 1601 | GNUNET_CONFIGURATION_get_value_time (cfg, |
1602 | "nat", | ||
1603 | "STUN_FREQUENCY", | ||
1582 | &h->stun_frequency)) | 1604 | &h->stun_frequency)) |
1583 | h->stun_frequency = STUN_FREQUENCY; | 1605 | h->stun_frequency = STUN_FREQUENCY; |
1584 | 1606 | ||
@@ -1599,25 +1621,28 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1599 | "No external IP address given to add to our list of addresses\n"); | 1621 | "No external IP address given to add to our list of addresses\n"); |
1600 | } | 1622 | } |
1601 | 1623 | ||
1602 | /* ENABLE STUN ONLY ON UDP*/ | 1624 | /* ENABLE STUN ONLY ON UDP */ |
1603 | if(!is_tcp && (NULL != sock) && h->use_stun ) | 1625 | if( (! is_tcp) && |
1626 | (NULL != sock) && | ||
1627 | h->use_stun) | ||
1604 | { | 1628 | { |
1605 | h->socket = sock; | ||
1606 | h->actual_stun_server = NULL; | ||
1607 | |||
1608 | /* Lets process the servers*/ | ||
1609 | char *stun_servers; | 1629 | char *stun_servers; |
1610 | |||
1611 | size_t urls; | 1630 | size_t urls; |
1612 | int pos; | 1631 | int pos; |
1613 | size_t pos_port; | 1632 | size_t pos_port; |
1614 | 1633 | ||
1634 | h->socket = sock; | ||
1635 | h->actual_stun_server = NULL; | ||
1636 | /* Lets process the servers*/ | ||
1615 | if (GNUNET_OK != | 1637 | if (GNUNET_OK != |
1616 | GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "STUN_SERVERS", | 1638 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1639 | "nat", | ||
1640 | "STUN_SERVERS", | ||
1617 | &stun_servers)) | 1641 | &stun_servers)) |
1618 | { | 1642 | { |
1619 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, | 1643 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, |
1620 | "nat", "STUN_SERVERS"); | 1644 | "nat", |
1645 | "STUN_SERVERS"); | ||
1621 | } | 1646 | } |
1622 | 1647 | ||
1623 | urls = 0; | 1648 | urls = 0; |
@@ -1649,10 +1674,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1649 | 1674 | ||
1650 | struct StunServerList* ml = GNUNET_new (struct StunServerList); | 1675 | struct StunServerList* ml = GNUNET_new (struct StunServerList); |
1651 | 1676 | ||
1652 | ml->next = NULL; | 1677 | ml->port = atoi (&stun_servers[pos_port]); |
1653 | ml->prev = NULL; | ||
1654 | |||
1655 | ml->port = atoi(&stun_servers[pos_port]); | ||
1656 | stun_servers[pos_port-1] = '\0'; | 1678 | stun_servers[pos_port-1] = '\0'; |
1657 | 1679 | ||
1658 | /* Remove trailing space */ | 1680 | /* Remove trailing space */ |
@@ -1662,11 +1684,15 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1662 | ml->address = GNUNET_strdup (&stun_servers[pos]); | 1684 | ml->address = GNUNET_strdup (&stun_servers[pos]); |
1663 | 1685 | ||
1664 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1686 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1665 | "Found STUN server %s port %i !!!\n", ml->address, ml->port); | 1687 | "Found STUN server %s:%i\n", |
1688 | ml->address, | ||
1689 | ml->port); | ||
1666 | 1690 | ||
1667 | GNUNET_CONTAINER_DLL_insert (h->stun_servers_head, h->stun_servers_tail, ml); | 1691 | GNUNET_CONTAINER_DLL_insert (h->stun_servers_head, |
1692 | h->stun_servers_tail, | ||
1693 | ml); | ||
1668 | /* Make sure that we STOP if is the last one*/ | 1694 | /* Make sure that we STOP if is the last one*/ |
1669 | if(0== pos) | 1695 | if (0 == pos) |
1670 | break; | 1696 | break; |
1671 | } | 1697 | } |
1672 | 1698 | ||
@@ -1684,17 +1710,21 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1684 | h->actual_stun_server = h->stun_servers_head; | 1710 | h->actual_stun_server = h->stun_servers_head; |
1685 | } | 1711 | } |
1686 | 1712 | ||
1687 | h->stun_task = GNUNET_SCHEDULER_add_now(&process_stun, | 1713 | h->stun_task = GNUNET_SCHEDULER_add_now (&process_stun, |
1688 | h); | 1714 | h); |
1689 | } | 1715 | } |
1690 | 1716 | ||
1691 | 1717 | ||
1692 | /* Test for SUID binaries */ | 1718 | /* Test for SUID binaries */ |
1693 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | 1719 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); |
1694 | if ((h->behind_nat == GNUNET_YES) && (GNUNET_YES == h->enable_nat_server) && | 1720 | if ( (GNUNET_YES == h->behind_nat) && |
1695 | (GNUNET_YES != | 1721 | (GNUNET_YES == h->enable_nat_server) && |
1696 | GNUNET_OS_check_helper_binary (binary, GNUNET_YES, "-d 127.0.0.1" ))) // use localhost as source for that one udp-port, ok for testing | 1722 | (GNUNET_YES != |
1723 | GNUNET_OS_check_helper_binary (binary, | ||
1724 | GNUNET_YES, | ||
1725 | "-d 127.0.0.1" ))) | ||
1697 | { | 1726 | { |
1727 | // use localhost as source for that one udp-port, ok for testing | ||
1698 | h->enable_nat_server = GNUNET_NO; | 1728 | h->enable_nat_server = GNUNET_NO; |
1699 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1729 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1700 | _("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), | 1730 | _("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), |
@@ -1708,8 +1738,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1708 | { | 1738 | { |
1709 | h->enable_nat_client = GNUNET_NO; | 1739 | h->enable_nat_client = GNUNET_NO; |
1710 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1740 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1711 | _ | 1741 | _("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), |
1712 | ("Configuration requires `%s', but binary is not installed properly (SUID bit not set). Option disabled.\n"), | ||
1713 | "gnunet-helper-nat-client"); | 1742 | "gnunet-helper-nat-client"); |
1714 | } | 1743 | } |
1715 | GNUNET_free (binary); | 1744 | GNUNET_free (binary); |
@@ -1809,10 +1838,14 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h) | |||
1809 | } | 1838 | } |
1810 | while (NULL != (lal = h->lal_head)) | 1839 | while (NULL != (lal = h->lal_head)) |
1811 | { | 1840 | { |
1812 | GNUNET_CONTAINER_DLL_remove (h->lal_head, h->lal_tail, lal); | 1841 | GNUNET_CONTAINER_DLL_remove (h->lal_head, |
1842 | h->lal_tail, | ||
1843 | lal); | ||
1813 | if (NULL != h->address_callback) | 1844 | if (NULL != h->address_callback) |
1814 | h->address_callback (h->callback_cls, GNUNET_NO, | 1845 | h->address_callback (h->callback_cls, |
1815 | (const struct sockaddr *) &lal[1], lal->addrlen); | 1846 | GNUNET_NO, |
1847 | (const struct sockaddr *) &lal[1], | ||
1848 | lal->addrlen); | ||
1816 | GNUNET_free (lal); | 1849 | GNUNET_free (lal); |
1817 | } | 1850 | } |
1818 | for (i = 0; i < h->num_local_addrs; i++) | 1851 | for (i = 0; i < h->num_local_addrs; i++) |