[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16231 - gnunet/src/vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16231 - gnunet/src/vpn |
Date: |
Wed, 27 Jul 2011 09:28:23 +0200 |
Author: toelke
Date: 2011-07-27 09:28:23 +0200 (Wed, 27 Jul 2011)
New Revision: 16231
Modified:
gnunet/src/vpn/gnunet-daemon-exit.c
gnunet/src/vpn/gnunet-daemon-vpn-helper.c
Log:
send ipv4 through gnunet
Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-07-27 07:28:21 UTC (rev 16230)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-07-27 07:28:23 UTC (rev 16231)
@@ -237,7 +237,6 @@
GNUNET_assert (size >= ntohs (hdr->size));
memcpy (buf, hdr, ntohs (hdr->size));
size = ntohs(hdr->size);
- GNUNET_free (cls);
if (NULL != GNUNET_MESH_tunnel_get_head(*tunnel))
{
@@ -262,6 +261,8 @@
GNUNET_MESH_tunnel_set_data(*tunnel, th);
}
+ GNUNET_free (cls);
+
return size;
}
Modified: gnunet/src/vpn/gnunet-daemon-vpn-helper.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-helper.c 2011-07-27 07:28:21 UTC (rev
16230)
+++ gnunet/src/vpn/gnunet-daemon-vpn-helper.c 2011-07-27 07:28:23 UTC (rev
16231)
@@ -455,7 +455,121 @@
if ((key = address4_mapping_exists (dadr)) != NULL)
{
+ struct map_entry *me =
+ GNUNET_CONTAINER_multihashmap_get (hashmap, key);
+ GNUNET_assert (me != NULL);
+ GNUNET_free (key);
+
+ size_t size =
+ sizeof (struct GNUNET_MESH_Tunnel *) +
+ sizeof (struct GNUNET_MessageHeader) +
+ sizeof (GNUNET_HashCode) + ntohs (pkt->ip_hdr.tot_lngth) -
4*pkt->ip_hdr.hdr_lngth;
+
+ struct GNUNET_MESH_Tunnel **cls = GNUNET_malloc (size);
+ struct GNUNET_MessageHeader *hdr =
+ (struct GNUNET_MessageHeader *) (cls + 1);
+ GNUNET_HashCode *hc = (GNUNET_HashCode *) (hdr + 1);
+
+ hdr->size = htons (sizeof (struct GNUNET_MessageHeader) +
sizeof (GNUNET_HashCode) + ntohs (pkt->ip_hdr.tot_lngth) -
4*pkt->ip_hdr.hdr_lngth);
+
+ GNUNET_MESH_ApplicationType app_type;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "me->addrlen is %d\n",
me->addrlen);
+ if (me->addrlen == 0)
+ {
+ /* This is a mapping to a gnunet-service */
+ memcpy (hc, &me->desc.service_descriptor,
+ sizeof (GNUNET_HashCode));
+
+ if (0x11 == pkt->ip_hdr.proto
+ && (me->desc.
+ service_type & htonl
(GNUNET_DNS_SERVICE_TYPE_UDP))
+ && (port_in_ports (me->desc.ports,
pkt_udp->udp_hdr.dpt)
+ || testBit (me->additional_ports,
+ ntohs (pkt_udp->udp_hdr.dpt))))
+ {
+ hdr->type = ntohs (GNUNET_MESSAGE_TYPE_SERVICE_UDP);
+
+ memcpy (hc + 1, &pkt_udp->udp_hdr,
+ ntohs (pkt_udp->udp_hdr.len));
+
+ }
+ else if (0x06 == pkt->ip_hdr.proto
+ && (me->desc.
+ service_type & htonl
(GNUNET_DNS_SERVICE_TYPE_TCP))
+ &&
+ (port_in_ports (me->desc.ports,
pkt_tcp->tcp_hdr.dpt)))
+ {
+ hdr->type = ntohs (GNUNET_MESSAGE_TYPE_SERVICE_TCP);
+
+ memcpy (hc + 1, &pkt_tcp->tcp_hdr,
+ ntohs (pkt->ip_hdr.tot_lngth) -
4*pkt->ip_hdr.hdr_lngth);
+
+ }
+ if (me->tunnel == NULL && NULL != cls)
+ {
+ *cls =
+ GNUNET_MESH_peer_request_connect_all (mesh_handle,
+
GNUNET_TIME_UNIT_FOREVER_REL,
+ 1,
+ (struct
+
GNUNET_PeerIdentity
+ *)
&me->desc.peer,
+
send_pkt_to_peer,
+ NULL, cls);
+ me->tunnel = *cls;
+ }
+ else if (NULL != cls)
+ {
+ *cls = me->tunnel;
+ send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity
*) 1,
+ NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Queued to send to peer %x, type %d\n",
+ *((unsigned int *) &me->desc.peer),
ntohs(hdr->type));
+ }
+ }
+ else
+ {
+ /* This is a mapping to a "real" address */
+ struct remote_addr *s = (struct remote_addr*) hc;
+ s->addrlen = me->addrlen;
+ memcpy(s->addr, me->addr, me->addrlen);
+ s->proto= pkt->ip_hdr.proto;
+ if (s->proto == 0x11)
+ {
+ hdr->type = htons(GNUNET_MESSAGE_TYPE_REMOTE_UDP);
+ memcpy (hc + 1, &pkt_udp->udp_hdr,
+ ntohs (pkt_udp->udp_hdr.len));
+ app_type =
GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY;
+ }
+ else if (s->proto == 0x06)
+ {
+ hdr->type = htons(GNUNET_MESSAGE_TYPE_REMOTE_TCP);
+ memcpy (hc + 1, &pkt_tcp->tcp_hdr,
+ ntohs (pkt->ip_hdr.tot_lngth) -
4*pkt->ip_hdr.hdr_lngth);
+ app_type =
GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY;
+ }
+ if (me->tunnel == NULL && NULL != cls)
+ {
+ *cls =
GNUNET_MESH_peer_request_connect_by_type(mesh_handle,
+
GNUNET_TIME_UNIT_FOREVER_REL,
+
app_type,
+
send_pkt_to_peer,
+ NULL,
+ cls);
+ me->tunnel = *cls;
+ }
+ else if (NULL != cls)
+ {
+ *cls = me->tunnel;
+ send_pkt_to_peer(cls, (struct GNUNET_PeerIdentity*)
1, NULL);
+ }
+ }
}
+ else
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Packet to %x which has
no mapping\n", dadr);
+ }
break;
case 0x01:
/* ICMP */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16231 - gnunet/src/vpn,
gnunet <=