From 8154c9edf0d39e8fec6f199115b02e84e49bba0b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 20 Jan 2012 17:21:21 +0000 Subject: [PATCH] -use different message types for different directions for TCP DATA --- src/exit/gnunet-daemon-exit.c | 5 +++-- src/include/gnunet_protocols.h | 15 ++++++++++----- src/vpn/gnunet-service-vpn.c | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 316133a75..9bdfba7da 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c @@ -721,7 +721,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, tnq->len = mlen; tdm = (struct GNUNET_EXIT_TcpDataMessage *) &tnq[1]; tdm->header.size = htons ((uint16_t) mlen); - tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA); + tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN); tdm->reserved = htonl (0); memcpy (&tdm->tcp_header, buf, @@ -789,6 +789,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, _("IPv4 packet options received. Ignored.\n")); return; } + size -= sizeof (struct GNUNET_TUN_IPv4Header); switch (pkt4->protocol) { @@ -2143,7 +2144,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0}, {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0}, {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0}, - {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA, 0}, + {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0}, {NULL, 0, 0} }; diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index bda20e37d..1bd590d5e 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -597,27 +597,32 @@ extern "C" /** * Type of messages containing an DNS request for a DNS exit service. */ -#define GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET 194 +#define GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET 193 /** * Type of messages containing an DNS reply from a DNS exit service. */ -#define GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET 195 +#define GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET 194 /** * Type of messages containing an TCP packet for a service. */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START 196 +#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START 195 /** * Type of messages containing an TCP packet for the Internet. */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START 197 +#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START 196 /** * Type of messages containing an TCP packet of an established connection. */ -#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA 198 +#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT 197 + +/** + * Type of messages containing an TCP packet of an established connection. + */ +#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN 198 /** * Type of messages containing an UDP packet for a service. diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index fe431b994..6b89c46ae 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -1196,7 +1196,7 @@ route_packet (struct DestinationEntry *destination, tnq->msg = &tnq[1]; tdm = (struct GNUNET_EXIT_TcpDataMessage *) &tnq[1]; tdm->header.size = htons ((uint16_t) mlen); - tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA); + tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT); tdm->reserved = htonl (0); tdm->tcp_header = *tcp; memcpy (&tdm[1], @@ -2322,7 +2322,7 @@ run (void *cls, }; static const struct GNUNET_MESH_MessageHandler mesh_handlers[] = { { &receive_udp_back, GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY, 0}, - { &receive_tcp_back, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA, 0}, + { &receive_tcp_back, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN, 0}, {NULL, 0, 0} }; static const GNUNET_MESH_ApplicationType types[] = { -- 2.25.1