aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-04-18 17:47:48 +0200
committerChristian Grothoff <christian@grothoff.org>2019-04-18 18:44:12 +0200
commit54682762caceae10c583e57548fe12d071d30fc1 (patch)
tree346622623a5d72634db6da08a38dd313d2846ccf /src
parent6fc8b0b7f221e6fb1b87e7a19982e939023d3265 (diff)
downloadgnunet-54682762caceae10c583e57548fe12d071d30fc1.tar.gz
gnunet-54682762caceae10c583e57548fe12d071d30fc1.zip
fix #5688 packed warnings
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_tun_lib.h174
1 files changed, 88 insertions, 86 deletions
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h
index 11c43e8b7..c01e641c1 100644
--- a/src/include/gnunet_tun_lib.h
+++ b/src/include/gnunet_tun_lib.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -23,10 +23,12 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * 24 *
25 * @file 25 * @file
26 * Standard TCP/IP network structs and IP checksum calculations for TUN interaction 26 * Standard TCP/IP network structs and IP checksum calculations for TUN
27 * interaction
27 * 28 *
28 * @defgroup tun TUN library 29 * @defgroup tun TUN library
29 * Standard TCP/IP network structs and IP checksum calculations for TUN interaction 30 * Standard TCP/IP network structs and IP checksum calculations for TUN
31 * interaction
30 * @{ 32 * @{
31 */ 33 */
32#ifndef GNUNET_TUN_LIB_H 34#ifndef GNUNET_TUN_LIB_H
@@ -96,13 +98,13 @@ struct GNUNET_TUN_Layer2PacketHeader
96struct GNUNET_TUN_IPv4Header 98struct GNUNET_TUN_IPv4Header
97{ 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;
101#elif __BYTE_ORDER == __BIG_ENDIAN 103#elif __BYTE_ORDER == __BIG_ENDIAN
102 unsigned int version:4 GNUNET_PACKED; 104 unsigned int version : 4 GNUNET_PACKED;
103 unsigned int header_length:4 GNUNET_PACKED; 105 unsigned int header_length : 4 GNUNET_PACKED;
104#else 106#else
105 #error byteorder undefined 107#error byteorder undefined
106#endif 108#endif
107 uint8_t diff_serv; 109 uint8_t diff_serv;
108 110
@@ -116,9 +118,9 @@ struct GNUNET_TUN_IPv4Header
116 */ 118 */
117 uint16_t identification GNUNET_PACKED; 119 uint16_t identification GNUNET_PACKED;
118 120
119 unsigned int flags:3 GNUNET_PACKED; 121 unsigned int flags : 3 GNUNET_PACKED;
120 122
121 unsigned int fragmentation_offset:13 GNUNET_PACKED; 123 unsigned int fragmentation_offset : 13 GNUNET_PACKED;
122 124
123 /** 125 /**
124 * How many more hops can this packet be forwarded? 126 * How many more hops can this packet be forwarded?
@@ -138,12 +140,12 @@ struct GNUNET_TUN_IPv4Header
138 /** 140 /**
139 * Origin of the packet. 141 * Origin of the packet.
140 */ 142 */
141 struct in_addr source_address GNUNET_PACKED; 143 struct in_addr source_address;
142 144
143 /** 145 /**
144 * Destination of the packet. 146 * Destination of the packet.
145 */ 147 */
146 struct in_addr destination_address GNUNET_PACKED; 148 struct in_addr destination_address;
147} GNUNET_GCC_STRUCT_LAYOUT; 149} GNUNET_GCC_STRUCT_LAYOUT;
148 150
149 151
@@ -153,16 +155,16 @@ struct GNUNET_TUN_IPv4Header
153struct GNUNET_TUN_IPv6Header 155struct GNUNET_TUN_IPv6Header
154{ 156{
155#if __BYTE_ORDER == __LITTLE_ENDIAN 157#if __BYTE_ORDER == __LITTLE_ENDIAN
156 unsigned int traffic_class_h:4 GNUNET_PACKED; 158 unsigned int traffic_class_h : 4 GNUNET_PACKED;
157 unsigned int version:4 GNUNET_PACKED; 159 unsigned int version : 4 GNUNET_PACKED;
158 unsigned int traffic_class_l:4 GNUNET_PACKED; 160 unsigned int traffic_class_l : 4 GNUNET_PACKED;
159 unsigned int flow_label:20 GNUNET_PACKED; 161 unsigned int flow_label : 20 GNUNET_PACKED;
160#elif __BYTE_ORDER == __BIG_ENDIAN 162#elif __BYTE_ORDER == __BIG_ENDIAN
161 unsigned int version:4 GNUNET_PACKED; 163 unsigned int version : 4 GNUNET_PACKED;
162 unsigned int traffic_class:8 GNUNET_PACKED; 164 unsigned int traffic_class : 8 GNUNET_PACKED;
163 unsigned int flow_label:20 GNUNET_PACKED; 165 unsigned int flow_label : 20 GNUNET_PACKED;
164#else 166#else
165 #error byteorder undefined 167#error byteorder undefined
166#endif 168#endif
167 /** 169 /**
168 * Length of the payload, excluding this header. 170 * Length of the payload, excluding this header.
@@ -246,7 +248,7 @@ struct GNUNET_TUN_TcpHeader
246 */ 248 */
247 unsigned int reserved : 4 GNUNET_PACKED; 249 unsigned int reserved : 4 GNUNET_PACKED;
248#else 250#else
249 #error byteorder undefined 251#error byteorder undefined
250#endif 252#endif
251 253
252 /** 254 /**
@@ -298,7 +300,6 @@ struct GNUNET_TUN_UdpHeader
298}; 300};
299 301
300 302
301
302/** 303/**
303 * A few common DNS classes (ok, only one is common, but I list a 304 * A few common DNS classes (ok, only one is common, but I list a
304 * couple more to make it clear what we're talking about here). 305 * couple more to make it clear what we're talking about here).
@@ -341,12 +342,12 @@ struct GNUNET_TUN_DnsFlags
341 /** 342 /**
342 * Set to 1 if recursion is desired (client -> server) 343 * Set to 1 if recursion is desired (client -> server)
343 */ 344 */
344 unsigned int recursion_desired : 1 GNUNET_PACKED; 345 unsigned int recursion_desired : 1 GNUNET_PACKED;
345 346
346 /** 347 /**
347 * Set to 1 if message is truncated 348 * Set to 1 if message is truncated
348 */ 349 */
349 unsigned int message_truncated : 1 GNUNET_PACKED; 350 unsigned int message_truncated : 1 GNUNET_PACKED;
350 351
351 /** 352 /**
352 * Set to 1 if this is an authoritative answer 353 * Set to 1 if this is an authoritative answer
@@ -356,48 +357,48 @@ struct GNUNET_TUN_DnsFlags
356 /** 357 /**
357 * See GNUNET_TUN_DNS_OPCODE_ defines. 358 * See GNUNET_TUN_DNS_OPCODE_ defines.
358 */ 359 */
359 unsigned int opcode : 4 GNUNET_PACKED; 360 unsigned int opcode : 4 GNUNET_PACKED;
360 361
361 /** 362 /**
362 * query:0, response:1 363 * query:0, response:1
363 */ 364 */
364 unsigned int query_or_response : 1 GNUNET_PACKED; 365 unsigned int query_or_response : 1 GNUNET_PACKED;
365 366
366 /** 367 /**
367 * See GNUNET_TUN_DNS_RETURN_CODE_ defines. 368 * See GNUNET_TUN_DNS_RETURN_CODE_ defines.
368 */ 369 */
369 unsigned int return_code : 4 GNUNET_PACKED; 370 unsigned int return_code : 4 GNUNET_PACKED;
370 371
371 /** 372 /**
372 * See RFC 4035. 373 * See RFC 4035.
373 */ 374 */
374 unsigned int checking_disabled : 1 GNUNET_PACKED; 375 unsigned int checking_disabled : 1 GNUNET_PACKED;
375 376
376 /** 377 /**
377 * Response has been cryptographically verified, RFC 4035. 378 * Response has been cryptographically verified, RFC 4035.
378 */ 379 */
379 unsigned int authenticated_data : 1 GNUNET_PACKED; 380 unsigned int authenticated_data : 1 GNUNET_PACKED;
380 381
381 /** 382 /**
382 * Always zero. 383 * Always zero.
383 */ 384 */
384 unsigned int zero : 1 GNUNET_PACKED; 385 unsigned int zero : 1 GNUNET_PACKED;
385 386
386 /** 387 /**
387 * Set to 1 if recursion is available (server -> client) 388 * Set to 1 if recursion is available (server -> client)
388 */ 389 */
389 unsigned int recursion_available : 1 GNUNET_PACKED; 390 unsigned int recursion_available : 1 GNUNET_PACKED;
390#elif __BYTE_ORDER == __BIG_ENDIAN 391#elif __BYTE_ORDER == __BIG_ENDIAN
391 392
392 /** 393 /**
393 * query:0, response:1 394 * query:0, response:1
394 */ 395 */
395 unsigned int query_or_response : 1 GNUNET_PACKED; 396 unsigned int query_or_response : 1 GNUNET_PACKED;
396 397
397 /** 398 /**
398 * See GNUNET_TUN_DNS_OPCODE_ defines. 399 * See GNUNET_TUN_DNS_OPCODE_ defines.
399 */ 400 */
400 unsigned int opcode : 4 GNUNET_PACKED; 401 unsigned int opcode : 4 GNUNET_PACKED;
401 402
402 /** 403 /**
403 * Set to 1 if this is an authoritative answer 404 * Set to 1 if this is an authoritative answer
@@ -407,46 +408,45 @@ struct GNUNET_TUN_DnsFlags
407 /** 408 /**
408 * Set to 1 if message is truncated 409 * Set to 1 if message is truncated
409 */ 410 */
410 unsigned int message_truncated : 1 GNUNET_PACKED; 411 unsigned int message_truncated : 1 GNUNET_PACKED;
411 412
412 /** 413 /**
413 * Set to 1 if recursion is desired (client -> server) 414 * Set to 1 if recursion is desired (client -> server)
414 */ 415 */
415 unsigned int recursion_desired : 1 GNUNET_PACKED; 416 unsigned int recursion_desired : 1 GNUNET_PACKED;
416 417
417 418
418 /** 419 /**
419 * Set to 1 if recursion is available (server -> client) 420 * Set to 1 if recursion is available (server -> client)
420 */ 421 */
421 unsigned int recursion_available : 1 GNUNET_PACKED; 422 unsigned int recursion_available : 1 GNUNET_PACKED;
422 423
423 /** 424 /**
424 * Always zero. 425 * Always zero.
425 */ 426 */
426 unsigned int zero : 1 GNUNET_PACKED; 427 unsigned int zero : 1 GNUNET_PACKED;
427 428
428 /** 429 /**
429 * Response has been cryptographically verified, RFC 4035. 430 * Response has been cryptographically verified, RFC 4035.
430 */ 431 */
431 unsigned int authenticated_data : 1 GNUNET_PACKED; 432 unsigned int authenticated_data : 1 GNUNET_PACKED;
432 433
433 /** 434 /**
434 * See RFC 4035. 435 * See RFC 4035.
435 */ 436 */
436 unsigned int checking_disabled : 1 GNUNET_PACKED; 437 unsigned int checking_disabled : 1 GNUNET_PACKED;
437 438
438 /** 439 /**
439 * See GNUNET_TUN_DNS_RETURN_CODE_ defines. 440 * See GNUNET_TUN_DNS_RETURN_CODE_ defines.
440 */ 441 */
441 unsigned int return_code : 4 GNUNET_PACKED; 442 unsigned int return_code : 4 GNUNET_PACKED;
442#else 443#else
443 #error byteorder undefined 444#error byteorder undefined
444#endif 445#endif
445 446
446} GNUNET_GCC_STRUCT_LAYOUT; 447} GNUNET_GCC_STRUCT_LAYOUT;
447 448
448 449
449
450/** 450/**
451 * DNS header. 451 * DNS header.
452 */ 452 */
@@ -683,21 +683,21 @@ struct GNUNET_TUN_DnsRecordLine
683}; 683};
684 684
685 685
686#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0 686#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0
687#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3 687#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3
688#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4 688#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4
689#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5 689#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5
690#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8 690#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8
691#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9 691#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9
692#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10 692#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10
693#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11 693#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11
694 694
695#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1 695#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1
696#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2 696#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2
697#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3 697#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3
698#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4 698#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4
699#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128 699#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128
700#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129 700#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129
701 701
702 702
703/** 703/**
@@ -716,8 +716,8 @@ struct GNUNET_TUN_IcmpHeader
716 */ 716 */
717 struct 717 struct
718 { 718 {
719 uint16_t identifier GNUNET_PACKED; 719 uint16_t identifier GNUNET_PACKED;
720 uint16_t sequence_number GNUNET_PACKED; 720 uint16_t sequence_number GNUNET_PACKED;
721 } echo; 721 } echo;
722 722
723 /** 723 /**
@@ -727,13 +727,14 @@ struct GNUNET_TUN_IcmpHeader
727 { 727 {
728 uint16_t empty GNUNET_PACKED; 728 uint16_t empty GNUNET_PACKED;
729 uint16_t next_hop_mtu GNUNET_PACKED; 729 uint16_t next_hop_mtu GNUNET_PACKED;
730 /* followed by original IP header + first 8 bytes of original IP datagram */ 730 /* followed by original IP header + first 8 bytes of original IP datagram
731 */
731 } destination_unreachable; 732 } destination_unreachable;
732 733
733 /** 734 /**
734 * ICMP Redirect 735 * ICMP Redirect
735 */ 736 */
736 struct in_addr redirect_gateway_address GNUNET_PACKED; 737 struct in_addr redirect_gateway_address;
737 738
738 /** 739 /**
739 * MTU for packets that are too big (IPv6). 740 * MTU for packets that are too big (IPv6).
@@ -741,7 +742,6 @@ struct GNUNET_TUN_IcmpHeader
741 uint32_t packet_too_big_mtu GNUNET_PACKED; 742 uint32_t packet_too_big_mtu GNUNET_PACKED;
742 743
743 } quench; 744 } quench;
744
745}; 745};
746 746
747 747
@@ -753,16 +753,17 @@ GNUNET_NETWORK_STRUCT_END
753 * 753 *
754 * @param ip header to initialize 754 * @param ip header to initialize
755 * @param protocol protocol to use (i.e. IPPROTO_UDP) 755 * @param protocol protocol to use (i.e. IPPROTO_UDP)
756 * @param payload_length number of bytes of payload that follow (excluding IPv4 header) 756 * @param payload_length number of bytes of payload that follow (excluding IPv4
757 * header)
757 * @param src source IP address to use 758 * @param src source IP address to use
758 * @param dst destination IP address to use 759 * @param dst destination IP address to use
759 */ 760 */
760void 761void
761GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip, 762GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip,
762 uint8_t protocol, 763 uint8_t protocol,
763 uint16_t payload_length, 764 uint16_t payload_length,
764 const struct in_addr *src, 765 const struct in_addr *src,
765 const struct in_addr *dst); 766 const struct in_addr *dst);
766 767
767 768
768/** 769/**
@@ -770,16 +771,17 @@ GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip,
770 * 771 *
771 * @param ip header to initialize 772 * @param ip header to initialize
772 * @param protocol protocol to use (i.e. IPPROTO_UDP) 773 * @param protocol protocol to use (i.e. IPPROTO_UDP)
773 * @param payload_length number of bytes of payload that follow (excluding IPv4 header) 774 * @param payload_length number of bytes of payload that follow (excluding IPv4
775 * header)
774 * @param src source IP address to use 776 * @param src source IP address to use
775 * @param dst destination IP address to use 777 * @param dst destination IP address to use
776 */ 778 */
777void 779void
778GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip, 780GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip,
779 uint8_t protocol, 781 uint8_t protocol,
780 uint16_t payload_length, 782 uint16_t payload_length,
781 const struct in6_addr *src, 783 const struct in6_addr *src,
782 const struct in6_addr *dst); 784 const struct in6_addr *dst);
783 785
784/** 786/**
785 * Calculate IPv4 TCP checksum. 787 * Calculate IPv4 TCP checksum.
@@ -791,9 +793,9 @@ GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip,
791 */ 793 */
792void 794void
793GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, 795GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
794 struct GNUNET_TUN_TcpHeader *tcp, 796 struct GNUNET_TUN_TcpHeader *tcp,
795 const void *payload, 797 const void *payload,
796 uint16_t payload_length); 798 uint16_t payload_length);
797 799
798/** 800/**
799 * Calculate IPv6 TCP checksum. 801 * Calculate IPv6 TCP checksum.
@@ -805,9 +807,9 @@ GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
805 */ 807 */
806void 808void
807GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, 809GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
808 struct GNUNET_TUN_TcpHeader *tcp, 810 struct GNUNET_TUN_TcpHeader *tcp,
809 const void *payload, 811 const void *payload,
810 uint16_t payload_length); 812 uint16_t payload_length);
811 813
812/** 814/**
813 * Calculate IPv4 UDP checksum. 815 * Calculate IPv4 UDP checksum.
@@ -819,9 +821,9 @@ GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
819 */ 821 */
820void 822void
821GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, 823GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
822 struct GNUNET_TUN_UdpHeader *udp, 824 struct GNUNET_TUN_UdpHeader *udp,
823 const void *payload, 825 const void *payload,
824 uint16_t payload_length); 826 uint16_t payload_length);
825 827
826 828
827/** 829/**
@@ -834,9 +836,9 @@ GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
834 */ 836 */
835void 837void
836GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, 838GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
837 struct GNUNET_TUN_UdpHeader *udp, 839 struct GNUNET_TUN_UdpHeader *udp,
838 const void *payload, 840 const void *payload,
839 uint16_t payload_length); 841 uint16_t payload_length);
840 842
841 843
842/** 844/**
@@ -848,8 +850,8 @@ GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
848 */ 850 */
849void 851void
850GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp, 852GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp,
851 const void *payload, 853 const void *payload,
852 uint16_t payload_length); 854 uint16_t payload_length);
853 855
854 856
855/** 857/**
@@ -949,4 +951,4 @@ GNUNET_TUN_compute_service_cadet_port (const struct GNUNET_HashCode *desc,
949 951
950#endif 952#endif
951 953
952/** @} */ /* end of group */ 954/** @} */ /* end of group */