From e055f79625bb0537b59e230505dc563f8a252e30 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Sun, 18 Sep 2011 11:59:13 +0000 Subject: [PATCH] fix bug in -vpn --- src/vpn/gnunet-daemon-vpn-helper.c | 17 +++++++++++------ src/vpn/gnunet-daemon-vpn.c | 7 +++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c index 9ce1e2996..eed073e07 100644 --- a/src/vpn/gnunet-daemon-vpn-helper.c +++ b/src/vpn/gnunet-daemon-vpn-helper.c @@ -296,7 +296,7 @@ message_token (void *cls __attribute__ ((unused)), void *client (port_in_ports (me->desc.ports, pkt6_udp->udp_hdr.dpt) || testBit (me->additional_ports, ntohs (pkt6_udp->udp_hdr.dpt)))) { - hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP); + hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP); memcpy (hc + 1, &pkt6_udp->udp_hdr, ntohs (pkt6_udp->udp_hdr.len)); @@ -305,11 +305,16 @@ message_token (void *cls __attribute__ ((unused)), void *client (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)) && (port_in_ports (me->desc.ports, pkt6_tcp->tcp_hdr.dpt))) { - hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP); + hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP); memcpy (hc + 1, &pkt6_tcp->tcp_hdr, ntohs (pkt6->ip6_hdr.paylgth)); } + else + { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "pip: %d\n", port_in_ports(me->desc.ports, pkt6_tcp->tcp_hdr.dpt)); + GNUNET_assert(0); + } if (me->tunnel == NULL && NULL != cls) { *cls = @@ -328,7 +333,7 @@ message_token (void *cls __attribute__ ((unused)), void *client *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", + "Queued to send IPv6 to peer %x, type %d\n", *((unsigned int *) &me->desc.peer), ntohs (hdr->type)); } } @@ -495,7 +500,7 @@ message_token (void *cls __attribute__ ((unused)), void *client (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_VPN_SERVICE_UDP); + hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP); memcpy (hc + 1, &pkt_udp->udp_hdr, ntohs (pkt_udp->udp_hdr.len)); @@ -505,7 +510,7 @@ message_token (void *cls __attribute__ ((unused)), void *client 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_VPN_SERVICE_TCP); + hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP); memcpy (hc + 1, &pkt_tcp->tcp_hdr, ntohs (pkt->ip_hdr.tot_lngth) - @@ -530,7 +535,7 @@ message_token (void *cls __attribute__ ((unused)), void *client *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", + "Queued to send IPv4 to peer %x, type %d\n", *((unsigned int *) &me->desc.peer), ntohs (hdr->type)); } diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 47eb9cf82..9c944ebef 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -329,7 +329,7 @@ port_in_ports (uint64_t ports, uint16_t port) { uint16_t *ps = (uint16_t *) & ports; - return ps[0] == port || ps[1] == port || ps[2] == port || ps[3] == port; + return ports == 0 || ps[0] == port || ps[1] == port || ps[2] == port || ps[3] == port; } void @@ -1056,7 +1056,10 @@ receive_tcp_back (void *cls ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - sizeof (GNUNET_HashCode); - if (s->addrlen == 16) + 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) { size_t size = pktlen + sizeof (struct ip6_tcp) - 1; -- 2.25.1