diff options
Diffstat (limited to 'include/linux/dccp.h')
-rw-r--r-- | include/linux/dccp.h | 132 |
1 files changed, 82 insertions, 50 deletions
diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 088529f54965..676333b9fad0 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 | */ |
20 | struct dccp_hdr { | 20 | struct 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 | */ |
54 | struct dccp_hdr_ext { | 54 | struct 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 | */ |
64 | struct dccp_hdr_request { | 64 | struct 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 | */ |
73 | struct dccp_hdr_ack_bits { | 73 | struct 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 | */ |
86 | struct dccp_hdr_response { | 86 | struct 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 | /** |
@@ -154,6 +154,10 @@ enum { | |||
154 | DCCPO_MANDATORY = 1, | 154 | DCCPO_MANDATORY = 1, |
155 | DCCPO_MIN_RESERVED = 3, | 155 | DCCPO_MIN_RESERVED = 3, |
156 | DCCPO_MAX_RESERVED = 31, | 156 | DCCPO_MAX_RESERVED = 31, |
157 | DCCPO_CHANGE_L = 32, | ||
158 | DCCPO_CONFIRM_L = 33, | ||
159 | DCCPO_CHANGE_R = 34, | ||
160 | DCCPO_CONFIRM_R = 35, | ||
157 | DCCPO_NDP_COUNT = 37, | 161 | DCCPO_NDP_COUNT = 37, |
158 | DCCPO_ACK_VECTOR_0 = 38, | 162 | DCCPO_ACK_VECTOR_0 = 38, |
159 | DCCPO_ACK_VECTOR_1 = 39, | 163 | DCCPO_ACK_VECTOR_1 = 39, |
@@ -168,7 +172,9 @@ enum { | |||
168 | /* DCCP features */ | 172 | /* DCCP features */ |
169 | enum { | 173 | enum { |
170 | DCCPF_RESERVED = 0, | 174 | DCCPF_RESERVED = 0, |
175 | DCCPF_CCID = 1, | ||
171 | DCCPF_SEQUENCE_WINDOW = 3, | 176 | DCCPF_SEQUENCE_WINDOW = 3, |
177 | DCCPF_ACK_RATIO = 5, | ||
172 | DCCPF_SEND_ACK_VECTOR = 6, | 178 | DCCPF_SEND_ACK_VECTOR = 6, |
173 | DCCPF_SEND_NDP_COUNT = 7, | 179 | DCCPF_SEND_NDP_COUNT = 7, |
174 | /* 10-127 reserved */ | 180 | /* 10-127 reserved */ |
@@ -176,9 +182,18 @@ enum { | |||
176 | DCCPF_MAX_CCID_SPECIFIC = 255, | 182 | DCCPF_MAX_CCID_SPECIFIC = 255, |
177 | }; | 183 | }; |
178 | 184 | ||
185 | /* this structure is argument to DCCP_SOCKOPT_CHANGE_X */ | ||
186 | struct dccp_so_feat { | ||
187 | __u8 dccpsf_feat; | ||
188 | __u8 *dccpsf_val; | ||
189 | __u8 dccpsf_len; | ||
190 | }; | ||
191 | |||
179 | /* DCCP socket options */ | 192 | /* DCCP socket options */ |
180 | #define DCCP_SOCKOPT_PACKET_SIZE 1 | 193 | #define DCCP_SOCKOPT_PACKET_SIZE 1 |
181 | #define DCCP_SOCKOPT_SERVICE 2 | 194 | #define DCCP_SOCKOPT_SERVICE 2 |
195 | #define DCCP_SOCKOPT_CHANGE_L 3 | ||
196 | #define DCCP_SOCKOPT_CHANGE_R 4 | ||
182 | #define DCCP_SOCKOPT_CCID_RX_INFO 128 | 197 | #define DCCP_SOCKOPT_CCID_RX_INFO 128 |
183 | #define DCCP_SOCKOPT_CCID_TX_INFO 192 | 198 | #define DCCP_SOCKOPT_CCID_TX_INFO 192 |
184 | 199 | ||
@@ -254,16 +269,12 @@ static inline unsigned int dccp_basic_hdr_len(const struct sk_buff *skb) | |||
254 | static inline __u64 dccp_hdr_seq(const struct sk_buff *skb) | 269 | static inline __u64 dccp_hdr_seq(const struct sk_buff *skb) |
255 | { | 270 | { |
256 | const struct dccp_hdr *dh = dccp_hdr(skb); | 271 | const struct dccp_hdr *dh = dccp_hdr(skb); |
257 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 272 | __u64 seq_nr = ntohs(dh->dccph_seq); |
258 | __u64 seq_nr = ntohl(dh->dccph_seq << 8); | ||
259 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
260 | __u64 seq_nr = ntohl(dh->dccph_seq); | ||
261 | #else | ||
262 | #error "Adjust your <asm/byteorder.h> defines" | ||
263 | #endif | ||
264 | 273 | ||
265 | if (dh->dccph_x != 0) | 274 | if (dh->dccph_x != 0) |
266 | 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; | ||
267 | 278 | ||
268 | return seq_nr; | 279 | return seq_nr; |
269 | } | 280 | } |
@@ -281,13 +292,7 @@ static inline struct dccp_hdr_ack_bits *dccp_hdr_ack_bits(const struct sk_buff * | |||
281 | static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb) | 292 | static inline u64 dccp_hdr_ack_seq(const struct sk_buff *skb) |
282 | { | 293 | { |
283 | 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); |
284 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 295 | return ((u64)ntohs(dhack->dccph_ack_nr_high) << 32) + ntohl(dhack->dccph_ack_nr_low); |
285 | return (((u64)ntohl(dhack->dccph_ack_nr_high << 8)) << 32) + ntohl(dhack->dccph_ack_nr_low); | ||
286 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
287 | return (((u64)ntohl(dhack->dccph_ack_nr_high)) << 32) + ntohl(dhack->dccph_ack_nr_low); | ||
288 | #else | ||
289 | #error "Adjust your <asm/byteorder.h> defines" | ||
290 | #endif | ||
291 | } | 296 | } |
292 | 297 | ||
293 | static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb) | 298 | static inline struct dccp_hdr_response *dccp_hdr_response(struct sk_buff *skb) |
@@ -314,38 +319,60 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb) | |||
314 | 319 | ||
315 | /* initial values for each feature */ | 320 | /* initial values for each feature */ |
316 | #define DCCPF_INITIAL_SEQUENCE_WINDOW 100 | 321 | #define DCCPF_INITIAL_SEQUENCE_WINDOW 100 |
317 | /* FIXME: for now we're using CCID 3 (TFRC) */ | 322 | #define DCCPF_INITIAL_ACK_RATIO 2 |
318 | #define DCCPF_INITIAL_CCID 3 | 323 | #define DCCPF_INITIAL_CCID 2 |
319 | #define DCCPF_INITIAL_SEND_ACK_VECTOR 0 | 324 | #define DCCPF_INITIAL_SEND_ACK_VECTOR 1 |
320 | /* FIXME: for now we're default to 1 but it should really be 0 */ | 325 | /* FIXME: for now we're default to 1 but it should really be 0 */ |
321 | #define DCCPF_INITIAL_SEND_NDP_COUNT 1 | 326 | #define DCCPF_INITIAL_SEND_NDP_COUNT 1 |
322 | 327 | ||
323 | #define DCCP_NDP_LIMIT 0xFFFFFF | 328 | #define DCCP_NDP_LIMIT 0xFFFFFF |
324 | 329 | ||
325 | /** | 330 | /** |
326 | * struct dccp_options - option values for a DCCP connection | 331 | * struct dccp_minisock - Minimal DCCP connection representation |
327 | * @dccpo_sequence_window - Sequence Window Feature (section 7.5.2) | 332 | * |
328 | * @dccpo_ccid - Congestion Control Id (CCID) (section 10) | 333 | * Will be used to pass the state from dccp_request_sock to dccp_sock. |
329 | * @dccpo_send_ack_vector - Send Ack Vector Feature (section 11.5) | 334 | * |
330 | * @dccpo_send_ndp_count - Send NDP Count Feature (7.7.2) | 335 | * @dccpms_sequence_window - Sequence Window Feature (section 7.5.2) |
336 | * @dccpms_ccid - Congestion Control Id (CCID) (section 10) | ||
337 | * @dccpms_send_ack_vector - Send Ack Vector Feature (section 11.5) | ||
338 | * @dccpms_send_ndp_count - Send NDP Count Feature (7.7.2) | ||
331 | */ | 339 | */ |
332 | struct dccp_options { | 340 | struct dccp_minisock { |
333 | __u64 dccpo_sequence_window; | 341 | __u64 dccpms_sequence_window; |
334 | __u8 dccpo_rx_ccid; | 342 | __u8 dccpms_rx_ccid; |
335 | __u8 dccpo_tx_ccid; | 343 | __u8 dccpms_tx_ccid; |
336 | __u8 dccpo_send_ack_vector; | 344 | __u8 dccpms_send_ack_vector; |
337 | __u8 dccpo_send_ndp_count; | 345 | __u8 dccpms_send_ndp_count; |
346 | __u8 dccpms_ack_ratio; | ||
347 | struct list_head dccpms_pending; | ||
348 | struct list_head dccpms_conf; | ||
349 | }; | ||
350 | |||
351 | struct dccp_opt_conf { | ||
352 | __u8 *dccpoc_val; | ||
353 | __u8 dccpoc_len; | ||
354 | }; | ||
355 | |||
356 | struct dccp_opt_pend { | ||
357 | struct list_head dccpop_node; | ||
358 | __u8 dccpop_type; | ||
359 | __u8 dccpop_feat; | ||
360 | __u8 *dccpop_val; | ||
361 | __u8 dccpop_len; | ||
362 | int dccpop_conf; | ||
363 | struct dccp_opt_conf *dccpop_sc; | ||
338 | }; | 364 | }; |
339 | 365 | ||
340 | extern void __dccp_options_init(struct dccp_options *dccpo); | 366 | extern void __dccp_minisock_init(struct dccp_minisock *dmsk); |
341 | extern void dccp_options_init(struct dccp_options *dccpo); | 367 | extern void dccp_minisock_init(struct dccp_minisock *dmsk); |
368 | |||
342 | extern int dccp_parse_options(struct sock *sk, struct sk_buff *skb); | 369 | extern int dccp_parse_options(struct sock *sk, struct sk_buff *skb); |
343 | 370 | ||
344 | struct dccp_request_sock { | 371 | struct dccp_request_sock { |
345 | struct inet_request_sock dreq_inet_rsk; | 372 | struct inet_request_sock dreq_inet_rsk; |
346 | __u64 dreq_iss; | 373 | __u64 dreq_iss; |
347 | __u64 dreq_isr; | 374 | __u64 dreq_isr; |
348 | __u32 dreq_service; | 375 | __be32 dreq_service; |
349 | }; | 376 | }; |
350 | 377 | ||
351 | static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req) | 378 | static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req) |
@@ -373,13 +400,13 @@ enum dccp_role { | |||
373 | 400 | ||
374 | struct dccp_service_list { | 401 | struct dccp_service_list { |
375 | __u32 dccpsl_nr; | 402 | __u32 dccpsl_nr; |
376 | __u32 dccpsl_list[0]; | 403 | __be32 dccpsl_list[0]; |
377 | }; | 404 | }; |
378 | 405 | ||
379 | #define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1) | 406 | #define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1) |
380 | 407 | ||
381 | static inline int dccp_list_has_service(const struct dccp_service_list *sl, | 408 | static inline int dccp_list_has_service(const struct dccp_service_list *sl, |
382 | const u32 service) | 409 | const __be32 service) |
383 | { | 410 | { |
384 | if (likely(sl != NULL)) { | 411 | if (likely(sl != NULL)) { |
385 | u32 i = sl->dccpsl_nr; | 412 | u32 i = sl->dccpsl_nr; |
@@ -425,17 +452,17 @@ struct dccp_sock { | |||
425 | __u64 dccps_gss; | 452 | __u64 dccps_gss; |
426 | __u64 dccps_gsr; | 453 | __u64 dccps_gsr; |
427 | __u64 dccps_gar; | 454 | __u64 dccps_gar; |
428 | __u32 dccps_service; | 455 | __be32 dccps_service; |
429 | struct dccp_service_list *dccps_service_list; | 456 | struct dccp_service_list *dccps_service_list; |
430 | struct timeval dccps_timestamp_time; | 457 | struct timeval dccps_timestamp_time; |
431 | __u32 dccps_timestamp_echo; | 458 | __u32 dccps_timestamp_echo; |
432 | __u32 dccps_packet_size; | 459 | __u32 dccps_packet_size; |
460 | __u16 dccps_l_ack_ratio; | ||
461 | __u16 dccps_r_ack_ratio; | ||
433 | unsigned long dccps_ndp_count; | 462 | unsigned long dccps_ndp_count; |
434 | __u32 dccps_mss_cache; | 463 | __u32 dccps_mss_cache; |
435 | struct dccp_options dccps_options; | 464 | struct dccp_minisock dccps_minisock; |
436 | struct dccp_ackvec *dccps_hc_rx_ackvec; | 465 | struct dccp_ackvec *dccps_hc_rx_ackvec; |
437 | void *dccps_hc_rx_ccid_private; | ||
438 | void *dccps_hc_tx_ccid_private; | ||
439 | struct ccid *dccps_hc_rx_ccid; | 466 | struct ccid *dccps_hc_rx_ccid; |
440 | struct ccid *dccps_hc_tx_ccid; | 467 | struct ccid *dccps_hc_tx_ccid; |
441 | struct dccp_options_received dccps_options_received; | 468 | struct dccp_options_received dccps_options_received; |
@@ -450,6 +477,11 @@ static inline struct dccp_sock *dccp_sk(const struct sock *sk) | |||
450 | return (struct dccp_sock *)sk; | 477 | return (struct dccp_sock *)sk; |
451 | } | 478 | } |
452 | 479 | ||
480 | static inline struct dccp_minisock *dccp_msk(const struct sock *sk) | ||
481 | { | ||
482 | return (struct dccp_minisock *)&dccp_sk(sk)->dccps_minisock; | ||
483 | } | ||
484 | |||
453 | static inline int dccp_service_not_initialized(const struct sock *sk) | 485 | static inline int dccp_service_not_initialized(const struct sock *sk) |
454 | { | 486 | { |
455 | return dccp_sk(sk)->dccps_service == DCCP_SERVICE_INVALID_VALUE; | 487 | return dccp_sk(sk)->dccps_service == DCCP_SERVICE_INVALID_VALUE; |