#define MAX_MESSAGE_QUEUE_SIZE 4
+#define PORT_VPN 42
+
/**
* State we keep for each of our tunnels.
*/
/**
* Method called whenever a peer has disconnected from the tunnel.
*
+ * FIXME merge with inbound_cleaner
+ *
* @param cls closure
* @param peer peer identity the tunnel stopped working with
*/
-static void
+void
tunnel_peer_disconnect_handler (void *cls,
const struct
GNUNET_PeerIdentity * peer)
* Method called whenever a peer has connected to the tunnel. Notifies
* the waiting client that the tunnel is now up.
*
+ * FIXME merge with tunnel_create
+ *
* @param cls closure
* @param peer peer identity the tunnel was created to, NULL on timeout
* @param atsi performance data for the connection
*/
-static void
+void
tunnel_peer_connect_handler (void *cls,
const struct GNUNET_PeerIdentity
* peer,
ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel,
GNUNET_NO /* cork */,
GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
tnq->len,
&send_to_peer_notify_callback,
ts);
ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel,
GNUNET_NO /* cork */,
GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
tnq->len,
&send_to_peer_notify_callback,
ts);
GNUNET_REGEX_search_cancel (ts->search);
ts->search = NULL;
ts->tunnel = GNUNET_MESH_tunnel_create (mesh_handle,
- ts,
- &tunnel_peer_connect_handler,
- &tunnel_peer_disconnect_handler,
- ts);
- GNUNET_MESH_peer_request_connect_add (ts->tunnel,
- id);
+ ts,
+ id,
+ PORT_VPN,
+ GNUNET_YES,
+ GNUNET_NO);
}
{
ts->tunnel = GNUNET_MESH_tunnel_create (mesh_handle,
ts,
- &tunnel_peer_connect_handler,
- &tunnel_peer_disconnect_handler,
- ts);
+ &de->details.service_destination.target,
+ PORT_VPN,
+ GNUNET_YES,
+ GNUNET_NO);
if (NULL == ts->tunnel)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Creating tunnel to peer %s offering service %s\n",
GNUNET_i2s (&de->details.service_destination.target),
GNUNET_h2s (&de->details.service_destination.service_descriptor));
- GNUNET_MESH_peer_request_connect_add (ts->tunnel,
- &de->details.service_destination.target);
}
else
{
{
char address[GNUNET_TUN_IPV4_REGEXLEN];
- GNUNET_TUN_ipv4toregex (&de->details.exit_destination.ip.v4,
+ GNUNET_TUN_ipv4toregexsearch (&de->details.exit_destination.ip.v4,
"255.255.255.255", address);
GNUNET_asprintf (&policy, "%s%s%s",
GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
{
char address[GNUNET_TUN_IPV6_REGEXLEN];
- GNUNET_TUN_ipv6toregex (&de->details.exit_destination.ip.v6,
+ GNUNET_TUN_ipv6toregexsearch (&de->details.exit_destination.ip.v6,
128, address);
GNUNET_asprintf (&policy, "%s%s%s",
GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
ts->destination_port = destination_port;
ts->heap_node = GNUNET_CONTAINER_heap_insert (tunnel_heap,
ts,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (tunnel_map,
&key,
is_new = GNUNET_NO;
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
}
GNUNET_assert (NULL != ts->tunnel);
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ void **tunnel_ctx,
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *ts = *tunnel_ctx;
const struct GNUNET_EXIT_IcmpToVPNMessage *i2v;
}
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return GNUNET_OK;
}
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ void **tunnel_ctx,
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *ts = *tunnel_ctx;
const struct GNUNET_EXIT_UdpReplyMessage *reply;
}
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return GNUNET_OK;
}
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *ts = *tunnel_ctx;
const struct GNUNET_EXIT_TcpDataMessage *data;
}
GNUNET_CONTAINER_heap_update_cost (tunnel_heap,
ts->heap_node,
- GNUNET_TIME_absolute_get ().abs_value);
+ GNUNET_TIME_absolute_get ().abs_value_us);
return GNUNET_OK;
}
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
de->heap_node = GNUNET_CONTAINER_heap_insert (destination_heap,
de,
- GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value);
+ GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value_us);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Active destinations"),
1, GNUNET_NO);
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
de->heap_node = GNUNET_CONTAINER_heap_insert (destination_heap,
de,
- GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value);
+ GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value_us);
while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings)
expire_destination (de);
ts = create_tunnel_to_destination (de,
}
-
-/**
- * Function called for inbound tunnels. As we don't offer
- * any mesh services, this function should never be called.
- *
- * @param cls closure
- * @param tunnel new handle to the tunnel
- * @param initiator peer that started the tunnel
- * @param atsi performance information for the tunnel
- * @return initial tunnel context for the tunnel
- * (can be NULL -- that's not an error)
- */
-static void *
-inbound_tunnel_cb (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
- const struct GNUNET_PeerIdentity *initiator,
- const struct GNUNET_ATS_Information *atsi)
-{
- /* How can and why should anyone open an inbound tunnel to vpn? */
- GNUNET_break (0);
- return NULL;
-}
-
-
/**
* Function called whenever an inbound tunnel is destroyed. Should clean up
* any associated state.
+ *
+ * FIXME now its also user for disconnections
*
* @param cls closure (set from GNUNET_MESH_connect)
* @param tunnel connection to the other end (henceforth invalid)
{ &receive_icmp_back, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN, 0},
{NULL, 0, 0}
};
- static const GNUNET_MESH_ApplicationType types[] = {
- GNUNET_APPLICATION_TYPE_END
- };
char *ifname;
char *ipv6addr;
char *ipv6prefix_s;
mesh_handle =
GNUNET_MESH_connect (cfg_, NULL,
- &inbound_tunnel_cb,
+ NULL,
&tunnel_cleaner,
mesh_handlers,
- types);
+ NULL);
helper_handle = GNUNET_HELPER_start (GNUNET_NO,
"gnunet-helper-vpn", vpn_argv,
&message_token, NULL, NULL);