aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-30 12:44:32 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-30 12:44:32 +0000
commit0cccabf5c6afcff54573de1b4ed761085a27310d (patch)
treeb64756aa7ace520419f102c50f6dbeb771040463 /src/exit
parent9ff99f23db620008bc3525f798bc395915c2e68b (diff)
downloadgnunet-0cccabf5c6afcff54573de1b4ed761085a27310d.tar.gz
gnunet-0cccabf5c6afcff54573de1b4ed761085a27310d.zip
-renaming some fields, fixing byte order issues
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-daemon-exit.c92
1 files changed, 46 insertions, 46 deletions
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,
436 * 436 *
437 * @param service_map map of services (TCP or UDP) 437 * @param service_map map of services (TCP or UDP)
438 * @param desc service descriptor 438 * @param desc service descriptor
439 * @param dpt destination port 439 * @param destination_port destination port
440 * @return NULL if we are not aware of such a service 440 * @return NULL if we are not aware of such a service
441 */ 441 */
442static struct LocalService * 442static struct LocalService *
443find_service (struct GNUNET_CONTAINER_MultiHashMap *service_map, 443find_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
444 const GNUNET_HashCode *desc, 444 const GNUNET_HashCode *desc,
445 uint16_t dpt) 445 uint16_t destination_port)
446{ 446{
447 char key[sizeof (GNUNET_HashCode) + sizeof (uint16_t)]; 447 char key[sizeof (GNUNET_HashCode) + sizeof (uint16_t)];
448 448
449 memcpy (&key[0], &dpt, sizeof (uint16_t)); 449 memcpy (&key[0], &destination_port, sizeof (uint16_t));
450 memcpy (&key[sizeof(uint16_t)], desc, sizeof (GNUNET_HashCode)); 450 memcpy (&key[sizeof(uint16_t)], desc, sizeof (GNUNET_HashCode));
451 return GNUNET_CONTAINER_multihashmap_get (service_map, 451 return GNUNET_CONTAINER_multihashmap_get (service_map,
452 (GNUNET_HashCode *) key); 452 (GNUNET_HashCode *) key);
@@ -480,13 +480,13 @@ free_service_record (void *cls,
480 * 480 *
481 * @param service_map map of services (TCP or UDP) 481 * @param service_map map of services (TCP or UDP)
482 * @param name name of the service 482 * @param name name of the service
483 * @param dpt destination port 483 * @param destination_port destination port
484 * @param service service information record to store (service->name will be set). 484 * @param service service information record to store (service->name will be set).
485 */ 485 */
486static void 486static void
487store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map, 487store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
488 const char *name, 488 const char *name,
489 uint16_t dpt, 489 uint16_t destination_port,
490 struct LocalService *service) 490 struct LocalService *service)
491{ 491{
492 char key[sizeof (GNUNET_HashCode) + sizeof (uint16_t)]; 492 char key[sizeof (GNUNET_HashCode) + sizeof (uint16_t)];
@@ -494,7 +494,7 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
494 494
495 GNUNET_CRYPTO_hash (name, strlen (name) + 1, &desc); 495 GNUNET_CRYPTO_hash (name, strlen (name) + 1, &desc);
496 service->name = GNUNET_strdup (name); 496 service->name = GNUNET_strdup (name);
497 memcpy (&key[0], &dpt, sizeof (uint16_t)); 497 memcpy (&key[0], &destination_port, sizeof (uint16_t));
498 memcpy (&key[sizeof(uint16_t)], &desc, sizeof (GNUNET_HashCode)); 498 memcpy (&key[sizeof(uint16_t)], &desc, sizeof (GNUNET_HashCode));
499 if (GNUNET_OK != 499 if (GNUNET_OK !=
500 GNUNET_CONTAINER_multihashmap_put (service_map, 500 GNUNET_CONTAINER_multihashmap_put (service_map,
@@ -506,7 +506,7 @@ store_service (struct GNUNET_CONTAINER_MultiHashMap *service_map,
506 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 506 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
507 _("Got duplicate service records for `%s:%u'\n"), 507 _("Got duplicate service records for `%s:%u'\n"),
508 name, 508 name,
509 (unsigned int) dpt); 509 (unsigned int) destination_port);
510 } 510 }
511} 511}
512 512
@@ -614,8 +614,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
614 const struct GNUNET_TUN_IPv6Header *ipv6; 614 const struct GNUNET_TUN_IPv6Header *ipv6;
615 const struct GNUNET_TUN_UdpHeader *udp; 615 const struct GNUNET_TUN_UdpHeader *udp;
616 size_t mlen; 616 size_t mlen;
617 uint16_t spt; 617 uint16_t source_port;
618 uint16_t dpt; 618 uint16_t destination_port;
619 uint8_t protocol; 619 uint8_t protocol;
620 620
621 { 621 {
@@ -640,8 +640,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
640 /* Find out if this is an ICMP packet in response to an existing 640 /* Find out if this is an ICMP packet in response to an existing
641 TCP/UDP packet and if so, figure out ports / protocol of the 641 TCP/UDP packet and if so, figure out ports / protocol of the
642 existing session from the IP data in the ICMP payload */ 642 existing session from the IP data in the ICMP payload */
643 spt = 0; 643 source_port = 0;
644 dpt = 0; 644 destination_port = 0;
645 protocol = IPPROTO_ICMP; 645 protocol = IPPROTO_ICMP;
646 switch (af) 646 switch (af)
647 { 647 {
@@ -667,8 +667,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
667 /* could be TCP or UDP, but both have the ports in the right 667 /* could be TCP or UDP, but both have the ports in the right
668 place, so that doesn't matter here */ 668 place, so that doesn't matter here */
669 udp = (const struct GNUNET_TUN_UdpHeader *) &ipv4[1]; 669 udp = (const struct GNUNET_TUN_UdpHeader *) &ipv4[1];
670 spt = ntohs (udp->spt); 670 source_port = ntohs (udp->source_port);
671 dpt = ntohs (udp->dpt); 671 destination_port = ntohs (udp->destination_port);
672 /* throw away ICMP payload, won't be useful for the other side anyway */ 672 /* throw away ICMP payload, won't be useful for the other side anyway */
673 pktlen = sizeof (struct GNUNET_TUN_IcmpHeader); 673 pktlen = sizeof (struct GNUNET_TUN_IcmpHeader);
674 break; 674 break;
@@ -699,8 +699,8 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
699 /* could be TCP or UDP, but both have the ports in the right 699 /* could be TCP or UDP, but both have the ports in the right
700 place, so that doesn't matter here */ 700 place, so that doesn't matter here */
701 udp = (const struct GNUNET_TUN_UdpHeader *) &ipv6[1]; 701 udp = (const struct GNUNET_TUN_UdpHeader *) &ipv6[1];
702 spt = ntohs (udp->spt); 702 source_port = ntohs (udp->source_port);
703 dpt = ntohs (udp->dpt); 703 destination_port = ntohs (udp->destination_port);
704 /* throw away ICMP payload, won't be useful for the other side anyway */ 704 /* throw away ICMP payload, won't be useful for the other side anyway */
705 pktlen = sizeof (struct GNUNET_TUN_IcmpHeader); 705 pktlen = sizeof (struct GNUNET_TUN_IcmpHeader);
706 break; 706 break;
@@ -728,17 +728,17 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
728 case IPPROTO_UDP: 728 case IPPROTO_UDP:
729 state = get_redirect_state (af, IPPROTO_UDP, 729 state = get_redirect_state (af, IPPROTO_UDP,
730 source_ip, 730 source_ip,
731 spt, 731 source_port,
732 destination_ip, 732 destination_ip,
733 dpt, 733 destination_port,
734 NULL); 734 NULL);
735 break; 735 break;
736 case IPPROTO_TCP: 736 case IPPROTO_TCP:
737 state = get_redirect_state (af, IPPROTO_TCP, 737 state = get_redirect_state (af, IPPROTO_TCP,
738 source_ip, 738 source_ip,
739 spt, 739 source_port,
740 destination_ip, 740 destination_ip,
741 dpt, 741 destination_port,
742 NULL); 742 NULL);
743 break; 743 break;
744 default: 744 default:
@@ -800,11 +800,11 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
800 inet_ntop (af, 800 inet_ntop (af,
801 source_ip, 801 source_ip,
802 sbuf, sizeof (sbuf)), 802 sbuf, sizeof (sbuf)),
803 (unsigned int) ntohs (udp->spt), 803 (unsigned int) ntohs (udp->source_port),
804 inet_ntop (af, 804 inet_ntop (af,
805 destination_ip, 805 destination_ip,
806 dbuf, sizeof (dbuf)), 806 dbuf, sizeof (dbuf)),
807 (unsigned int) ntohs (udp->dpt)); 807 (unsigned int) ntohs (udp->destination_port));
808 } 808 }
809 if (pktlen < sizeof (struct GNUNET_TUN_UdpHeader)) 809 if (pktlen < sizeof (struct GNUNET_TUN_UdpHeader))
810 { 810 {
@@ -820,9 +820,9 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
820 } 820 }
821 state = get_redirect_state (af, IPPROTO_UDP, 821 state = get_redirect_state (af, IPPROTO_UDP,
822 source_ip, 822 source_ip,
823 ntohs (udp->spt), 823 ntohs (udp->source_port),
824 destination_ip, 824 destination_ip,
825 ntohs (udp->dpt), 825 ntohs (udp->destination_port),
826 NULL); 826 NULL);
827 if (NULL == state) 827 if (NULL == state)
828 { 828 {
@@ -881,11 +881,11 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
881 inet_ntop (af, 881 inet_ntop (af,
882 source_ip, 882 source_ip,
883 sbuf, sizeof (sbuf)), 883 sbuf, sizeof (sbuf)),
884 (unsigned int) ntohs (tcp->spt), 884 (unsigned int) ntohs (tcp->source_port),
885 inet_ntop (af, 885 inet_ntop (af,
886 destination_ip, 886 destination_ip,
887 dbuf, sizeof (dbuf)), 887 dbuf, sizeof (dbuf)),
888 (unsigned int) ntohs (tcp->dpt)); 888 (unsigned int) ntohs (tcp->destination_port));
889 } 889 }
890 if (pktlen < sizeof (struct GNUNET_TUN_TcpHeader)) 890 if (pktlen < sizeof (struct GNUNET_TUN_TcpHeader))
891 { 891 {
@@ -895,9 +895,9 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
895 } 895 }
896 state = get_redirect_state (af, IPPROTO_TCP, 896 state = get_redirect_state (af, IPPROTO_TCP,
897 source_ip, 897 source_ip,
898 ntohs (tcp->spt), 898 ntohs (tcp->source_port),
899 destination_ip, 899 destination_ip,
900 ntohs (tcp->dpt), 900 ntohs (tcp->destination_port),
901 NULL); 901 NULL);
902 if (NULL == state) 902 if (NULL == state)
903 { 903 {
@@ -910,8 +910,8 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
910 sender will need to lookup the correct values anyway */ 910 sender will need to lookup the correct values anyway */
911 memcpy (buf, tcp, pktlen); 911 memcpy (buf, tcp, pktlen);
912 mtcp = (struct GNUNET_TUN_TcpHeader *) buf; 912 mtcp = (struct GNUNET_TUN_TcpHeader *) buf;
913 mtcp->spt = 0; 913 mtcp->source_port = 0;
914 mtcp->dpt = 0; 914 mtcp->destination_port = 0;
915 mtcp->crc = 0; 915 mtcp->crc = 0;
916 916
917 mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + (pktlen - sizeof (struct GNUNET_TUN_TcpHeader)); 917 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,
1316 { 1316 {
1317 struct GNUNET_TUN_UdpHeader *pkt4_udp = (struct GNUNET_TUN_UdpHeader *) &pkt4[1]; 1317 struct GNUNET_TUN_UdpHeader *pkt4_udp = (struct GNUNET_TUN_UdpHeader *) &pkt4[1];
1318 1318
1319 pkt4_udp->spt = htons (src_address->port); 1319 pkt4_udp->source_port = htons (src_address->port);
1320 pkt4_udp->dpt = htons (dst_address->port); 1320 pkt4_udp->destination_port = htons (dst_address->port);
1321 pkt4_udp->len = htons ((uint16_t) payload_length); 1321 pkt4_udp->len = htons ((uint16_t) payload_length);
1322 GNUNET_TUN_calculate_udp4_checksum (pkt4, 1322 GNUNET_TUN_calculate_udp4_checksum (pkt4,
1323 pkt4_udp, 1323 pkt4_udp,
@@ -1330,8 +1330,8 @@ prepare_ipv4_packet (const void *payload, size_t payload_length,
1330 struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1]; 1330 struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1];
1331 1331
1332 *pkt4_tcp = *tcp_header; 1332 *pkt4_tcp = *tcp_header;
1333 pkt4_tcp->spt = htons (src_address->port); 1333 pkt4_tcp->source_port = htons (src_address->port);
1334 pkt4_tcp->dpt = htons (dst_address->port); 1334 pkt4_tcp->destination_port = htons (dst_address->port);
1335 GNUNET_TUN_calculate_tcp4_checksum (pkt4, 1335 GNUNET_TUN_calculate_tcp4_checksum (pkt4,
1336 pkt4_tcp, 1336 pkt4_tcp,
1337 payload, 1337 payload,
@@ -1403,8 +1403,8 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1403 { 1403 {
1404 struct GNUNET_TUN_UdpHeader *pkt6_udp = (struct GNUNET_TUN_UdpHeader *) &pkt6[1]; 1404 struct GNUNET_TUN_UdpHeader *pkt6_udp = (struct GNUNET_TUN_UdpHeader *) &pkt6[1];
1405 1405
1406 pkt6_udp->spt = htons (src_address->port); 1406 pkt6_udp->source_port = htons (src_address->port);
1407 pkt6_udp->dpt = htons (dst_address->port); 1407 pkt6_udp->destination_port = htons (dst_address->port);
1408 pkt6_udp->len = htons ((uint16_t) payload_length); 1408 pkt6_udp->len = htons ((uint16_t) payload_length);
1409 GNUNET_TUN_calculate_udp6_checksum (pkt6, 1409 GNUNET_TUN_calculate_udp6_checksum (pkt6,
1410 pkt6_udp, 1410 pkt6_udp,
@@ -1419,8 +1419,8 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1419 1419
1420 /* memcpy first here as some TCP header fields are initialized this way! */ 1420 /* memcpy first here as some TCP header fields are initialized this way! */
1421 *pkt6_tcp = *tcp_header; 1421 *pkt6_tcp = *tcp_header;
1422 pkt6_tcp->spt = htons (src_address->port); 1422 pkt6_tcp->source_port = htons (src_address->port);
1423 pkt6_tcp->dpt = htons (dst_address->port); 1423 pkt6_tcp->destination_port = htons (dst_address->port);
1424 GNUNET_TUN_calculate_tcp6_checksum (pkt6, 1424 GNUNET_TUN_calculate_tcp6_checksum (pkt6,
1425 pkt6_tcp, 1425 pkt6_tcp,
1426 payload, 1426 payload,
@@ -1584,14 +1584,14 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1584 "Received data from %s for forwarding to TCP service %s on port %u\n", 1584 "Received data from %s for forwarding to TCP service %s on port %u\n",
1585 GNUNET_i2s (sender), 1585 GNUNET_i2s (sender),
1586 GNUNET_h2s (&start->service_descriptor), 1586 GNUNET_h2s (&start->service_descriptor),
1587 (unsigned int) ntohs (start->tcp_header.dpt)); 1587 (unsigned int) ntohs (start->tcp_header.destination_port));
1588 if (NULL == (state->serv = find_service (tcp_services, &start->service_descriptor, 1588 if (NULL == (state->serv = find_service (tcp_services, &start->service_descriptor,
1589 ntohs (start->tcp_header.dpt)))) 1589 ntohs (start->tcp_header.destination_port))))
1590 { 1590 {
1591 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1591 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1592 _("No service found for %s on port %d!\n"), 1592 _("No service found for %s on port %d!\n"),
1593 "TCP", 1593 "TCP",
1594 ntohs (start->tcp_header.dpt)); 1594 ntohs (start->tcp_header.destination_port));
1595 GNUNET_STATISTICS_update (stats, 1595 GNUNET_STATISTICS_update (stats,
1596 gettext_noop ("# TCP requests dropped (no such service)"), 1596 gettext_noop ("# TCP requests dropped (no such service)"),
1597 1, GNUNET_NO); 1597 1, GNUNET_NO);
@@ -1707,10 +1707,10 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1707 inet_ntop (af, 1707 inet_ntop (af,
1708 &state->ri.remote_address.address, 1708 &state->ri.remote_address.address,
1709 buf, sizeof (buf)), 1709 buf, sizeof (buf)),
1710 (unsigned int) ntohs (start->tcp_header.dpt)); 1710 (unsigned int) ntohs (start->tcp_header.destination_port));
1711 } 1711 }
1712 state->ri.remote_address.proto = IPPROTO_TCP; 1712 state->ri.remote_address.proto = IPPROTO_TCP;
1713 state->ri.remote_address.port = ntohs (start->tcp_header.dpt); 1713 state->ri.remote_address.port = ntohs (start->tcp_header.destination_port);
1714 setup_state_record (state); 1714 setup_state_record (state);
1715 send_tcp_packet_via_tun (&state->ri.remote_address, 1715 send_tcp_packet_via_tun (&state->ri.remote_address,
1716 &state->ri.local_address, 1716 &state->ri.local_address,
@@ -1913,8 +1913,8 @@ make_up_icmpv4_payload (struct TunnelState *state,
1913 sizeof (struct GNUNET_TUN_TcpHeader), 1913 sizeof (struct GNUNET_TUN_TcpHeader),
1914 &state->ri.remote_address.address.ipv4, 1914 &state->ri.remote_address.address.ipv4,
1915 &state->ri.local_address.address.ipv4); 1915 &state->ri.local_address.address.ipv4);
1916 udp->spt = htons (state->ri.remote_address.port); 1916 udp->source_port = htons (state->ri.remote_address.port);
1917 udp->dpt = htons (state->ri.local_address.port); 1917 udp->destination_port = htons (state->ri.local_address.port);
1918 udp->len = htons (0); 1918 udp->len = htons (0);
1919 udp->crc = htons (0); 1919 udp->crc = htons (0);
1920} 1920}
@@ -1939,8 +1939,8 @@ make_up_icmpv6_payload (struct TunnelState *state,
1939 sizeof (struct GNUNET_TUN_TcpHeader), 1939 sizeof (struct GNUNET_TUN_TcpHeader),
1940 &state->ri.remote_address.address.ipv6, 1940 &state->ri.remote_address.address.ipv6,
1941 &state->ri.local_address.address.ipv6); 1941 &state->ri.local_address.address.ipv6);
1942 udp->spt = htons (state->ri.remote_address.port); 1942 udp->source_port = htons (state->ri.remote_address.port);
1943 udp->dpt = htons (state->ri.local_address.port); 1943 udp->destination_port = htons (state->ri.local_address.port);
1944 udp->len = htons (0); 1944 udp->len = htons (0);
1945 udp->crc = htons (0); 1945 udp->crc = htons (0);
1946} 1946}