diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-06-15 07:15:33 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-06-15 07:15:33 +0000 |
commit | bd039b96c0050dbe4bfc2173b58611aa1ce6517a (patch) | |
tree | 08e62eaa9f2112b37a14fa69a479b1f76e041a33 /src/vpn | |
parent | 73c443600ed1c75ccaa1436d81dd89da7968e5f5 (diff) | |
download | gnunet-bd039b96c0050dbe4bfc2173b58611aa1ce6517a.tar.gz gnunet-bd039b96c0050dbe4bfc2173b58611aa1ce6517a.zip |
handle traffic from remotes hosts coming back to daemon-vpn
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn-helper.c | 7 | ||||
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 30 | ||||
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.h | 7 |
3 files changed, 29 insertions, 15 deletions
diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c index 3ac11a2b2..ca885ecec 100644 --- a/src/vpn/gnunet-daemon-vpn-helper.c +++ b/src/vpn/gnunet-daemon-vpn-helper.c | |||
@@ -45,13 +45,6 @@ | |||
45 | 45 | ||
46 | struct GNUNET_VPN_HELPER_Handle *helper_handle; | 46 | struct GNUNET_VPN_HELPER_Handle *helper_handle; |
47 | 47 | ||
48 | struct remote_addr | ||
49 | { | ||
50 | char addrlen; | ||
51 | unsigned char addr[16]; | ||
52 | char proto; | ||
53 | }; | ||
54 | |||
55 | /** | 48 | /** |
56 | * Start the helper-process | 49 | * Start the helper-process |
57 | * | 50 | * |
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 6da86a0eb..3e32ab149 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -528,6 +528,7 @@ receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | |||
528 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 528 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
529 | { | 529 | { |
530 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); | 530 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); |
531 | struct remote_addr* s = (struct remote_addr*)desc; | ||
531 | struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); | 532 | struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); |
532 | const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel); | 533 | const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel); |
533 | 534 | ||
@@ -537,7 +538,10 @@ receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | |||
537 | 538 | ||
538 | GNUNET_assert(pkt6 != NULL); | 539 | GNUNET_assert(pkt6 != NULL); |
539 | 540 | ||
540 | new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc); | 541 | if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK) |
542 | new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc); | ||
543 | else | ||
544 | new_ip6addr_remote(pkt6->ip6_hdr.sadr, s->addr, s->addrlen); | ||
541 | 545 | ||
542 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d bytes!\n", size, ntohs(message->size), ntohs(pkt->len)); | 546 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d bytes!\n", size, ntohs(message->size), ntohs(pkt->len)); |
543 | 547 | ||
@@ -573,11 +577,14 @@ receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | |||
573 | GNUNET_free(key); | 577 | GNUNET_free(key); |
574 | 578 | ||
575 | GNUNET_assert (me != NULL); | 579 | GNUNET_assert (me != NULL); |
576 | GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP)); | 580 | if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK) |
577 | if (!port_in_ports(me->desc.ports, pkt6->udp_hdr.spt) && | 581 | { |
578 | !testBit(me->additional_ports, ntohs(pkt6->udp_hdr.spt))) { | 582 | GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP)); |
579 | add_additional_port(me, ntohs(pkt6->udp_hdr.spt)); | 583 | if (!port_in_ports(me->desc.ports, pkt6->udp_hdr.spt) && |
580 | } | 584 | !testBit(me->additional_ports, ntohs(pkt6->udp_hdr.spt))) { |
585 | add_additional_port(me, ntohs(pkt6->udp_hdr.spt)); | ||
586 | } | ||
587 | } | ||
581 | 588 | ||
582 | pkt6->udp_hdr.crc = 0; | 589 | pkt6->udp_hdr.crc = 0; |
583 | uint32_t sum = 0; | 590 | uint32_t sum = 0; |
@@ -604,6 +611,7 @@ receive_tcp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | |||
604 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 611 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
605 | { | 612 | { |
606 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); | 613 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); |
614 | struct remote_addr* s = (struct remote_addr*)desc; | ||
607 | struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); | 615 | struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); |
608 | const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel); | 616 | const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel); |
609 | 617 | ||
@@ -614,7 +622,10 @@ receive_tcp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | |||
614 | 622 | ||
615 | GNUNET_assert(pkt6 != NULL); | 623 | GNUNET_assert(pkt6 != NULL); |
616 | 624 | ||
617 | new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc); | 625 | if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK) |
626 | new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc); | ||
627 | else | ||
628 | new_ip6addr_remote(pkt6->ip6_hdr.sadr, s->addr, s->addrlen); | ||
618 | 629 | ||
619 | pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER); | 630 | pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER); |
620 | pkt6->shdr.size = htons(size); | 631 | pkt6->shdr.size = htons(size); |
@@ -648,7 +659,8 @@ receive_tcp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | |||
648 | GNUNET_free(key); | 659 | GNUNET_free(key); |
649 | 660 | ||
650 | GNUNET_assert (me != NULL); | 661 | GNUNET_assert (me != NULL); |
651 | GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_TCP)); | 662 | if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK) |
663 | GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_TCP)); | ||
652 | 664 | ||
653 | pkt6->tcp_hdr.crc = 0; | 665 | pkt6->tcp_hdr.crc = 0; |
654 | uint32_t sum = 0; | 666 | uint32_t sum = 0; |
@@ -689,6 +701,8 @@ run (void *cls, | |||
689 | const static struct GNUNET_MESH_MessageHandler handlers[] = { | 701 | const static struct GNUNET_MESH_MessageHandler handlers[] = { |
690 | {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0}, | 702 | {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0}, |
691 | {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0}, | 703 | {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0}, |
704 | {receive_udp_back, GNUNET_MESSAGE_TYPE_REMOTE_UDP_BACK, 0}, | ||
705 | {receive_tcp_back, GNUNET_MESSAGE_TYPE_REMOTE_TCP_BACK, 0}, | ||
692 | {NULL, 0, 0} | 706 | {NULL, 0, 0} |
693 | }; | 707 | }; |
694 | mesh_handle = GNUNET_MESH_connect(cfg_, | 708 | mesh_handle = GNUNET_MESH_connect(cfg_, |
diff --git a/src/vpn/gnunet-daemon-vpn.h b/src/vpn/gnunet-daemon-vpn.h index 3ddd6eef6..85d806603 100644 --- a/src/vpn/gnunet-daemon-vpn.h +++ b/src/vpn/gnunet-daemon-vpn.h | |||
@@ -110,4 +110,11 @@ void clearBit (char *bitArray, unsigned int bitIdx); | |||
110 | */ | 110 | */ |
111 | int testBit (char *bitArray, unsigned int bitIdx); | 111 | int testBit (char *bitArray, unsigned int bitIdx); |
112 | 112 | ||
113 | struct remote_addr | ||
114 | { | ||
115 | char addrlen; | ||
116 | unsigned char addr[16]; | ||
117 | char proto; | ||
118 | }; | ||
119 | |||
113 | #endif /* end of include guard: GNUNET-DAEMON-VPN_H */ | 120 | #endif /* end of include guard: GNUNET-DAEMON-VPN_H */ |