aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrea Bittau <a.bittau@cs.ucl.ac.uk>2006-03-20 22:23:32 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-20 22:23:32 -0500
commit60fe62e789076ae7c13f7ffb35fec4b24802530d (patch)
treecc8d507a4276c3d5a2bcb72746660d485bc2e045 /include
parenta193a4abdd1f742a57f3f70b6a83c3e536876e97 (diff)
[DCCP]: sparse endianness annotations
This also fixes the layout of dccp_hdr short sequence numbers, problem was not fatal now as we only support long (48 bits) sequence numbers. Signed-off-by: Andrea Bittau <a.bittau@cs.ucl.ac.uk> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/dccp.h52
1 files changed, 21 insertions, 31 deletions
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index bdd756cc60b1..496dbad8e896 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -18,7 +18,7 @@
18 * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x 18 * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
19 */ 19 */
20struct dccp_hdr { 20struct dccp_hdr {
21 __u16 dccph_sport, 21 __be16 dccph_sport,
22 dccph_dport; 22 dccph_dport;
23 __u8 dccph_doff; 23 __u8 dccph_doff;
24#if defined(__LITTLE_ENDIAN_BITFIELD) 24#if defined(__LITTLE_ENDIAN_BITFIELD)
@@ -32,18 +32,18 @@ struct dccp_hdr {
32#endif 32#endif
33 __u16 dccph_checksum; 33 __u16 dccph_checksum;
34#if defined(__LITTLE_ENDIAN_BITFIELD) 34#if defined(__LITTLE_ENDIAN_BITFIELD)
35 __u32 dccph_x:1, 35 __u8 dccph_x:1,
36 dccph_type:4, 36 dccph_type:4,
37 dccph_reserved:3, 37 dccph_reserved:3;
38 dccph_seq:24;
39#elif defined(__BIG_ENDIAN_BITFIELD) 38#elif defined(__BIG_ENDIAN_BITFIELD)
40 __u32 dccph_reserved:3, 39 __u8 dccph_reserved:3,
41 dccph_type:4, 40 dccph_type:4,
42 dccph_x:1, 41 dccph_x:1;
43 dccph_seq:24;
44#else 42#else
45#error "Adjust your <asm/byteorder.h> defines" 43#error "Adjust your <asm/byteorder.h> defines"
46#endif 44#endif
45 __u8 dccph_seq2;
46 __be16 dccph_seq;
47}; 47};
48 48
49/** 49/**
@@ -52,7 +52,7 @@ struct dccp_hdr {
52 * @dccph_seq_low - low 24 bits of a 48 bit seq packet 52 * @dccph_seq_low - low 24 bits of a 48 bit seq packet
53 */ 53 */
54struct dccp_hdr_ext { 54struct dccp_hdr_ext {
55 __u32 dccph_seq_low; 55 __be32 dccph_seq_low;
56}; 56};
57 57
58/** 58/**
@@ -62,7 +62,7 @@ struct dccp_hdr_ext {
62 * @dccph_req_options - list of options (must be a multiple of 32 bits 62 * @dccph_req_options - list of options (must be a multiple of 32 bits
63 */ 63 */
64struct dccp_hdr_request { 64struct dccp_hdr_request {
65 __u32 dccph_req_service; 65 __be32 dccph_req_service;
66}; 66};
67/** 67/**
68 * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets 68 * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
@@ -71,9 +71,9 @@ struct dccp_hdr_request {
71 * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR 71 * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
72 */ 72 */
73struct dccp_hdr_ack_bits { 73struct dccp_hdr_ack_bits {
74 __u32 dccph_reserved1:8, 74 __be16 dccph_reserved1;
75 dccph_ack_nr_high:24; 75 __be16 dccph_ack_nr_high;
76 __u32 dccph_ack_nr_low; 76 __be32 dccph_ack_nr_low;
77}; 77};
78/** 78/**
79 * struct dccp_hdr_response - Conection initiation response header 79 * struct dccp_hdr_response - Conection initiation response header
@@ -85,7 +85,7 @@ struct dccp_hdr_ack_bits {
85 */ 85 */
86struct dccp_hdr_response { 86struct dccp_hdr_response {
87 struct dccp_hdr_ack_bits dccph_resp_ack; 87 struct dccp_hdr_ack_bits dccph_resp_ack;
88 __u32 dccph_resp_service; 88 __be32 dccph_resp_service;
89}; 89};
90 90
91/** 91/**
@@ -269,16 +269,12 @@ static inline unsigned int dccp_basic_hdr_len(const struct sk_buff *skb)
269static inline __u64 dccp_hdr_seq(const struct sk_buff *skb) 269static inline __u64 dccp_hdr_seq(const struct sk_buff *skb)
270{ 270{
271 const struct dccp_hdr *dh = dccp_hdr(skb); 271 const struct dccp_hdr *dh = dccp_hdr(skb);
272#if defined(__LITTLE_ENDIAN_BITFIELD) 272 __u64 seq_nr = ntohs(dh->dccph_seq);
273 __u64 seq_nr = ntohl(dh->dccph_seq << 8);
274#elif defined(__BIG_ENDIAN_BITFIELD)
275 __u64 seq_nr = ntohl(dh->dccph_seq);
276#else
277#error "Adjust your <asm/byteorder.h> defines"
278#endif
279 273
280 if (dh->dccph_x != 0) 274 if (dh->dccph_x != 0)
281 seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low); 275 seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low);
276 else
277 seq_nr += (u32)dh->dccph_seq2 << 16;
282 278
283 return seq_nr; 279 return seq_nr;
284} 280}
@@ -296,13 +292,7 @@ static inline struct dccp_hdr_ack_bits *dccp_hdr_ack_bits(const struct sk_buff *
296static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb) 292static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb)
297{ 293{
298 const struct dccp_hdr_ack_bits *dhack = dccp_hdr_ack_bits(skb); 294 const struct dccp_hdr_ack_bits *dhack = dccp_hdr_ack_bits(skb);
299#if defined(__LITTLE_ENDIAN_BITFIELD) 295 return ((u64)ntohs(dhack->dccph_ack_nr_high) << 32) + ntohl(dhack->dccph_ack_nr_low);
300 return (((u64)ntohl(dhack->dccph_ack_nr_high << 8)) << 32) + ntohl(dhack->dccph_ack_nr_low);
301#elif defined(__BIG_ENDIAN_BITFIELD)
302 return (((u64)ntohl(dhack->dccph_ack_nr_high)) << 32) + ntohl(dhack->dccph_ack_nr_low);
303#else
304#error "Adjust your <asm/byteorder.h> defines"
305#endif
306} 296}
307 297
308static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb) 298static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb)
@@ -387,7 +377,7 @@ struct dccp_request_sock {
387 struct inet_request_sock dreq_inet_rsk; 377 struct inet_request_sock dreq_inet_rsk;
388 __u64 dreq_iss; 378 __u64 dreq_iss;
389 __u64 dreq_isr; 379 __u64 dreq_isr;
390 __u32 dreq_service; 380 __be32 dreq_service;
391}; 381};
392 382
393static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req) 383static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
@@ -415,13 +405,13 @@ enum dccp_role {
415 405
416struct dccp_service_list { 406struct dccp_service_list {
417 __u32 dccpsl_nr; 407 __u32 dccpsl_nr;
418 __u32 dccpsl_list[0]; 408 __be32 dccpsl_list[0];
419}; 409};
420 410
421#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1) 411#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
422 412
423static inline int dccp_list_has_service(const struct dccp_service_list *sl, 413static inline int dccp_list_has_service(const struct dccp_service_list *sl,
424 const u32 service) 414 const __be32 service)
425{ 415{
426 if (likely(sl != NULL)) { 416 if (likely(sl != NULL)) {
427 u32 i = sl->dccpsl_nr; 417 u32 i = sl->dccpsl_nr;
@@ -467,7 +457,7 @@ struct dccp_sock {
467 __u64 dccps_gss; 457 __u64 dccps_gss;
468 __u64 dccps_gsr; 458 __u64 dccps_gsr;
469 __u64 dccps_gar; 459 __u64 dccps_gar;
470 __u32 dccps_service; 460 __be32 dccps_service;
471 struct dccp_service_list *dccps_service_list; 461 struct dccp_service_list *dccps_service_list;
472 struct timeval dccps_timestamp_time; 462 struct timeval dccps_timestamp_time;
473 __u32 dccps_timestamp_echo; 463 __u32 dccps_timestamp_echo;