aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-15 16:29:36 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-15 16:29:36 +0000
commit6d754e6c89fda8cb0da00c4152ffc6dcc707e6ce (patch)
tree41e157010353508c53f753b2e8cfeda28e1af909 /src
parent2694b957d0db8668dc479699bfde4ba081bd09a7 (diff)
downloadgnunet-6d754e6c89fda8cb0da00c4152ffc6dcc707e6ce.tar.gz
gnunet-6d754e6c89fda8cb0da00c4152ffc6dcc707e6ce.zip
-adding some rudimentary logging
Diffstat (limited to 'src')
-rw-r--r--src/vpn/gnunet-service-vpn.c119
1 files changed, 109 insertions, 10 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 7219471bf..b1b00dd98 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -28,7 +28,6 @@
28 * 28 *
29 * TODO: 29 * TODO:
30 * Basics: 30 * Basics:
31 * - need some logging
32 * - need some statistics 31 * - need some statistics
33 * - test! 32 * - test!
34 * - better message queue management (bounded state, drop oldest/RED?) 33 * - better message queue management (bounded state, drop oldest/RED?)
@@ -492,7 +491,10 @@ tunnel_peer_disconnect_handler (void *cls,
492 GNUNET_PeerIdentity * peer) 491 GNUNET_PeerIdentity * peer)
493{ 492{
494 struct TunnelState *ts = cls; 493 struct TunnelState *ts = cls;
495 494
495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
496 "Peer %s disconnected from tunnel.\n",
497 GNUNET_i2s (peer));
496 if (NULL != ts->th) 498 if (NULL != ts->th)
497 { 499 {
498 GNUNET_MESH_notify_transmit_ready_cancel (ts->th); 500 GNUNET_MESH_notify_transmit_ready_cancel (ts->th);
@@ -523,6 +525,9 @@ tunnel_peer_connect_handler (void *cls,
523{ 525{
524 struct TunnelState *ts = cls; 526 struct TunnelState *ts = cls;
525 527
528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
529 "Peer %s connected to tunnel.\n",
530 GNUNET_i2s (peer));
526 if (NULL == ts->client) 531 if (NULL == ts->client)
527 return; /* nothing to do */ 532 return; /* nothing to do */
528 send_client_reply (ts->client, 533 send_client_reply (ts->client,
@@ -555,6 +560,9 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
555 tnq = ts->head; 560 tnq = ts->head;
556 GNUNET_assert (NULL != tnq); 561 GNUNET_assert (NULL != tnq);
557 GNUNET_assert (size >= tnq->len); 562 GNUNET_assert (size >= tnq->len);
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
564 "Sending %u bytes via mesh tunnel\n",
565 tnq->len);
558 GNUNET_CONTAINER_DLL_remove (ts->head, 566 GNUNET_CONTAINER_DLL_remove (ts->head,
559 ts->tail, 567 ts->tail,
560 tnq); 568 tnq);
@@ -587,6 +595,9 @@ static void
587send_to_tunnel (struct TunnelMessageQueueEntry *tnq, 595send_to_tunnel (struct TunnelMessageQueueEntry *tnq,
588 struct TunnelState *ts) 596 struct TunnelState *ts)
589{ 597{
598 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
599 "Queueing %u bytes for transmission via mesh tunnel\n",
600 tnq->len);
590 GNUNET_CONTAINER_DLL_insert_tail (ts->head, 601 GNUNET_CONTAINER_DLL_insert_tail (ts->head,
591 ts->tail, 602 ts->tail,
592 tnq); 603 tnq);
@@ -637,6 +648,10 @@ create_tunnel_to_destination (struct DestinationEntry *de,
637 ts); 648 ts);
638 if (de->is_service) 649 if (de->is_service)
639 { 650 {
651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
652 "Creating tunnel to peer %s offering service %s\n",
653 GNUNET_i2s (&de->details.service_destination.target),
654 GNUNET_h2s (&de->details.service_destination.service_descriptor));
640 GNUNET_MESH_peer_request_connect_add (ts->tunnel, 655 GNUNET_MESH_peer_request_connect_add (ts->tunnel,
641 &de->details.service_destination.target); 656 &de->details.service_destination.target);
642 } 657 }
@@ -647,10 +662,16 @@ create_tunnel_to_destination (struct DestinationEntry *de,
647 case AF_INET: 662 case AF_INET:
648 GNUNET_MESH_peer_request_connect_by_type (ts->tunnel, 663 GNUNET_MESH_peer_request_connect_by_type (ts->tunnel,
649 GNUNET_APPLICATION_TYPE_IPV4_GATEWAY); 664 GNUNET_APPLICATION_TYPE_IPV4_GATEWAY);
665 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
666 "Creating tunnel to exit peer for %s\n",
667 "IPv4");
650 break; 668 break;
651 case AF_INET6: 669 case AF_INET6:
652 GNUNET_MESH_peer_request_connect_by_type (ts->tunnel, 670 GNUNET_MESH_peer_request_connect_by_type (ts->tunnel,
653 GNUNET_APPLICATION_TYPE_IPV6_GATEWAY); 671 GNUNET_APPLICATION_TYPE_IPV6_GATEWAY);
672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
673 "Creating tunnel to exit peer for %s\n",
674 "IPv6");
654 break; 675 break;
655 default: 676 default:
656 GNUNET_assert (0); 677 GNUNET_assert (0);
@@ -686,7 +707,6 @@ route_packet (struct DestinationEntry *destination,
686 struct TunnelMessageQueueEntry *tnq; 707 struct TunnelMessageQueueEntry *tnq;
687 size_t alen; 708 size_t alen;
688 size_t mlen; 709 size_t mlen;
689 GNUNET_MESH_ApplicationType app_type;
690 int is_new; 710 int is_new;
691 const struct udp_packet *udp; 711 const struct udp_packet *udp;
692 const struct tcp_packet *tcp; 712 const struct tcp_packet *tcp;
@@ -741,29 +761,57 @@ route_packet (struct DestinationEntry *destination,
741 (unsigned int) protocol); 761 (unsigned int) protocol);
742 return; 762 return;
743 } 763 }
744
745 if (! destination->is_service) 764 if (! destination->is_service)
746 { 765 {
747 switch (destination->details.exit_destination.af) 766 switch (destination->details.exit_destination.af)
748 { 767 {
749 case AF_INET: 768 case AF_INET:
750 alen = sizeof (struct in_addr); 769 alen = sizeof (struct in_addr);
751 app_type = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
752 break; 770 break;
753 case AF_INET6: 771 case AF_INET6:
754 alen = sizeof (struct in6_addr); 772 alen = sizeof (struct in6_addr);
755 app_type = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
756 break; 773 break;
757 default: 774 default:
758 alen = 0; 775 alen = 0;
759 GNUNET_assert (0); 776 GNUNET_assert (0);
760 } 777 }
778
779 {
780 char sbuf[INET6_ADDRSTRLEN];
781 char dbuf[INET6_ADDRSTRLEN];
782 char xbuf[INET6_ADDRSTRLEN];
783
784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
785 "Routing %s packet from %s:%u -> %s:%u to destination %s:%u\n",
786 (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
787 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)),
788 spt,
789 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)),
790 dpt,
791 inet_ntop (destination->details.exit_destination.af,
792 &destination->details.exit_destination.ip,
793 xbuf, sizeof (xbuf)));
794 }
761 } 795 }
762 else 796 else
763 { 797 {
764 /* make compiler happy */ 798 /* make compiler happy */
765 alen = 0; 799 alen = 0;
766 app_type = 0; 800 {
801 char sbuf[INET6_ADDRSTRLEN];
802 char dbuf[INET6_ADDRSTRLEN];
803
804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
805 "Routing %s packet from %s:%u -> %s:%u to service %s at peer %s\n",
806 (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
807 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)),
808 spt,
809 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)),
810 dpt,
811 GNUNET_h2s (&destination->details.service_destination.service_descriptor),
812 GNUNET_i2s (&destination->details.service_destination.target));
813 }
814
767 } 815 }
768 816
769 /* see if we have an existing tunnel for this destination */ 817 /* see if we have an existing tunnel for this destination */
@@ -1147,6 +1195,18 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1147 } 1195 }
1148 reply = (const struct GNUNET_EXIT_UdpReplyMessage *) message; 1196 reply = (const struct GNUNET_EXIT_UdpReplyMessage *) message;
1149 mlen -= sizeof (struct GNUNET_EXIT_UdpReplyMessage); 1197 mlen -= sizeof (struct GNUNET_EXIT_UdpReplyMessage);
1198 {
1199 char sbuf[INET6_ADDRSTRLEN];
1200 char dbuf[INET6_ADDRSTRLEN];
1201
1202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1203 "Received UDP reply from mesh, sending %u bytes from %s:%u -> %s:%u via TUN\n",
1204 (unsigned int) mlen,
1205 inet_ntop (ts->af, &ts->destination_ip, sbuf, sizeof (sbuf)),
1206 ts->destination_port,
1207 inet_ntop (ts->af, &ts->source_ip, dbuf, sizeof (dbuf)),
1208 ts->source_port);
1209 }
1150 switch (ts->af) 1210 switch (ts->af)
1151 { 1211 {
1152 case AF_INET: 1212 case AF_INET:
@@ -1310,6 +1370,18 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1310 } 1370 }
1311 data = (const struct GNUNET_EXIT_TcpDataMessage *) message; 1371 data = (const struct GNUNET_EXIT_TcpDataMessage *) message;
1312 mlen -= sizeof (struct GNUNET_EXIT_TcpDataMessage); 1372 mlen -= sizeof (struct GNUNET_EXIT_TcpDataMessage);
1373 {
1374 char sbuf[INET6_ADDRSTRLEN];
1375 char dbuf[INET6_ADDRSTRLEN];
1376
1377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1378 "Received TCP reply from mesh, sending %u bytes from %s:%u -> %s:%u via TUN\n",
1379 (unsigned int) mlen,
1380 inet_ntop (ts->af, &ts->destination_ip, sbuf, sizeof (sbuf)),
1381 ts->destination_port,
1382 inet_ntop (ts->af, &ts->source_ip, dbuf, sizeof (dbuf)),
1383 ts->source_port);
1384 }
1313 switch (ts->af) 1385 switch (ts->af)
1314 { 1386 {
1315 case AF_INET: 1387 case AF_INET:
@@ -1566,7 +1638,6 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
1566 void *addr; 1638 void *addr;
1567 struct DestinationEntry *de; 1639 struct DestinationEntry *de;
1568 GNUNET_HashCode key; 1640 GNUNET_HashCode key;
1569 GNUNET_MESH_ApplicationType app_type;
1570 1641
1571 /* validate and parse request */ 1642 /* validate and parse request */
1572 mlen = ntohs (message->size); 1643 mlen = ntohs (message->size);
@@ -1588,7 +1659,6 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
1588 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1659 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1589 return; 1660 return;
1590 } 1661 }
1591 app_type = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
1592 break; 1662 break;
1593 case AF_INET6: 1663 case AF_INET6:
1594 if (alen != sizeof (struct in6_addr)) 1664 if (alen != sizeof (struct in6_addr))
@@ -1597,7 +1667,6 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
1597 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1667 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1598 return; 1668 return;
1599 } 1669 }
1600 app_type = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
1601 break; 1670 break;
1602 default: 1671 default:
1603 GNUNET_break (0); 1672 GNUNET_break (0);
@@ -1658,6 +1727,17 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
1658 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1727 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1659 return; 1728 return;
1660 } 1729 }
1730
1731 {
1732 char sbuf[INET6_ADDRSTRLEN];
1733 char dbuf[INET6_ADDRSTRLEN];
1734
1735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1736 "Allocated address %s for redirection via exit to %s\n",
1737 inet_ntop (result_af, addr, sbuf, sizeof (sbuf)),
1738 inet_ntop (addr_af,
1739 &msg[1], dbuf, sizeof (dbuf)));
1740 }
1661 1741
1662 /* setup destination record */ 1742 /* setup destination record */
1663 de = GNUNET_malloc (sizeof (struct DestinationEntry)); 1743 de = GNUNET_malloc (sizeof (struct DestinationEntry));
@@ -1763,9 +1843,21 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
1763 if (result_af == AF_UNSPEC) 1843 if (result_af == AF_UNSPEC)
1764 { 1844 {
1765 /* failure, we're done */ 1845 /* failure, we're done */
1846 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1847 _("Failed to allocate IP address for new destination\n"));
1766 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1848 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1767 return; 1849 return;
1768 } 1850 }
1851
1852 {
1853 char sbuf[INET6_ADDRSTRLEN];
1854
1855 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1856 "Allocated address %s for redirection to service %s on peer %s\n",
1857 inet_ntop (result_af, addr, sbuf, sizeof (sbuf)),
1858 GNUNET_h2s (&msg->service_descriptor),
1859 GNUNET_i2s (&msg->target));
1860 }
1769 1861
1770 /* setup destination record */ 1862 /* setup destination record */
1771 de = GNUNET_malloc (sizeof (struct DestinationEntry)); 1863 de = GNUNET_malloc (sizeof (struct DestinationEntry));
@@ -1827,6 +1919,8 @@ free_tunnel_state (struct TunnelState *ts)
1827 GNUNET_HashCode key; 1919 GNUNET_HashCode key;
1828 struct TunnelMessageQueueEntry *tnq; 1920 struct TunnelMessageQueueEntry *tnq;
1829 1921
1922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1923 "Cleaning up tunnel state\n");
1830 while (NULL != (tnq = ts->head)) 1924 while (NULL != (tnq = ts->head))
1831 { 1925 {
1832 GNUNET_CONTAINER_DLL_remove (ts->head, 1926 GNUNET_CONTAINER_DLL_remove (ts->head,
@@ -1884,6 +1978,9 @@ free_tunnel_state (struct TunnelState *ts)
1884static void 1978static void
1885free_destination_entry (struct DestinationEntry *de) 1979free_destination_entry (struct DestinationEntry *de)
1886{ 1980{
1981 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1982 "Cleaning up destination entry\n");
1983
1887 if (NULL != de->ts) 1984 if (NULL != de->ts)
1888 { 1985 {
1889 free_tunnel_state (de->ts); 1986 free_tunnel_state (de->ts);
@@ -1979,6 +2076,8 @@ cleanup (void *cls GNUNET_UNUSED,
1979{ 2076{
1980 unsigned int i; 2077 unsigned int i;
1981 2078
2079 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2080 "VPN is shutting down\n");
1982 if (NULL != destination_map) 2081 if (NULL != destination_map)
1983 { 2082 {
1984 GNUNET_CONTAINER_multihashmap_iterate (destination_map, 2083 GNUNET_CONTAINER_multihashmap_iterate (destination_map,