diff options
Diffstat (limited to 'src/include/gnunet_tun_lib.h')
-rw-r--r-- | src/include/gnunet_tun_lib.h | 144 |
1 files changed, 81 insertions, 63 deletions
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 941f394aa..0af9a1d3e 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h | |||
@@ -78,7 +78,8 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
78 | /** | 78 | /** |
79 | * Header from Linux TUN interface. | 79 | * Header from Linux TUN interface. |
80 | */ | 80 | */ |
81 | struct GNUNET_TUN_Layer2PacketHeader { | 81 | struct GNUNET_TUN_Layer2PacketHeader |
82 | { | ||
82 | /** | 83 | /** |
83 | * Some flags (unused). | 84 | * Some flags (unused). |
84 | */ | 85 | */ |
@@ -94,7 +95,8 @@ struct GNUNET_TUN_Layer2PacketHeader { | |||
94 | /** | 95 | /** |
95 | * Standard IPv4 header. | 96 | * Standard IPv4 header. |
96 | */ | 97 | */ |
97 | struct GNUNET_TUN_IPv4Header { | 98 | struct GNUNET_TUN_IPv4Header |
99 | { | ||
98 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 100 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
99 | unsigned int header_length : 4 GNUNET_PACKED; | 101 | unsigned int header_length : 4 GNUNET_PACKED; |
100 | unsigned int version : 4 GNUNET_PACKED; | 102 | unsigned int version : 4 GNUNET_PACKED; |
@@ -150,7 +152,8 @@ struct GNUNET_TUN_IPv4Header { | |||
150 | /** | 152 | /** |
151 | * Standard IPv6 header. | 153 | * Standard IPv6 header. |
152 | */ | 154 | */ |
153 | struct GNUNET_TUN_IPv6Header { | 155 | struct GNUNET_TUN_IPv6Header |
156 | { | ||
154 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 157 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
155 | unsigned int traffic_class_h : 4 GNUNET_PACKED; | 158 | unsigned int traffic_class_h : 4 GNUNET_PACKED; |
156 | unsigned int version : 4 GNUNET_PACKED; | 159 | unsigned int version : 4 GNUNET_PACKED; |
@@ -205,7 +208,8 @@ struct GNUNET_TUN_IPv6Header { | |||
205 | /** | 208 | /** |
206 | * TCP packet header. | 209 | * TCP packet header. |
207 | */ | 210 | */ |
208 | struct GNUNET_TUN_TcpHeader { | 211 | struct GNUNET_TUN_TcpHeader |
212 | { | ||
209 | /** | 213 | /** |
210 | * Source port (in NBO). | 214 | * Source port (in NBO). |
211 | */ | 215 | */ |
@@ -272,7 +276,8 @@ struct GNUNET_TUN_TcpHeader { | |||
272 | /** | 276 | /** |
273 | * UDP packet header. | 277 | * UDP packet header. |
274 | */ | 278 | */ |
275 | struct GNUNET_TUN_UdpHeader { | 279 | struct GNUNET_TUN_UdpHeader |
280 | { | ||
276 | /** | 281 | /** |
277 | * Source port (in NBO). | 282 | * Source port (in NBO). |
278 | */ | 283 | */ |
@@ -331,7 +336,8 @@ struct GNUNET_TUN_UdpHeader { | |||
331 | /** | 336 | /** |
332 | * DNS flags (largely RFC 1035 / RFC 2136). | 337 | * DNS flags (largely RFC 1035 / RFC 2136). |
333 | */ | 338 | */ |
334 | struct GNUNET_TUN_DnsFlags { | 339 | struct GNUNET_TUN_DnsFlags |
340 | { | ||
335 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 341 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
336 | /** | 342 | /** |
337 | * Set to 1 if recursion is desired (client -> server) | 343 | * Set to 1 if recursion is desired (client -> server) |
@@ -442,7 +448,8 @@ struct GNUNET_TUN_DnsFlags { | |||
442 | /** | 448 | /** |
443 | * DNS header. | 449 | * DNS header. |
444 | */ | 450 | */ |
445 | struct GNUNET_TUN_DnsHeader { | 451 | struct GNUNET_TUN_DnsHeader |
452 | { | ||
446 | /** | 453 | /** |
447 | * Unique identifier for the request/response. | 454 | * Unique identifier for the request/response. |
448 | */ | 455 | */ |
@@ -478,7 +485,8 @@ struct GNUNET_TUN_DnsHeader { | |||
478 | /** | 485 | /** |
479 | * Payload of DNS SOA record (header). | 486 | * Payload of DNS SOA record (header). |
480 | */ | 487 | */ |
481 | struct GNUNET_TUN_DnsSoaRecord { | 488 | struct GNUNET_TUN_DnsSoaRecord |
489 | { | ||
482 | /** | 490 | /** |
483 | * The version number of the original copy of the zone. (NBO) | 491 | * The version number of the original copy of the zone. (NBO) |
484 | */ | 492 | */ |
@@ -512,7 +520,8 @@ struct GNUNET_TUN_DnsSoaRecord { | |||
512 | /** | 520 | /** |
513 | * Payload of DNS SRV record (header). | 521 | * Payload of DNS SRV record (header). |
514 | */ | 522 | */ |
515 | struct GNUNET_TUN_DnsSrvRecord { | 523 | struct GNUNET_TUN_DnsSrvRecord |
524 | { | ||
516 | /** | 525 | /** |
517 | * Preference for this entry (lower value is higher preference). Clients | 526 | * Preference for this entry (lower value is higher preference). Clients |
518 | * will contact hosts from the lowest-priority group first and fall back | 527 | * will contact hosts from the lowest-priority group first and fall back |
@@ -539,7 +548,8 @@ struct GNUNET_TUN_DnsSrvRecord { | |||
539 | /** | 548 | /** |
540 | * Payload of DNS CERT record. | 549 | * Payload of DNS CERT record. |
541 | */ | 550 | */ |
542 | struct GNUNET_TUN_DnsCertRecord { | 551 | struct GNUNET_TUN_DnsCertRecord |
552 | { | ||
543 | /** | 553 | /** |
544 | * Certificate type | 554 | * Certificate type |
545 | */ | 555 | */ |
@@ -563,7 +573,8 @@ struct GNUNET_TUN_DnsCertRecord { | |||
563 | * Payload of DNSSEC TLSA record. | 573 | * Payload of DNSSEC TLSA record. |
564 | * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/ | 574 | * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/ |
565 | */ | 575 | */ |
566 | struct GNUNET_TUN_DnsTlsaRecord { | 576 | struct GNUNET_TUN_DnsTlsaRecord |
577 | { | ||
567 | /** | 578 | /** |
568 | * Certificate usage | 579 | * Certificate usage |
569 | * 0: CA cert | 580 | * 0: CA cert |
@@ -607,7 +618,8 @@ struct GNUNET_TUN_DnsTlsaRecord { | |||
607 | /** | 618 | /** |
608 | * Payload of GNS VPN record | 619 | * Payload of GNS VPN record |
609 | */ | 620 | */ |
610 | struct GNUNET_TUN_GnsVpnRecord { | 621 | struct GNUNET_TUN_GnsVpnRecord |
622 | { | ||
611 | /** | 623 | /** |
612 | * The peer to contact | 624 | * The peer to contact |
613 | */ | 625 | */ |
@@ -625,7 +637,8 @@ struct GNUNET_TUN_GnsVpnRecord { | |||
625 | /** | 637 | /** |
626 | * DNS query prefix. | 638 | * DNS query prefix. |
627 | */ | 639 | */ |
628 | struct GNUNET_TUN_DnsQueryLine { | 640 | struct GNUNET_TUN_DnsQueryLine |
641 | { | ||
629 | /** | 642 | /** |
630 | * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) | 643 | * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) |
631 | */ | 644 | */ |
@@ -641,7 +654,8 @@ struct GNUNET_TUN_DnsQueryLine { | |||
641 | /** | 654 | /** |
642 | * General DNS record prefix. | 655 | * General DNS record prefix. |
643 | */ | 656 | */ |
644 | struct GNUNET_TUN_DnsRecordLine { | 657 | struct GNUNET_TUN_DnsRecordLine |
658 | { | ||
645 | /** | 659 | /** |
646 | * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) | 660 | * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) |
647 | */ | 661 | */ |
@@ -684,16 +698,19 @@ struct GNUNET_TUN_DnsRecordLine { | |||
684 | /** | 698 | /** |
685 | * ICMP header. | 699 | * ICMP header. |
686 | */ | 700 | */ |
687 | struct GNUNET_TUN_IcmpHeader { | 701 | struct GNUNET_TUN_IcmpHeader |
702 | { | ||
688 | uint8_t type; | 703 | uint8_t type; |
689 | uint8_t code; | 704 | uint8_t code; |
690 | uint16_t crc GNUNET_PACKED; | 705 | uint16_t crc GNUNET_PACKED; |
691 | 706 | ||
692 | union { | 707 | union |
708 | { | ||
693 | /** | 709 | /** |
694 | * ICMP Echo (request/reply) | 710 | * ICMP Echo (request/reply) |
695 | */ | 711 | */ |
696 | struct { | 712 | struct |
713 | { | ||
697 | uint16_t identifier GNUNET_PACKED; | 714 | uint16_t identifier GNUNET_PACKED; |
698 | uint16_t sequence_number GNUNET_PACKED; | 715 | uint16_t sequence_number GNUNET_PACKED; |
699 | } echo; | 716 | } echo; |
@@ -701,7 +718,8 @@ struct GNUNET_TUN_IcmpHeader { | |||
701 | /** | 718 | /** |
702 | * ICMP Destination Unreachable (RFC 1191) | 719 | * ICMP Destination Unreachable (RFC 1191) |
703 | */ | 720 | */ |
704 | struct ih_pmtu { | 721 | struct ih_pmtu |
722 | { | ||
705 | uint16_t empty GNUNET_PACKED; | 723 | uint16_t empty GNUNET_PACKED; |
706 | uint16_t next_hop_mtu GNUNET_PACKED; | 724 | uint16_t next_hop_mtu GNUNET_PACKED; |
707 | /* followed by original IP header + first 8 bytes of original IP datagram | 725 | /* followed by original IP header + first 8 bytes of original IP datagram |
@@ -735,11 +753,11 @@ GNUNET_NETWORK_STRUCT_END | |||
735 | * @param dst destination IP address to use | 753 | * @param dst destination IP address to use |
736 | */ | 754 | */ |
737 | void | 755 | void |
738 | GNUNET_TUN_initialize_ipv4_header(struct GNUNET_TUN_IPv4Header *ip, | 756 | GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip, |
739 | uint8_t protocol, | 757 | uint8_t protocol, |
740 | uint16_t payload_length, | 758 | uint16_t payload_length, |
741 | const struct in_addr *src, | 759 | const struct in_addr *src, |
742 | const struct in_addr *dst); | 760 | const struct in_addr *dst); |
743 | 761 | ||
744 | 762 | ||
745 | /** | 763 | /** |
@@ -753,11 +771,11 @@ GNUNET_TUN_initialize_ipv4_header(struct GNUNET_TUN_IPv4Header *ip, | |||
753 | * @param dst destination IP address to use | 771 | * @param dst destination IP address to use |
754 | */ | 772 | */ |
755 | void | 773 | void |
756 | GNUNET_TUN_initialize_ipv6_header(struct GNUNET_TUN_IPv6Header *ip, | 774 | GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip, |
757 | uint8_t protocol, | 775 | uint8_t protocol, |
758 | uint16_t payload_length, | 776 | uint16_t payload_length, |
759 | const struct in6_addr *src, | 777 | const struct in6_addr *src, |
760 | const struct in6_addr *dst); | 778 | const struct in6_addr *dst); |
761 | 779 | ||
762 | /** | 780 | /** |
763 | * Calculate IPv4 TCP checksum. | 781 | * Calculate IPv4 TCP checksum. |
@@ -768,10 +786,10 @@ GNUNET_TUN_initialize_ipv6_header(struct GNUNET_TUN_IPv6Header *ip, | |||
768 | * @param payload_length number of bytes of TCP @a payload | 786 | * @param payload_length number of bytes of TCP @a payload |
769 | */ | 787 | */ |
770 | void | 788 | void |
771 | GNUNET_TUN_calculate_tcp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, | 789 | GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, |
772 | struct GNUNET_TUN_TcpHeader *tcp, | 790 | struct GNUNET_TUN_TcpHeader *tcp, |
773 | const void *payload, | 791 | const void *payload, |
774 | uint16_t payload_length); | 792 | uint16_t payload_length); |
775 | 793 | ||
776 | /** | 794 | /** |
777 | * Calculate IPv6 TCP checksum. | 795 | * Calculate IPv6 TCP checksum. |
@@ -782,10 +800,10 @@ GNUNET_TUN_calculate_tcp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, | |||
782 | * @param payload_length number of bytes of TCP payload | 800 | * @param payload_length number of bytes of TCP payload |
783 | */ | 801 | */ |
784 | void | 802 | void |
785 | GNUNET_TUN_calculate_tcp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, | 803 | GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, |
786 | struct GNUNET_TUN_TcpHeader *tcp, | 804 | struct GNUNET_TUN_TcpHeader *tcp, |
787 | const void *payload, | 805 | const void *payload, |
788 | uint16_t payload_length); | 806 | uint16_t payload_length); |
789 | 807 | ||
790 | /** | 808 | /** |
791 | * Calculate IPv4 UDP checksum. | 809 | * Calculate IPv4 UDP checksum. |
@@ -796,10 +814,10 @@ GNUNET_TUN_calculate_tcp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, | |||
796 | * @param payload_length number of bytes of UDP @a payload | 814 | * @param payload_length number of bytes of UDP @a payload |
797 | */ | 815 | */ |
798 | void | 816 | void |
799 | GNUNET_TUN_calculate_udp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, | 817 | GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, |
800 | struct GNUNET_TUN_UdpHeader *udp, | 818 | struct GNUNET_TUN_UdpHeader *udp, |
801 | const void *payload, | 819 | const void *payload, |
802 | uint16_t payload_length); | 820 | uint16_t payload_length); |
803 | 821 | ||
804 | 822 | ||
805 | /** | 823 | /** |
@@ -811,10 +829,10 @@ GNUNET_TUN_calculate_udp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, | |||
811 | * @param payload_length number of bytes of @a payload | 829 | * @param payload_length number of bytes of @a payload |
812 | */ | 830 | */ |
813 | void | 831 | void |
814 | GNUNET_TUN_calculate_udp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, | 832 | GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, |
815 | struct GNUNET_TUN_UdpHeader *udp, | 833 | struct GNUNET_TUN_UdpHeader *udp, |
816 | const void *payload, | 834 | const void *payload, |
817 | uint16_t payload_length); | 835 | uint16_t payload_length); |
818 | 836 | ||
819 | 837 | ||
820 | /** | 838 | /** |
@@ -825,9 +843,9 @@ GNUNET_TUN_calculate_udp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, | |||
825 | * @param payload_length number of bytes of @a payload | 843 | * @param payload_length number of bytes of @a payload |
826 | */ | 844 | */ |
827 | void | 845 | void |
828 | GNUNET_TUN_calculate_icmp_checksum(struct GNUNET_TUN_IcmpHeader *icmp, | 846 | GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp, |
829 | const void *payload, | 847 | const void *payload, |
830 | uint16_t payload_length); | 848 | uint16_t payload_length); |
831 | 849 | ||
832 | 850 | ||
833 | /** | 851 | /** |
@@ -839,9 +857,9 @@ GNUNET_TUN_calculate_icmp_checksum(struct GNUNET_TUN_IcmpHeader *icmp, | |||
839 | * bytes long. | 857 | * bytes long. |
840 | */ | 858 | */ |
841 | void | 859 | void |
842 | GNUNET_TUN_ipv4toregexsearch(const struct in_addr *ip, | 860 | GNUNET_TUN_ipv4toregexsearch (const struct in_addr *ip, |
843 | uint16_t port, | 861 | uint16_t port, |
844 | char *rxstr); | 862 | char *rxstr); |
845 | 863 | ||
846 | 864 | ||
847 | /** | 865 | /** |
@@ -853,9 +871,9 @@ GNUNET_TUN_ipv4toregexsearch(const struct in_addr *ip, | |||
853 | * bytes long. | 871 | * bytes long. |
854 | */ | 872 | */ |
855 | void | 873 | void |
856 | GNUNET_TUN_ipv6toregexsearch(const struct in6_addr *ipv6, | 874 | GNUNET_TUN_ipv6toregexsearch (const struct in6_addr *ipv6, |
857 | uint16_t port, | 875 | uint16_t port, |
858 | char *rxstr); | 876 | char *rxstr); |
859 | 877 | ||
860 | 878 | ||
861 | /** | 879 | /** |
@@ -868,7 +886,7 @@ GNUNET_TUN_ipv6toregexsearch(const struct in6_addr *ipv6, | |||
868 | * @return regular expression, NULL on error | 886 | * @return regular expression, NULL on error |
869 | */ | 887 | */ |
870 | char * | 888 | char * |
871 | GNUNET_TUN_ipv6policy2regex(const char *policy); | 889 | GNUNET_TUN_ipv6policy2regex (const char *policy); |
872 | 890 | ||
873 | 891 | ||
874 | /** | 892 | /** |
@@ -881,7 +899,7 @@ GNUNET_TUN_ipv6policy2regex(const char *policy); | |||
881 | * @return regular expression, NULL on error | 899 | * @return regular expression, NULL on error |
882 | */ | 900 | */ |
883 | char * | 901 | char * |
884 | GNUNET_TUN_ipv4policy2regex(const char *policy); | 902 | GNUNET_TUN_ipv4policy2regex (const char *policy); |
885 | 903 | ||
886 | 904 | ||
887 | /** | 905 | /** |
@@ -893,8 +911,8 @@ GNUNET_TUN_ipv4policy2regex(const char *policy); | |||
893 | * @param[out] hc corresponding hash | 911 | * @param[out] hc corresponding hash |
894 | */ | 912 | */ |
895 | void | 913 | void |
896 | GNUNET_TUN_service_name_to_hash(const char *service_name, | 914 | GNUNET_TUN_service_name_to_hash (const char *service_name, |
897 | struct GNUNET_HashCode *hc); | 915 | struct GNUNET_HashCode *hc); |
898 | 916 | ||
899 | 917 | ||
900 | /** | 918 | /** |
@@ -906,9 +924,9 @@ GNUNET_TUN_service_name_to_hash(const char *service_name, | |||
906 | * @return #GNUNET_YES if they are equal | 924 | * @return #GNUNET_YES if they are equal |
907 | */ | 925 | */ |
908 | int | 926 | int |
909 | GNUNET_TUN_sockaddr_cmp(const struct sockaddr *sa, | 927 | GNUNET_TUN_sockaddr_cmp (const struct sockaddr *sa, |
910 | const struct sockaddr *sb, | 928 | const struct sockaddr *sb, |
911 | int include_port); | 929 | int include_port); |
912 | 930 | ||
913 | 931 | ||
914 | /** | 932 | /** |
@@ -921,9 +939,9 @@ GNUNET_TUN_sockaddr_cmp(const struct sockaddr *sa, | |||
921 | * @param[out] cadet_port CADET port to use | 939 | * @param[out] cadet_port CADET port to use |
922 | */ | 940 | */ |
923 | void | 941 | void |
924 | GNUNET_TUN_compute_service_cadet_port(const struct GNUNET_HashCode *desc, | 942 | GNUNET_TUN_compute_service_cadet_port (const struct GNUNET_HashCode *desc, |
925 | uint16_t ip_port, | 943 | uint16_t ip_port, |
926 | struct GNUNET_HashCode *cadet_port); | 944 | struct GNUNET_HashCode *cadet_port); |
927 | 945 | ||
928 | #endif | 946 | #endif |
929 | 947 | ||