aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-11-23 13:38:57 +0000
committerChristian Grothoff <christian@grothoff.org>2010-11-23 13:38:57 +0000
commit7f47ffbde7e95bb949f340e1a48aa05e73654a3e (patch)
treeb7f9a7da6c86476527dc4f41f442e8cd0f674794
parente1575262ecd499d389438e75197e71ea7aa1d966 (diff)
downloadgnunet-7f47ffbde7e95bb949f340e1a48aa05e73654a3e.tar.gz
gnunet-7f47ffbde7e95bb949f340e1a48aa05e73654a3e.zip
cleaning up TCP code, incomplete
-rw-r--r--src/transport/plugin_transport_tcp.c415
1 files changed, 223 insertions, 192 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 9ef606f68..c77963e32 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -38,8 +38,9 @@
38#include "transport.h" 38#include "transport.h"
39 39
40#define DEBUG_TCP GNUNET_NO 40#define DEBUG_TCP GNUNET_NO
41
41#define DEBUG_TCP_NAT GNUNET_NO 42#define DEBUG_TCP_NAT GNUNET_NO
42#define MULTIPLE_PEER_SESSIONS GNUNET_YES 43
43/** 44/**
44 * How long until we give up on transmitting the welcome message? 45 * How long until we give up on transmitting the welcome message?
45 */ 46 */
@@ -63,6 +64,7 @@ struct WelcomeMessage
63 64
64}; 65};
65 66
67
66/** 68/**
67 * Basically a WELCOME message, but with the purpose 69 * Basically a WELCOME message, but with the purpose
68 * of giving the waiting peer a client handle to use 70 * of giving the waiting peer a client handle to use
@@ -81,6 +83,7 @@ struct TCP_NAT_ProbeMessage
81 83
82}; 84};
83 85
86
84/** 87/**
85 * Context for sending a NAT probe via TCP. 88 * Context for sending a NAT probe via TCP.
86 */ 89 */
@@ -143,6 +146,7 @@ struct IPv6TcpAddress
143 146
144}; 147};
145 148
149
146/** 150/**
147 * Encapsulation of all of the state of the plugin. 151 * Encapsulation of all of the state of the plugin.
148 */ 152 */
@@ -440,6 +444,14 @@ struct Plugin
440}; 444};
441 445
442 446
447/**
448 * Add the given address to the list of 'local' addresses, thereby
449 * making it a 'legal' address for this peer to have.
450 *
451 * @param plugin the plugin
452 * @param arg the address, either an IPv4 or an IPv6 IP address
453 * @param arg_size number of bytes in arg
454 */
443static void 455static void
444add_to_address_list (struct Plugin *plugin, 456add_to_address_list (struct Plugin *plugin,
445 const void *arg, 457 const void *arg,
@@ -464,6 +476,14 @@ add_to_address_list (struct Plugin *plugin,
464} 476}
465 477
466 478
479/**
480 * Check if the given address is in the list of 'local' addresses.
481 *
482 * @param plugin the plugin
483 * @param arg the address, either an IPv4 or an IPv6 IP address
484 * @param arg_size number of bytes in arg
485 * @return GNUNET_OK if this is one of our IPs, GNUNET_SYSERR if not
486 */
467static int 487static int
468check_local_addr (struct Plugin *plugin, 488check_local_addr (struct Plugin *plugin,
469 const void *arg, 489 const void *arg,
@@ -527,9 +547,10 @@ tcp_address_to_string (void *cls,
527 } 547 }
528 else 548 else
529 { 549 {
530 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 550 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
531 _("Unexpected address length: %u\n"), 551 "tcp",
532 addrlen); 552 _("Unexpected address length: %u\n"),
553 addrlen);
533 GNUNET_break (0); 554 GNUNET_break (0);
534 return NULL; 555 return NULL;
535 } 556 }
@@ -550,6 +571,8 @@ tcp_address_to_string (void *cls,
550/** 571/**
551 * Find the session handle for the given client. 572 * Find the session handle for the given client.
552 * 573 *
574 * @param plugin the plugin
575 * @param client which client to find the session handle for
553 * @return NULL if no matching session exists 576 * @return NULL if no matching session exists
554 */ 577 */
555static struct Session * 578static struct Session *
@@ -564,29 +587,11 @@ find_session_by_client (struct Plugin *plugin,
564 return ret; 587 return ret;
565} 588}
566 589
567#if !MULTIPLE_PEER_SESSIONS
568/**
569 * Find the session handle for the given client.
570 *
571 * @return NULL if no matching session exists
572 */
573static struct Session *
574find_session_by_id (struct Plugin *plugin,
575 const struct GNUNET_PeerIdentity *peer)
576{
577 struct Session *ret;
578
579 ret = plugin->sessions;
580 while ((ret != NULL) && (0 != memcmp(peer, &ret->target, sizeof(struct GNUNET_PeerIdentity))))
581 ret = ret->next;
582 return ret;
583}
584#endif
585 590
586/** 591/**
587 * Create a new session. Also queues a welcome message. 592 * Create a new session. Also queues a welcome message.
588 * 593 *
589 * @param plugin us 594 * @param plugin the plugin
590 * @param target peer to connect to 595 * @param target peer to connect to
591 * @param client client to use 596 * @param client client to use
592 * @param is_nat this a NAT session, we should wait for a client to 597 * @param is_nat this a NAT session, we should wait for a client to
@@ -597,7 +602,8 @@ find_session_by_id (struct Plugin *plugin,
597static struct Session * 602static struct Session *
598create_session (struct Plugin *plugin, 603create_session (struct Plugin *plugin,
599 const struct GNUNET_PeerIdentity *target, 604 const struct GNUNET_PeerIdentity *target,
600 struct GNUNET_SERVER_Client *client, int is_nat) 605 struct GNUNET_SERVER_Client *client,
606 int is_nat)
601{ 607{
602 struct Session *ret; 608 struct Session *ret;
603 struct PendingMessage *pm; 609 struct PendingMessage *pm;
@@ -607,9 +613,9 @@ create_session (struct Plugin *plugin,
607 GNUNET_assert (client != NULL); 613 GNUNET_assert (client != NULL);
608 else 614 else
609 GNUNET_assert (client == NULL); 615 GNUNET_assert (client == NULL);
610
611#if DEBUG_TCP 616#if DEBUG_TCP
612 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 617 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
618 "tcp",
613 "Creating new session for peer `%4s'\n", 619 "Creating new session for peer `%4s'\n",
614 GNUNET_i2s (target)); 620 GNUNET_i2s (target));
615#endif 621#endif
@@ -687,7 +693,8 @@ do_transmit (void *cls, size_t size, void *buf)
687 if (buf == NULL) 693 if (buf == NULL)
688 { 694 {
689#if DEBUG_TCP 695#if DEBUG_TCP
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 696 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
697 "tcp",
691 "Timeout trying to transmit to peer `%4s', discarding message queue.\n", 698 "Timeout trying to transmit to peer `%4s', discarding message queue.\n",
692 GNUNET_i2s (&session->target)); 699 GNUNET_i2s (&session->target));
693#endif 700#endif
@@ -703,7 +710,8 @@ do_transmit (void *cls, size_t size, void *buf)
703 session->pending_messages_tail, 710 session->pending_messages_tail,
704 pos); 711 pos);
705#if DEBUG_TCP 712#if DEBUG_TCP
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 713 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
714 "tcp",
707 "Failed to transmit %u byte message to `%4s'.\n", 715 "Failed to transmit %u byte message to `%4s'.\n",
708 pos->message_size, 716 pos->message_size,
709 GNUNET_i2s (&session->target)); 717 GNUNET_i2s (&session->target));
@@ -775,8 +783,10 @@ do_transmit (void *cls, size_t size, void *buf)
775 GNUNET_assert (hd == NULL); 783 GNUNET_assert (hd == NULL);
776 GNUNET_assert (tl == NULL); 784 GNUNET_assert (tl == NULL);
777#if DEBUG_TCP > 1 785#if DEBUG_TCP > 1
778 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 786 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
779 "Transmitting %u bytes\n", ret); 787 "tcp",
788 "Transmitting %u bytes\n",
789 ret);
780#endif 790#endif
781 GNUNET_STATISTICS_update (plugin->env->stats, 791 GNUNET_STATISTICS_update (plugin->env->stats,
782 gettext_noop ("# bytes currently in TCP buffers"), 792 gettext_noop ("# bytes currently in TCP buffers"),
@@ -831,7 +841,8 @@ disconnect_session (struct Session *session)
831 struct PendingMessage *pm; 841 struct PendingMessage *pm;
832 842
833#if DEBUG_TCP 843#if DEBUG_TCP
834 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 844 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
845 "tcp",
835 "Disconnecting from `%4s' at %s (session %p).\n", 846 "Disconnecting from `%4s' at %s (session %p).\n",
836 GNUNET_i2s (&session->target), 847 GNUNET_i2s (&session->target),
837 (session->connect_addr != NULL) ? 848 (session->connect_addr != NULL) ?
@@ -865,8 +876,8 @@ disconnect_session (struct Session *session)
865 while (NULL != (pm = session->pending_messages_head)) 876 while (NULL != (pm = session->pending_messages_head))
866 { 877 {
867#if DEBUG_TCP 878#if DEBUG_TCP
868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 879 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
869 880 "tcp",
870 pm->transmit_cont != NULL 881 pm->transmit_cont != NULL
871 ? "Could not deliver message to `%4s'.\n" 882 ? "Could not deliver message to `%4s'.\n"
872 : 883 :
@@ -945,61 +956,51 @@ select_better_session (struct Session *s1,
945 956
946/** 957/**
947 * We learned about a peer (possibly behind NAT) so run the 958 * We learned about a peer (possibly behind NAT) so run the
948 * gnunet-nat-client to send dummy ICMP responses 959 * gnunet-nat-client to send dummy ICMP responses.
949 * 960 *
950 * @param plugin the plugin for this transport 961 * @param plugin the plugin for this transport
951 * @param addr the address of the peer 962 * @param addr the address of the peer (IPv4-only)
952 * @param addrlen the length of the address
953 */ 963 */
954void 964static void
955run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen) 965run_gnunet_nat_client (struct Plugin *plugin,
966 const struct sockaddr_in *sa)
956{ 967{
957 char inet4[INET_ADDRSTRLEN]; 968 char inet4[INET_ADDRSTRLEN];
958 char *address_as_string; 969 char port_as_string[6];
959 char *port_as_string;
960 struct GNUNET_OS_Process *proc; 970 struct GNUNET_OS_Process *proc;
961 const struct sockaddr *sa = (const struct sockaddr *)addr;
962
963#if DEBUG_TCP_NAT
964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
965 _("called run_gnunet_nat_client addrlen %d others are %d and %d\n"), addrlen, sizeof (struct sockaddr), sizeof (struct sockaddr_in));
966#endif
967
968 if (addrlen < sizeof (struct sockaddr))
969 return;
970 971
971 switch (sa->sa_family) 972 GNUNET_assert (sa->sin_family == AF_INET);
973 if (NULL == inet_ntop (AF_INET,
974 &sa->sin_addr,
975 inet4, INET_ADDRSTRLEN))
972 { 976 {
973 case AF_INET: 977 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
974 if (addrlen != sizeof (struct sockaddr_in))
975 return;
976 if (NULL == inet_ntop (AF_INET,
977 &((struct sockaddr_in *) sa)->sin_addr,
978 inet4, INET_ADDRSTRLEN))
979 {
980 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
981 return;
982 }
983 address_as_string = GNUNET_strdup (inet4);
984 break;
985 case AF_INET6:
986 default:
987 return; 978 return;
988 } 979 }
989 980 GNUNET_snprintf(port_as_string,
990 GNUNET_asprintf(&port_as_string, "%d", plugin->adv_port); 981 sizeof (port_as_string),
982 "%d",
983 plugin->adv_port);
991#if DEBUG_TCP_NAT 984#if DEBUG_TCP_NAT
992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 985 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
993 _("Running gnunet-nat-client with arguments: %s %s %d\n"), plugin->external_address, address_as_string, plugin->adv_port); 986 "tcp",
987 _("Running gnunet-nat-client %s %s %u\n"),
988 plugin->external_address,
989 inet4,
990 (unsigned int) plugin->adv_port);
994#endif 991#endif
995 992 proc = GNUNET_OS_start_process (NULL,
996 /* Start the client process */ 993 NULL,
997 proc = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL); 994 "gnunet-nat-client",
998 GNUNET_free(address_as_string); 995 "gnunet-nat-client",
999 GNUNET_free(port_as_string); 996 plugin->external_address,
997 inet4,
998 port_as_string,
999 NULL);
1000 /* we know that the gnunet-nat-client will terminate virtually
1001 instantly */
1000 GNUNET_OS_process_wait (proc); 1002 GNUNET_OS_process_wait (proc);
1001 GNUNET_OS_process_close (proc); 1003 GNUNET_OS_process_close (proc);
1002 proc = NULL;
1003} 1004}
1004 1005
1005 1006
@@ -1102,14 +1103,8 @@ tcp_plugin_send (void *cls,
1102 GNUNET_break (0); 1103 GNUNET_break (0);
1103 break; 1104 break;
1104 } 1105 }
1105#if IGNORE_INBOUND 1106 if ( (addrlen != session->connect_alen) &&
1106 if (session->inbound == GNUNET_YES) /* FIXME: why do we ignore inbound sessions? */ 1107 (session->is_nat == GNUNET_NO) )
1107 {
1108 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ignoring inbound session\n");
1109 continue;
1110 }
1111#endif
1112 if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO))
1113 continue; 1108 continue;
1114 if ((0 != memcmp (session->connect_addr, 1109 if ((0 != memcmp (session->connect_addr,
1115 addr, 1110 addr,
@@ -1124,8 +1119,9 @@ tcp_plugin_send (void *cls,
1124 (addr == NULL) ) 1119 (addr == NULL) )
1125 { 1120 {
1126#if DEBUG_TCP 1121#if DEBUG_TCP
1127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1122 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1128 "Asked to transmit to `%4s' without address and I have no existing connection (failing).\n", 1123 "tcp",
1124 "Asked to transmit to `%4s' without address and I have no existing connection (failing).\n",
1129 GNUNET_i2s (target)); 1125 GNUNET_i2s (target));
1130#endif 1126#endif
1131 GNUNET_STATISTICS_update (plugin->env->stats, 1127 GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1172,7 +1168,8 @@ tcp_plugin_send (void *cls,
1172 } 1168 }
1173 else 1169 else
1174 { 1170 {
1175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1171 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
1172 "tcp",
1176 _("Address of unexpected length: %u\n"), 1173 _("Address of unexpected length: %u\n"),
1177 addrlen); 1174 addrlen);
1178 GNUNET_break (0); 1175 GNUNET_break (0);
@@ -1187,7 +1184,8 @@ tcp_plugin_send (void *cls,
1187 (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &target->hashPubKey))) 1184 (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &target->hashPubKey)))
1188 { 1185 {
1189#if DEBUG_TCP_NAT 1186#if DEBUG_TCP_NAT
1190 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1187 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1188 "tcp",
1191 _("Found valid IPv4 NAT address (creating session)!\n")); 1189 _("Found valid IPv4 NAT address (creating session)!\n"));
1192#endif 1190#endif
1193 session = create_session (plugin, 1191 session = create_session (plugin,
@@ -1214,12 +1212,13 @@ tcp_plugin_send (void *cls,
1214 1212
1215 GNUNET_assert(GNUNET_CONTAINER_multihashmap_put(plugin->nat_wait_conns, &target->hashPubKey, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == GNUNET_OK); 1213 GNUNET_assert(GNUNET_CONTAINER_multihashmap_put(plugin->nat_wait_conns, &target->hashPubKey, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == GNUNET_OK);
1216#if DEBUG_TCP_NAT 1214#if DEBUG_TCP_NAT
1217 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1215 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1216 "tcp",
1218 "Created NAT WAIT connection to `%4s' at `%s'\n", 1217 "Created NAT WAIT connection to `%4s' at `%s'\n",
1219 GNUNET_i2s (target), 1218 GNUNET_i2s (target),
1220 GNUNET_a2s (sb, sbs)); 1219 GNUNET_a2s (sb, sbs));
1221#endif 1220#endif
1222 run_gnunet_nat_client (plugin, sb, sbs); 1221 run_gnunet_nat_client (plugin, &a4);
1223 return 0; 1222 return 0;
1224 } 1223 }
1225 else if ((plugin->allow_nat == GNUNET_YES) && (is_natd == GNUNET_YES) && (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &target->hashPubKey))) 1224 else if ((plugin->allow_nat == GNUNET_YES) && (is_natd == GNUNET_YES) && (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &target->hashPubKey)))
@@ -1231,7 +1230,8 @@ tcp_plugin_send (void *cls,
1231 if (sa == NULL) 1230 if (sa == NULL)
1232 { 1231 {
1233#if DEBUG_TCP 1232#if DEBUG_TCP
1234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1233 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1234 "tcp",
1235 "Failed to create connection to `%4s' at `%s'\n", 1235 "Failed to create connection to `%4s' at `%s'\n",
1236 GNUNET_i2s (target), 1236 GNUNET_i2s (target),
1237 GNUNET_a2s (sb, sbs)); 1237 GNUNET_a2s (sb, sbs));
@@ -1243,7 +1243,8 @@ tcp_plugin_send (void *cls,
1243 return -1; 1243 return -1;
1244 } 1244 }
1245#if DEBUG_TCP_NAT 1245#if DEBUG_TCP_NAT
1246 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1246 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1247 "tcp",
1247 "Asked to transmit to `%4s', creating fresh session using address `%s'.\n", 1248 "Asked to transmit to `%4s', creating fresh session using address `%s'.\n",
1248 GNUNET_i2s (target), 1249 GNUNET_i2s (target),
1249 GNUNET_a2s (sb, sbs)); 1250 GNUNET_a2s (sb, sbs));
@@ -1279,7 +1280,8 @@ tcp_plugin_send (void *cls,
1279 session->pending_messages_tail, 1280 session->pending_messages_tail,
1280 pm); 1281 pm);
1281#if DEBUG_TCP 1282#if DEBUG_TCP
1282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1283 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1284 "tcp",
1283 "Asked to transmit %u bytes to `%s', added message to list.\n", 1285 "Asked to transmit %u bytes to `%s', added message to list.\n",
1284 msgbuf_size, 1286 msgbuf_size,
1285 GNUNET_i2s (target)); 1287 GNUNET_i2s (target));
@@ -1315,7 +1317,8 @@ tcp_plugin_disconnect (void *cls,
1315 struct PendingMessage *pm; 1317 struct PendingMessage *pm;
1316 1318
1317#if DEBUG_TCP 1319#if DEBUG_TCP
1318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1320 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1321 "tcp",
1319 "Asked to cancel session with `%4s'\n", 1322 "Asked to cancel session with `%4s'\n",
1320 GNUNET_i2s (target)); 1323 GNUNET_i2s (target));
1321#endif 1324#endif
@@ -1573,7 +1576,9 @@ handle_tcp_nat_probe (void *cls,
1573 const struct sockaddr_in6 *s6; 1576 const struct sockaddr_in6 *s6;
1574 1577
1575#if DEBUG_TCP_NAT 1578#if DEBUG_TCP_NAT
1576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received tcp NAT probe\n"); 1579 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1580 "tcp",
1581 "received tcp NAT probe\n");
1577#endif 1582#endif
1578 /* We have received a TCP NAT probe, meaning we (hopefully) initiated 1583 /* We have received a TCP NAT probe, meaning we (hopefully) initiated
1579 * a connection to this peer by running gnunet-nat-client. This peer 1584 * a connection to this peer by running gnunet-nat-client. This peer
@@ -1583,9 +1588,6 @@ handle_tcp_nat_probe (void *cls,
1583 */ 1588 */
1584 if (ntohs(message->size) != sizeof(struct TCP_NAT_ProbeMessage)) 1589 if (ntohs(message->size) != sizeof(struct TCP_NAT_ProbeMessage))
1585 { 1590 {
1586#if DEBUG_TCP_NAT
1587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bad size for tcp NAT probe, expected %d got %d.\n", sizeof(struct TCP_NAT_ProbeMessage), ntohs(message->size));
1588#endif
1589 GNUNET_break_op(0); 1591 GNUNET_break_op(0);
1590 return; 1592 return;
1591 } 1593 }
@@ -1594,7 +1596,9 @@ handle_tcp_nat_probe (void *cls,
1594 if (GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &tcp_nat_probe->clientIdentity.hashPubKey) == GNUNET_YES) 1596 if (GNUNET_CONTAINER_multihashmap_contains(plugin->nat_wait_conns, &tcp_nat_probe->clientIdentity.hashPubKey) == GNUNET_YES)
1595 { 1597 {
1596#if DEBUG_TCP_NAT 1598#if DEBUG_TCP_NAT
1597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found session for NAT probe!\n"); 1599 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1600 "tcp",
1601 "Found session for NAT probe!\n");
1598#endif 1602#endif
1599 session = GNUNET_CONTAINER_multihashmap_get(plugin->nat_wait_conns, &tcp_nat_probe->clientIdentity.hashPubKey); 1603 session = GNUNET_CONTAINER_multihashmap_get(plugin->nat_wait_conns, &tcp_nat_probe->clientIdentity.hashPubKey);
1600 GNUNET_assert(session != NULL); 1604 GNUNET_assert(session != NULL);
@@ -1608,7 +1612,8 @@ handle_tcp_nat_probe (void *cls,
1608 GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1612 GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1609 { 1613 {
1610#if DEBUG_TCP_NAT 1614#if DEBUG_TCP_NAT
1611 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1615 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1616 "tcp",
1612 "handle_tcp_nat_probe Found address `%s' for incoming connection %p\n", 1617 "handle_tcp_nat_probe Found address `%s' for incoming connection %p\n",
1613 GNUNET_a2s (vaddr, alen), 1618 GNUNET_a2s (vaddr, alen),
1614 client); 1619 client);
@@ -1636,8 +1641,9 @@ handle_tcp_nat_probe (void *cls,
1636 else 1641 else
1637 { 1642 {
1638#if DEBUG_TCP_NAT 1643#if DEBUG_TCP_NAT
1639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1644 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1640 "Bad address for incoming connection!\n"); 1645 "tcp",
1646 "Bad address for incoming connection!\n");
1641#endif 1647#endif
1642 } 1648 }
1643 GNUNET_free (vaddr); 1649 GNUNET_free (vaddr);
@@ -1654,7 +1660,9 @@ handle_tcp_nat_probe (void *cls,
1654 else 1660 else
1655 { 1661 {
1656#if DEBUG_TCP_NAT 1662#if DEBUG_TCP_NAT
1657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Did NOT find session for NAT probe!\n"); 1663 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1664 "tcp",
1665 "Did NOT find session for NAT probe!\n");
1658#endif 1666#endif
1659 } 1667 }
1660 1668
@@ -1685,7 +1693,8 @@ handle_tcp_welcome (void *cls,
1685 const struct sockaddr_in6 *s6; 1693 const struct sockaddr_in6 *s6;
1686 1694
1687#if DEBUG_TCP 1695#if DEBUG_TCP
1688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1696 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1697 "tcp",
1689 "Received %s message from a `%4s/%p'.\n", 1698 "Received %s message from a `%4s/%p'.\n",
1690 "WELCOME", 1699 "WELCOME",
1691 GNUNET_i2s (&wm->clientIdentity), client); 1700 GNUNET_i2s (&wm->clientIdentity), client);
@@ -1694,17 +1703,14 @@ handle_tcp_welcome (void *cls,
1694 gettext_noop ("# TCP WELCOME messages received"), 1703 gettext_noop ("# TCP WELCOME messages received"),
1695 1, 1704 1,
1696 GNUNET_NO); 1705 GNUNET_NO);
1697#if MULTIPLE_PEER_SESSIONS
1698 session = find_session_by_client (plugin, client); 1706 session = find_session_by_client (plugin, client);
1699#else
1700 session = find_session_by_id(plugin, &wm->clientIdentity);
1701#endif
1702 1707
1703 if (session == NULL) 1708 if (session == NULL)
1704 { 1709 {
1705 GNUNET_SERVER_client_keep (client); 1710 GNUNET_SERVER_client_keep (client);
1706#if DEBUG_TCP_NAT 1711#if DEBUG_TCP_NAT
1707 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1712 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1713 "tcp",
1708 "Received %s message from a `%4s/%p', creating session\n", 1714 "Received %s message from a `%4s/%p', creating session\n",
1709 "WELCOME", 1715 "WELCOME",
1710 GNUNET_i2s (&wm->clientIdentity), client); 1716 GNUNET_i2s (&wm->clientIdentity), client);
@@ -1716,7 +1722,8 @@ handle_tcp_welcome (void *cls,
1716 GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1722 GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1717 { 1723 {
1718#if DEBUG_TCP_NAT 1724#if DEBUG_TCP_NAT
1719 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1725 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1726 "tcp",
1720 "Found address `%s' for incoming connection %p\n", 1727 "Found address `%s' for incoming connection %p\n",
1721 GNUNET_a2s (vaddr, alen), 1728 GNUNET_a2s (vaddr, alen),
1722 client); 1729 client);
@@ -1747,12 +1754,14 @@ handle_tcp_welcome (void *cls,
1747 else 1754 else
1748 { 1755 {
1749#if DEBUG_TCP 1756#if DEBUG_TCP
1750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1757 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1758 "tcp",
1751 "Did not obtain TCP socket address for incoming connection\n"); 1759 "Did not obtain TCP socket address for incoming connection\n");
1752#endif 1760#endif
1753 } 1761 }
1754#if DEBUG_TCP 1762#if DEBUG_TCP
1755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1763 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1764 "tcp",
1756 "Creating new session %p for connection %p\n", 1765 "Creating new session %p for connection %p\n",
1757 session, client); 1766 session, client);
1758#endif 1767#endif
@@ -1764,22 +1773,21 @@ handle_tcp_welcome (void *cls,
1764 if (GNUNET_OK == 1773 if (GNUNET_OK ==
1765 GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1774 GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1766 { 1775 {
1767 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1776 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1768 "Found address `%s' (already have session) for incoming connection %p\n", 1777 "tcp",
1769 GNUNET_a2s (vaddr, alen), 1778 "Found address `%s' (already have session) for incoming connection %p\n",
1770 client); 1779 GNUNET_a2s (vaddr, alen),
1780 client);
1771 } 1781 }
1772#endif 1782#endif
1773 } 1783 }
1774 1784
1775#if MULTIPLE_PEER_SESSIONS
1776 if (session->expecting_welcome != GNUNET_YES) 1785 if (session->expecting_welcome != GNUNET_YES)
1777 { 1786 {
1778 GNUNET_break_op (0); 1787 GNUNET_break_op (0);
1779 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1788 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1780 return; 1789 return;
1781 } 1790 }
1782#endif
1783 session->last_activity = GNUNET_TIME_absolute_get (); 1791 session->last_activity = GNUNET_TIME_absolute_get ();
1784 session->expecting_welcome = GNUNET_NO; 1792 session->expecting_welcome = GNUNET_NO;
1785 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1793 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -1844,7 +1852,8 @@ handle_tcp_data (void *cls,
1844 } 1852 }
1845 session->last_activity = GNUNET_TIME_absolute_get (); 1853 session->last_activity = GNUNET_TIME_absolute_get ();
1846#if DEBUG_TCP > 1 1854#if DEBUG_TCP > 1
1847 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1855 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1856 "tcp",
1848 "Passing %u bytes of type %u from `%4s' to transport service.\n", 1857 "Passing %u bytes of type %u from `%4s' to transport service.\n",
1849 (unsigned int) ntohs (message->size), 1858 (unsigned int) ntohs (message->size),
1850 (unsigned int) ntohs (message->type), 1859 (unsigned int) ntohs (message->type),
@@ -1886,7 +1895,8 @@ disconnect_notify (void *cls,
1886 if (session == NULL) 1895 if (session == NULL)
1887 return; /* unknown, nothing to do */ 1896 return; /* unknown, nothing to do */
1888#if DEBUG_TCP 1897#if DEBUG_TCP
1889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1898 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1899 "tcp",
1890 "Destroying session of `%4s' with %s (%p) due to network-level disconnect.\n", 1900 "Destroying session of `%4s' with %s (%p) due to network-level disconnect.\n",
1891 GNUNET_i2s (&session->target), 1901 GNUNET_i2s (&session->target),
1892 (session->connect_addr != NULL) ? 1902 (session->connect_addr != NULL) ?
@@ -1935,7 +1945,10 @@ process_interfaces (void *cls,
1935 GNUNET_assert(NULL != inet_ntop(AF_INET, &t4.ipv4_addr, &buf[0], INET_ADDRSTRLEN)); 1945 GNUNET_assert(NULL != inet_ntop(AF_INET, &t4.ipv4_addr, &buf[0], INET_ADDRSTRLEN));
1936 if ((plugin->bind_address != NULL) && (0 != strcmp(buf, plugin->bind_address))) 1946 if ((plugin->bind_address != NULL) && (0 != strcmp(buf, plugin->bind_address)))
1937 { 1947 {
1938 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Not notifying transport of address %s\n", "TCP", GNUNET_a2s (addr, addrlen)); 1948 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1949 "tcp",
1950 "Not notifying transport of address %s\n",
1951 GNUNET_a2s (addr, addrlen));
1939 return GNUNET_OK; 1952 return GNUNET_OK;
1940 } 1953 }
1941 add_to_address_list (plugin, &t4.ipv4_addr, sizeof (uint32_t)); 1954 add_to_address_list (plugin, &t4.ipv4_addr, sizeof (uint32_t));
@@ -1954,7 +1967,8 @@ process_interfaces (void *cls,
1954 } 1967 }
1955 else if (af == AF_INET6) 1968 else if (af == AF_INET6)
1956 { 1969 {
1957 if ((IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *) addr)->sin6_addr)) || (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(plugin->env->cfg, "transport-tcp", "disablev6"))) 1970 if ( (IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *) addr)->sin6_addr)) ||
1971 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(plugin->env->cfg, "transport-tcp", "DISABLEV6")) )
1958 { 1972 {
1959 /* skip link local addresses */ 1973 /* skip link local addresses */
1960 return GNUNET_OK; 1974 return GNUNET_OK;
@@ -1983,19 +1997,20 @@ process_interfaces (void *cls,
1983 GNUNET_break (0); 1997 GNUNET_break (0);
1984 return GNUNET_OK; 1998 return GNUNET_OK;
1985 } 1999 }
1986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2000 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
2001 "tcp",
1987 _("Found address `%s' (%s) len %d\n"), 2002 _("Found address `%s' (%s) len %d\n"),
1988 GNUNET_a2s (addr, addrlen), name, args); 2003 GNUNET_a2s (addr, addrlen), name, args);
1989
1990 plugin->env->notify_address (plugin->env->cls, 2004 plugin->env->notify_address (plugin->env->cls,
1991 "tcp", 2005 "tcp",
1992 arg, args, GNUNET_TIME_UNIT_FOREVER_REL); 2006 arg, args, GNUNET_TIME_UNIT_FOREVER_REL);
1993 2007
1994 if (arg_nat != NULL) 2008 if (arg_nat != NULL)
1995 { 2009 {
1996 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2010 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1997 _("Found address `%s' (%s) len %d\n"), 2011 "tcp",
1998 GNUNET_a2s (addr, addrlen), name, args); 2012 _("Found address `%s' (%s) len %d\n"),
2013 GNUNET_a2s (addr, addrlen), name, args);
1999 plugin->env->notify_address (plugin->env->cls, 2014 plugin->env->notify_address (plugin->env->cls,
2000 "tcp", 2015 "tcp",
2001 arg_nat, args, GNUNET_TIME_UNIT_FOREVER_REL); 2016 arg_nat, args, GNUNET_TIME_UNIT_FOREVER_REL);
@@ -2055,39 +2070,42 @@ static size_t notify_send_probe (void *cls,
2055 return sizeof(tcp_probe_ctx->message); 2070 return sizeof(tcp_probe_ctx->message);
2056} 2071}
2057 2072
2058/* 2073
2059 * @param cls the plugin handle 2074/**
2060 * @param tc the scheduling context (for rescheduling this function again)
2061 *
2062 * We have been notified that gnunet-nat-server has written something to stdout. 2075 * We have been notified that gnunet-nat-server has written something to stdout.
2063 * Handle the output, then reschedule this function to be called again once 2076 * Handle the output, then reschedule this function to be called again once
2064 * more is available. 2077 * more is available.
2065 * 2078 *
2079 * @param cls the plugin handle
2080 * @param tc the scheduling context
2066 */ 2081 */
2067static void 2082static void
2068tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 2083tcp_plugin_server_read (void *cls,
2084 const struct GNUNET_SCHEDULER_TaskContext *tc)
2069{ 2085{
2070 struct Plugin *plugin = cls; 2086 struct Plugin *plugin = cls;
2071 char mybuf[40]; 2087 char mybuf[40];
2072 ssize_t bytes; 2088 ssize_t bytes;
2073 memset(&mybuf, 0, sizeof(mybuf)); 2089 size_t i;
2074 int i;
2075 int port; 2090 int port;
2076 char *port_start; 2091 const char *port_start;
2077 struct sockaddr_in in_addr; 2092 struct sockaddr_in sin_addr;
2078 struct TCPProbeContext *tcp_probe_ctx; 2093 struct TCPProbeContext *tcp_probe_ctx;
2079 struct GNUNET_CONNECTION_Handle *sock; 2094 struct GNUNET_CONNECTION_Handle *sock;
2080 2095
2081 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 2096 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2082 return; 2097 return;
2083 2098 memset (mybuf, 0, sizeof(mybuf));
2084 bytes = GNUNET_DISK_file_read(plugin->server_stdout_handle, &mybuf, sizeof(mybuf)); 2099 bytes = GNUNET_DISK_file_read(plugin->server_stdout_handle,
2085 2100 mybuf,
2101 sizeof(mybuf));
2086 if (bytes < 1) 2102 if (bytes < 1)
2087 { 2103 {
2088#if DEBUG_TCP_NAT 2104#if DEBUG_TCP_NAT
2089 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2105 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
2090 _("Finished reading from server stdout with code: %d\n"), bytes); 2106 "tcp",
2107 "Finished reading from server stdout with code: %d\n",
2108 bytes);
2091#endif 2109#endif
2092 return; 2110 return;
2093 } 2111 }
@@ -2105,75 +2123,86 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2105 } 2123 }
2106 } 2124 }
2107 2125
2108 if (port_start != NULL) 2126 /* construct socket address of sender */
2109 port = atoi(port_start); 2127 memset (&sin_addr, 0, sizeof (sin_addr));
2110 else 2128 sin_addr.sin_family = AF_INET;
2111 { 2129 sin_addr.sin_port = htons((uint16_t) port);
2112 plugin->server_read_task = 2130#if HAVE_SOCKADDR_IN_SIN_LEN
2113 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 2131 sin_addr.sin_len = sizeof (sin_addr);
2114 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2132#endif
2133 if ( (NULL == port_start) ||
2134 (1 != sscanf (port_start, "%d", &port)) ||
2135 (-1 == inet_pton(AF_INET, mybuf, &sin_addr.sin_addr)) )
2136 {
2137 /* should we restart gnunet-nat-server? */
2138 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
2139 "tcp",
2140 _("gnunet-nat-server generated malformed address `%s'\n"),
2141 mybuf);
2142 plugin->server_read_task
2143 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2144 plugin->server_stdout_handle,
2145 &tcp_plugin_server_read,
2146 plugin);
2115 return; 2147 return;
2116 } 2148 }
2117 2149
2118#if DEBUG_TCP_NAT 2150#if DEBUG_TCP_NAT
2119 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2151 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
2120 _("nat-server-read read: %s port %d\n"), &mybuf, port); 2152 "tcp",
2153 "gnunet-nat-server read: %s:%d\n",
2154 mybuf, port);
2121#endif 2155#endif
2122 2156
2123
2124 if (inet_pton(AF_INET, &mybuf[0], &in_addr.sin_addr) != 1)
2125 {
2126
2127 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2128 _("nat-server-read malformed address\n"), &mybuf, port);
2129
2130 plugin->server_read_task =
2131 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2132 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
2133 return;
2134 }
2135
2136 in_addr.sin_family = AF_INET;
2137 in_addr.sin_port = htons(port);
2138 /** 2157 /**
2139 * We have received an ICMP response, ostensibly from a non-NAT'd peer 2158 * We have received an ICMP response, ostensibly from a peer
2140 * that wants to connect to us! Send a message to establish a connection. 2159 * that wants to connect to us! Send a message to establish a connection.
2141 */ 2160 */
2142 sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, (struct sockaddr *)&in_addr, 2161 sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET,
2143 sizeof(in_addr)); 2162 (const struct sockaddr *)&sin_addr,
2144 2163 sizeof (sin_addr));
2145
2146 if (sock == NULL) 2164 if (sock == NULL)
2147 { 2165 {
2166 /* failed for some odd reason (out of sockets?); ignore attempt */
2148 plugin->server_read_task = 2167 plugin->server_read_task =
2149 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 2168 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2150 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2169 plugin->server_stdout_handle,
2170 &tcp_plugin_server_read,
2171 plugin);
2151 return; 2172 return;
2152 } 2173 }
2153 else
2154 {
2155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2156 _("Sending TCP probe message!\n"), &mybuf, port);
2157
2158 tcp_probe_ctx = GNUNET_malloc(sizeof(struct TCPProbeContext));
2159 tcp_probe_ctx->message.header.size = htons(sizeof(struct TCP_NAT_ProbeMessage));
2160 tcp_probe_ctx->message.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
2161 memcpy(&tcp_probe_ctx->message.clientIdentity, plugin->env->my_identity, sizeof(struct GNUNET_PeerIdentity));
2162 tcp_probe_ctx->plugin = plugin;
2163 tcp_probe_ctx->sock = sock;
2164 tcp_probe_ctx->transmit_handle = GNUNET_CONNECTION_notify_transmit_ready (sock,
2165 ntohs(tcp_probe_ctx->message.header.size),
2166 GNUNET_TIME_UNIT_FOREVER_REL,
2167 &notify_send_probe, tcp_probe_ctx);
2168
2169 }
2170 2174
2171 /*GNUNET_SERVER_connect_socket(plugin->server, sock);*/ 2175 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
2176 "Sending TCP probe message to `%s:%u'!\n",
2177 mybuf,
2178 (unsigned int) port);
2179 /* FIXME: do we need to track these probe context objects so that
2180 we can clean them up on plugin unload? */
2181 tcp_probe_ctx
2182 = GNUNET_malloc(sizeof(struct TCPProbeContext));
2183 tcp_probe_ctx->message.header.size
2184 = htons(sizeof(struct TCP_NAT_ProbeMessage));
2185 tcp_probe_ctx->message.header.type
2186 = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
2187 memcpy (&tcp_probe_ctx->message.clientIdentity,
2188 plugin->env->my_identity,
2189 sizeof(struct GNUNET_PeerIdentity));
2190 tcp_probe_ctx->plugin = plugin;
2191 tcp_probe_ctx->sock = sock;
2192 tcp_probe_ctx->transmit_handle
2193 = GNUNET_CONNECTION_notify_transmit_ready (sock,
2194 ntohs (tcp_probe_ctx->message.header.size),
2195 GNUNET_TIME_UNIT_FOREVER_REL,
2196 &notify_send_probe, tcp_probe_ctx);
2197
2172 plugin->server_read_task = 2198 plugin->server_read_task =
2173 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 2199 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
2174 plugin->server_stdout_handle, &tcp_plugin_server_read, plugin); 2200 plugin->server_stdout_handle,
2201 &tcp_plugin_server_read,
2202 plugin);
2175} 2203}
2176 2204
2205
2177/** 2206/**
2178 * Start the gnunet-nat-server process for users behind NAT. 2207 * Start the gnunet-nat-server process for users behind NAT.
2179 * 2208 *
@@ -2184,13 +2213,15 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2184static int 2213static int
2185tcp_transport_start_nat_server(struct Plugin *plugin) 2214tcp_transport_start_nat_server(struct Plugin *plugin)
2186{ 2215{
2187 2216 plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES,
2188 plugin->server_stdout = GNUNET_DISK_pipe(GNUNET_YES, GNUNET_NO, GNUNET_YES); 2217 GNUNET_NO,
2218 GNUNET_YES);
2189 if (plugin->server_stdout == NULL) 2219 if (plugin->server_stdout == NULL)
2190 return GNUNET_SYSERR; 2220 return GNUNET_SYSERR;
2191 2221
2192#if DEBUG_TCP_NAT 2222#if DEBUG_TCP_NAT
2193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2223 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
2224 "tcp"
2194 "Starting gnunet-nat-server process cmd: %s %s\n", "gnunet-nat-server", plugin->internal_address); 2225 "Starting gnunet-nat-server process cmd: %s %s\n", "gnunet-nat-server", plugin->internal_address);
2195#endif 2226#endif
2196 /* Start the server process */ 2227 /* Start the server process */