aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-communicator-tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-communicator-tcp.c')
-rw-r--r--src/transport/gnunet-communicator-tcp.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 273dbac48..c8a4c0375 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -739,7 +739,6 @@ struct Addresses
739}; 739};
740 740
741 741
742
743/** 742/**
744 * Maximum queue length before we stop reading towards the transport service. 743 * Maximum queue length before we stop reading towards the transport service.
745 */ 744 */
@@ -953,6 +952,9 @@ queue_destroy (struct Queue *queue)
953 else 952 else
954 GNUNET_free (queue); 953 GNUNET_free (queue);
955 954
955 if (NULL == lt)
956 return;
957
956 if ((! shutdown_running) && (NULL == lt->listen_task)) 958 if ((! shutdown_running) && (NULL == lt->listen_task))
957 { 959 {
958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 960 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1193,6 +1195,7 @@ setup_cipher (const struct GNUNET_HashCode *dh,
1193 0)); 1195 0));
1194} 1196}
1195 1197
1198
1196/** 1199/**
1197 * Callback called when peerstore store operation for rekey monotime value is finished. 1200 * Callback called when peerstore store operation for rekey monotime value is finished.
1198 * @param cls Queue context the store operation was executed. 1201 * @param cls Queue context the store operation was executed.
@@ -1210,6 +1213,7 @@ rekey_monotime_store_cb (void *cls, int success)
1210 queue->rekey_monotime_sc = NULL; 1213 queue->rekey_monotime_sc = NULL;
1211} 1214}
1212 1215
1216
1213/** 1217/**
1214 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY 1218 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY
1215 * where found. 1219 * where found.
@@ -1266,6 +1270,7 @@ rekey_monotime_cb (void *cls,
1266 queue); 1270 queue);
1267} 1271}
1268 1272
1273
1269/** 1274/**
1270 * Setup cipher of @a queue for decryption. 1275 * Setup cipher of @a queue for decryption.
1271 * 1276 *
@@ -1344,6 +1349,7 @@ do_rekey (struct Queue *queue, const struct TCPRekey *rekey)
1344 setup_in_cipher (&rekey->ephemeral, queue); 1349 setup_in_cipher (&rekey->ephemeral, queue);
1345} 1350}
1346 1351
1352
1347/** 1353/**
1348 * Callback called when peerstore store operation for handshake ack monotime value is finished. 1354 * Callback called when peerstore store operation for handshake ack monotime value is finished.
1349 * @param cls Queue context the store operation was executed. 1355 * @param cls Queue context the store operation was executed.
@@ -1362,6 +1368,7 @@ handshake_ack_monotime_store_cb (void *cls, int success)
1362 queue->handshake_ack_monotime_sc = NULL; 1368 queue->handshake_ack_monotime_sc = NULL;
1363} 1369}
1364 1370
1371
1365/** 1372/**
1366 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK 1373 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK
1367 * where found. 1374 * where found.
@@ -1420,6 +1427,7 @@ handshake_ack_monotime_cb (void *cls,
1420 queue); 1427 queue);
1421} 1428}
1422 1429
1430
1423/** 1431/**
1424 * Sending challenge with TcpConfirmationAck back to sender of ephemeral key. 1432 * Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
1425 * 1433 *
@@ -1465,6 +1473,7 @@ send_challenge (struct ChallengeNonceP challenge, struct Queue *queue)
1465 "sending challenge done\n"); 1473 "sending challenge done\n");
1466} 1474}
1467 1475
1476
1468/** 1477/**
1469 * Setup cipher for outgoing data stream based on target and 1478 * Setup cipher for outgoing data stream based on target and
1470 * our ephemeral private key. 1479 * our ephemeral private key.
@@ -1545,6 +1554,7 @@ inject_rekey (struct Queue *queue)
1545 setup_out_cipher (queue); 1554 setup_out_cipher (queue);
1546} 1555}
1547 1556
1557
1548/** 1558/**
1549 * We have been notified that our socket is ready to write. 1559 * We have been notified that our socket is ready to write.
1550 * Then reschedule this function to be called again once more is available. 1560 * Then reschedule this function to be called again once more is available.
@@ -1634,6 +1644,7 @@ queue_write (void *cls)
1634 queue); 1644 queue);
1635} 1645}
1636 1646
1647
1637/** 1648/**
1638 * Test if we have received a full message in plaintext. 1649 * Test if we have received a full message in plaintext.
1639 * If so, handle it. 1650 * If so, handle it.
@@ -1975,6 +1986,7 @@ queue_read (void *cls)
1975 queue_finish (queue); 1986 queue_finish (queue);
1976} 1987}
1977 1988
1989
1978/** 1990/**
1979 * Convert a `struct sockaddr_in6 to a `struct sockaddr *` 1991 * Convert a `struct sockaddr_in6 to a `struct sockaddr *`
1980 * 1992 *
@@ -2001,6 +2013,7 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
2001 return in; 2013 return in;
2002} 2014}
2003 2015
2016
2004/** 2017/**
2005 * Convert a `struct sockaddr_in4 to a `struct sockaddr *` 2018 * Convert a `struct sockaddr_in4 to a `struct sockaddr *`
2006 * 2019 *
@@ -2024,6 +2037,7 @@ tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4,
2024 return in; 2037 return in;
2025} 2038}
2026 2039
2040
2027/** 2041/**
2028 * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *` 2042 * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *`
2029 * 2043 *
@@ -2083,6 +2097,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
2083 return po; 2097 return po;
2084} 2098}
2085 2099
2100
2086/** 2101/**
2087 * This Method extracts the address part of the BINDTO string. 2102 * This Method extracts the address part of the BINDTO string.
2088 * 2103 *
@@ -2117,7 +2132,8 @@ extract_address (const char *bindto)
2117 start++; /* skip over '['*/ 2132 start++; /* skip over '['*/
2118 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ 2133 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
2119 } 2134 }
2120 else { 2135 else
2136 {
2121 token = strtok_r (cp, "]", &rest); 2137 token = strtok_r (cp, "]", &rest);
2122 if (strlen (bindto) == strlen (token)) 2138 if (strlen (bindto) == strlen (token))
2123 { 2139 {
@@ -2139,6 +2155,7 @@ extract_address (const char *bindto)
2139 return start; 2155 return start;
2140} 2156}
2141 2157
2158
2142/** 2159/**
2143 * This Method extracts the port part of the BINDTO string. 2160 * This Method extracts the port part of the BINDTO string.
2144 * 2161 *
@@ -2217,6 +2234,7 @@ extract_port (const char *addr_and_port)
2217 return port; 2234 return port;
2218} 2235}
2219 2236
2237
2220/** 2238/**
2221 * Convert TCP bind specification to a `struct sockaddr *` 2239 * Convert TCP bind specification to a `struct sockaddr *`
2222 * 2240 *
@@ -2245,7 +2263,6 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2245 bindto); 2263 bindto);
2246 2264
2247 2265
2248
2249 if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) 2266 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
2250 { 2267 {
2251 // colon = strrchr (cp, ':'); 2268 // colon = strrchr (cp, ':');
@@ -2263,7 +2280,8 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2263 port = extract_port (bindto); 2280 port = extract_port (bindto);
2264 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); 2281 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port);
2265 } 2282 }
2266 else{ 2283 else
2284 {
2267 GNUNET_assert (0); 2285 GNUNET_assert (0);
2268 } 2286 }
2269 2287
@@ -2272,6 +2290,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2272 return in; 2290 return in;
2273} 2291}
2274 2292
2293
2275/** 2294/**
2276 * Signature of functions implementing the sending functionality of a 2295 * Signature of functions implementing the sending functionality of a
2277 * message queue. 2296 * message queue.
@@ -2510,6 +2529,7 @@ start_initial_kx_out (struct Queue *queue)
2510 transmit_kx (queue, &epub); 2529 transmit_kx (queue, &epub);
2511} 2530}
2512 2531
2532
2513/** 2533/**
2514 * Callback called when peerstore store operation for handshake monotime is finished. 2534 * Callback called when peerstore store operation for handshake monotime is finished.
2515 * @param cls Queue context the store operation was executed. 2535 * @param cls Queue context the store operation was executed.
@@ -2527,6 +2547,7 @@ handshake_monotime_store_cb (void *cls, int success)
2527 queue->handshake_monotime_sc = NULL; 2547 queue->handshake_monotime_sc = NULL;
2528} 2548}
2529 2549
2550
2530/** 2551/**
2531 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE 2552 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE
2532 * where found. 2553 * where found.
@@ -2585,6 +2606,7 @@ handshake_monotime_cb (void *cls,
2585 queue); 2606 queue);
2586} 2607}
2587 2608
2609
2588/** 2610/**
2589 * We have received the first bytes from the other side on a @a queue. 2611 * We have received the first bytes from the other side on a @a queue.
2590 * Decrypt the @a tc contained in @a ibuf and check the signature. 2612 * Decrypt the @a tc contained in @a ibuf and check the signature.
@@ -2651,6 +2673,7 @@ free_proto_queue (struct ProtoQueue *pq)
2651 GNUNET_free (pq); 2673 GNUNET_free (pq);
2652} 2674}
2653 2675
2676
2654/** 2677/**
2655 * Read from the socket of the proto queue until we have enough data 2678 * Read from the socket of the proto queue until we have enough data
2656 * to upgrade to full queue. 2679 * to upgrade to full queue.
@@ -2892,6 +2915,7 @@ queue_read_kx (void *cls)
2892 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); 2915 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue);
2893} 2916}
2894 2917
2918
2895/** 2919/**
2896 * Function called by the transport service to initialize a 2920 * Function called by the transport service to initialize a
2897 * message queue given address information about another peer. 2921 * message queue given address information about another peer.
@@ -2991,6 +3015,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2991 return GNUNET_OK; 3015 return GNUNET_OK;
2992} 3016}
2993 3017
3018
2994/** 3019/**
2995 * Iterator over all ListenTasks to clean up. 3020 * Iterator over all ListenTasks to clean up.
2996 * 3021 *
@@ -3021,6 +3046,7 @@ get_lt_delete_it (void *cls,
3021 return GNUNET_OK; 3046 return GNUNET_OK;
3022} 3047}
3023 3048
3049
3024/** 3050/**
3025 * Iterator over all message queues to clean up. 3051 * Iterator over all message queues to clean up.
3026 * 3052 *
@@ -3042,6 +3068,7 @@ get_queue_delete_it (void *cls,
3042 return GNUNET_OK; 3068 return GNUNET_OK;
3043} 3069}
3044 3070
3071
3045/** 3072/**
3046 * Shutdown the UNIX communicator. 3073 * Shutdown the UNIX communicator.
3047 * 3074 *
@@ -3182,6 +3209,7 @@ nat_address_cb (void *cls,
3182 } 3209 }
3183} 3210}
3184 3211
3212
3185/** 3213/**
3186 * This method adds addresses to the DLL, that are later register at the NAT service. 3214 * This method adds addresses to the DLL, that are later register at the NAT service.
3187 */ 3215 */
@@ -3211,6 +3239,7 @@ add_addr (struct sockaddr *in, socklen_t in_len)
3211 addrs_lens++; 3239 addrs_lens++;
3212} 3240}
3213 3241
3242
3214/** 3243/**
3215 * This method launch network interactions for each address we like to bind to. 3244 * This method launch network interactions for each address we like to bind to.
3216 * 3245 *
@@ -3336,7 +3365,7 @@ init_socket (struct sockaddr *addr,
3336 if (NULL == queue_map) 3365 if (NULL == queue_map)
3337 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 3366 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
3338 3367
3339 if (NULL == ch ) 3368 if (NULL == ch)
3340 ch = GNUNET_TRANSPORT_communicator_connect (cfg, 3369 ch = GNUNET_TRANSPORT_communicator_connect (cfg,
3341 COMMUNICATOR_CONFIG_SECTION, 3370 COMMUNICATOR_CONFIG_SECTION,
3342 COMMUNICATOR_ADDRESS_PREFIX, 3371 COMMUNICATOR_ADDRESS_PREFIX,
@@ -3360,6 +3389,7 @@ init_socket (struct sockaddr *addr,
3360 3389
3361} 3390}
3362 3391
3392
3363/** 3393/**
3364 * This method reads from the DLL addrs_head to register them at the NAT service. 3394 * This method reads from the DLL addrs_head to register them at the NAT service.
3365 */ 3395 */
@@ -3421,6 +3451,7 @@ nat_register ()
3421 } 3451 }
3422} 3452}
3423 3453
3454
3424/** 3455/**
3425 * This method is the callback called by the resolver API, and wraps method init_socket. 3456 * This method is the callback called by the resolver API, and wraps method init_socket.
3426 * 3457 *
@@ -3476,6 +3507,7 @@ init_socket_resolv (void *cls,
3476 } 3507 }
3477} 3508}
3478 3509
3510
3479/** 3511/**
3480 * Setup communicator and launch network interactions. 3512 * Setup communicator and launch network interactions.
3481 * 3513 *