/*}}}*/
+void
+initialize_tunnel_state(struct GNUNET_MESH_Tunnel* tunnel, int addrlen, struct GNUNET_MESH_TransmitHandle* th)
+{
+ struct tunnel_state* ts = GNUNET_malloc(sizeof *ts);
+ ts->addrlen = addrlen;
+ ts->th = th;
+ GNUNET_MESH_tunnel_set_data(tunnel, ts);
+}
+
/**
* Send an dns-answer-packet to the helper
*/
send_pkt_to_peer, NULL,
cls);
me->tunnel = *cls;
+ initialize_tunnel_state(me->tunnel, 16, NULL);
}
else if (NULL != cls)
{
send_pkt_to_peer,
NULL, cls);
me->tunnel = *cls;
+ initialize_tunnel_state(me->tunnel, 16, NULL);
if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type)
udp_tunnel = *cls;
else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type)
send_pkt_to_peer, NULL,
cls);
me->tunnel = *cls;
+ initialize_tunnel_state(me->tunnel, 4, NULL);
}
else if (NULL != cls)
{
send_pkt_to_peer,
NULL, cls);
me->tunnel = *cls;
+ initialize_tunnel_state(me->tunnel, 4, NULL);
}
else if (NULL != cls)
{
{
struct GNUNET_MESH_Tunnel **tunnel = cls;
- GNUNET_MESH_tunnel_set_data (*tunnel, NULL);
+ struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
+ ts->th = NULL;
if (NULL != buf)
{
GNUNET_MESH_tunnel_set_head (*tunnel, head);
GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
- struct GNUNET_MESH_TransmitHandle *th =
+ ts->th =
GNUNET_MESH_notify_transmit_ready (*tunnel,
GNUNET_NO,
42,
element->cls);
/* save the handle */
- GNUNET_MESH_tunnel_set_data (*tunnel, th);
GNUNET_free (element);
}
GNUNET_free (cls);
GNUNET_assert (NULL != tunnel);
GNUNET_assert (NULL != *tunnel);
- if (NULL == GNUNET_MESH_tunnel_get_data (*tunnel))
+ struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
+ if (NULL == ts->th)
{
- struct GNUNET_MESH_TransmitHandle *th =
+ ts->th =
GNUNET_MESH_notify_transmit_ready (*tunnel,
GNUNET_NO,
42,
ntohs (hdr->size),
send_pkt_to_peer_notify_callback,
cls);
-
- GNUNET_MESH_tunnel_set_data (*tunnel, th);
}
else
{
struct remote_addr *s = (struct remote_addr *) desc;
struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
+ struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
- if (16 == s->addrlen)
+ if (16 == ts->addrlen)
{
size_t size =
sizeof (struct ip6_udp) + ntohs (pkt->len) - 1 -
struct remote_addr *s = (struct remote_addr *) desc;
struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1);
const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
+ struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
size_t pktlen =
ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) -
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet back, addrlen = %d\n", s->addrlen);
if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP_BACK ||
- s->addrlen == 16)
+ ts->addrlen == 16)
{
size_t size = pktlen + sizeof (struct ip6_tcp) - 1;