diff options
-rw-r--r-- | src/include/gnunet_common.h | 9 | ||||
-rw-r--r-- | src/include/gnunet_tun_lib.h | 12 | ||||
-rw-r--r-- | src/util/common_endian.c | 8 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 04847ee5b..d934c109e 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -66,6 +66,15 @@ | |||
66 | 66 | ||
67 | #define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b)) | 67 | #define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b)) |
68 | 68 | ||
69 | /* some systems use one underscore only... */ | ||
70 | #ifndef __BYTE_ORDER | ||
71 | #ifdef _BYTE_ORDER | ||
72 | #define __BYTE_ORDER _BYTE_ORDER | ||
73 | #define __LITTLE_ENDIAN _LITTLE_ENDIAN | ||
74 | #define __BIG_ENDIAN _BIG_ENDIAN | ||
75 | #endif | ||
76 | #endif | ||
77 | |||
69 | /** | 78 | /** |
70 | * Endian operations | 79 | * Endian operations |
71 | */ | 80 | */ |
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 33938354b..dac11d6a8 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h | |||
@@ -70,10 +70,10 @@ struct GNUNET_TUN_Layer2PacketHeader | |||
70 | */ | 70 | */ |
71 | struct GNUNET_TUN_IPv4Header | 71 | struct GNUNET_TUN_IPv4Header |
72 | { | 72 | { |
73 | #if __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN | 73 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
74 | unsigned int header_length:4 GNUNET_PACKED; | 74 | unsigned int header_length:4 GNUNET_PACKED; |
75 | unsigned int version:4 GNUNET_PACKED; | 75 | unsigned int version:4 GNUNET_PACKED; |
76 | #elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN | 76 | #elif __BYTE_ORDER == __BIG_ENDIAN |
77 | unsigned int version:4 GNUNET_PACKED; | 77 | unsigned int version:4 GNUNET_PACKED; |
78 | unsigned int header_length:4 GNUNET_PACKED; | 78 | unsigned int header_length:4 GNUNET_PACKED; |
79 | #else | 79 | #else |
@@ -127,12 +127,12 @@ struct GNUNET_TUN_IPv4Header | |||
127 | */ | 127 | */ |
128 | struct GNUNET_TUN_IPv6Header | 128 | struct GNUNET_TUN_IPv6Header |
129 | { | 129 | { |
130 | #if __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN | 130 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
131 | unsigned int traffic_class_h:4 GNUNET_PACKED; | 131 | unsigned int traffic_class_h:4 GNUNET_PACKED; |
132 | unsigned int version:4 GNUNET_PACKED; | 132 | unsigned int version:4 GNUNET_PACKED; |
133 | unsigned int traffic_class_l:4 GNUNET_PACKED; | 133 | unsigned int traffic_class_l:4 GNUNET_PACKED; |
134 | unsigned int flow_label:20 GNUNET_PACKED; | 134 | unsigned int flow_label:20 GNUNET_PACKED; |
135 | #elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN | 135 | #elif __BYTE_ORDER == __BIG_ENDIAN |
136 | unsigned int version:4 GNUNET_PACKED; | 136 | unsigned int version:4 GNUNET_PACKED; |
137 | unsigned int traffic_class:8 GNUNET_PACKED; | 137 | unsigned int traffic_class:8 GNUNET_PACKED; |
138 | unsigned int flow_label:20 GNUNET_PACKED; | 138 | unsigned int flow_label:20 GNUNET_PACKED; |
@@ -183,7 +183,7 @@ struct GNUNET_TUN_TcpHeader | |||
183 | * Acknowledgement number. | 183 | * Acknowledgement number. |
184 | */ | 184 | */ |
185 | uint32_t ack GNUNET_PACKED; | 185 | uint32_t ack GNUNET_PACKED; |
186 | #if __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN | 186 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
187 | /** | 187 | /** |
188 | * Reserved. Must be zero. | 188 | * Reserved. Must be zero. |
189 | */ | 189 | */ |
@@ -192,7 +192,7 @@ struct GNUNET_TUN_TcpHeader | |||
192 | * Number of 32-bit words in TCP header. | 192 | * Number of 32-bit words in TCP header. |
193 | */ | 193 | */ |
194 | unsigned int off : 4 GNUNET_PACKED; | 194 | unsigned int off : 4 GNUNET_PACKED; |
195 | #elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN | 195 | #elif __BYTE_ORDER == __BIG_ENDIAN |
196 | /** | 196 | /** |
197 | * Number of 32-bit words in TCP header. | 197 | * Number of 32-bit words in TCP header. |
198 | */ | 198 | */ |
diff --git a/src/util/common_endian.c b/src/util/common_endian.c index 1867ba01d..117e575e4 100644 --- a/src/util/common_endian.c +++ b/src/util/common_endian.c | |||
@@ -32,9 +32,9 @@ | |||
32 | uint64_t | 32 | uint64_t |
33 | GNUNET_ntohll (uint64_t n) | 33 | GNUNET_ntohll (uint64_t n) |
34 | { | 34 | { |
35 | #if __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN | 35 | #if __BYTE_ORDER == __BIG_ENDIAN |
36 | return n; | 36 | return n; |
37 | #elif __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN | 37 | #elif __BYTE_ORDER == __LITTLE_ENDIAN |
38 | return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32); | 38 | return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32); |
39 | #else | 39 | #else |
40 | #error byteorder undefined | 40 | #error byteorder undefined |
@@ -44,9 +44,9 @@ GNUNET_ntohll (uint64_t n) | |||
44 | uint64_t | 44 | uint64_t |
45 | GNUNET_htonll (uint64_t n) | 45 | GNUNET_htonll (uint64_t n) |
46 | { | 46 | { |
47 | #if __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN | 47 | #if __BYTE_ORDER == __BIG_ENDIAN |
48 | return n; | 48 | return n; |
49 | #elif __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN | 49 | #elif __BYTE_ORDER == __LITTLE_ENDIAN |
50 | return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32); | 50 | return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32); |
51 | #else | 51 | #else |
52 | #error byteorder undefined | 52 | #error byteorder undefined |