From 9d077316ac3c6a18a4b13e90d7549188c2fe1f81 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 17 Jan 2012 19:06:15 +0000 Subject: [PATCH] -renaming TUN structs to follow namnig conventions --- src/dns/dnsparser.c | 16 ++-- src/dns/gnunet-service-dns.c | 78 ++++++++++---------- src/exit/exit.h | 6 +- src/exit/gnunet-daemon-exit.c | 116 ++++++++++++++--------------- src/include/gnunet_tun_lib.h | 38 +++++----- src/tun/Makefile.am | 2 +- src/vpn/gnunet-service-vpn.c | 134 +++++++++++++++++----------------- 7 files changed, 195 insertions(+), 195 deletions(-) diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c index 12253a2e7..63207d5ce 100644 --- a/src/dns/dnsparser.c +++ b/src/dns/dnsparser.c @@ -32,7 +32,7 @@ // DNS-Stuff GNUNET_NETWORK_STRUCT_BEGIN /* FIXME: replace this one with the one from tcpip_tun.h! */ -struct dns_header +struct GNUNET_TUN_DnsHeader { uint16_t id GNUNET_PACKED; struct GNUNET_DNSPARSER_Flags flags; @@ -306,15 +306,15 @@ GNUNET_DNSPARSER_parse (const char *udp_payload, size_t udp_payload_length) { struct GNUNET_DNSPARSER_Packet *p; - const struct dns_header *dns; + const struct GNUNET_TUN_DnsHeader *dns; size_t off; unsigned int n; unsigned int i; - if (udp_payload_length < sizeof (struct dns_header)) + if (udp_payload_length < sizeof (struct GNUNET_TUN_DnsHeader)) return NULL; - dns = (const struct dns_header *) udp_payload; - off = sizeof (struct dns_header); + dns = (const struct GNUNET_TUN_DnsHeader *) udp_payload; + off = sizeof (struct GNUNET_TUN_DnsHeader); p = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_Packet)); p->flags = dns->flags; p->id = dns->id; @@ -711,7 +711,7 @@ GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, char **buf, size_t *buf_length) { - struct dns_header dns; + struct GNUNET_TUN_DnsHeader dns; size_t off; char tmp[max]; unsigned int i; @@ -730,7 +730,7 @@ GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, dns.authority_rcount = htons (p->num_authority_records); dns.additional_rcount = htons (p->num_additional_records); - off = sizeof (struct dns_header); + off = sizeof (struct GNUNET_TUN_DnsHeader); trc = GNUNET_NO; for (i=0;inum_queries;i++) { @@ -783,7 +783,7 @@ GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, if (GNUNET_YES == trc) dns.flags.message_truncated = 1; - memcpy (tmp, &dns, sizeof (struct dns_header)); + memcpy (tmp, &dns, sizeof (struct GNUNET_TUN_DnsHeader)); *buf = GNUNET_malloc (off); *buf_length = off; diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index 76beaaf5c..175215634 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c @@ -328,21 +328,21 @@ request_done (struct RequestRecord *rr) /* send response via hijacker */ reply_len = sizeof (struct GNUNET_MessageHeader); - reply_len += sizeof (struct tun_header); + reply_len += sizeof (struct GNUNET_TUN_Layer2PacketHeader); switch (rr->src_addr.ss_family) { case AF_INET: - reply_len += sizeof (struct ip4_header); + reply_len += sizeof (struct GNUNET_TUN_IPv4Header); break; case AF_INET6: - reply_len += sizeof (struct ip6_header); + reply_len += sizeof (struct GNUNET_TUN_IPv6Header); break; default: GNUNET_break (0); cleanup_rr (rr); return; } - reply_len += sizeof (struct udp_packet); + reply_len += sizeof (struct GNUNET_TUN_UdpHeader); reply_len += rr->payload_length; if (reply_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { @@ -364,15 +364,15 @@ request_done (struct RequestRecord *rr) /* first, TUN header */ { - struct tun_header tun; + struct GNUNET_TUN_Layer2PacketHeader tun; tun.flags = htons (0); if (rr->src_addr.ss_family == AF_INET) tun.proto = htons (ETH_P_IPV4); else tun.proto = htons (ETH_P_IPV6); - memcpy (&buf[off], &tun, sizeof (struct tun_header)); - off += sizeof (struct tun_header); + memcpy (&buf[off], &tun, sizeof (struct GNUNET_TUN_Layer2PacketHeader)); + off += sizeof (struct GNUNET_TUN_Layer2PacketHeader); } /* now IP header */ @@ -383,11 +383,11 @@ request_done (struct RequestRecord *rr) { struct sockaddr_in *src = (struct sockaddr_in *) &rr->src_addr; struct sockaddr_in *dst = (struct sockaddr_in *) &rr->dst_addr; - struct ip4_header ip; + struct GNUNET_TUN_IPv4Header ip; spt = dst->sin_port; dpt = src->sin_port; - ip.header_length = sizeof (struct ip4_header) / 4; + ip.header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; ip.version = IPVERSION; /* aka 4 */ ip.diff_serv = 0; ip.total_length = htons ((uint16_t) reply_len - off); @@ -412,7 +412,7 @@ request_done (struct RequestRecord *rr) udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, &tmp, sizeof (uint16_t)); - tmp = htons (rr->payload_length + sizeof (struct udp_packet)); + tmp = htons (rr->payload_length + sizeof (struct GNUNET_TUN_UdpHeader)); udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, &tmp, sizeof (uint16_t)); @@ -425,7 +425,7 @@ request_done (struct RequestRecord *rr) { struct sockaddr_in6 *src = (struct sockaddr_in6 *) &rr->src_addr; struct sockaddr_in6 *dst = (struct sockaddr_in6 *) &rr->dst_addr; - struct ip6_header ip; + struct GNUNET_TUN_IPv6Header ip; spt = dst->sin6_port; dpt = src->sin6_port; @@ -444,7 +444,7 @@ request_done (struct RequestRecord *rr) { uint32_t tmp; - tmp = htons (rr->payload_length + sizeof (struct udp_packet)); + tmp = htons (rr->payload_length + sizeof (struct GNUNET_TUN_UdpHeader)); udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, &tmp, sizeof (uint32_t)); @@ -463,7 +463,7 @@ request_done (struct RequestRecord *rr) /* now UDP header */ { - struct udp_packet udp; + struct GNUNET_TUN_UdpHeader udp; udp.spt = spt; udp.dpt = dpt; @@ -597,11 +597,11 @@ next_phase (struct RequestRecord *rr) { case AF_INET: dnsout = dnsout4; - salen = sizeof (struct ip4_header); + salen = sizeof (struct GNUNET_TUN_IPv4Header); break; case AF_INET6: dnsout = dnsout6; - salen = sizeof (struct ip6_header); + salen = sizeof (struct GNUNET_TUN_IPv6Header); break; default: GNUNET_break (0); @@ -715,7 +715,7 @@ read_response (void *cls, struct sockaddr_in addr4; struct sockaddr_in6 addr6; struct sockaddr *addr; - struct dns_header *dns; + struct GNUNET_TUN_DnsHeader *dns; socklen_t addrlen; struct RequestRecord *rr; ssize_t r; @@ -765,14 +765,14 @@ read_response (void *cls, GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "recvfrom"); return; } - if (sizeof (struct dns_header) > r) + if (sizeof (struct GNUNET_TUN_DnsHeader) > r) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Received DNS response that is too small (%u bytes)"), r); return; } - dns = (struct dns_header *) buf; + dns = (struct GNUNET_TUN_DnsHeader *) buf; rr = &requests[dns->id]; if (rr->phase != RP_INTERNET_DNS) { @@ -986,7 +986,7 @@ handle_client_response (void *cls GNUNET_UNUSED, break; case 2: /* update */ msize -= sizeof (struct GNUNET_DNS_Response); - if ( (sizeof (struct dns_header) > msize) || + if ( (sizeof (struct GNUNET_TUN_DnsHeader) > msize) || (RP_REQUEST_MONITOR == rr->phase) || (RP_RESPONSE_MONITOR == rr->phase) ) { @@ -1036,11 +1036,11 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, const struct GNUNET_MessageHeader *message) { uint16_t msize; - const struct tun_header *tun; - const struct ip4_header *ip4; - const struct ip6_header *ip6; - const struct udp_packet *udp; - const struct dns_header *dns; + const struct GNUNET_TUN_Layer2PacketHeader *tun; + const struct GNUNET_TUN_IPv4Header *ip4; + const struct GNUNET_TUN_IPv6Header *ip6; + const struct GNUNET_TUN_UdpHeader *udp; + const struct GNUNET_TUN_DnsHeader *dns; struct RequestRecord *rr; struct sockaddr_in *srca4; struct sockaddr_in6 *srca6; @@ -1048,22 +1048,22 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, struct sockaddr_in6 *dsta6; msize = ntohs (message->size); - if (msize < sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header) + sizeof (struct ip4_header)) + if (msize < sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_TUN_IPv4Header)) { /* non-IP packet received on TUN!? */ GNUNET_break (0); return; } msize -= sizeof (struct GNUNET_MessageHeader); - tun = (const struct tun_header *) &message[1]; - msize -= sizeof (struct tun_header); + tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1]; + msize -= sizeof (struct GNUNET_TUN_Layer2PacketHeader); switch (ntohs (tun->proto)) { case ETH_P_IPV4: - ip4 = (const struct ip4_header *) &tun[1]; - if ( (msize < sizeof (struct ip4_header)) || + ip4 = (const struct GNUNET_TUN_IPv4Header *) &tun[1]; + if ( (msize < sizeof (struct GNUNET_TUN_IPv4Header)) || (ip4->version != IPVERSION) || - (ip4->header_length != sizeof (struct ip4_header) / 4) || + (ip4->header_length != sizeof (struct GNUNET_TUN_IPv4Header) / 4) || (ntohs(ip4->total_length) != msize) || (ip4->protocol != IPPROTO_UDP) ) { @@ -1072,12 +1072,12 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, _("Received malformed IPv4-UDP packet on TUN interface.\n")); return; } - udp = (const struct udp_packet*) &ip4[1]; - msize -= sizeof (struct ip4_header); + udp = (const struct GNUNET_TUN_UdpHeader*) &ip4[1]; + msize -= sizeof (struct GNUNET_TUN_IPv4Header); break; case ETH_P_IPV6: - ip6 = (const struct ip6_header *) &tun[1]; - if ( (msize < sizeof (struct ip6_header)) || + ip6 = (const struct GNUNET_TUN_IPv6Header *) &tun[1]; + if ( (msize < sizeof (struct GNUNET_TUN_IPv6Header)) || (ip6->version != 6) || (ntohs (ip6->payload_length) != msize) || (ip6->next_header != IPPROTO_UDP) ) @@ -1087,8 +1087,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, _("Received malformed IPv6-UDP packet on TUN interface.\n")); return; } - udp = (const struct udp_packet*) &ip6[1]; - msize -= sizeof (struct ip6_header); + udp = (const struct GNUNET_TUN_UdpHeader*) &ip6[1]; + msize -= sizeof (struct GNUNET_TUN_IPv6Header); break; default: /* non-IP packet received on TUN!? */ @@ -1098,7 +1098,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, ntohs (tun->proto)); return; } - if (msize <= sizeof (struct udp_packet) + sizeof (struct dns_header)) + if (msize <= sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_TUN_DnsHeader)) { /* non-DNS packet received on TUN, ignore */ GNUNET_STATISTICS_update (stats, @@ -1106,8 +1106,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, 1, GNUNET_NO); return; } - msize -= sizeof (struct udp_packet); - dns = (const struct dns_header*) &udp[1]; + msize -= sizeof (struct GNUNET_TUN_UdpHeader); + dns = (const struct GNUNET_TUN_DnsHeader*) &udp[1]; rr = &requests[dns->id]; /* clean up from previous request */ diff --git a/src/exit/exit.h b/src/exit/exit.h index 2047ca113..3cd4292bd 100644 --- a/src/exit/exit.h +++ b/src/exit/exit.h @@ -53,7 +53,7 @@ struct GNUNET_EXIT_TcpServiceStartMessage * Skeleton of the TCP header to send. Port numbers are to * be replaced and the checksum may be updated as necessary. */ - struct tcp_packet tcp_header; + struct GNUNET_TUN_TcpHeader tcp_header; /* followed by TCP payload */ }; @@ -79,7 +79,7 @@ struct GNUNET_EXIT_TcpInternetStartMessage * Skeleton of the TCP header to send. Port numbers are to * be replaced and the checksum may be updated as necessary. */ - struct tcp_packet tcp_header; + struct GNUNET_TUN_TcpHeader tcp_header; /* followed by IP address of the destination; either 'struct in_addr' or 'struct in6_addr', depending on af */ @@ -110,7 +110,7 @@ struct GNUNET_EXIT_TcpDataMessage * Skeleton of the TCP header to send. Port numbers are to * be replaced and the checksum may be updated as necessary. (The destination port number should not be changed, as it contains the desired destination port.) */ - struct tcp_packet tcp_header; + struct GNUNET_TUN_TcpHeader tcp_header; /* followed by TCP payload */ }; diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 3dce69a3e..7df72fb02 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c @@ -595,7 +595,7 @@ send_packet_to_mesh_tunnel (struct GNUNET_MESH_Tunnel *mesh_tunnel, * be the original destination address) */ static void -udp_from_helper (const struct udp_packet *udp, +udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, size_t pktlen, int af, const void *destination_ip, @@ -617,7 +617,7 @@ udp_from_helper (const struct udp_packet *udp, dbuf, sizeof (dbuf)), (unsigned int) ntohs (udp->dpt)); } - if (pktlen < sizeof (struct udp_packet)) + if (pktlen < sizeof (struct GNUNET_TUN_UdpHeader)) { /* blame kernel */ GNUNET_break (0); @@ -642,7 +642,7 @@ udp_from_helper (const struct udp_packet *udp, return; } send_packet_to_mesh_tunnel (state->tunnel, - &udp[1], pktlen - sizeof (struct udp_packet), + &udp[1], pktlen - sizeof (struct GNUNET_TUN_UdpHeader), NULL, state->serv != NULL ? GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP_BACK @@ -662,7 +662,7 @@ udp_from_helper (const struct udp_packet *udp, * be the original destination address) */ static void -tcp_from_helper (const struct tcp_packet *tcp, +tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, size_t pktlen, int af, const void *destination_ip, @@ -670,7 +670,7 @@ tcp_from_helper (const struct tcp_packet *tcp, { struct TunnelState *state; char buf[pktlen]; - struct tcp_packet *mtcp; + struct GNUNET_TUN_TcpHeader *mtcp; { char sbuf[INET6_ADDRSTRLEN]; @@ -686,7 +686,7 @@ tcp_from_helper (const struct tcp_packet *tcp, dbuf, sizeof (dbuf)), (unsigned int) ntohs (tcp->dpt)); } - if (pktlen < sizeof (struct tcp_packet)) + if (pktlen < sizeof (struct GNUNET_TUN_TcpHeader)) { /* blame kernel */ GNUNET_break (0); @@ -708,7 +708,7 @@ tcp_from_helper (const struct tcp_packet *tcp, /* mug port numbers and crc to avoid information leakage; sender will need to lookup the correct values anyway */ memcpy (buf, tcp, pktlen); - mtcp = (struct tcp_packet *) buf; + mtcp = (struct GNUNET_TUN_TcpHeader *) buf; mtcp->spt = 0; mtcp->dpt = 0; mtcp->crc = 0; @@ -732,7 +732,7 @@ static void message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, const struct GNUNET_MessageHeader *message) { - const struct tun_header *pkt_tun; + const struct GNUNET_TUN_Layer2PacketHeader *pkt_tun; size_t size; GNUNET_STATISTICS_update (stats, @@ -744,7 +744,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, return; } size = ntohs (message->size); - if (size < sizeof (struct tun_header) + sizeof (struct GNUNET_MessageHeader)) + if (size < sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_MessageHeader)) { GNUNET_break (0); return; @@ -752,38 +752,38 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, GNUNET_STATISTICS_update (stats, gettext_noop ("# Bytes received from TUN"), size, GNUNET_NO); - pkt_tun = (const struct tun_header *) &message[1]; - size -= sizeof (struct tun_header) + sizeof (struct GNUNET_MessageHeader); + pkt_tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1]; + size -= sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_MessageHeader); switch (ntohs (pkt_tun->proto)) { case ETH_P_IPV6: { - const struct ip6_header *pkt6; + const struct GNUNET_TUN_IPv6Header *pkt6; - if (size < sizeof (struct ip6_header)) + if (size < sizeof (struct GNUNET_TUN_IPv6Header)) { /* Kernel to blame? */ GNUNET_break (0); return; } - pkt6 = (struct ip6_header *) &pkt_tun[1]; + pkt6 = (struct GNUNET_TUN_IPv6Header *) &pkt_tun[1]; if (size != ntohs (pkt6->payload_length)) { /* Kernel to blame? */ GNUNET_break (0); return; } - size -= sizeof (struct ip6_header); + size -= sizeof (struct GNUNET_TUN_IPv6Header); switch (pkt6->next_header) { case IPPROTO_UDP: - udp_from_helper ((const struct udp_packet *) &pkt6[1], size, + udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt6[1], size, AF_INET6, &pkt6->destination_address, &pkt6->source_address); break; case IPPROTO_TCP: - tcp_from_helper ((const struct tcp_packet *) &pkt6[1], size, + tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt6[1], size, AF_INET6, &pkt6->destination_address, &pkt6->source_address); @@ -797,37 +797,37 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, break; case ETH_P_IPV4: { - const struct ip4_header *pkt4; + const struct GNUNET_TUN_IPv4Header *pkt4; - if (size < sizeof (struct ip4_header)) + if (size < sizeof (struct GNUNET_TUN_IPv4Header)) { /* Kernel to blame? */ GNUNET_break (0); return; } - pkt4 = (const struct ip4_header *) &pkt_tun[1]; + pkt4 = (const struct GNUNET_TUN_IPv4Header *) &pkt_tun[1]; if (size != ntohs (pkt4->total_length)) { /* Kernel to blame? */ GNUNET_break (0); return; } - if (pkt4->header_length * 4 != sizeof (struct ip4_header)) + if (pkt4->header_length * 4 != sizeof (struct GNUNET_TUN_IPv4Header)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("IPv4 packet options received. Ignored.\n")); return; } - size -= sizeof (struct ip4_header); + size -= sizeof (struct GNUNET_TUN_IPv4Header); switch (pkt4->protocol) { case IPPROTO_UDP: - udp_from_helper ((const struct udp_packet *) &pkt4[1], size, + udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt4[1], size, AF_INET, &pkt4->destination_address, &pkt4->source_address); case IPPROTO_TCP: - tcp_from_helper ((const struct tcp_packet *) &pkt4[1], size, + tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt4[1], size, AF_INET, &pkt4->destination_address, &pkt4->source_address); @@ -1038,10 +1038,10 @@ setup_state_record (struct TunnelState *state) static void prepare_ipv4_packet (const void *payload, size_t payload_length, int protocol, - const struct tcp_packet *tcp_header, + const struct GNUNET_TUN_TcpHeader *tcp_header, const struct SocketAddress *src_address, const struct SocketAddress *dst_address, - struct ip4_header *pkt4) + struct GNUNET_TUN_IPv4Header *pkt4) { size_t len; @@ -1049,26 +1049,26 @@ prepare_ipv4_packet (const void *payload, size_t payload_length, switch (protocol) { case IPPROTO_UDP: - len += sizeof (struct udp_packet); + len += sizeof (struct GNUNET_TUN_UdpHeader); break; case IPPROTO_TCP: - len += sizeof (struct tcp_packet); + len += sizeof (struct GNUNET_TUN_TcpHeader); GNUNET_assert (NULL != tcp_header); break; default: GNUNET_break (0); return; } - if (len + sizeof (struct ip4_header) > UINT16_MAX) + if (len + sizeof (struct GNUNET_TUN_IPv4Header) > UINT16_MAX) { GNUNET_break (0); return; } pkt4->version = 4; - pkt4->header_length = sizeof (struct ip4_header) / 4; + pkt4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; pkt4->diff_serv = 0; - pkt4->total_length = htons ((uint16_t) (sizeof (struct ip4_header) + len)); + pkt4->total_length = htons ((uint16_t) (sizeof (struct GNUNET_TUN_IPv4Header) + len)); pkt4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT16_MAX + 1); pkt4->flags = 0; @@ -1078,13 +1078,13 @@ prepare_ipv4_packet (const void *payload, size_t payload_length, pkt4->checksum = 0; pkt4->destination_address = dst_address->address.ipv4; pkt4->source_address = src_address->address.ipv4; - pkt4->checksum = GNUNET_CRYPTO_crc16_n (pkt4, sizeof (struct ip4_header)); + pkt4->checksum = GNUNET_CRYPTO_crc16_n (pkt4, sizeof (struct GNUNET_TUN_IPv4Header)); switch (protocol) { case IPPROTO_UDP: { - struct udp_packet *pkt4_udp = (struct udp_packet *) &pkt4[1]; + struct GNUNET_TUN_UdpHeader *pkt4_udp = (struct GNUNET_TUN_UdpHeader *) &pkt4[1]; pkt4_udp->spt = htons (src_address->port); pkt4_udp->dpt = htons (dst_address->port); @@ -1095,9 +1095,9 @@ prepare_ipv4_packet (const void *payload, size_t payload_length, break; case IPPROTO_TCP: { - struct tcp_packet *pkt4_tcp = (struct tcp_packet *) &pkt4[1]; + struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1]; - memcpy (pkt4_tcp, tcp_header, sizeof (struct tcp_packet)); + memcpy (pkt4_tcp, tcp_header, sizeof (struct GNUNET_TUN_TcpHeader)); memcpy (&pkt4_tcp[1], payload, payload_length); pkt4_tcp->spt = htons (src_address->port); pkt4_tcp->dpt = htons (dst_address->port); @@ -1138,10 +1138,10 @@ prepare_ipv4_packet (const void *payload, size_t payload_length, static void prepare_ipv6_packet (const void *payload, size_t payload_length, int protocol, - const struct tcp_packet *tcp_header, + const struct GNUNET_TUN_TcpHeader *tcp_header, const struct SocketAddress *src_address, const struct SocketAddress *dst_address, - struct ip6_header *pkt6) + struct GNUNET_TUN_IPv6Header *pkt6) { size_t len; @@ -1149,11 +1149,11 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, switch (protocol) { case IPPROTO_UDP: - len += sizeof (struct udp_packet); + len += sizeof (struct GNUNET_TUN_UdpHeader); break; case IPPROTO_TCP: /* tcp_header (with port/crc not set) must be part of payload! */ - if (len < sizeof (struct tcp_packet)) + if (len < sizeof (struct GNUNET_TUN_TcpHeader)) { GNUNET_break (0); return; @@ -1171,7 +1171,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, pkt6->version = 6; pkt6->next_header = protocol; - pkt6->payload_length = htons ((uint16_t) (len + sizeof (struct ip6_header))); + pkt6->payload_length = htons ((uint16_t) (len + sizeof (struct GNUNET_TUN_IPv6Header))); pkt6->hop_limit = 255; pkt6->destination_address = dst_address->address.ipv6; pkt6->source_address = src_address->address.ipv6; @@ -1180,7 +1180,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, { case IPPROTO_UDP: { - struct udp_packet *pkt6_udp = (struct udp_packet *) &pkt6[1]; + struct GNUNET_TUN_UdpHeader *pkt6_udp = (struct GNUNET_TUN_UdpHeader *) &pkt6[1]; memcpy (&pkt6[1], payload, payload_length); pkt6_udp->crc = 0; @@ -1202,7 +1202,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, break; case IPPROTO_TCP: { - struct tcp_packet *pkt6_tcp = (struct tcp_packet *) pkt6; + struct GNUNET_TUN_TcpHeader *pkt6_tcp = (struct GNUNET_TUN_TcpHeader *) pkt6; memcpy (pkt6_tcp, payload, payload_length); pkt6_tcp->crc = 0; @@ -1239,7 +1239,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, static void send_tcp_packet_via_tun (const struct SocketAddress *destination_address, const struct SocketAddress *source_address, - const struct tcp_packet *tcp_header, + const struct GNUNET_TUN_TcpHeader *tcp_header, const void *payload, size_t payload_length) { size_t len; @@ -1250,14 +1250,14 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending packet with %u bytes TCP payload via TUN\n", (unsigned int) payload_length); - len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header); + len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader); switch (source_address->af) { case AF_INET: - len += sizeof (struct ip4_header); + len += sizeof (struct GNUNET_TUN_IPv4Header); break; case AF_INET6: - len += sizeof (struct ip6_header); + len += sizeof (struct GNUNET_TUN_IPv6Header); break; default: GNUNET_break (0); @@ -1272,18 +1272,18 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address, { char buf[len]; struct GNUNET_MessageHeader *hdr; - struct tun_header *tun; + struct GNUNET_TUN_Layer2PacketHeader *tun; hdr= (struct GNUNET_MessageHeader *) buf; hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); hdr->size = htons (len); - tun = (struct tun_header*) &hdr[1]; + tun = (struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1]; tun->flags = htons (0); switch (source_address->af) { case AF_INET: { - struct ip4_header * ipv4 = (struct ip4_header*) &tun[1]; + struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1]; tun->proto = htons (ETH_P_IPV4); prepare_ipv4_packet (payload, payload_length, @@ -1296,7 +1296,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address, break; case AF_INET6: { - struct ip6_header * ipv6 = (struct ip6_header*) &tun[1]; + struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; tun->proto = htons (ETH_P_IPV6); prepare_ipv6_packet (payload, payload_length, @@ -1589,20 +1589,20 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending packet with %u bytes UDP payload via TUN\n", (unsigned int) payload_length); - len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header); + len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader); switch (source_address->af) { case AF_INET: - len += sizeof (struct ip4_header); + len += sizeof (struct GNUNET_TUN_IPv4Header); break; case AF_INET6: - len += sizeof (struct ip6_header); + len += sizeof (struct GNUNET_TUN_IPv6Header); break; default: GNUNET_break (0); return; } - len += sizeof (struct udp_packet); + len += sizeof (struct GNUNET_TUN_UdpHeader); len += payload_length; if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { @@ -1612,18 +1612,18 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address, { char buf[len]; struct GNUNET_MessageHeader *hdr; - struct tun_header *tun; + struct GNUNET_TUN_Layer2PacketHeader *tun; hdr= (struct GNUNET_MessageHeader *) buf; hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); hdr->size = htons (len); - tun = (struct tun_header*) &hdr[1]; + tun = (struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1]; tun->flags = htons (0); switch (source_address->af) { case AF_INET: { - struct ip4_header * ipv4 = (struct ip4_header*) &tun[1]; + struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1]; tun->proto = htons (ETH_P_IPV4); prepare_ipv4_packet (payload, payload_length, @@ -1636,7 +1636,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address, break; case AF_INET6: { - struct ip6_header * ipv6 = (struct ip6_header*) &tun[1]; + struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; tun->proto = htons (ETH_P_IPV6); prepare_ipv6_packet (payload, payload_length, diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index ca521db3b..dc6f01e1e 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h @@ -23,32 +23,35 @@ * @brief standard TCP/IP network structs and IP checksum calculations for TUN interaction * @author Philipp Toelke * @author Christian Grothoff - * - * TODO: - * - currently does not follow our naming conventions */ -#ifndef TCPIP_TUN_H -#define TCPIP_TUN_H +#ifndef GNUNET_TUN_LIB_H +#define GNUNET_TUN_LIB_H -#include "platform.h" #include "gnunet_util_lib.h" /* see http://www.iana.org/assignments/ethernet-numbers */ #ifndef ETH_P_IPV4 +/** + * Number for IPv4 + */ #define ETH_P_IPV4 0x0800 #endif #ifndef ETH_P_IPV6 +/** + * Number for IPv6 + */ #define ETH_P_IPV6 0x86DD #endif GNUNET_NETWORK_STRUCT_BEGIN + /** * Header from Linux TUN interface. */ -struct tun_header +struct GNUNET_TUN_Layer2PacketHeader { /** * Some flags (unused). @@ -65,7 +68,7 @@ struct tun_header /** * Standard IPv4 header. */ -struct ip4_header +struct GNUNET_TUN_IPv4Header { unsigned header_length:4 GNUNET_PACKED; unsigned version:4 GNUNET_PACKED; @@ -81,10 +84,11 @@ struct ip4_header struct in_addr destination_address GNUNET_PACKED; }; + /** * Standard IPv6 header. */ -struct ip6_header +struct GNUNET_TUN_IPv6Header { unsigned traffic_class_h:4 GNUNET_PACKED; unsigned version:4 GNUNET_PACKED; @@ -97,12 +101,11 @@ struct ip6_header struct in6_addr destination_address GNUNET_PACKED; }; -#define TCP_FLAG_SYN 2 /** * TCP packet header (FIXME: rename!) */ -struct tcp_packet +struct GNUNET_TUN_TcpHeader { unsigned spt:16 GNUNET_PACKED; unsigned dpt:16 GNUNET_PACKED; @@ -116,10 +119,11 @@ struct tcp_packet unsigned urg:16 GNUNET_PACKED; }; + /** * UDP packet header (FIXME: rename!) */ -struct udp_packet +struct GNUNET_TUN_UdpHeader { uint16_t spt GNUNET_PACKED; uint16_t dpt GNUNET_PACKED; @@ -127,10 +131,11 @@ struct udp_packet uint16_t crc GNUNET_PACKED; }; + /** * DNS header. */ -struct dns_header +struct GNUNET_TUN_DnsHeader { uint16_t id GNUNET_PACKED; uint16_t flags GNUNET_PACKED; @@ -139,13 +144,8 @@ struct dns_header uint16_t nscount GNUNET_PACKED; uint16_t arcount GNUNET_PACKED; }; -GNUNET_NETWORK_STRUCT_END - - - - - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/tun/Makefile.am b/src/tun/Makefile.am index 15b0d6205..bfc1135d8 100644 --- a/src/tun/Makefile.am +++ b/src/tun/Makefile.am @@ -15,6 +15,6 @@ libgnunettun_la_SOURCES = \ tun.c libgnunettun_la_LIBADD = \ $(top_builddir)/src/util/libgnunetutil.la $(XLIB) -libgnunethello_la_LDFLAGS = \ +libgnunettun_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 9c0fb1667..7aeabf457 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -880,8 +880,8 @@ route_packet (struct DestinationEntry *destination, size_t alen; size_t mlen; int is_new; - const struct udp_packet *udp; - const struct tcp_packet *tcp; + const struct GNUNET_TUN_UdpHeader *udp; + const struct GNUNET_TUN_TcpHeader *tcp; uint16_t spt; uint16_t dpt; @@ -889,7 +889,7 @@ route_packet (struct DestinationEntry *destination, { case IPPROTO_UDP: { - if (payload_length < sizeof (struct udp_packet)) + if (payload_length < sizeof (struct GNUNET_TUN_UdpHeader)) { /* blame kernel? */ GNUNET_break (0); @@ -909,7 +909,7 @@ route_packet (struct DestinationEntry *destination, break; case IPPROTO_TCP: { - if (payload_length < sizeof (struct tcp_packet)) + if (payload_length < sizeof (struct GNUNET_TUN_TcpHeader)) { /* blame kernel? */ GNUNET_break (0); @@ -1050,7 +1050,7 @@ route_packet (struct DestinationEntry *destination, struct GNUNET_EXIT_UdpServiceMessage *usm; mlen = sizeof (struct GNUNET_EXIT_UdpServiceMessage) + - payload_length - sizeof (struct udp_packet); + payload_length - sizeof (struct GNUNET_TUN_UdpHeader); if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); @@ -1069,7 +1069,7 @@ route_packet (struct DestinationEntry *destination, usm->service_descriptor = destination->details.service_destination.service_descriptor; memcpy (&usm[1], &udp[1], - payload_length - sizeof (struct udp_packet)); + payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); } else { @@ -1079,7 +1079,7 @@ route_packet (struct DestinationEntry *destination, void *payload; mlen = sizeof (struct GNUNET_EXIT_UdpInternetMessage) + - alen + payload_length - sizeof (struct udp_packet); + alen + payload_length - sizeof (struct GNUNET_TUN_UdpHeader); if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); @@ -1112,7 +1112,7 @@ route_packet (struct DestinationEntry *destination, } memcpy (payload, &udp[1], - payload_length - sizeof (struct udp_packet)); + payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); } break; case IPPROTO_TCP: @@ -1123,7 +1123,7 @@ route_packet (struct DestinationEntry *destination, struct GNUNET_EXIT_TcpServiceStartMessage *tsm; mlen = sizeof (struct GNUNET_EXIT_TcpServiceStartMessage) + - payload_length - sizeof (struct tcp_packet); + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); @@ -1140,7 +1140,7 @@ route_packet (struct DestinationEntry *destination, tsm->tcp_header = *tcp; memcpy (&tsm[1], &tcp[1], - payload_length - sizeof (struct tcp_packet)); + payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); } else { @@ -1150,7 +1150,7 @@ route_packet (struct DestinationEntry *destination, void *payload; mlen = sizeof (struct GNUNET_EXIT_TcpInternetStartMessage) + - alen + payload_length - sizeof (struct tcp_packet); + alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); @@ -1181,7 +1181,7 @@ route_packet (struct DestinationEntry *destination, } memcpy (payload, &tcp[1], - payload_length - sizeof (struct tcp_packet)); + payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); } } else @@ -1189,7 +1189,7 @@ route_packet (struct DestinationEntry *destination, struct GNUNET_EXIT_TcpDataMessage *tdm; mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + - alen + payload_length - sizeof (struct tcp_packet); + alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); @@ -1205,7 +1205,7 @@ route_packet (struct DestinationEntry *destination, tdm->tcp_header = *tcp; memcpy (&tdm[1], &tcp[1], - payload_length - sizeof (struct tcp_packet)); + payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); } break; default: @@ -1231,7 +1231,7 @@ static void message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, const struct GNUNET_MessageHeader *message) { - const struct tun_header *tun; + const struct GNUNET_TUN_Layer2PacketHeader *tun; size_t mlen; GNUNET_HashCode key; struct DestinationEntry *de; @@ -1241,26 +1241,26 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, 1, GNUNET_NO); mlen = ntohs (message->size); if ( (ntohs (message->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) || - (mlen < sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header)) ) + (mlen < sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader)) ) { GNUNET_break (0); return; } - tun = (const struct tun_header *) &message[1]; - mlen -= (sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header)); + tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1]; + mlen -= (sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader)); switch (ntohs (tun->proto)) { case ETH_P_IPV6: { - const struct ip6_header *pkt6; + const struct GNUNET_TUN_IPv6Header *pkt6; - if (mlen < sizeof (struct ip6_header)) + if (mlen < sizeof (struct GNUNET_TUN_IPv6Header)) { /* blame kernel */ GNUNET_break (0); return; } - pkt6 = (const struct ip6_header *) &tun[1]; + pkt6 = (const struct GNUNET_TUN_IPv6Header *) &tun[1]; get_destination_key_from_ip (AF_INET6, &pkt6->destination_address, &key); @@ -1288,20 +1288,20 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, &pkt6->source_address, &pkt6->destination_address, &pkt6[1], - mlen - sizeof (struct ip6_header)); + mlen - sizeof (struct GNUNET_TUN_IPv6Header)); } break; case ETH_P_IPV4: { - struct ip4_header *pkt4; + struct GNUNET_TUN_IPv4Header *pkt4; - if (mlen < sizeof (struct ip4_header)) + if (mlen < sizeof (struct GNUNET_TUN_IPv4Header)) { /* blame kernel */ GNUNET_break (0); return; } - pkt4 = (struct ip4_header *) &tun[1]; + pkt4 = (struct GNUNET_TUN_IPv4Header *) &tun[1]; get_destination_key_from_ip (AF_INET, &pkt4->destination_address, &key); @@ -1323,7 +1323,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, sizeof (buf))); return; } - if (pkt4->header_length * 4 != sizeof (struct ip4_header)) + if (pkt4->header_length * 4 != sizeof (struct GNUNET_TUN_IPv4Header)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received IPv4 packet with options (dropping it)\n")); @@ -1335,7 +1335,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, &pkt4->source_address, &pkt4->destination_address, &pkt4[1], - mlen - sizeof (struct ip4_header)); + mlen - sizeof (struct GNUNET_TUN_IPv4Header)); } break; default: @@ -1407,26 +1407,26 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, { case AF_INET: { - size_t size = sizeof (struct ip4_header) - + sizeof (struct udp_packet) + size_t size = sizeof (struct GNUNET_TUN_IPv4Header) + + sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_MessageHeader) + - sizeof (struct tun_header) + + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + mlen; { char buf[size]; struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; - struct tun_header *tun = (struct tun_header*) &msg[1]; - struct ip4_header *ipv4 = (struct ip4_header *) &tun[1]; - struct udp_packet *udp = (struct udp_packet *) &ipv4[1]; + struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; + struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1]; + struct GNUNET_TUN_UdpHeader *udp = (struct GNUNET_TUN_UdpHeader *) &ipv4[1]; msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); msg->size = htons (size); tun->flags = htons (0); tun->proto = htons (ETH_P_IPV4); ipv4->version = 4; - ipv4->header_length = sizeof (struct ip4_header) / 4; + ipv4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; ipv4->diff_serv = 0; - ipv4->total_length = htons (sizeof (struct ip4_header) + - sizeof (struct udp_packet) + + ipv4->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + + sizeof (struct GNUNET_TUN_UdpHeader) + mlen); ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT16_MAX + 1); @@ -1438,7 +1438,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, ipv4->source_address = ts->destination_ip.v4; ipv4->destination_address = ts->source_ip.v4; ipv4->checksum = - GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct ip4_header)); + GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct GNUNET_TUN_IPv4Header)); if (0 == ntohs (reply->source_port)) udp->spt = htons (ts->destination_port); else @@ -1447,7 +1447,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, udp->dpt = htons (ts->source_port); else udp->dpt = reply->destination_port; - udp->len = htons (mlen + sizeof (struct udp_packet)); + udp->len = htons (mlen + sizeof (struct GNUNET_TUN_UdpHeader)); udp->crc = 0; // FIXME: optional, but we might want to calculate this one anyway memcpy (&udp[1], &reply[1], @@ -1461,17 +1461,17 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, break; case AF_INET6: { - size_t size = sizeof (struct ip6_header) - + sizeof (struct udp_packet) + size_t size = sizeof (struct GNUNET_TUN_IPv6Header) + + sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_MessageHeader) + - sizeof (struct tun_header) + + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + mlen; { char buf[size]; struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; - struct tun_header *tun = (struct tun_header*) &msg[1]; - struct ip6_header *ipv6 = (struct ip6_header *) &tun[1]; - struct udp_packet *udp = (struct udp_packet *) &ipv6[1]; + struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; + struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1]; + struct GNUNET_TUN_UdpHeader *udp = (struct GNUNET_TUN_UdpHeader *) &ipv6[1]; msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); msg->size = htons (size); tun->flags = htons (0); @@ -1480,7 +1480,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, ipv6->version = 6; ipv6->traffic_class_l = 0; ipv6->flow_label = 0; - ipv6->payload_length = htons (sizeof (struct udp_packet) + sizeof (struct ip6_header) + mlen); + ipv6->payload_length = htons (sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_TUN_IPv6Header) + mlen); ipv6->next_header = IPPROTO_UDP; ipv6->hop_limit = 255; ipv6->source_address = ts->destination_ip.v6; @@ -1493,7 +1493,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, udp->dpt = htons (ts->source_port); else udp->dpt = reply->destination_port; - udp->len = htons (mlen + sizeof (struct udp_packet)); + udp->len = htons (mlen + sizeof (struct GNUNET_TUN_UdpHeader)); udp->crc = 0; memcpy (&udp[1], &reply[1], @@ -1585,26 +1585,26 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, { case AF_INET: { - size_t size = sizeof (struct ip4_header) - + sizeof (struct tcp_packet) + size_t size = sizeof (struct GNUNET_TUN_IPv4Header) + + sizeof (struct GNUNET_TUN_TcpHeader) + sizeof (struct GNUNET_MessageHeader) + - sizeof (struct tun_header) + + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + mlen; { char buf[size]; struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; - struct tun_header *tun = (struct tun_header*) &msg[1]; - struct ip4_header *ipv4 = (struct ip4_header *) &tun[1]; - struct tcp_packet *tcp = (struct tcp_packet *) &ipv4[1]; + struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; + struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1]; + struct GNUNET_TUN_TcpHeader *tcp = (struct GNUNET_TUN_TcpHeader *) &ipv4[1]; msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); msg->size = htons (size); tun->flags = htons (0); tun->proto = htons (ETH_P_IPV4); ipv4->version = 4; - ipv4->header_length = sizeof (struct ip4_header) / 4; + ipv4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; ipv4->diff_serv = 0; - ipv4->total_length = htons (sizeof (struct ip4_header) + - sizeof (struct tcp_packet) + + ipv4->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + + sizeof (struct GNUNET_TUN_TcpHeader) + mlen); ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT16_MAX + 1); @@ -1616,7 +1616,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, ipv4->source_address = ts->destination_ip.v4; ipv4->destination_address = ts->source_ip.v4; ipv4->checksum = - GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct ip4_header)); + GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct GNUNET_TUN_IPv4Header)); *tcp = data->tcp_header; tcp->spt = htons (ts->destination_port); tcp->dpt = htons (ts->source_port); @@ -1631,9 +1631,9 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, sum = GNUNET_CRYPTO_crc16_step (sum, &ipv4->source_address, 2 * sizeof (struct in_addr)); - tmp = htonl ((IPPROTO_TCP << 16) | (mlen + sizeof (struct tcp_packet))); + tmp = htonl ((IPPROTO_TCP << 16) | (mlen + sizeof (struct GNUNET_TUN_TcpHeader))); sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); - sum = GNUNET_CRYPTO_crc16_step (sum, tcp, mlen + sizeof (struct tcp_packet)); + sum = GNUNET_CRYPTO_crc16_step (sum, tcp, mlen + sizeof (struct GNUNET_TUN_TcpHeader)); tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); } (void) GNUNET_HELPER_send (helper_handle, @@ -1645,17 +1645,17 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, break; case AF_INET6: { - size_t size = sizeof (struct ip6_header) - + sizeof (struct tcp_packet) + size_t size = sizeof (struct GNUNET_TUN_IPv6Header) + + sizeof (struct GNUNET_TUN_TcpHeader) + sizeof (struct GNUNET_MessageHeader) + - sizeof (struct tun_header) + + sizeof (struct GNUNET_TUN_Layer2PacketHeader) + mlen; { char buf[size]; struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; - struct tun_header *tun = (struct tun_header*) &msg[1]; - struct ip6_header *ipv6 = (struct ip6_header *) &tun[1]; - struct tcp_packet *tcp = (struct tcp_packet *) &ipv6[1]; + struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; + struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1]; + struct GNUNET_TUN_TcpHeader *tcp = (struct GNUNET_TUN_TcpHeader *) &ipv6[1]; msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); msg->size = htons (size); tun->flags = htons (0); @@ -1664,7 +1664,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, ipv6->version = 6; ipv6->traffic_class_l = 0; ipv6->flow_label = 0; - ipv6->payload_length = htons (sizeof (struct tcp_packet) + sizeof (struct ip6_header) + mlen); + ipv6->payload_length = htons (sizeof (struct GNUNET_TUN_TcpHeader) + sizeof (struct GNUNET_TUN_IPv6Header) + mlen); ipv6->next_header = IPPROTO_TCP; ipv6->hop_limit = 255; ipv6->source_address = ts->destination_ip.v6; @@ -1677,12 +1677,12 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, uint32_t tmp; sum = GNUNET_CRYPTO_crc16_step (sum, &ipv6->source_address, 2 * sizeof (struct in6_addr)); - tmp = htonl (sizeof (struct tcp_packet) + mlen); + tmp = htonl (sizeof (struct GNUNET_TUN_TcpHeader) + mlen); sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); tmp = htonl (IPPROTO_TCP); sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); sum = GNUNET_CRYPTO_crc16_step (sum, tcp, - sizeof (struct tcp_packet) + mlen); + sizeof (struct GNUNET_TUN_TcpHeader) + mlen); tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); } (void) GNUNET_HELPER_send (helper_handle, -- 2.25.1