diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-06-28 14:34:55 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-06-28 14:34:55 +0000 |
commit | cf19b5082fe8de33e38957f54d28647635b46b60 (patch) | |
tree | e6e41da7d5cb14d9a342ef6533633ecb2f34b18d /src/vpn/gnunet-service-vpn.c | |
parent | 166d8f9122bf7ebbaa2a662d09a3fa4d34f6d092 (diff) | |
download | gnunet-cf19b5082fe8de33e38957f54d28647635b46b60.tar.gz gnunet-cf19b5082fe8de33e38957f54d28647635b46b60.zip |
Replace mesh with new version
Diffstat (limited to 'src/vpn/gnunet-service-vpn.c')
-rw-r--r-- | src/vpn/gnunet-service-vpn.c | 81 |
1 files changed, 24 insertions, 57 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index bc2327e96..7844df15b 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -50,6 +50,8 @@ | |||
50 | #define MAX_MESSAGE_QUEUE_SIZE 4 | 50 | #define MAX_MESSAGE_QUEUE_SIZE 4 |
51 | 51 | ||
52 | 52 | ||
53 | #define PORT_VPN 42 | ||
54 | |||
53 | /** | 55 | /** |
54 | * State we keep for each of our tunnels. | 56 | * State we keep for each of our tunnels. |
55 | */ | 57 | */ |
@@ -601,10 +603,12 @@ destroy_tunnel_task (void *cls, | |||
601 | /** | 603 | /** |
602 | * Method called whenever a peer has disconnected from the tunnel. | 604 | * Method called whenever a peer has disconnected from the tunnel. |
603 | * | 605 | * |
606 | * FIXME merge with inbound_cleaner | ||
607 | * | ||
604 | * @param cls closure | 608 | * @param cls closure |
605 | * @param peer peer identity the tunnel stopped working with | 609 | * @param peer peer identity the tunnel stopped working with |
606 | */ | 610 | */ |
607 | static void | 611 | void |
608 | tunnel_peer_disconnect_handler (void *cls, | 612 | tunnel_peer_disconnect_handler (void *cls, |
609 | const struct | 613 | const struct |
610 | GNUNET_PeerIdentity * peer) | 614 | GNUNET_PeerIdentity * peer) |
@@ -635,11 +639,13 @@ tunnel_peer_disconnect_handler (void *cls, | |||
635 | * Method called whenever a peer has connected to the tunnel. Notifies | 639 | * Method called whenever a peer has connected to the tunnel. Notifies |
636 | * the waiting client that the tunnel is now up. | 640 | * the waiting client that the tunnel is now up. |
637 | * | 641 | * |
642 | * FIXME merge with tunnel_create | ||
643 | * | ||
638 | * @param cls closure | 644 | * @param cls closure |
639 | * @param peer peer identity the tunnel was created to, NULL on timeout | 645 | * @param peer peer identity the tunnel was created to, NULL on timeout |
640 | * @param atsi performance data for the connection | 646 | * @param atsi performance data for the connection |
641 | */ | 647 | */ |
642 | static void | 648 | void |
643 | tunnel_peer_connect_handler (void *cls, | 649 | tunnel_peer_connect_handler (void *cls, |
644 | const struct GNUNET_PeerIdentity | 650 | const struct GNUNET_PeerIdentity |
645 | * peer, | 651 | * peer, |
@@ -699,7 +705,6 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf) | |||
699 | ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, | 705 | ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, |
700 | GNUNET_NO /* cork */, | 706 | GNUNET_NO /* cork */, |
701 | GNUNET_TIME_UNIT_FOREVER_REL, | 707 | GNUNET_TIME_UNIT_FOREVER_REL, |
702 | NULL, | ||
703 | tnq->len, | 708 | tnq->len, |
704 | &send_to_peer_notify_callback, | 709 | &send_to_peer_notify_callback, |
705 | ts); | 710 | ts); |
@@ -751,7 +756,6 @@ send_to_tunnel (struct TunnelMessageQueueEntry *tnq, | |||
751 | ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, | 756 | ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, |
752 | GNUNET_NO /* cork */, | 757 | GNUNET_NO /* cork */, |
753 | GNUNET_TIME_UNIT_FOREVER_REL, | 758 | GNUNET_TIME_UNIT_FOREVER_REL, |
754 | NULL, | ||
755 | tnq->len, | 759 | tnq->len, |
756 | &send_to_peer_notify_callback, | 760 | &send_to_peer_notify_callback, |
757 | ts); | 761 | ts); |
@@ -782,11 +786,8 @@ handle_regex_result (void *cls, | |||
782 | ts->search = NULL; | 786 | ts->search = NULL; |
783 | ts->tunnel = GNUNET_MESH_tunnel_create (mesh_handle, | 787 | ts->tunnel = GNUNET_MESH_tunnel_create (mesh_handle, |
784 | ts, | 788 | ts, |
785 | &tunnel_peer_connect_handler, | 789 | id, |
786 | &tunnel_peer_disconnect_handler, | 790 | PORT_VPN); |
787 | ts); | ||
788 | GNUNET_MESH_peer_request_connect_add (ts->tunnel, | ||
789 | id); | ||
790 | } | 791 | } |
791 | 792 | ||
792 | 793 | ||
@@ -826,9 +827,8 @@ create_tunnel_to_destination (struct DestinationEntry *de, | |||
826 | { | 827 | { |
827 | ts->tunnel = GNUNET_MESH_tunnel_create (mesh_handle, | 828 | ts->tunnel = GNUNET_MESH_tunnel_create (mesh_handle, |
828 | ts, | 829 | ts, |
829 | &tunnel_peer_connect_handler, | 830 | &de->details.service_destination.target, |
830 | &tunnel_peer_disconnect_handler, | 831 | PORT_VPN); |
831 | ts); | ||
832 | if (NULL == ts->tunnel) | 832 | if (NULL == ts->tunnel) |
833 | { | 833 | { |
834 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 834 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -840,8 +840,6 @@ create_tunnel_to_destination (struct DestinationEntry *de, | |||
840 | "Creating tunnel to peer %s offering service %s\n", | 840 | "Creating tunnel to peer %s offering service %s\n", |
841 | GNUNET_i2s (&de->details.service_destination.target), | 841 | GNUNET_i2s (&de->details.service_destination.target), |
842 | GNUNET_h2s (&de->details.service_destination.service_descriptor)); | 842 | GNUNET_h2s (&de->details.service_destination.service_descriptor)); |
843 | GNUNET_MESH_peer_request_connect_add (ts->tunnel, | ||
844 | &de->details.service_destination.target); | ||
845 | } | 843 | } |
846 | else | 844 | else |
847 | { | 845 | { |
@@ -1741,17 +1739,15 @@ make_up_icmpv6_payload (struct TunnelState *ts, | |||
1741 | * @param cls closure, NULL | 1739 | * @param cls closure, NULL |
1742 | * @param tunnel connection to the other end | 1740 | * @param tunnel connection to the other end |
1743 | * @param tunnel_ctx pointer to our 'struct TunnelState *' | 1741 | * @param tunnel_ctx pointer to our 'struct TunnelState *' |
1744 | * @param sender who sent the message | ||
1745 | * @param message the actual message | 1742 | * @param message the actual message |
1746 | * @param atsi performance data for the connection | 1743 | * |
1747 | * @return GNUNET_OK to keep the connection open, | 1744 | * @return GNUNET_OK to keep the connection open, |
1748 | * GNUNET_SYSERR to close it (signal serious error) | 1745 | * GNUNET_SYSERR to close it (signal serious error) |
1749 | */ | 1746 | */ |
1750 | static int | 1747 | static int |
1751 | receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | 1748 | receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, |
1752 | void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender, | 1749 | void **tunnel_ctx, |
1753 | const struct GNUNET_MessageHeader *message, | 1750 | const struct GNUNET_MessageHeader *message) |
1754 | const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED) | ||
1755 | { | 1751 | { |
1756 | struct TunnelState *ts = *tunnel_ctx; | 1752 | struct TunnelState *ts = *tunnel_ctx; |
1757 | const struct GNUNET_EXIT_IcmpToVPNMessage *i2v; | 1753 | const struct GNUNET_EXIT_IcmpToVPNMessage *i2v; |
@@ -2082,17 +2078,15 @@ receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
2082 | * @param cls closure, NULL | 2078 | * @param cls closure, NULL |
2083 | * @param tunnel connection to the other end | 2079 | * @param tunnel connection to the other end |
2084 | * @param tunnel_ctx pointer to our 'struct TunnelState *' | 2080 | * @param tunnel_ctx pointer to our 'struct TunnelState *' |
2085 | * @param sender who sent the message | ||
2086 | * @param message the actual message | 2081 | * @param message the actual message |
2087 | * @param atsi performance data for the connection | 2082 | * |
2088 | * @return GNUNET_OK to keep the connection open, | 2083 | * @return GNUNET_OK to keep the connection open, |
2089 | * GNUNET_SYSERR to close it (signal serious error) | 2084 | * GNUNET_SYSERR to close it (signal serious error) |
2090 | */ | 2085 | */ |
2091 | static int | 2086 | static int |
2092 | receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | 2087 | receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, |
2093 | void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender, | 2088 | void **tunnel_ctx, |
2094 | const struct GNUNET_MessageHeader *message, | 2089 | const struct GNUNET_MessageHeader *message) |
2095 | const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED) | ||
2096 | { | 2090 | { |
2097 | struct TunnelState *ts = *tunnel_ctx; | 2091 | struct TunnelState *ts = *tunnel_ctx; |
2098 | const struct GNUNET_EXIT_UdpReplyMessage *reply; | 2092 | const struct GNUNET_EXIT_UdpReplyMessage *reply; |
@@ -2239,18 +2233,15 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
2239 | * @param cls closure, NULL | 2233 | * @param cls closure, NULL |
2240 | * @param tunnel connection to the other end | 2234 | * @param tunnel connection to the other end |
2241 | * @param tunnel_ctx pointer to our 'struct TunnelState *' | 2235 | * @param tunnel_ctx pointer to our 'struct TunnelState *' |
2242 | * @param sender who sent the message | ||
2243 | * @param message the actual message | 2236 | * @param message the actual message |
2244 | * @param atsi performance data for the connection | 2237 | * |
2245 | * @return GNUNET_OK to keep the connection open, | 2238 | * @return GNUNET_OK to keep the connection open, |
2246 | * GNUNET_SYSERR to close it (signal serious error) | 2239 | * GNUNET_SYSERR to close it (signal serious error) |
2247 | */ | 2240 | */ |
2248 | static int | 2241 | static int |
2249 | receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | 2242 | receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, |
2250 | void **tunnel_ctx, | 2243 | void **tunnel_ctx, |
2251 | const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED, | 2244 | const struct GNUNET_MessageHeader *message) |
2252 | const struct GNUNET_MessageHeader *message, | ||
2253 | const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED) | ||
2254 | { | 2245 | { |
2255 | struct TunnelState *ts = *tunnel_ctx; | 2246 | struct TunnelState *ts = *tunnel_ctx; |
2256 | const struct GNUNET_EXIT_TcpDataMessage *data; | 2247 | const struct GNUNET_EXIT_TcpDataMessage *data; |
@@ -2842,32 +2833,11 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien | |||
2842 | } | 2833 | } |
2843 | 2834 | ||
2844 | 2835 | ||
2845 | |||
2846 | /** | ||
2847 | * Function called for inbound tunnels. As we don't offer | ||
2848 | * any mesh services, this function should never be called. | ||
2849 | * | ||
2850 | * @param cls closure | ||
2851 | * @param tunnel new handle to the tunnel | ||
2852 | * @param initiator peer that started the tunnel | ||
2853 | * @param atsi performance information for the tunnel | ||
2854 | * @return initial tunnel context for the tunnel | ||
2855 | * (can be NULL -- that's not an error) | ||
2856 | */ | ||
2857 | static void * | ||
2858 | inbound_tunnel_cb (void *cls, struct GNUNET_MESH_Tunnel *tunnel, | ||
2859 | const struct GNUNET_PeerIdentity *initiator, | ||
2860 | const struct GNUNET_ATS_Information *atsi) | ||
2861 | { | ||
2862 | /* How can and why should anyone open an inbound tunnel to vpn? */ | ||
2863 | GNUNET_break (0); | ||
2864 | return NULL; | ||
2865 | } | ||
2866 | |||
2867 | |||
2868 | /** | 2836 | /** |
2869 | * Function called whenever an inbound tunnel is destroyed. Should clean up | 2837 | * Function called whenever an inbound tunnel is destroyed. Should clean up |
2870 | * any associated state. | 2838 | * any associated state. |
2839 | * | ||
2840 | * FIXME now its also user for disconnections | ||
2871 | * | 2841 | * |
2872 | * @param cls closure (set from GNUNET_MESH_connect) | 2842 | * @param cls closure (set from GNUNET_MESH_connect) |
2873 | * @param tunnel connection to the other end (henceforth invalid) | 2843 | * @param tunnel connection to the other end (henceforth invalid) |
@@ -3081,9 +3051,6 @@ run (void *cls, | |||
3081 | { &receive_icmp_back, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN, 0}, | 3051 | { &receive_icmp_back, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN, 0}, |
3082 | {NULL, 0, 0} | 3052 | {NULL, 0, 0} |
3083 | }; | 3053 | }; |
3084 | static const GNUNET_MESH_ApplicationType types[] = { | ||
3085 | GNUNET_APPLICATION_TYPE_END | ||
3086 | }; | ||
3087 | char *ifname; | 3054 | char *ifname; |
3088 | char *ipv6addr; | 3055 | char *ipv6addr; |
3089 | char *ipv6prefix_s; | 3056 | char *ipv6prefix_s; |
@@ -3209,10 +3176,10 @@ run (void *cls, | |||
3209 | 3176 | ||
3210 | mesh_handle = | 3177 | mesh_handle = |
3211 | GNUNET_MESH_connect (cfg_, NULL, | 3178 | GNUNET_MESH_connect (cfg_, NULL, |
3212 | &inbound_tunnel_cb, | 3179 | NULL, |
3213 | &tunnel_cleaner, | 3180 | &tunnel_cleaner, |
3214 | mesh_handlers, | 3181 | mesh_handlers, |
3215 | types); | 3182 | NULL); |
3216 | helper_handle = GNUNET_HELPER_start (GNUNET_NO, | 3183 | helper_handle = GNUNET_HELPER_start (GNUNET_NO, |
3217 | "gnunet-helper-vpn", vpn_argv, | 3184 | "gnunet-helper-vpn", vpn_argv, |
3218 | &message_token, NULL, NULL); | 3185 | &message_token, NULL, NULL); |