From 0cccabf5c6afcff54573de1b4ed761085a27310d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 30 Jan 2012 12:44:32 +0000 Subject: [PATCH] -renaming some fields, fixing byte order issues --- src/dns/gnunet-service-dns.c | 24 ++++----- src/exit/gnunet-daemon-exit.c | 92 +++++++++++++++++------------------ src/include/gnunet_tun_lib.h | 54 ++++++++++++-------- src/vpn/gnunet-service-vpn.c | 78 ++++++++++++++--------------- 4 files changed, 131 insertions(+), 117 deletions(-) diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index a30c6582b..74d3d25ac 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c @@ -384,8 +384,8 @@ request_done (struct RequestRecord *rr) { struct GNUNET_MessageHeader *hdr; size_t reply_len; - uint16_t spt; - uint16_t dpt; + uint16_t source_port; + uint16_t destination_port; GNUNET_array_grow (rr->client_wait_list, rr->client_wait_list_length, @@ -455,8 +455,8 @@ 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; - spt = dst->sin_port; - dpt = src->sin_port; + source_port = dst->sin_port; + destination_port = src->sin_port; GNUNET_TUN_initialize_ipv4_header (&ip4, IPPROTO_UDP, reply_len - off - sizeof (struct GNUNET_TUN_IPv4Header), @@ -471,8 +471,8 @@ 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; - spt = dst->sin6_port; - dpt = src->sin6_port; + source_port = dst->sin6_port; + destination_port = src->sin6_port; GNUNET_TUN_initialize_ipv6_header (&ip6, IPPROTO_UDP, reply_len - sizeof (struct GNUNET_TUN_IPv6Header), @@ -490,8 +490,8 @@ request_done (struct RequestRecord *rr) { struct GNUNET_TUN_UdpHeader udp; - udp.spt = spt; - udp.dpt = dpt; + udp.source_port = source_port; + udp.destination_port = destination_port; udp.len = htons (reply_len - off); if (AF_INET == rr->src_addr.ss_family) GNUNET_TUN_calculate_udp4_checksum (&ip4, @@ -1235,8 +1235,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, dsta4->sin_family = AF_INET; srca4->sin_addr = ip4->source_address; dsta4->sin_addr = ip4->destination_address; - srca4->sin_port = udp->spt; - dsta4->sin_port = udp->dpt; + srca4->sin_port = udp->source_port; + dsta4->sin_port = udp->destination_port; #if HAVE_SOCKADDR_IN_SIN_LEN srca4->sin_len = sizeof (struct sockaddr_in)) dsta4->sin_len = sizeof (struct sockaddr_in); @@ -1253,8 +1253,8 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, dsta6->sin6_family = AF_INET6; srca6->sin6_addr = ip6->source_address; dsta6->sin6_addr = ip6->destination_address; - srca6->sin6_port = udp->spt; - dsta6->sin6_port = udp->dpt; + srca6->sin6_port = udp->source_port; + dsta6->sin6_port = udp->destination_port; #if HAVE_SOCKADDR_IN_SIN_LEN srca6->sin6_len = sizeof (struct sockaddr_in6); dsta6->sin6_len = sizeof (struct sockaddr_in6); diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 720a0ade4..99dec5ea0 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c @@ -436,17 +436,17 @@ get_redirect_state (int af, * * @param service_map map of services (TCP or UDP) * @param desc service descriptor - * @param dpt destination port + * @param destination_port destination port * @return NULL if we are not aware of such a service */ static struct LocalService * find_service (struct GNUNET_CONTAINER_MultiHashMap *service_map, const GNUNET_HashCode *desc, - uint16_t dpt) + uint16_t destination_port) { char key[sizeof (GNUNET_HashCode) + sizeof (uint16_t)]; - memcpy (&key[0], &dpt, sizeof (uint16_t)); + memcpy (&key[0], &destination_port, sizeof (uint16_t)); memcpy (&key[sizeof(uint16_t)], desc, sizeof (GNUNET_HashCode)); return GNUNET_CONTAINER_multihashmap_get (service_map, (GNUNET_HashCode *) key); @@ -480,13 +480,13 @@ free_service_record (void *cls, * * @param service_map map of services (TCP or UDP) * @param name name of the service - * @param dpt destination port + * @param destination_port destination port * @param service service information record to store (service->name will be set). */ static void store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map, const char *name, - uint16_t dpt, + uint16_t destination_port, struct LocalService *service) { char key[sizeof (GNUNET_HashCode) + sizeof (uint16_t)]; @@ -494,7 +494,7 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map, GNUNET_CRYPTO_hash (name, strlen (name) + 1, &desc); service->name = GNUNET_strdup (name); - memcpy (&key[0], &dpt, sizeof (uint16_t)); + memcpy (&key[0], &destination_port, sizeof (uint16_t)); memcpy (&key[sizeof(uint16_t)], &desc, sizeof (GNUNET_HashCode)); if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (service_map, @@ -506,7 +506,7 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Got duplicate service records for `%s:%u'\n"), name, - (unsigned int) dpt); + (unsigned int) destination_port); } } @@ -614,8 +614,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, const struct GNUNET_TUN_IPv6Header *ipv6; const struct GNUNET_TUN_UdpHeader *udp; size_t mlen; - uint16_t spt; - uint16_t dpt; + uint16_t source_port; + uint16_t destination_port; uint8_t protocol; { @@ -640,8 +640,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, /* Find out if this is an ICMP packet in response to an existing TCP/UDP packet and if so, figure out ports / protocol of the existing session from the IP data in the ICMP payload */ - spt = 0; - dpt = 0; + source_port = 0; + destination_port = 0; protocol = IPPROTO_ICMP; switch (af) { @@ -667,8 +667,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, /* could be TCP or UDP, but both have the ports in the right place, so that doesn't matter here */ udp = (const struct GNUNET_TUN_UdpHeader *) &ipv4[1]; - spt = ntohs (udp->spt); - dpt = ntohs (udp->dpt); + source_port = ntohs (udp->source_port); + destination_port = ntohs (udp->destination_port); /* throw away ICMP payload, won't be useful for the other side anyway */ pktlen = sizeof (struct GNUNET_TUN_IcmpHeader); break; @@ -699,8 +699,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, /* could be TCP or UDP, but both have the ports in the right place, so that doesn't matter here */ udp = (const struct GNUNET_TUN_UdpHeader *) &ipv6[1]; - spt = ntohs (udp->spt); - dpt = ntohs (udp->dpt); + source_port = ntohs (udp->source_port); + destination_port = ntohs (udp->destination_port); /* throw away ICMP payload, won't be useful for the other side anyway */ pktlen = sizeof (struct GNUNET_TUN_IcmpHeader); break; @@ -728,17 +728,17 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp, case IPPROTO_UDP: state = get_redirect_state (af, IPPROTO_UDP, source_ip, - spt, + source_port, destination_ip, - dpt, + destination_port, NULL); break; case IPPROTO_TCP: state = get_redirect_state (af, IPPROTO_TCP, source_ip, - spt, + source_port, destination_ip, - dpt, + destination_port, NULL); break; default: @@ -800,11 +800,11 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), - (unsigned int) ntohs (udp->spt), + (unsigned int) ntohs (udp->source_port), inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), - (unsigned int) ntohs (udp->dpt)); + (unsigned int) ntohs (udp->destination_port)); } if (pktlen < sizeof (struct GNUNET_TUN_UdpHeader)) { @@ -820,9 +820,9 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp, } state = get_redirect_state (af, IPPROTO_UDP, source_ip, - ntohs (udp->spt), + ntohs (udp->source_port), destination_ip, - ntohs (udp->dpt), + ntohs (udp->destination_port), NULL); if (NULL == state) { @@ -881,11 +881,11 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), - (unsigned int) ntohs (tcp->spt), + (unsigned int) ntohs (tcp->source_port), inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), - (unsigned int) ntohs (tcp->dpt)); + (unsigned int) ntohs (tcp->destination_port)); } if (pktlen < sizeof (struct GNUNET_TUN_TcpHeader)) { @@ -895,9 +895,9 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, } state = get_redirect_state (af, IPPROTO_TCP, source_ip, - ntohs (tcp->spt), + ntohs (tcp->source_port), destination_ip, - ntohs (tcp->dpt), + ntohs (tcp->destination_port), NULL); if (NULL == state) { @@ -910,8 +910,8 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp, sender will need to lookup the correct values anyway */ memcpy (buf, tcp, pktlen); mtcp = (struct GNUNET_TUN_TcpHeader *) buf; - mtcp->spt = 0; - mtcp->dpt = 0; + mtcp->source_port = 0; + mtcp->destination_port = 0; mtcp->crc = 0; mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + (pktlen - sizeof (struct GNUNET_TUN_TcpHeader)); @@ -1316,8 +1316,8 @@ prepare_ipv4_packet (const void *payload, size_t payload_length, { 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); + pkt4_udp->source_port = htons (src_address->port); + pkt4_udp->destination_port = htons (dst_address->port); pkt4_udp->len = htons ((uint16_t) payload_length); GNUNET_TUN_calculate_udp4_checksum (pkt4, pkt4_udp, @@ -1330,8 +1330,8 @@ prepare_ipv4_packet (const void *payload, size_t payload_length, struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1]; *pkt4_tcp = *tcp_header; - pkt4_tcp->spt = htons (src_address->port); - pkt4_tcp->dpt = htons (dst_address->port); + pkt4_tcp->source_port = htons (src_address->port); + pkt4_tcp->destination_port = htons (dst_address->port); GNUNET_TUN_calculate_tcp4_checksum (pkt4, pkt4_tcp, payload, @@ -1403,8 +1403,8 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, { struct GNUNET_TUN_UdpHeader *pkt6_udp = (struct GNUNET_TUN_UdpHeader *) &pkt6[1]; - pkt6_udp->spt = htons (src_address->port); - pkt6_udp->dpt = htons (dst_address->port); + pkt6_udp->source_port = htons (src_address->port); + pkt6_udp->destination_port = htons (dst_address->port); pkt6_udp->len = htons ((uint16_t) payload_length); GNUNET_TUN_calculate_udp6_checksum (pkt6, pkt6_udp, @@ -1419,8 +1419,8 @@ prepare_ipv6_packet (const void *payload, size_t payload_length, /* memcpy first here as some TCP header fields are initialized this way! */ *pkt6_tcp = *tcp_header; - pkt6_tcp->spt = htons (src_address->port); - pkt6_tcp->dpt = htons (dst_address->port); + pkt6_tcp->source_port = htons (src_address->port); + pkt6_tcp->destination_port = htons (dst_address->port); GNUNET_TUN_calculate_tcp6_checksum (pkt6, pkt6_tcp, payload, @@ -1584,14 +1584,14 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, "Received data from %s for forwarding to TCP service %s on port %u\n", GNUNET_i2s (sender), GNUNET_h2s (&start->service_descriptor), - (unsigned int) ntohs (start->tcp_header.dpt)); + (unsigned int) ntohs (start->tcp_header.destination_port)); if (NULL == (state->serv = find_service (tcp_services, &start->service_descriptor, - ntohs (start->tcp_header.dpt)))) + ntohs (start->tcp_header.destination_port)))) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("No service found for %s on port %d!\n"), "TCP", - ntohs (start->tcp_header.dpt)); + ntohs (start->tcp_header.destination_port)); GNUNET_STATISTICS_update (stats, gettext_noop ("# TCP requests dropped (no such service)"), 1, GNUNET_NO); @@ -1707,10 +1707,10 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, inet_ntop (af, &state->ri.remote_address.address, buf, sizeof (buf)), - (unsigned int) ntohs (start->tcp_header.dpt)); + (unsigned int) ntohs (start->tcp_header.destination_port)); } state->ri.remote_address.proto = IPPROTO_TCP; - state->ri.remote_address.port = ntohs (start->tcp_header.dpt); + state->ri.remote_address.port = ntohs (start->tcp_header.destination_port); setup_state_record (state); send_tcp_packet_via_tun (&state->ri.remote_address, &state->ri.local_address, @@ -1913,8 +1913,8 @@ make_up_icmpv4_payload (struct TunnelState *state, sizeof (struct GNUNET_TUN_TcpHeader), &state->ri.remote_address.address.ipv4, &state->ri.local_address.address.ipv4); - udp->spt = htons (state->ri.remote_address.port); - udp->dpt = htons (state->ri.local_address.port); + udp->source_port = htons (state->ri.remote_address.port); + udp->destination_port = htons (state->ri.local_address.port); udp->len = htons (0); udp->crc = htons (0); } @@ -1939,8 +1939,8 @@ make_up_icmpv6_payload (struct TunnelState *state, sizeof (struct GNUNET_TUN_TcpHeader), &state->ri.remote_address.address.ipv6, &state->ri.local_address.address.ipv6); - udp->spt = htons (state->ri.remote_address.port); - udp->dpt = htons (state->ri.local_address.port); + udp->source_port = htons (state->ri.remote_address.port); + udp->destination_port = htons (state->ri.local_address.port); udp->len = htons (0); udp->crc = htons (0); } diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 61eb86389..fd5d70a3d 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h @@ -70,13 +70,13 @@ struct GNUNET_TUN_Layer2PacketHeader */ struct GNUNET_TUN_IPv4Header { - unsigned header_length:4 GNUNET_PACKED; - unsigned version:4 GNUNET_PACKED; + unsigned int header_length:4 GNUNET_PACKED; + unsigned int version:4 GNUNET_PACKED; uint8_t diff_serv; uint16_t total_length GNUNET_PACKED; uint16_t identification GNUNET_PACKED; - unsigned flags:3 GNUNET_PACKED; - unsigned fragmentation_offset:13 GNUNET_PACKED; + unsigned int flags:3 GNUNET_PACKED; + unsigned int fragmentation_offset:13 GNUNET_PACKED; uint8_t ttl; uint8_t protocol; uint16_t checksum GNUNET_PACKED; @@ -90,10 +90,10 @@ struct GNUNET_TUN_IPv4Header */ struct GNUNET_TUN_IPv6Header { - unsigned traffic_class_h:4 GNUNET_PACKED; - unsigned version:4 GNUNET_PACKED; - unsigned traffic_class_l:4 GNUNET_PACKED; - unsigned flow_label:20 GNUNET_PACKED; + unsigned int traffic_class_h:4 GNUNET_PACKED; + unsigned int version:4 GNUNET_PACKED; + unsigned int traffic_class_l:4 GNUNET_PACKED; + unsigned int flow_label:20 GNUNET_PACKED; uint16_t payload_length GNUNET_PACKED; uint8_t next_header; uint8_t hop_limit; @@ -107,28 +107,42 @@ struct GNUNET_TUN_IPv6Header */ struct GNUNET_TUN_TcpHeader { - unsigned spt:16 GNUNET_PACKED; - unsigned dpt:16 GNUNET_PACKED; - unsigned seq:32 GNUNET_PACKED; - unsigned ack:32 GNUNET_PACKED; + uint16_t source_port GNUNET_PACKED; + uint16_t destination_port GNUNET_PACKED; + uint32_t seq GNUNET_PACKED; + uint32_t ack GNUNET_PACKED; +#if __BYTE_ORDER == __LITTLE_ENDIAN /** * Reserved. */ - unsigned rsv:4 GNUNET_PACKED; + unsigned int reserved : 4 GNUNET_PACKED; /** * Number of 32-bit words in TCP header. */ - unsigned off:4 GNUNET_PACKED; - unsigned flg:8 GNUNET_PACKED; + unsigned int off : 4 GNUNET_PACKED; +#elif __BYTE_ORDER == __BIG_ENDIAN + /** + * Number of 32-bit words in TCP header. + */ + unsigned int off : 4 GNUNET_PACKED; + /** + * Reserved. + */ + unsigned int reserved : 4 GNUNET_PACKED; +#endif + uint8_t flags; + /** * Window size. */ - unsigned wsz:16 GNUNET_PACKED; - unsigned crc:16 GNUNET_PACKED; + uint16_t window_size GNUNET_PACKED; + + uint16_t crc GNUNET_PACKED; + /** * Urgent pointer. */ - unsigned urg:16 GNUNET_PACKED; + uint16_t urgent_pointer GNUNET_PACKED; }; @@ -137,8 +151,8 @@ struct GNUNET_TUN_TcpHeader */ struct GNUNET_TUN_UdpHeader { - uint16_t spt GNUNET_PACKED; - uint16_t dpt GNUNET_PACKED; + uint16_t source_port GNUNET_PACKED; + uint16_t destination_port GNUNET_PACKED; uint16_t len GNUNET_PACKED; uint16_t crc GNUNET_PACKED; }; diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index a32e739d2..8e6ae655d 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -881,8 +881,8 @@ route_packet (struct DestinationEntry *destination, const struct GNUNET_TUN_UdpHeader *udp; const struct GNUNET_TUN_TcpHeader *tcp; const struct GNUNET_TUN_IcmpHeader *icmp; - uint16_t spt; - uint16_t dpt; + uint16_t source_port; + uint16_t destination_port; switch (protocol) { @@ -900,14 +900,14 @@ route_packet (struct DestinationEntry *destination, GNUNET_break_op (0); return; } - spt = ntohs (udp->spt); - dpt = ntohs (udp->dpt); + source_port = ntohs (udp->source_port); + destination_port = ntohs (udp->destination_port); get_tunnel_key_from_ips (af, IPPROTO_UDP, source_ip, - spt, + source_port, destination_ip, - dpt, + destination_port, &key); } break; @@ -925,14 +925,14 @@ route_packet (struct DestinationEntry *destination, GNUNET_break_op (0); return; } - spt = ntohs (tcp->spt); - dpt = ntohs (tcp->dpt); + source_port = ntohs (tcp->source_port); + destination_port = ntohs (tcp->destination_port); get_tunnel_key_from_ips (af, IPPROTO_TCP, source_ip, - spt, + source_port, destination_ip, - dpt, + destination_port, &key); } break; @@ -945,8 +945,8 @@ route_packet (struct DestinationEntry *destination, return; } icmp = payload; - spt = 0; - dpt = 0; + source_port = 0; + destination_port = 0; get_tunnel_key_from_ips (af, IPPROTO_ICMP, source_ip, @@ -986,13 +986,13 @@ route_packet (struct DestinationEntry *destination, "Routing %s packet from %s:%u -> %s:%u to destination %s:%u\n", (protocol == IPPROTO_TCP) ? "TCP" : "UDP", inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), - spt, + source_port, inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), - dpt, + destination_port, inet_ntop (destination->details.exit_destination.af, &destination->details.exit_destination.ip, xbuf, sizeof (xbuf)), - dpt); + destination_port); } } else @@ -1007,9 +1007,9 @@ route_packet (struct DestinationEntry *destination, "Routing %s packet from %s:%u -> %s:%u to service %s at peer %s\n", (protocol == IPPROTO_TCP) ? "TCP" : "UDP", inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), - spt, + source_port, inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), - dpt, + destination_port, GNUNET_h2s (&destination->details.service_destination.service_descriptor), GNUNET_i2s (&destination->details.service_destination.target)); } @@ -1045,8 +1045,8 @@ route_packet (struct DestinationEntry *destination, ts->source_ip.v6 = * (const struct in6_addr *) source_ip; ts->destination_ip.v6 = * (const struct in6_addr *) destination_ip; } - ts->source_port = spt; - ts->destination_port = dpt; + ts->source_port = source_port; + ts->destination_port = destination_port; ts->heap_node = GNUNET_CONTAINER_heap_insert (tunnel_heap, ts, GNUNET_TIME_absolute_get ().abs_value); @@ -1093,8 +1093,8 @@ route_packet (struct DestinationEntry *destination, usm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE); /* if the source port is below 32000, we assume it has a special meaning; if not, we pick a random port (this is a heuristic) */ - usm->source_port = (ntohs (udp->spt) < 32000) ? udp->spt : 0; - usm->destination_port = udp->dpt; + usm->source_port = (ntohs (udp->source_port) < 32000) ? udp->source_port : 0; + usm->destination_port = udp->destination_port; usm->service_descriptor = destination->details.service_destination.service_descriptor; memcpy (&usm[1], &udp[1], @@ -1122,8 +1122,8 @@ route_packet (struct DestinationEntry *destination, uim->header.size = htons ((uint16_t) mlen); uim->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET); uim->af = htonl (destination->details.exit_destination.af); - uim->source_port = (ntohs (udp->spt) < 32000) ? udp->spt : 0; - uim->destination_port = udp->dpt; + uim->source_port = (ntohs (udp->source_port) < 32000) ? udp->source_port : 0; + uim->destination_port = udp->destination_port; switch (destination->details.exit_destination.af) { case AF_INET: @@ -1630,8 +1630,8 @@ make_up_icmpv4_payload (struct TunnelState *ts, sizeof (struct GNUNET_TUN_TcpHeader), &ts->source_ip.v4, &ts->destination_ip.v4); - udp->spt = htons (ts->source_port); - udp->dpt = htons (ts->destination_port); + udp->source_port = htons (ts->source_port); + udp->destination_port = htons (ts->destination_port); udp->len = htons (0); udp->crc = htons (0); } @@ -1656,8 +1656,8 @@ make_up_icmpv6_payload (struct TunnelState *ts, sizeof (struct GNUNET_TUN_TcpHeader), &ts->source_ip.v6, &ts->destination_ip.v6); - udp->spt = htons (ts->source_port); - udp->dpt = htons (ts->destination_port); + udp->source_port = htons (ts->source_port); + udp->destination_port = htons (ts->destination_port); udp->len = htons (0); udp->crc = htons (0); } @@ -2085,13 +2085,13 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, &ts->destination_ip.v4, &ts->source_ip.v4); if (0 == ntohs (reply->source_port)) - udp->spt = htons (ts->destination_port); + udp->source_port = htons (ts->destination_port); else - udp->spt = reply->source_port; + udp->source_port = reply->source_port; if (0 == ntohs (reply->destination_port)) - udp->dpt = htons (ts->source_port); + udp->destination_port = htons (ts->source_port); else - udp->dpt = reply->destination_port; + udp->destination_port = reply->destination_port; udp->len = htons (mlen + sizeof (struct GNUNET_TUN_UdpHeader)); GNUNET_TUN_calculate_udp4_checksum (ipv4, udp, @@ -2130,13 +2130,13 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, &ts->destination_ip.v6, &ts->source_ip.v6); if (0 == ntohs (reply->source_port)) - udp->spt = htons (ts->destination_port); + udp->source_port = htons (ts->destination_port); else - udp->spt = reply->source_port; + udp->source_port = reply->source_port; if (0 == ntohs (reply->destination_port)) - udp->dpt = htons (ts->source_port); + udp->destination_port = htons (ts->source_port); else - udp->dpt = reply->destination_port; + udp->destination_port = reply->destination_port; udp->len = htons (mlen + sizeof (struct GNUNET_TUN_UdpHeader)); GNUNET_TUN_calculate_udp6_checksum (ipv6, udp, @@ -2243,8 +2243,8 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, &ts->destination_ip.v4, &ts->source_ip.v4); *tcp = data->tcp_header; - tcp->spt = htons (ts->destination_port); - tcp->dpt = htons (ts->source_port); + tcp->source_port = htons (ts->destination_port); + tcp->destination_port = htons (ts->source_port); GNUNET_TUN_calculate_tcp4_checksum (ipv4, tcp, &data[1], @@ -2282,8 +2282,8 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, &ts->destination_ip.v6, &ts->source_ip.v6); *tcp = data->tcp_header; - tcp->spt = htons (ts->destination_port); - tcp->dpt = htons (ts->source_port); + tcp->source_port = htons (ts->destination_port); + tcp->destination_port = htons (ts->source_port); GNUNET_TUN_calculate_tcp6_checksum (ipv6, tcp, &data[1], -- 2.25.1