aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-15 15:37:38 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-15 15:37:38 +0000
commit2694b957d0db8668dc479699bfde4ba081bd09a7 (patch)
treee418c378077f633eb2347ab1d0ae97ec3a75cc8e /src
parent8d4671bb0e9e1ae40053a8250203e281b53c7d5c (diff)
downloadgnunet-2694b957d0db8668dc479699bfde4ba081bd09a7.tar.gz
gnunet-2694b957d0db8668dc479699bfde4ba081bd09a7.zip
-adding some rudimentary logging
Diffstat (limited to 'src')
-rw-r--r--src/exit/gnunet-daemon-exit.c98
1 files changed, 94 insertions, 4 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index f5dd1f585..cf72bf964 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -25,7 +25,6 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 * 26 *
27 * TODO: 27 * TODO:
28 * - need some logging
29 * - need some statistics 28 * - need some statistics
30 * - test 29 * - test
31 * 30 *
@@ -596,6 +595,20 @@ udp_from_helper (const struct udp_packet *udp,
596{ 595{
597 struct TunnelState *state; 596 struct TunnelState *state;
598 597
598 {
599 char sbuf[INET6_ADDRSTRLEN];
600 char dbuf[INET6_ADDRSTRLEN];
601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
602 "Received UDP packet going from %s:%u to %s:%u\n",
603 inet_ntop (af,
604 source_ip,
605 sbuf, sizeof (sbuf)),
606 (unsigned int) ntohs (udp->spt),
607 inet_ntop (af,
608 source_ip,
609 dbuf, sizeof (dbuf)),
610 (unsigned int) ntohs (udp->dpt));
611 }
599 if (pktlen < sizeof (struct udp_packet)) 612 if (pktlen < sizeof (struct udp_packet))
600 { 613 {
601 /* blame kernel */ 614 /* blame kernel */
@@ -651,6 +664,20 @@ tcp_from_helper (const struct tcp_packet *tcp,
651 char buf[pktlen]; 664 char buf[pktlen];
652 struct tcp_packet *mtcp; 665 struct tcp_packet *mtcp;
653 666
667 {
668 char sbuf[INET6_ADDRSTRLEN];
669 char dbuf[INET6_ADDRSTRLEN];
670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
671 "Received TCP packet going from %s:%u to %s:%u\n",
672 inet_ntop (af,
673 source_ip,
674 sbuf, sizeof (sbuf)),
675 (unsigned int) ntohs (tcp->spt),
676 inet_ntop (af,
677 source_ip,
678 dbuf, sizeof (dbuf)),
679 (unsigned int) ntohs (tcp->dpt));
680 }
654 if (pktlen < sizeof (struct tcp_packet)) 681 if (pktlen < sizeof (struct tcp_packet))
655 { 682 {
656 /* blame kernel */ 683 /* blame kernel */
@@ -940,12 +967,21 @@ setup_state_record (struct TunnelState *state)
940 state->serv->address.proto, 967 state->serv->address.proto,
941 &state->ri.local_address); 968 &state->ri.local_address);
942 } while (NULL != get_redirect_state (state->ri.remote_address.af, 969 } while (NULL != get_redirect_state (state->ri.remote_address.af,
943 IPPROTO_UDP, 970 state->ri.remote_address.proto,
944 &state->ri.remote_address.address, 971 &state->ri.remote_address.address,
945 state->ri.remote_address.port, 972 state->ri.remote_address.port,
946 &state->ri.local_address.address, 973 &state->ri.local_address.address,
947 state->ri.local_address.port, 974 state->ri.local_address.port,
948 &key)); 975 &key));
976 {
977 char buf[INET6_ADDRSTRLEN];
978 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
979 "Picked local address %s:%u for new connection\n",
980 inet_ntop (state->ri.local_address.af,
981 &state->ri.local_address.address,
982 buf, sizeof (buf)),
983 (unsigned int) state->ri.local_address.port);
984 }
949 GNUNET_assert (GNUNET_OK == 985 GNUNET_assert (GNUNET_OK ==
950 GNUNET_CONTAINER_multihashmap_put (connections_map, 986 GNUNET_CONTAINER_multihashmap_put (connections_map,
951 &key, state, 987 &key, state,
@@ -1194,6 +1230,9 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1194{ 1230{
1195 size_t len; 1231 size_t len;
1196 1232
1233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1234 "Sending packet with %u bytes TCP payload via TUN\n",
1235 (unsigned int) payload_length);
1197 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header); 1236 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header);
1198 switch (source_address->af) 1237 switch (source_address->af)
1199 { 1238 {
@@ -1304,6 +1343,11 @@ receive_tcp_service (void *unused GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunn
1304 } 1343 }
1305 GNUNET_break_op (ntohl (start->reserved) == 0); 1344 GNUNET_break_op (ntohl (start->reserved) == 0);
1306 /* setup fresh connection */ 1345 /* setup fresh connection */
1346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1347 "Received data from %s for forwarding to TCP service %s on port %u\n",
1348 GNUNET_i2s (sender),
1349 GNUNET_h2s (&start->service_descriptor),
1350 (unsigned int) ntohs (start->tcp_header.dpt));
1307 if (NULL == (state->serv = find_service (tcp_services, &start->service_descriptor, 1351 if (NULL == (state->serv = find_service (tcp_services, &start->service_descriptor,
1308 ntohs (start->tcp_header.dpt)))) 1352 ntohs (start->tcp_header.dpt))))
1309 { 1353 {
@@ -1394,6 +1438,17 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1394 GNUNET_break_op (0); 1438 GNUNET_break_op (0);
1395 return GNUNET_SYSERR; 1439 return GNUNET_SYSERR;
1396 } 1440 }
1441 {
1442 char buf[INET6_ADDRSTRLEN];
1443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1444 "Received data from %s for starting TCP stream to %s:%u\n",
1445 GNUNET_i2s (sender),
1446 inet_ntop (af,
1447 &state->ri.remote_address.address,
1448 buf, sizeof (buf)),
1449 (unsigned int) ntohs (start->tcp_header.dpt));
1450 }
1451
1397 state->ri.remote_address.proto = IPPROTO_TCP; 1452 state->ri.remote_address.proto = IPPROTO_TCP;
1398 state->ri.remote_address.port = ntohs (start->tcp_header.dpt); 1453 state->ri.remote_address.port = ntohs (start->tcp_header.dpt);
1399 setup_state_record (state); 1454 setup_state_record (state);
@@ -1445,6 +1500,17 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1445 return GNUNET_SYSERR; 1500 return GNUNET_SYSERR;
1446 } 1501 }
1447 GNUNET_break_op (ntohl (data->reserved) == 0); 1502 GNUNET_break_op (ntohl (data->reserved) == 0);
1503 {
1504 char buf[INET6_ADDRSTRLEN];
1505 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1506 "Received additional data from %s for TCP stream to %s:%u\n",
1507 GNUNET_i2s (sender),
1508 inet_ntop (state->ri.remote_address.af,
1509 &state->ri.remote_address.address,
1510 buf, sizeof (buf)),
1511 (unsigned int) state->ri.remote_address.port);
1512 }
1513
1448 send_tcp_packet_via_tun (&state->ri.remote_address, 1514 send_tcp_packet_via_tun (&state->ri.remote_address,
1449 &state->ri.local_address, 1515 &state->ri.local_address,
1450 &data->tcp_header, 1516 &data->tcp_header,
@@ -1468,6 +1534,9 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
1468{ 1534{
1469 size_t len; 1535 size_t len;
1470 1536
1537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1538 "Sending packet with %u bytes UDP payload via TUN\n",
1539 (unsigned int) payload_length);
1471 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header); 1540 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header);
1472 switch (source_address->af) 1541 switch (source_address->af)
1473 { 1542 {
@@ -1602,6 +1671,16 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1602 GNUNET_break_op (0); 1671 GNUNET_break_op (0);
1603 return GNUNET_SYSERR; 1672 return GNUNET_SYSERR;
1604 } 1673 }
1674 {
1675 char buf[INET6_ADDRSTRLEN];
1676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1677 "Received data from %s for forwarding to UDP %s:%u\n",
1678 GNUNET_i2s (sender),
1679 inet_ntop (af,
1680 &state->ri.remote_address.address,
1681 buf, sizeof (buf)),
1682 (unsigned int) ntohs (msg->destination_port));
1683 }
1605 state->ri.remote_address.proto = IPPROTO_UDP; 1684 state->ri.remote_address.proto = IPPROTO_UDP;
1606 state->ri.remote_address.port = msg->destination_port; 1685 state->ri.remote_address.port = msg->destination_port;
1607 if (NULL == state->heap_node) 1686 if (NULL == state->heap_node)
@@ -1647,7 +1726,11 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1647 } 1726 }
1648 msg = (const struct GNUNET_EXIT_UdpServiceMessage*) message; 1727 msg = (const struct GNUNET_EXIT_UdpServiceMessage*) message;
1649 pkt_len -= sizeof (struct GNUNET_EXIT_UdpServiceMessage); 1728 pkt_len -= sizeof (struct GNUNET_EXIT_UdpServiceMessage);
1650 1729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1730 "Received data from %s for forwarding to UDP service %s on port %u\n",
1731 GNUNET_i2s (sender),
1732 GNUNET_h2s (&msg->service_descriptor),
1733 (unsigned int) ntohs (msg->destination_port));
1651 if (NULL == (state->serv = find_service (udp_services, &msg->service_descriptor, 1734 if (NULL == (state->serv = find_service (udp_services, &msg->service_descriptor,
1652 ntohs (msg->destination_port)))) 1735 ntohs (msg->destination_port))))
1653 { 1736 {
@@ -1683,7 +1766,10 @@ new_tunnel (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1683 const struct GNUNET_ATS_Information *ats GNUNET_UNUSED) 1766 const struct GNUNET_ATS_Information *ats GNUNET_UNUSED)
1684{ 1767{
1685 struct TunnelState *s = GNUNET_malloc (sizeof (struct TunnelState)); 1768 struct TunnelState *s = GNUNET_malloc (sizeof (struct TunnelState));
1686 1769
1770 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1771 "Received inbound tunnel from `%s'\n",
1772 GNUNET_i2s (initiator));
1687 s->tunnel = tunnel; 1773 s->tunnel = tunnel;
1688 return s; 1774 return s;
1689} 1775}
@@ -1705,6 +1791,8 @@ clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
1705 struct TunnelState *s = tunnel_ctx; 1791 struct TunnelState *s = tunnel_ctx;
1706 struct TunnelMessageQueue *tnq; 1792 struct TunnelMessageQueue *tnq;
1707 1793
1794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1795 "Tunnel destroyed\n");
1708 while (NULL != (tnq = s->head)) 1796 while (NULL != (tnq = s->head))
1709 { 1797 {
1710 GNUNET_CONTAINER_DLL_remove (s->head, 1798 GNUNET_CONTAINER_DLL_remove (s->head,
@@ -1755,6 +1843,8 @@ cleanup (void *cls GNUNET_UNUSED,
1755{ 1843{
1756 unsigned int i; 1844 unsigned int i;
1757 1845
1846 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1847 "Exit service is shutting down now\n");
1758 if (helper_handle != NULL) 1848 if (helper_handle != NULL)
1759 { 1849 {
1760 GNUNET_HELPER_stop (helper_handle); 1850 GNUNET_HELPER_stop (helper_handle);