aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-vpn.13
-rw-r--r--src/gns/gnunet-service-gns_resolver.c1
-rw-r--r--src/include/gnunet_vpn_service.h8
-rw-r--r--src/pt/gnunet-daemon-pt.c1
-rw-r--r--src/pt/test_gnunet_vpn.c2
-rw-r--r--src/vpn/gnunet-service-vpn.c162
-rw-r--r--src/vpn/gnunet-vpn.c10
-rw-r--r--src/vpn/vpn.h16
-rw-r--r--src/vpn/vpn_api.c24
9 files changed, 27 insertions, 200 deletions
diff --git a/doc/man/gnunet-vpn.1 b/doc/man/gnunet-vpn.1
index 80b78ce14..68a5905d8 100644
--- a/doc/man/gnunet-vpn.1
+++ b/doc/man/gnunet-vpn.1
@@ -21,9 +21,6 @@ Desired IP address on this end of the tunnel should be an IPv4 address.
21.IP "\-6, \-\-ipv6" 21.IP "\-6, \-\-ipv6"
22Desired IP address on this end of the tunnel should be an IPv6 address. 22Desired IP address on this end of the tunnel should be an IPv6 address.
23.B 23.B
24.IP "\-a, \-\-after\-connect"
25Display IP address only after the tunnel is fully connected.
26.B
27.IP "\-c FILENAME, \-\-config=FILENAME" 24.IP "\-c FILENAME, \-\-config=FILENAME"
28Use the configuration file FILENAME. 25Use the configuration file FILENAME.
29.B 26.B
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 1495a16f0..5dd66a9a5 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1152,7 +1152,6 @@ handle_gns_resolution_result (void *cls,
1152 ntohs (vpn->proto), 1152 ntohs (vpn->proto),
1153 &vpn->peer, 1153 &vpn->peer,
1154 &vhash, 1154 &vhash,
1155 GNUNET_NO,
1156 GNUNET_TIME_relative_to_absolute (VPN_TIMEOUT), 1155 GNUNET_TIME_relative_to_absolute (VPN_TIMEOUT),
1157 &vpn_allocation_cb, 1156 &vpn_allocation_cb,
1158 rh); 1157 rh);
diff --git a/src/include/gnunet_vpn_service.h b/src/include/gnunet_vpn_service.h
index d7335bb71..fe21cff9b 100644
--- a/src/include/gnunet_vpn_service.h
+++ b/src/include/gnunet_vpn_service.h
@@ -81,9 +81,6 @@ GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr);
81 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP 81 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
82 * @param peer target peer for the redirection 82 * @param peer target peer for the redirection
83 * @param serv service descriptor to give to the peer 83 * @param serv service descriptor to give to the peer
84 * @param nac GNUNET_YES to notify via callback only after completion of
85 * the MESH-level connection,
86 * GNUNET_NO to notify as soon as the IP has been reserved
87 * @param expiration_time at what time should the redirection expire? 84 * @param expiration_time at what time should the redirection expire?
88 * (this should not impact connections that are active at that time) 85 * (this should not impact connections that are active at that time)
89 * @param cb function to call with the IP 86 * @param cb function to call with the IP
@@ -98,7 +95,6 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
98 uint8_t protocol, 95 uint8_t protocol,
99 const struct GNUNET_PeerIdentity *peer, 96 const struct GNUNET_PeerIdentity *peer,
100 const struct GNUNET_HashCode *serv, 97 const struct GNUNET_HashCode *serv,
101 int nac,
102 struct GNUNET_TIME_Absolute expiration_time, 98 struct GNUNET_TIME_Absolute expiration_time,
103 GNUNET_VPN_AllocationCallback cb, 99 GNUNET_VPN_AllocationCallback cb,
104 void *cb_cls); 100 void *cb_cls);
@@ -119,9 +115,6 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
119 * @param addr_af address family for 'addr', AF_INET or AF_INET6 115 * @param addr_af address family for 'addr', AF_INET or AF_INET6
120 * @param addr destination IP address on the Internet; destination 116 * @param addr destination IP address on the Internet; destination
121 * port is to be taken from the VPN packet itself 117 * port is to be taken from the VPN packet itself
122 * @param nac GNUNET_YES to notify via callback only after completion of
123 * the MESH-level connection,
124 * GNUNET_NO to notify as soon as the IP has been reserved
125 * @param expiration_time at what time should the redirection expire? 118 * @param expiration_time at what time should the redirection expire?
126 * (this should not impact connections that are active at that time) 119 * (this should not impact connections that are active at that time)
127 * @param cb function to call with the IP 120 * @param cb function to call with the IP
@@ -135,7 +128,6 @@ GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
135 int result_af, 128 int result_af,
136 int addr_af, 129 int addr_af,
137 const void *addr, 130 const void *addr,
138 int nac,
139 struct GNUNET_TIME_Absolute expiration_time, 131 struct GNUNET_TIME_Absolute expiration_time,
140 GNUNET_VPN_AllocationCallback cb, 132 GNUNET_VPN_AllocationCallback cb,
141 void *cb_cls); 133 void *cb_cls);
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c
index 14f6e0885..19e1629cf 100644
--- a/src/pt/gnunet-daemon-pt.c
+++ b/src/pt/gnunet-daemon-pt.c
@@ -390,7 +390,6 @@ modify_address (struct ReplyContext *rc,
390 rc->rr = GNUNET_VPN_redirect_to_ip (vpn_handle, 390 rc->rr = GNUNET_VPN_redirect_to_ip (vpn_handle,
391 af, af, 391 af, af,
392 rec->data.raw.data, 392 rec->data.raw.data,
393 GNUNET_NO /* nac */,
394 GNUNET_TIME_relative_to_absolute (TIMEOUT), 393 GNUNET_TIME_relative_to_absolute (TIMEOUT),
395 &vpn_allocation_callback, 394 &vpn_allocation_callback,
396 rc); 395 rc);
diff --git a/src/pt/test_gnunet_vpn.c b/src/pt/test_gnunet_vpn.c
index 408325776..975cb7ee0 100644
--- a/src/pt/test_gnunet_vpn.c
+++ b/src/pt/test_gnunet_vpn.c
@@ -384,7 +384,7 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
384 default: 384 default:
385 GNUNET_assert (0); 385 GNUNET_assert (0);
386 } 386 }
387 rr = GNUNET_VPN_redirect_to_ip (vpn, src_af, dest_af, addr, GNUNET_YES, 387 rr = GNUNET_VPN_redirect_to_ip (vpn, src_af, dest_af, addr,
388 GNUNET_TIME_UNIT_FOREVER_ABS, &allocation_cb, 388 GNUNET_TIME_UNIT_FOREVER_ABS, &allocation_cb,
389 NULL); 389 NULL);
390 ctrl_c_task_id = 390 ctrl_c_task_id =
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 030816797..2b5b41e14 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -204,23 +204,12 @@ struct TunnelState
204 struct TunnelMessageQueueEntry *tmq_tail; 204 struct TunnelMessageQueueEntry *tmq_tail;
205 205
206 /** 206 /**
207 * Client that needs to be notified about the tunnel being
208 * up as soon as a peer is connected; NULL for none.
209 */
210 struct GNUNET_SERVER_Client *client;
211
212 /**
213 * Destination entry that has a pointer to this tunnel state; 207 * Destination entry that has a pointer to this tunnel state;
214 * NULL if this tunnel state is in the tunnel map. 208 * NULL if this tunnel state is in the tunnel map.
215 */ 209 */
216 struct DestinationEntry *destination_container; 210 struct DestinationEntry *destination_container;
217 211
218 /** 212 /**
219 * ID of the client request that caused us to setup this entry.
220 */
221 uint64_t request_id;
222
223 /**
224 * Destination to which this tunnel leads. Note that 213 * Destination to which this tunnel leads. Note that
225 * this struct is NOT in the destination_map (but a 214 * this struct is NOT in the destination_map (but a
226 * local copy) and that the 'heap_node' should always 215 * local copy) and that the 'heap_node' should always
@@ -636,40 +625,6 @@ tunnel_peer_disconnect_handler (void *cls,
636 625
637 626
638/** 627/**
639 * Method called whenever a peer has connected to the tunnel. Notifies
640 * the waiting client that the tunnel is now up.
641 *
642 * FIXME merge with tunnel_create
643 *
644 * @param cls closure
645 * @param peer peer identity the tunnel was created to, NULL on timeout
646 * @param atsi performance data for the connection
647 */
648void
649tunnel_peer_connect_handler (void *cls,
650 const struct GNUNET_PeerIdentity *peer,
651 const struct
652 GNUNET_ATS_Information * atsi)
653{
654 struct TunnelState *ts = cls;
655
656 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
657 "Peer %s connected to tunnel.\n",
658 GNUNET_i2s (peer));
659 GNUNET_STATISTICS_update (stats,
660 gettext_noop ("# peers connected to mesh tunnels"),
661 1, GNUNET_NO);
662 if (NULL == ts->client)
663 return; /* nothing to do */
664 send_client_reply (ts->client,
665 ts->request_id,
666 ts->af,
667 &ts->destination_ip);
668 ts->client = NULL;
669}
670
671
672/**
673 * Send a message from the message queue via mesh. 628 * Send a message from the message queue via mesh.
674 * 629 *
675 * @param cls the `struct TunnelState` with the message queue 630 * @param cls the `struct TunnelState` with the message queue
@@ -796,14 +751,12 @@ handle_regex_result (void *cls,
796 * Initialize the given destination entry's mesh tunnel. 751 * Initialize the given destination entry's mesh tunnel.
797 * 752 *
798 * @param de destination entry for which we need to setup a tunnel 753 * @param de destination entry for which we need to setup a tunnel
799 * @param client client to notify on successful tunnel setup, or NULL for none
800 * @param client_af address family of the address returned to the client 754 * @param client_af address family of the address returned to the client
801 * @param request_id request ID to send in client notification (unused if client is NULL) 755 * @param request_id request ID to send in client notification (unused if client is NULL)
802 * @return tunnel state of the tunnel that was created 756 * @return tunnel state of the tunnel that was created
803 */ 757 */
804static struct TunnelState * 758static struct TunnelState *
805create_tunnel_to_destination (struct DestinationEntry *de, 759create_tunnel_to_destination (struct DestinationEntry *de,
806 struct GNUNET_SERVER_Client *client,
807 int client_af, 760 int client_af,
808 uint64_t request_id) 761 uint64_t request_id)
809{ 762{
@@ -815,11 +768,6 @@ create_tunnel_to_destination (struct DestinationEntry *de,
815 GNUNET_assert (NULL == de->ts); 768 GNUNET_assert (NULL == de->ts);
816 ts = GNUNET_new (struct TunnelState); 769 ts = GNUNET_new (struct TunnelState);
817 ts->af = client_af; 770 ts->af = client_af;
818 if (NULL != client)
819 {
820 ts->request_id = request_id;
821 ts->client = client;
822 }
823 ts->destination = *de; 771 ts->destination = *de;
824 ts->destination.heap_node = NULL; /* copy is NOT in destination heap */ 772 ts->destination.heap_node = NULL; /* copy is NOT in destination heap */
825 de->ts = ts; 773 de->ts = ts;
@@ -1093,7 +1041,7 @@ route_packet (struct DestinationEntry *destination,
1093 available) or create a fresh one */ 1041 available) or create a fresh one */
1094 is_new = GNUNET_YES; 1042 is_new = GNUNET_YES;
1095 if (NULL == destination->ts) 1043 if (NULL == destination->ts)
1096 ts = create_tunnel_to_destination (destination, NULL, af, 0); 1044 ts = create_tunnel_to_destination (destination, af, 0);
1097 else 1045 else
1098 ts = destination->ts; 1046 ts = destination->ts;
1099 if (NULL == ts) 1047 if (NULL == ts)
@@ -2579,16 +2527,17 @@ allocate_response_ip (int *result_af,
2579 2527
2580 2528
2581/** 2529/**
2582 * A client asks us to setup a redirection via some exit 2530 * A client asks us to setup a redirection via some exit node to a
2583 * node to a particular IP. Setup the redirection and 2531 * particular IP. Setup the redirection and give the client the
2584 * give the client the allocated IP. 2532 * allocated IP.
2585 * 2533 *
2586 * @param cls unused 2534 * @param cls unused
2587 * @param client requesting client 2535 * @param client requesting client
2588 * @param message redirection request (a `struct RedirectToIpRequestMessage`) 2536 * @param message redirection request (a `struct RedirectToIpRequestMessage`)
2589 */ 2537 */
2590static void 2538static void
2591service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *client, 2539service_redirect_to_ip (void *cls,
2540 struct GNUNET_SERVER_Client *client,
2592 const struct GNUNET_MessageHeader *message) 2541 const struct GNUNET_MessageHeader *message)
2593{ 2542{
2594 size_t mlen; 2543 size_t mlen;
@@ -2647,15 +2596,11 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
2647 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 2596 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
2648 return; 2597 return;
2649 } 2598 }
2650 if ( (result_af == AF_UNSPEC) || 2599 /* send reply with our IP address */
2651 (GNUNET_NO == ntohl (msg->nac)) ) 2600 send_client_reply (client,
2652 { 2601 msg->request_id,
2653 /* send reply "instantly" */ 2602 result_af,
2654 send_client_reply (client, 2603 addr);
2655 msg->request_id,
2656 result_af,
2657 addr);
2658 }
2659 if (result_af == AF_UNSPEC) 2604 if (result_af == AF_UNSPEC)
2660 { 2605 {
2661 /* failure, we're done */ 2606 /* failure, we're done */
@@ -2701,7 +2646,6 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
2701 2646
2702 /* setup tunnel to destination */ 2647 /* setup tunnel to destination */
2703 ts = create_tunnel_to_destination (de, 2648 ts = create_tunnel_to_destination (de,
2704 (GNUNET_NO == ntohl (msg->nac)) ? NULL : client,
2705 result_af, 2649 result_af,
2706 msg->request_id); 2650 msg->request_id);
2707 switch (result_af) 2651 switch (result_af)
@@ -2754,15 +2698,10 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
2754 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 2698 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
2755 return; 2699 return;
2756 } 2700 }
2757 if ( (result_af == AF_UNSPEC) || 2701 send_client_reply (client,
2758 (GNUNET_NO == ntohl (msg->nac)) ) 2702 msg->request_id,
2759 { 2703 result_af,
2760 /* send reply "instantly" */ 2704 addr);
2761 send_client_reply (client,
2762 msg->request_id,
2763 result_af,
2764 addr);
2765 }
2766 if (result_af == AF_UNSPEC) 2705 if (result_af == AF_UNSPEC)
2767 { 2706 {
2768 /* failure, we're done */ 2707 /* failure, we're done */
@@ -2802,7 +2741,6 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
2802 while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings) 2741 while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings)
2803 expire_destination (de); 2742 expire_destination (de);
2804 ts = create_tunnel_to_destination (de, 2743 ts = create_tunnel_to_destination (de,
2805 (GNUNET_NO == ntohl (msg->nac)) ? NULL : client,
2806 result_af, 2744 result_af,
2807 msg->request_id); 2745 msg->request_id);
2808 switch (result_af) 2746 switch (result_af)
@@ -2948,75 +2886,6 @@ cleanup (void *cls,
2948 2886
2949 2887
2950/** 2888/**
2951 * A client disconnected, clean up all references to it.
2952 *
2953 * @param cls the client that disconnected
2954 * @param key unused
2955 * @param value a `struct TunnelState *`
2956 * @return #GNUNET_OK (continue to iterate)
2957 */
2958static int
2959cleanup_tunnel_client (void *cls,
2960 const struct GNUNET_HashCode *key,
2961 void *value)
2962{
2963 struct GNUNET_SERVER_Client *client = cls;
2964 struct TunnelState *ts = value;
2965
2966 if (client == ts->client)
2967 ts->client = NULL;
2968 return GNUNET_OK;
2969}
2970
2971
2972/**
2973 * A client disconnected, clean up all references to it.
2974 *
2975 * @param cls the client that disconnected
2976 * @param key unused
2977 * @param value a `struct DestinationEntry *`
2978 * @return #GNUNET_OK (continue to iterate)
2979 */
2980static int
2981cleanup_destination_client (void *cls,
2982 const struct GNUNET_HashCode *key,
2983 void *value)
2984{
2985 struct GNUNET_SERVER_Client *client = cls;
2986 struct DestinationEntry *de = value;
2987 struct TunnelState *ts;
2988
2989 if (NULL == (ts = de->ts))
2990 return GNUNET_OK;
2991 if (client == ts->client)
2992 ts->client = NULL;
2993 return GNUNET_OK;
2994}
2995
2996
2997/**
2998 * A client has disconnected from us. If we are currently building
2999 * a tunnel for it, cancel the operation.
3000 *
3001 * @param cls unused
3002 * @param client handle to the client that disconnected
3003 */
3004static void
3005client_disconnect (void *cls,
3006 struct GNUNET_SERVER_Client *client)
3007{
3008 if (NULL != tunnel_map)
3009 GNUNET_CONTAINER_multihashmap_iterate (tunnel_map,
3010 &cleanup_tunnel_client,
3011 client);
3012 if (NULL != destination_map)
3013 GNUNET_CONTAINER_multihashmap_iterate (destination_map,
3014 &cleanup_destination_client,
3015 client);
3016}
3017
3018
3019/**
3020 * Main function that will be run by the scheduler. 2889 * Main function that will be run by the scheduler.
3021 * 2890 *
3022 * @param cls closure 2891 * @param cls closure
@@ -3176,7 +3045,6 @@ run (void *cls,
3176 &message_token, NULL, NULL); 3045 &message_token, NULL, NULL);
3177 nc = GNUNET_SERVER_notification_context_create (server, 1); 3046 nc = GNUNET_SERVER_notification_context_create (server, 1);
3178 GNUNET_SERVER_add_handlers (server, service_handlers); 3047 GNUNET_SERVER_add_handlers (server, service_handlers);
3179 GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL);
3180 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); 3048 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
3181} 3049}
3182 3050
diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c
index 6402e1063..4c8dc43c0 100644
--- a/src/vpn/gnunet-vpn.c
+++ b/src/vpn/gnunet-vpn.c
@@ -80,11 +80,6 @@ static int udp;
80static int verbosity; 80static int verbosity;
81 81
82/** 82/**
83 * Option '-a': Notify only once the tunnel is connected?
84 */
85static int nac;
86
87/**
88 * Global return value. 83 * Global return value.
89 */ 84 */
90static int ret; 85static int ret;
@@ -246,7 +241,6 @@ run (void *cls, char *const *args, const char *cfgfile,
246 protocol, 241 protocol,
247 &peer, 242 &peer,
248 &sd, 243 &sd,
249 nac,
250 etime, 244 etime,
251 &allocation_cb, NULL); 245 &allocation_cb, NULL);
252 } 246 }
@@ -275,7 +269,6 @@ run (void *cls, char *const *args, const char *cfgfile,
275 req_af, 269 req_af,
276 dst_af, 270 dst_af,
277 addr, 271 addr,
278 nac,
279 etime, 272 etime,
280 &allocation_cb, NULL); 273 &allocation_cb, NULL);
281 } 274 }
@@ -297,9 +290,6 @@ main (int argc, char *const *argv)
297 {'6', "ipv6", NULL, 290 {'6', "ipv6", NULL,
298 gettext_noop ("request that result should be an IPv6 address"), 291 gettext_noop ("request that result should be an IPv6 address"),
299 0, &GNUNET_GETOPT_set_one, &ipv6}, 292 0, &GNUNET_GETOPT_set_one, &ipv6},
300 {'a', "after-connect", NULL,
301 gettext_noop ("print IP address only after mesh tunnel has been created"),
302 0, &GNUNET_GETOPT_set_one, &ipv6},
303 {'d', "duration", "TIME", 293 {'d', "duration", "TIME",
304 gettext_noop ("how long should the mapping be valid for new tunnels?"), 294 gettext_noop ("how long should the mapping be valid for new tunnels?"),
305 1, &GNUNET_GETOPT_set_relative_time, &duration}, 295 1, &GNUNET_GETOPT_set_relative_time, &duration},
diff --git a/src/vpn/vpn.h b/src/vpn/vpn.h
index e1ae130e7..b74b5b766 100644
--- a/src/vpn/vpn.h
+++ b/src/vpn/vpn.h
@@ -38,15 +38,14 @@ GNUNET_NETWORK_STRUCT_BEGIN
38struct RedirectToIpRequestMessage 38struct RedirectToIpRequestMessage
39{ 39{
40 /** 40 /**
41 * Type is GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP 41 * Type is #GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP
42 */ 42 */
43 struct GNUNET_MessageHeader header; 43 struct GNUNET_MessageHeader header;
44 44
45 /** 45 /**
46 * GNUNET_YES to notify only after completion of the mesh-level connection, 46 * Always zero.
47 * GNUNET_NO to notify as soon as an address was allocated (in nbo).
48 */ 47 */
49 int32_t nac GNUNET_PACKED; 48 uint32_t reserved GNUNET_PACKED;
50 49
51 /** 50 /**
52 * How long should the redirection be maintained at most? 51 * How long should the redirection be maintained at most?
@@ -82,15 +81,14 @@ struct RedirectToIpRequestMessage
82struct RedirectToServiceRequestMessage 81struct RedirectToServiceRequestMessage
83{ 82{
84 /** 83 /**
85 * Type is GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE 84 * Type is #GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE
86 */ 85 */
87 struct GNUNET_MessageHeader header; 86 struct GNUNET_MessageHeader header;
88 87
89 /** 88 /**
90 * GNUNET_YES to notify only after completion of the mesh-level connection, 89 * Always zero.
91 * GNUNET_NO to notify as soon as an address was allocated (in nbo).
92 */ 90 */
93 int32_t nac GNUNET_PACKED; 91 uint32_t reserved GNUNET_PACKED;
94 92
95 /** 93 /**
96 * How long should the redirection be maintained at most? 94 * How long should the redirection be maintained at most?
@@ -134,7 +132,7 @@ struct RedirectToIpResponseMessage
134{ 132{
135 133
136 /** 134 /**
137 * Type is GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP 135 * Type is #GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP
138 */ 136 */
139 struct GNUNET_MessageHeader header; 137 struct GNUNET_MessageHeader header;
140 138
diff --git a/src/vpn/vpn_api.c b/src/vpn/vpn_api.c
index e4da5fae0..8539a6a37 100644
--- a/src/vpn/vpn_api.c
+++ b/src/vpn/vpn_api.c
@@ -143,12 +143,6 @@ struct GNUNET_VPN_RedirectionRequest
143 int addr_af; 143 int addr_af;
144 144
145 /** 145 /**
146 * GNUNET_YES if we are to call the callback only after successful
147 * mesh tunnel creation.
148 */
149 int nac;
150
151 /**
152 * For service redirection, IPPROT_UDP or IPPROTO_TCP. 146 * For service redirection, IPPROT_UDP or IPPROTO_TCP.
153 */ 147 */
154 uint8_t protocol; 148 uint8_t protocol;
@@ -285,7 +279,7 @@ transmit_request (void *cls,
285 GNUNET_assert (ret <= size); 279 GNUNET_assert (ret <= size);
286 rs.header.size = htons ((uint16_t) ret); 280 rs.header.size = htons ((uint16_t) ret);
287 rs.header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE); 281 rs.header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE);
288 rs.nac = htonl (rr->nac); 282 rs.reserved = htonl (0);
289 rs.expiration_time = GNUNET_TIME_absolute_hton (rr->expiration_time); 283 rs.expiration_time = GNUNET_TIME_absolute_hton (rr->expiration_time);
290 rs.protocol = htonl (rr->protocol); 284 rs.protocol = htonl (rr->protocol);
291 rs.result_af = htonl (rr->result_af); 285 rs.result_af = htonl (rr->result_af);
@@ -312,7 +306,7 @@ transmit_request (void *cls,
312 GNUNET_assert (ret <= size); 306 GNUNET_assert (ret <= size);
313 rip.header.size = htons ((uint16_t) ret); 307 rip.header.size = htons ((uint16_t) ret);
314 rip.header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP); 308 rip.header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP);
315 rip.nac = htonl (rr->nac); 309 rip.reserved = htonl (0);
316 rip.expiration_time = GNUNET_TIME_absolute_hton (rr->expiration_time); 310 rip.expiration_time = GNUNET_TIME_absolute_hton (rr->expiration_time);
317 rip.result_af = htonl (rr->result_af); 311 rip.result_af = htonl (rr->result_af);
318 rip.addr_af = htonl (rr->addr_af); 312 rip.addr_af = htonl (rr->addr_af);
@@ -448,9 +442,6 @@ GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr)
448 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP 442 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
449 * @param peer target peer for the redirection 443 * @param peer target peer for the redirection
450 * @param serv service descriptor to give to the peer 444 * @param serv service descriptor to give to the peer
451 * @param nac GNUNET_YES to notify via callback only after completion of
452 * the MESH-level connection,
453 * GNUNET_NO to notify as soon as the IP has been reserved
454 * @param expiration_time at what time should the redirection expire? 445 * @param expiration_time at what time should the redirection expire?
455 * (this should not impact connections that are active at that time) 446 * (this should not impact connections that are active at that time)
456 * @param cb function to call with the IP 447 * @param cb function to call with the IP
@@ -465,14 +456,13 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
465 uint8_t protocol, 456 uint8_t protocol,
466 const struct GNUNET_PeerIdentity *peer, 457 const struct GNUNET_PeerIdentity *peer,
467 const struct GNUNET_HashCode *serv, 458 const struct GNUNET_HashCode *serv,
468 int nac,
469 struct GNUNET_TIME_Absolute expiration_time, 459 struct GNUNET_TIME_Absolute expiration_time,
470 GNUNET_VPN_AllocationCallback cb, 460 GNUNET_VPN_AllocationCallback cb,
471 void *cb_cls) 461 void *cb_cls)
472{ 462{
473 struct GNUNET_VPN_RedirectionRequest *rr; 463 struct GNUNET_VPN_RedirectionRequest *rr;
474 464
475 rr = GNUNET_malloc (sizeof (struct GNUNET_VPN_RedirectionRequest)); 465 rr = GNUNET_new (struct GNUNET_VPN_RedirectionRequest);
476 rr->vh = vh; 466 rr->vh = vh;
477 rr->cb = cb; 467 rr->cb = cb;
478 rr->cb_cls = cb_cls; 468 rr->cb_cls = cb_cls;
@@ -480,7 +470,6 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
480 rr->serv = *serv; 470 rr->serv = *serv;
481 rr->expiration_time = expiration_time; 471 rr->expiration_time = expiration_time;
482 rr->result_af = result_af; 472 rr->result_af = result_af;
483 rr->nac = nac;
484 rr->protocol = protocol; 473 rr->protocol = protocol;
485 queue_request (rr); 474 queue_request (rr);
486 return rr; 475 return rr;
@@ -501,9 +490,6 @@ GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
501 * @param addr_af address family for 'addr', AF_INET or AF_INET6 490 * @param addr_af address family for 'addr', AF_INET or AF_INET6
502 * @param addr destination IP address on the Internet; destination 491 * @param addr destination IP address on the Internet; destination
503 * port is to be taken from the VPN packet itself 492 * port is to be taken from the VPN packet itself
504 * @param nac GNUNET_YES to notify via callback only after completion of
505 * the MESH-level connection,
506 * GNUNET_NO to notify as soon as the IP has been reserved
507 * @param expiration_time at what time should the redirection expire? 493 * @param expiration_time at what time should the redirection expire?
508 * (this should not impact connections that are active at that time) 494 * (this should not impact connections that are active at that time)
509 * @param cb function to call with the IP 495 * @param cb function to call with the IP
@@ -517,7 +503,6 @@ GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
517 int result_af, 503 int result_af,
518 int addr_af, 504 int addr_af,
519 const void *addr, 505 const void *addr,
520 int nac,
521 struct GNUNET_TIME_Absolute expiration_time, 506 struct GNUNET_TIME_Absolute expiration_time,
522 GNUNET_VPN_AllocationCallback cb, 507 GNUNET_VPN_AllocationCallback cb,
523 void *cb_cls) 508 void *cb_cls)
@@ -545,7 +530,6 @@ GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
545 rr->expiration_time = expiration_time; 530 rr->expiration_time = expiration_time;
546 rr->result_af = result_af; 531 rr->result_af = result_af;
547 rr->addr_af = addr_af; 532 rr->addr_af = addr_af;
548 rr->nac = nac;
549 memcpy (&rr[1], addr, alen); 533 memcpy (&rr[1], addr, alen);
550 queue_request (rr); 534 queue_request (rr);
551 return rr; 535 return rr;
@@ -563,7 +547,7 @@ GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
563{ 547{
564 struct GNUNET_VPN_Handle *vh; 548 struct GNUNET_VPN_Handle *vh;
565 549
566 vh = GNUNET_malloc (sizeof (struct GNUNET_VPN_Handle)); 550 vh = GNUNET_new (struct GNUNET_VPN_Handle);
567 vh->cfg = cfg; 551 vh->cfg = cfg;
568 vh->client = GNUNET_CLIENT_connect ("vpn", cfg); 552 vh->client = GNUNET_CLIENT_connect ("vpn", cfg);
569 if (NULL == vh->client) 553 if (NULL == vh->client)