aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-21 20:35:27 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-21 20:35:27 +0000
commit3b6f84aa1508a93e33cda16490446d38267a48a4 (patch)
tree0570055e02b8cb43a1bc9f9ff810331f46c22306 /src/vpn
parent0c2b7b70615a33599bf58e9a8574fa5ff9c73370 (diff)
downloadgnunet-3b6f84aa1508a93e33cda16490446d38267a48a4.tar.gz
gnunet-3b6f84aa1508a93e33cda16490446d38267a48a4.zip
-doxygen and minor code cleanup
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-service-vpn.c95
1 files changed, 42 insertions, 53 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index a896eb6c6..f713fa18e 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -82,8 +82,8 @@ struct DestinationEntry
82 struct GNUNET_CONTAINER_HeapNode *heap_node; 82 struct GNUNET_CONTAINER_HeapNode *heap_node;
83 83
84 /** 84 /**
85 * GNUNET_NO if this is a tunnel to an Internet-exit, 85 * #GNUNET_NO if this is a tunnel to an Internet-exit,
86 * GNUNET_YES if this tunnel is to a service. 86 * #GNUNET_YES if this tunnel is to a service.
87 */ 87 */
88 int is_service; 88 int is_service;
89 89
@@ -581,7 +581,7 @@ free_tunnel_state (struct TunnelState *ts)
581/** 581/**
582 * Destroy the mesh tunnel. 582 * Destroy the mesh tunnel.
583 * 583 *
584 * @param cls the 'struct TunnelState' with the tunnel to destroy 584 * @param cls the `struct TunnelState` with the tunnel to destroy
585 * @param tc scheduler context 585 * @param tc scheduler context
586 */ 586 */
587static void 587static void
@@ -611,7 +611,7 @@ destroy_tunnel_task (void *cls,
611void 611void
612tunnel_peer_disconnect_handler (void *cls, 612tunnel_peer_disconnect_handler (void *cls,
613 const struct 613 const struct
614 GNUNET_PeerIdentity * peer) 614 GNUNET_PeerIdentity *peer)
615{ 615{
616 struct TunnelState *ts = cls; 616 struct TunnelState *ts = cls;
617 617
@@ -647,8 +647,7 @@ tunnel_peer_disconnect_handler (void *cls,
647 */ 647 */
648void 648void
649tunnel_peer_connect_handler (void *cls, 649tunnel_peer_connect_handler (void *cls,
650 const struct GNUNET_PeerIdentity 650 const struct GNUNET_PeerIdentity *peer,
651 * peer,
652 const struct 651 const struct
653 GNUNET_ATS_Information * atsi) 652 GNUNET_ATS_Information * atsi)
654{ 653{
@@ -673,10 +672,10 @@ tunnel_peer_connect_handler (void *cls,
673/** 672/**
674 * Send a message from the message queue via mesh. 673 * Send a message from the message queue via mesh.
675 * 674 *
676 * @param cls the 'struct TunnelState' with the message queue 675 * @param cls the `struct TunnelState` with the message queue
677 * @param size number of bytes available in buf 676 * @param size number of bytes available in @a buf
678 * @param buf where to copy the message 677 * @param buf where to copy the message
679 * @return number of bytes copied to buf 678 * @return number of bytes copied to @a buf
680 */ 679 */
681static size_t 680static size_t
682send_to_peer_notify_callback (void *cls, size_t size, void *buf) 681send_to_peer_notify_callback (void *cls, size_t size, void *buf)
@@ -814,7 +813,7 @@ create_tunnel_to_destination (struct DestinationEntry *de,
814 gettext_noop ("# Mesh tunnels created"), 813 gettext_noop ("# Mesh tunnels created"),
815 1, GNUNET_NO); 814 1, GNUNET_NO);
816 GNUNET_assert (NULL == de->ts); 815 GNUNET_assert (NULL == de->ts);
817 ts = GNUNET_malloc (sizeof (struct TunnelState)); 816 ts = GNUNET_new (struct TunnelState);
818 ts->af = client_af; 817 ts->af = client_af;
819 if (NULL != client) 818 if (NULL != client)
820 { 819 {
@@ -1599,11 +1598,6 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
1599 &pkt6->destination_address, 1598 &pkt6->destination_address,
1600 &key); 1599 &key);
1601 de = GNUNET_CONTAINER_multihashmap_get (destination_map, &key); 1600 de = GNUNET_CONTAINER_multihashmap_get (destination_map, &key);
1602 /* FIXME: do we need to guard against hash collision?
1603 (if so, we need to also store the local destination IP in the
1604 destination entry and then compare here; however, the risk
1605 of collision seems minimal AND the impact is unlikely to be
1606 super-problematic as well... */
1607 if (NULL == de) 1601 if (NULL == de)
1608 { 1602 {
1609 char buf[INET6_ADDRSTRLEN]; 1603 char buf[INET6_ADDRSTRLEN];
@@ -1640,11 +1634,6 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
1640 &pkt4->destination_address, 1634 &pkt4->destination_address,
1641 &key); 1635 &key);
1642 de = GNUNET_CONTAINER_multihashmap_get (destination_map, &key); 1636 de = GNUNET_CONTAINER_multihashmap_get (destination_map, &key);
1643 /* FIXME: do we need to guard against hash collision?
1644 (if so, we need to also store the local destination IP in the
1645 destination entry and then compare here; however, the risk
1646 of collision seems minimal AND the impact is unlikely to be
1647 super-problematic as well... */
1648 if (NULL == de) 1637 if (NULL == de)
1649 { 1638 {
1650 char buf[INET_ADDRSTRLEN]; 1639 char buf[INET_ADDRSTRLEN];
@@ -1742,9 +1731,8 @@ make_up_icmpv6_payload (struct TunnelState *ts,
1742 * @param tunnel connection to the other end 1731 * @param tunnel connection to the other end
1743 * @param tunnel_ctx pointer to our 'struct TunnelState *' 1732 * @param tunnel_ctx pointer to our 'struct TunnelState *'
1744 * @param message the actual message 1733 * @param message the actual message
1745 * 1734 * @return #GNUNET_OK to keep the connection open,
1746 * @return GNUNET_OK to keep the connection open, 1735 * #GNUNET_SYSERR to close it (signal serious error)
1747 * GNUNET_SYSERR to close it (signal serious error)
1748 */ 1736 */
1749static int 1737static int
1750receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, 1738receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
@@ -2081,9 +2069,8 @@ receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2081 * @param tunnel connection to the other end 2069 * @param tunnel connection to the other end
2082 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2070 * @param tunnel_ctx pointer to our 'struct TunnelState *'
2083 * @param message the actual message 2071 * @param message the actual message
2084 * 2072 * @return #GNUNET_OK to keep the connection open,
2085 * @return GNUNET_OK to keep the connection open, 2073 * #GNUNET_SYSERR to close it (signal serious error)
2086 * GNUNET_SYSERR to close it (signal serious error)
2087 */ 2074 */
2088static int 2075static int
2089receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, 2076receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
@@ -2234,11 +2221,10 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2234 * 2221 *
2235 * @param cls closure, NULL 2222 * @param cls closure, NULL
2236 * @param tunnel connection to the other end 2223 * @param tunnel connection to the other end
2237 * @param tunnel_ctx pointer to our 'struct TunnelState *' 2224 * @param tunnel_ctx pointer to our `struct TunnelState *`
2238 * @param message the actual message 2225 * @param message the actual message
2239 * 2226 * @return #GNUNET_OK to keep the connection open,
2240 * @return GNUNET_OK to keep the connection open, 2227 * #GNUNET_SYSERR to close it (signal serious error)
2241 * GNUNET_SYSERR to close it (signal serious error)
2242 */ 2228 */
2243static int 2229static int
2244receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, 2230receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
@@ -2375,8 +2361,8 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2375 * for a new redirection. 2361 * for a new redirection.
2376 * 2362 *
2377 * @param v4 where to store the address 2363 * @param v4 where to store the address
2378 * @return GNUNET_OK on success, 2364 * @return #GNUNET_OK on success,
2379 * GNUNET_SYSERR on error 2365 * #GNUNET_SYSERR on error
2380 */ 2366 */
2381static int 2367static int
2382allocate_v4_address (struct in_addr *v4) 2368allocate_v4_address (struct in_addr *v4)
@@ -2426,8 +2412,8 @@ allocate_v4_address (struct in_addr *v4)
2426 * for a new redirection. 2412 * for a new redirection.
2427 * 2413 *
2428 * @param v6 where to store the address 2414 * @param v6 where to store the address
2429 * @return GNUNET_OK on success, 2415 * @return #GNUNET_OK on success,
2430 * GNUNET_SYSERR on error 2416 * #GNUNET_SYSERR on error
2431 */ 2417 */
2432static int 2418static int
2433allocate_v6_address (struct in6_addr *v6) 2419allocate_v6_address (struct in6_addr *v6)
@@ -2544,7 +2530,7 @@ expire_destination (struct DestinationEntry *except)
2544 * storage location was used; set to NULL if allocation failed 2530 * storage location was used; set to NULL if allocation failed
2545 * @param v4 storage space for an IPv4 address 2531 * @param v4 storage space for an IPv4 address
2546 * @param v6 storage space for an IPv6 address 2532 * @param v6 storage space for an IPv6 address
2547 * @return GNUNET_OK normally, GNUNET_SYSERR if '*result_af' was 2533 * @return #GNUNET_OK normally, #GNUNET_SYSERR if `* result_af` was
2548 * an unsupported address family (not AF_INET, AF_INET6 or AF_UNSPEC) 2534 * an unsupported address family (not AF_INET, AF_INET6 or AF_UNSPEC)
2549 */ 2535 */
2550static int 2536static int
@@ -2599,7 +2585,7 @@ allocate_response_ip (int *result_af,
2599 * 2585 *
2600 * @param cls unused 2586 * @param cls unused
2601 * @param client requesting client 2587 * @param client requesting client
2602 * @param message redirection request (a 'struct RedirectToIpRequestMessage') 2588 * @param message redirection request (a `struct RedirectToIpRequestMessage`)
2603 */ 2589 */
2604static void 2590static void
2605service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *client, 2591service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *client,
@@ -2689,7 +2675,7 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
2689 } 2675 }
2690 2676
2691 /* setup destination record */ 2677 /* setup destination record */
2692 de = GNUNET_malloc (sizeof (struct DestinationEntry)); 2678 de = GNUNET_new (struct DestinationEntry);
2693 de->is_service = GNUNET_NO; 2679 de->is_service = GNUNET_NO;
2694 de->details.exit_destination.af = addr_af; 2680 de->details.exit_destination.af = addr_af;
2695 memcpy (&de->details.exit_destination.ip, 2681 memcpy (&de->details.exit_destination.ip,
@@ -2741,7 +2727,7 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
2741 * 2727 *
2742 * @param cls unused 2728 * @param cls unused
2743 * @param client requesting client 2729 * @param client requesting client
2744 * @param message redirection request (a 'struct RedirectToPeerRequestMessage') 2730 * @param message redirection request (a `struct RedirectToPeerRequestMessage`)
2745 */ 2731 */
2746static void 2732static void
2747service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *client, 2733service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *client,
@@ -2797,7 +2783,7 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
2797 } 2783 }
2798 2784
2799 /* setup destination record */ 2785 /* setup destination record */
2800 de = GNUNET_malloc (sizeof (struct DestinationEntry)); 2786 de = GNUNET_new (struct DestinationEntry);
2801 de->is_service = GNUNET_YES; 2787 de->is_service = GNUNET_YES;
2802 de->details.service_destination.service_descriptor = msg->service_descriptor; 2788 de->details.service_destination.service_descriptor = msg->service_descriptor;
2803 de->details.service_destination.target = msg->target; 2789 de->details.service_destination.target = msg->target;
@@ -2841,13 +2827,15 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
2841 * 2827 *
2842 * FIXME now its also user for disconnections 2828 * FIXME now its also user for disconnections
2843 * 2829 *
2844 * @param cls closure (set from GNUNET_MESH_connect) 2830 * @param cls closure (set from #GNUNET_MESH_connect)
2845 * @param tunnel connection to the other end (henceforth invalid) 2831 * @param tunnel connection to the other end (henceforth invalid)
2846 * @param tunnel_ctx place where local state associated 2832 * @param tunnel_ctx place where local state associated
2847 * with the tunnel is stored (our 'struct TunnelState') 2833 * with the tunnel is stored (our `struct TunnelState`)
2848 */ 2834 */
2849static void 2835static void
2850tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx) 2836tunnel_cleaner (void *cls,
2837 const struct GNUNET_MESH_Tunnel *tunnel,
2838 void *tunnel_ctx)
2851{ 2839{
2852 /* we don't have inbound tunnels, so this function should never be called */ 2840 /* we don't have inbound tunnels, so this function should never be called */
2853 GNUNET_break (0); 2841 GNUNET_break (0);
@@ -2859,8 +2847,8 @@ tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel
2859 * 2847 *
2860 * @param cls unused 2848 * @param cls unused
2861 * @param key unused 2849 * @param key unused
2862 * @param value a 'struct DestinationEntry *' 2850 * @param value a `struct DestinationEntry *`
2863 * @return GNUNET_OK (continue to iterate) 2851 * @return #GNUNET_OK (continue to iterate)
2864 */ 2852 */
2865static int 2853static int
2866cleanup_destination (void *cls, 2854cleanup_destination (void *cls,
@@ -2879,8 +2867,8 @@ cleanup_destination (void *cls,
2879 * 2867 *
2880 * @param cls unused 2868 * @param cls unused
2881 * @param key unused 2869 * @param key unused
2882 * @param value a 'struct TunnelState *' 2870 * @param value a `struct TunnelState *`
2883 * @return GNUNET_OK (continue to iterate) 2871 * @return #GNUNET_OK (continue to iterate)
2884 */ 2872 */
2885static int 2873static int
2886cleanup_tunnel (void *cls, 2874cleanup_tunnel (void *cls,
@@ -2901,7 +2889,7 @@ cleanup_tunnel (void *cls,
2901 * @param tc unused 2889 * @param tc unused
2902 */ 2890 */
2903static void 2891static void
2904cleanup (void *cls GNUNET_UNUSED, 2892cleanup (void *cls,
2905 const struct GNUNET_SCHEDULER_TaskContext *tc) 2893 const struct GNUNET_SCHEDULER_TaskContext *tc)
2906{ 2894{
2907 unsigned int i; 2895 unsigned int i;
@@ -2949,7 +2937,7 @@ cleanup (void *cls GNUNET_UNUSED,
2949 GNUNET_SERVER_notification_context_destroy (nc); 2937 GNUNET_SERVER_notification_context_destroy (nc);
2950 nc = NULL; 2938 nc = NULL;
2951 } 2939 }
2952 if (stats != NULL) 2940 if (NULL != stats)
2953 { 2941 {
2954 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 2942 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
2955 stats = NULL; 2943 stats = NULL;
@@ -2964,8 +2952,8 @@ cleanup (void *cls GNUNET_UNUSED,
2964 * 2952 *
2965 * @param cls the client that disconnected 2953 * @param cls the client that disconnected
2966 * @param key unused 2954 * @param key unused
2967 * @param value a 'struct TunnelState *' 2955 * @param value a `struct TunnelState *`
2968 * @return GNUNET_OK (continue to iterate) 2956 * @return #GNUNET_OK (continue to iterate)
2969 */ 2957 */
2970static int 2958static int
2971cleanup_tunnel_client (void *cls, 2959cleanup_tunnel_client (void *cls,
@@ -2986,8 +2974,8 @@ cleanup_tunnel_client (void *cls,
2986 * 2974 *
2987 * @param cls the client that disconnected 2975 * @param cls the client that disconnected
2988 * @param key unused 2976 * @param key unused
2989 * @param value a 'struct DestinationEntry *' 2977 * @param value a `struct DestinationEntry *`
2990 * @return GNUNET_OK (continue to iterate) 2978 * @return #GNUNET_OK (continue to iterate)
2991 */ 2979 */
2992static int 2980static int
2993cleanup_destination_client (void *cls, 2981cleanup_destination_client (void *cls,
@@ -3014,7 +3002,8 @@ cleanup_destination_client (void *cls,
3014 * @param client handle to the client that disconnected 3002 * @param client handle to the client that disconnected
3015 */ 3003 */
3016static void 3004static void
3017client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) 3005client_disconnect (void *cls,
3006 struct GNUNET_SERVER_Client *client)
3018{ 3007{
3019 if (NULL != tunnel_map) 3008 if (NULL != tunnel_map)
3020 GNUNET_CONTAINER_multihashmap_iterate (tunnel_map, 3009 GNUNET_CONTAINER_multihashmap_iterate (tunnel_map,