aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/options.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2005-08-13 19:34:54 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:59:26 -0400
commit7690af3fff7633e40b1b9950eb8489129251d074 (patch)
tree92fa07234a7547c4a7dd74877972b5a291673fcf /net/dccp/options.c
parentc173437669967301facff151bfeb7bae67354e4c (diff)
[DCCP]: Just reflow the source code to fit in 80 columns
Andrew Morton should be happy now 8) Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/options.c')
-rw-r--r--net/dccp/options.c215
1 files changed, 131 insertions, 84 deletions
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 5bf997683a16..68d6614edcf1 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -59,14 +59,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
59{ 59{
60 struct dccp_sock *dp = dccp_sk(sk); 60 struct dccp_sock *dp = dccp_sk(sk);
61#ifdef DCCP_DEBUG 61#ifdef DCCP_DEBUG
62 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx opt: " : 62 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
63 "server rx opt: "; 63 "CLIENT rx opt: " : "server rx opt: ";
64#endif 64#endif
65 const struct dccp_hdr *dh = dccp_hdr(skb); 65 const struct dccp_hdr *dh = dccp_hdr(skb);
66 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type; 66 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
67 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb); 67 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
68 unsigned char *opt_ptr = options; 68 unsigned char *opt_ptr = options;
69 const unsigned char *opt_end = (unsigned char *)dh + (dh->dccph_doff * 4); 69 const unsigned char *opt_end = (unsigned char *)dh +
70 (dh->dccph_doff * 4);
70 struct dccp_options_received *opt_recv = &dp->dccps_options_received; 71 struct dccp_options_received *opt_recv = &dp->dccps_options_received;
71 unsigned char opt, len; 72 unsigned char opt, len;
72 unsigned char *value; 73 unsigned char *value;
@@ -106,7 +107,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
106 goto out_invalid_option; 107 goto out_invalid_option;
107 108
108 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len); 109 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
109 dccp_pr_debug("%sNDP count=%d\n", debug_prefix, opt_recv->dccpor_ndp); 110 dccp_pr_debug("%sNDP count=%d\n", debug_prefix,
111 opt_recv->dccpor_ndp);
110 break; 112 break;
111 case DCCPO_ACK_VECTOR_0: 113 case DCCPO_ACK_VECTOR_0:
112 if (len > DCCP_MAX_ACK_VECTOR_LEN) 114 if (len > DCCP_MAX_ACK_VECTOR_LEN)
@@ -124,8 +126,9 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
124 DCCP_SKB_CB(skb)->dccpd_ack_seq); 126 DCCP_SKB_CB(skb)->dccpd_ack_seq);
125 dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, 127 dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq,
126 value, len); 128 value, len);
127 dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts, sk, 129 dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts,
128 DCCP_SKB_CB(skb)->dccpd_ack_seq, 130 sk,
131 DCCP_SKB_CB(skb)->dccpd_ack_seq,
129 len, value); 132 len, value);
130 break; 133 break;
131 case DCCPO_TIMESTAMP: 134 case DCCPO_TIMESTAMP:
@@ -148,15 +151,21 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
148 151
149 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value); 152 opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value);
150 153
151 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, diff=%u\n", 154 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, "
152 debug_prefix, opt_recv->dccpor_timestamp_echo, 155 "diff=%u\n",
156 debug_prefix,
157 opt_recv->dccpor_timestamp_echo,
153 len + 2, 158 len + 2,
154 (unsigned long long) 159 (unsigned long long)
155 DCCP_SKB_CB(skb)->dccpd_ack_seq, 160 DCCP_SKB_CB(skb)->dccpd_ack_seq,
156 tcp_time_stamp - opt_recv->dccpor_timestamp_echo); 161 (tcp_time_stamp -
157 162 opt_recv->dccpor_timestamp_echo));
158 opt_recv->dccpor_elapsed_time = dccp_decode_value_var(value + 4, len - 4); 163
159 dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", debug_prefix, 164 opt_recv->dccpor_elapsed_time =
165 dccp_decode_value_var(value + 4,
166 len - 4);
167 dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n",
168 debug_prefix,
160 opt_recv->dccpor_elapsed_time); 169 opt_recv->dccpor_elapsed_time);
161 break; 170 break;
162 case DCCPO_ELAPSED_TIME: 171 case DCCPO_ELAPSED_TIME:
@@ -165,33 +174,41 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
165 174
166 if (pkt_type == DCCP_PKT_DATA) 175 if (pkt_type == DCCP_PKT_DATA)
167 continue; 176 continue;
168 opt_recv->dccpor_elapsed_time = dccp_decode_value_var(value, len); 177 opt_recv->dccpor_elapsed_time =
178 dccp_decode_value_var(value, len);
169 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, 179 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix,
170 opt_recv->dccpor_elapsed_time); 180 opt_recv->dccpor_elapsed_time);
171 break; 181 break;
172 /* 182 /*
173 * From draft-ietf-dccp-spec-11.txt: 183 * From draft-ietf-dccp-spec-11.txt:
174 * 184 *
175 * Option numbers 128 through 191 are for options sent from the HC- 185 * Option numbers 128 through 191 are for
176 * Sender to the HC-Receiver; option numbers 192 through 255 are for 186 * options sent from the HC-Sender to the
177 * options sent from the HC-Receiver to the HC-Sender. 187 * HC-Receiver; option numbers 192 through 255
188 * are for options sent from the HC-Receiver to
189 * the HC-Sender.
178 */ 190 */
179 case 128 ... 191: { 191 case 128 ... 191: {
180 const u16 idx = value - options; 192 const u16 idx = value - options;
181 193
182 if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk, opt, len, idx, value) != 0) 194 if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
195 opt, len, idx,
196 value) != 0)
183 goto out_invalid_option; 197 goto out_invalid_option;
184 } 198 }
185 break; 199 break;
186 case 192 ... 255: { 200 case 192 ... 255: {
187 const u16 idx = value - options; 201 const u16 idx = value - options;
188 202
189 if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk, opt, len, idx, value) != 0) 203 if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
204 opt, len, idx,
205 value) != 0)
190 goto out_invalid_option; 206 goto out_invalid_option;
191 } 207 }
192 break; 208 break;
193 default: 209 default:
194 pr_info("DCCP(%p): option %d(len=%d) not implemented, ignoring\n", 210 pr_info("DCCP(%p): option %d(len=%d) not "
211 "implemented, ignoring\n",
195 sk, opt, len); 212 sk, opt, len);
196 break; 213 break;
197 } 214 }
@@ -231,7 +248,8 @@ void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
231 unsigned char *to; 248 unsigned char *to;
232 249
233 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) { 250 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) {
234 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert %d option!\n", option); 251 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
252 "%d option!\n", option);
235 return; 253 return;
236 } 254 }
237 255
@@ -287,8 +305,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
287{ 305{
288#ifdef DCCP_DEBUG 306#ifdef DCCP_DEBUG
289 struct dccp_sock *dp = dccp_sk(sk); 307 struct dccp_sock *dp = dccp_sk(sk);
290 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : 308 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
291 "server TX opt: "; 309 "CLIENT TX opt: " : "server TX opt: ";
292#endif 310#endif
293 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); 311 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
294 const int len = 2 + elapsed_time_len; 312 const int len = 2 + elapsed_time_len;
@@ -299,7 +317,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
299 return; 317 return;
300 318
301 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 319 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
302 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert elapsed time!\n"); 320 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
321 "insert elapsed time!\n");
303 return; 322 return;
304 } 323 }
305 324
@@ -323,8 +342,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
323{ 342{
324 struct dccp_sock *dp = dccp_sk(sk); 343 struct dccp_sock *dp = dccp_sk(sk);
325#ifdef DCCP_DEBUG 344#ifdef DCCP_DEBUG
326 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : 345 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
327 "server TX opt: "; 346 "CLIENT TX opt: " : "server TX opt: ";
328#endif 347#endif
329 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; 348 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
330 int len = ap->dccpap_buf_vector_len + 2; 349 int len = ap->dccpap_buf_vector_len + 2;
@@ -335,7 +354,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
335 dccp_insert_option_elapsed_time(sk, skb, elapsed_time); 354 dccp_insert_option_elapsed_time(sk, skb, elapsed_time);
336 355
337 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 356 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
338 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert ACK Vector!\n"); 357 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
358 "insert ACK Vector!\n");
339 return; 359 return;
340 } 360 }
341 361
@@ -360,7 +380,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
360 380
361 /* Check if buf_head wraps */ 381 /* Check if buf_head wraps */
362 if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) { 382 if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) {
363 const unsigned int tailsize = ap->dccpap_buf_len - ap->dccpap_buf_head; 383 const unsigned int tailsize = (ap->dccpap_buf_len -
384 ap->dccpap_buf_head);
364 385
365 memcpy(to, from, tailsize); 386 memcpy(to, from, tailsize);
366 to += tailsize; 387 to += tailsize;
@@ -375,8 +396,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
375 * For each acknowledgement it sends, the HC-Receiver will add an 396 * For each acknowledgement it sends, the HC-Receiver will add an
376 * acknowledgement record. ack_seqno will equal the HC-Receiver 397 * acknowledgement record. ack_seqno will equal the HC-Receiver
377 * sequence number it used for the ack packet; ack_ptr will equal 398 * sequence number it used for the ack packet; ack_ptr will equal
378 * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will equal 399 * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will
379 * buf_nonce. 400 * equal buf_nonce.
380 * 401 *
381 * This implemention uses just one ack record for now. 402 * This implemention uses just one ack record for now.
382 */ 403 */
@@ -386,33 +407,38 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
386 ap->dccpap_ack_nonce = ap->dccpap_buf_nonce; 407 ap->dccpap_ack_nonce = ap->dccpap_buf_nonce;
387 ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len; 408 ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len;
388 409
389 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, ack_ackno=%llu\n", 410 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, "
411 "ack_ackno=%llu\n",
390 debug_prefix, ap->dccpap_ack_vector_len, 412 debug_prefix, ap->dccpap_ack_vector_len,
391 (unsigned long long) ap->dccpap_ack_seqno, 413 (unsigned long long) ap->dccpap_ack_seqno,
392 (unsigned long long) ap->dccpap_ack_ackno); 414 (unsigned long long) ap->dccpap_ack_ackno);
393} 415}
394 416
395static inline void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) 417static inline void dccp_insert_option_timestamp(struct sock *sk,
418 struct sk_buff *skb)
396{ 419{
397 const u32 now = htonl(tcp_time_stamp); 420 const u32 now = htonl(tcp_time_stamp);
398 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now)); 421 dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
399} 422}
400 423
401static void dccp_insert_option_timestamp_echo(struct sock *sk, struct sk_buff *skb) 424static void dccp_insert_option_timestamp_echo(struct sock *sk,
425 struct sk_buff *skb)
402{ 426{
403 struct dccp_sock *dp = dccp_sk(sk); 427 struct dccp_sock *dp = dccp_sk(sk);
404#ifdef DCCP_DEBUG 428#ifdef DCCP_DEBUG
405 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : 429 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
406 "server TX opt: "; 430 "CLIENT TX opt: " : "server TX opt: ";
407#endif 431#endif
408 u32 tstamp_echo; 432 u32 tstamp_echo;
409 const u32 elapsed_time = jiffies_to_usecs(jiffies - dp->dccps_timestamp_time) / 10; 433 const u32 elapsed_time = jiffies_to_usecs(jiffies -
434 dp->dccps_timestamp_time) / 10;
410 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); 435 const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
411 const int len = 6 + elapsed_time_len; 436 const int len = 6 + elapsed_time_len;
412 unsigned char *to; 437 unsigned char *to;
413 438
414 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { 439 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
415 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert timestamp echo!\n"); 440 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
441 "timestamp echo!\n");
416 return; 442 return;
417 } 443 }
418 444
@@ -447,7 +473,8 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
447 473
448 if (!dccp_packet_without_ack(skb)) { 474 if (!dccp_packet_without_ack(skb)) {
449 if (dp->dccps_options.dccpo_send_ack_vector && 475 if (dp->dccps_options.dccpo_send_ack_vector &&
450 dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != DCCP_MAX_SEQNO + 1) 476 (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno !=
477 DCCP_MAX_SEQNO + 1))
451 dccp_insert_option_ack_vector(sk, skb); 478 dccp_insert_option_ack_vector(sk, skb);
452 479
453 dccp_insert_option_timestamp(sk, skb); 480 dccp_insert_option_timestamp(sk, skb);
@@ -480,12 +507,16 @@ struct dccp_ackpkts *dccp_ackpkts_alloc(unsigned int len, int priority)
480#ifdef DCCP_DEBUG 507#ifdef DCCP_DEBUG
481 memset(ap->dccpap_buf, 0xFF, len); 508 memset(ap->dccpap_buf, 0xFF, len);
482#endif 509#endif
483 ap->dccpap_buf_len = len; 510 ap->dccpap_buf_len = len;
484 ap->dccpap_buf_head = ap->dccpap_buf_tail = ap->dccpap_buf_len - 1; 511 ap->dccpap_buf_head =
485 ap->dccpap_buf_ackno = ap->dccpap_ack_ackno = ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; 512 ap->dccpap_buf_tail =
486 ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0; 513 ap->dccpap_buf_len - 1;
487 ap->dccpap_ack_ptr = 0; 514 ap->dccpap_buf_ackno =
488 ap->dccpap_time = 0; 515 ap->dccpap_ack_ackno =
516 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
517 ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0;
518 ap->dccpap_ack_ptr = 0;
519 ap->dccpap_time = 0;
489 ap->dccpap_buf_vector_len = ap->dccpap_ack_vector_len = 0; 520 ap->dccpap_buf_vector_len = ap->dccpap_ack_vector_len = 0;
490 } 521 }
491 522
@@ -567,15 +598,16 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
567 * 598 *
568 * From Appendix A: 599 * From Appendix A:
569 * 600 *
570 * Of course, the circular buffer may overflow, either when the HC- 601 * Of course, the circular buffer may overflow, either when the
571 * Sender is sending data at a very high rate, when the HC-Receiver's 602 * HC-Sender is sending data at a very high rate, when the
572 * acknowledgements are not reaching the HC-Sender, or when the HC- 603 * HC-Receiver's acknowledgements are not reaching the HC-Sender,
573 * Sender is forgetting to acknowledge those acks (so the HC-Receiver 604 * or when the HC-Sender is forgetting to acknowledge those acks
574 * is unable to clean up old state). In this case, the HC-Receiver 605 * (so the HC-Receiver is unable to clean up old state). In this
575 * should either compress the buffer (by increasing run lengths when 606 * case, the HC-Receiver should either compress the buffer (by
576 * possible), transfer its state to a larger buffer, or, as a last 607 * increasing run lengths when possible), transfer its state to
577 * resort, drop all received packets, without processing them 608 * a larger buffer, or, as a last resort, drop all received
578 * whatsoever, until its buffer shrinks again. 609 * packets, without processing them whatsoever, until its buffer
610 * shrinks again.
579 */ 611 */
580 612
581 /* See if this is the first ackno being inserted */ 613 /* See if this is the first ackno being inserted */
@@ -583,15 +615,17 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
583 ap->dccpap_buf[ap->dccpap_buf_head] = state; 615 ap->dccpap_buf[ap->dccpap_buf_head] = state;
584 ap->dccpap_buf_vector_len = 1; 616 ap->dccpap_buf_vector_len = 1;
585 } else if (after48(ackno, ap->dccpap_buf_ackno)) { 617 } else if (after48(ackno, ap->dccpap_buf_ackno)) {
586 const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno, ackno); 618 const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno,
619 ackno);
587 620
588 /* 621 /*
589 * Look if the state of this packet is the same as the previous ackno 622 * Look if the state of this packet is the same as the
590 * and if so if we can bump the head len. 623 * previous ackno and if so if we can bump the head len.
591 */ 624 */
592 if (delta == 1 && 625 if (delta == 1 &&
593 dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state && 626 dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state &&
594 dccp_ackpkts_len(ap, ap->dccpap_buf_head) < DCCP_ACKPKTS_LEN_MASK) 627 (dccp_ackpkts_len(ap, ap->dccpap_buf_head) <
628 DCCP_ACKPKTS_LEN_MASK))
595 ap->dccpap_buf[ap->dccpap_buf_head]++; 629 ap->dccpap_buf[ap->dccpap_buf_head]++;
596 else if (dccp_ackpkts_set_buf_head_state(ap, delta, state)) 630 else if (dccp_ackpkts_set_buf_head_state(ap, delta, state))
597 return -ENOBUFS; 631 return -ENOBUFS;
@@ -599,9 +633,10 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
599 /* 633 /*
600 * A.1.2. Old Packets 634 * A.1.2. Old Packets
601 * 635 *
602 * When a packet with Sequence Number S arrives, and S <= buf_ackno, 636 * When a packet with Sequence Number S arrives, and
603 * the HC-Receiver will scan the table for the byte corresponding to S. 637 * S <= buf_ackno, the HC-Receiver will scan the table
604 * (Indexing structures could reduce the complexity of this scan.) 638 * for the byte corresponding to S. (Indexing structures
639 * could reduce the complexity of this scan.)
605 */ 640 */
606 u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno); 641 u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno);
607 unsigned int index = ap->dccpap_buf_head; 642 unsigned int index = ap->dccpap_buf_head;
@@ -610,11 +645,12 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
610 const u8 len = dccp_ackpkts_len(ap, index); 645 const u8 len = dccp_ackpkts_len(ap, index);
611 const u8 state = dccp_ackpkts_state(ap, index); 646 const u8 state = dccp_ackpkts_state(ap, index);
612 /* 647 /*
613 * valid packets not yet in dccpap_buf have a reserved entry, with 648 * valid packets not yet in dccpap_buf have a reserved
614 * a len equal to 0 649 * entry, with a len equal to 0.
615 */ 650 */
616 if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED && 651 if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED &&
617 len == 0 && delta == 0) { /* Found our reserved seat! */ 652 len == 0 && delta == 0) { /* Found our
653 reserved seat! */
618 dccp_pr_debug("Found %llu reserved seat!\n", 654 dccp_pr_debug("Found %llu reserved seat!\n",
619 (unsigned long long) ackno); 655 (unsigned long long) ackno);
620 ap->dccpap_buf[index] = state; 656 ap->dccpap_buf[index] = state;
@@ -639,13 +675,14 @@ out:
639 675
640out_duplicate: 676out_duplicate:
641 /* Duplicate packet */ 677 /* Duplicate packet */
642 dccp_pr_debug("Received a dup or already considered lost packet: %llu\n", 678 dccp_pr_debug("Received a dup or already considered lost "
643 (unsigned long long) ackno); 679 "packet: %llu\n", (unsigned long long) ackno);
644 return -EILSEQ; 680 return -EILSEQ;
645} 681}
646 682
647#ifdef DCCP_DEBUG 683#ifdef DCCP_DEBUG
648void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len) 684void dccp_ackvector_print(const u64 ackno, const unsigned char *vector,
685 int len)
649{ 686{
650 if (!dccp_debug) 687 if (!dccp_debug)
651 return; 688 return;
@@ -678,8 +715,9 @@ static void dccp_ackpkts_trow_away_ack_record(struct dccp_ackpkts *ap)
678 * As we're keeping track of the ack vector size 715 * As we're keeping track of the ack vector size
679 * (dccpap_buf_vector_len) and the sent ack vector size 716 * (dccpap_buf_vector_len) and the sent ack vector size
680 * (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but 717 * (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but
681 * keep this code here as in the future we'll implement a vector of ack 718 * keep this code here as in the future we'll implement a vector of
682 * records, as suggested in draft-ietf-dccp-spec-11.txt Appendix A. -acme 719 * ack records, as suggested in draft-ietf-dccp-spec-11.txt
720 * Appendix A. -acme
683 */ 721 */
684#if 0 722#if 0
685 ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1; 723 ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1;
@@ -699,10 +737,11 @@ void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk,
699 if (ackno == ap->dccpap_ack_seqno) { 737 if (ackno == ap->dccpap_ack_seqno) {
700#ifdef DCCP_DEBUG 738#ifdef DCCP_DEBUG
701 struct dccp_sock *dp = dccp_sk(sk); 739 struct dccp_sock *dp = dccp_sk(sk);
702 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx ack: " : 740 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
703 "server rx ack: "; 741 "CLIENT rx ack: " : "server rx ack: ";
704#endif 742#endif
705 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, ack_ackno=%llu, ACKED!\n", 743 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, "
744 "ack_ackno=%llu, ACKED!\n",
706 debug_prefix, 1, 745 debug_prefix, 1,
707 (unsigned long long) ap->dccpap_ack_seqno, 746 (unsigned long long) ap->dccpap_ack_seqno,
708 (unsigned long long) ap->dccpap_ack_ackno); 747 (unsigned long long) ap->dccpap_ack_ackno);
@@ -722,20 +761,21 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
722 if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1) 761 if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1)
723 return; 762 return;
724 /* 763 /*
725 * We're in the receiver half connection, so if the received an ACK vector 764 * We're in the receiver half connection, so if the received an ACK
726 * ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're not interested. 765 * vector ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're
766 * not interested.
727 * 767 *
728 * Extra explanation with example: 768 * Extra explanation with example:
729 * 769 *
730 * if we received an ACK vector with ackno 50, it can only be acking 770 * if we received an ACK vector with ackno 50, it can only be acking
731 * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent). 771 * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent).
732 */ 772 */
733 // dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); 773 /* dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); */
734 if (before48(ackno, ap->dccpap_ack_seqno)) { 774 if (before48(ackno, ap->dccpap_ack_seqno)) {
735 // dccp_pr_debug_cat("yes\n"); 775 /* dccp_pr_debug_cat("yes\n"); */
736 return; 776 return;
737 } 777 }
738 // dccp_pr_debug_cat("no\n"); 778 /* dccp_pr_debug_cat("no\n"); */
739 779
740 i = len; 780 i = len;
741 while (i--) { 781 while (i--) {
@@ -744,18 +784,25 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
744 784
745 dccp_set_seqno(&ackno_end_rl, ackno - rl); 785 dccp_set_seqno(&ackno_end_rl, ackno - rl);
746 786
747 // dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl, ap->dccpap_ack_seqno, ackno); 787 /*
788 * dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl,
789 * ap->dccpap_ack_seqno, ackno);
790 */
748 if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) { 791 if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) {
749 const u8 state = (*vector & DCCP_ACKPKTS_STATE_MASK) >> 6; 792 const u8 state = (*vector &
750 // dccp_pr_debug_cat("yes\n"); 793 DCCP_ACKPKTS_STATE_MASK) >> 6;
794 /* dccp_pr_debug_cat("yes\n"); */
751 795
752 if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) { 796 if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) {
753#ifdef DCCP_DEBUG 797#ifdef DCCP_DEBUG
754 struct dccp_sock *dp = dccp_sk(sk); 798 struct dccp_sock *dp = dccp_sk(sk);
755 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx ack: " : 799 const char *debug_prefix =
756 "server rx ack: "; 800 dp->dccps_role == DCCP_ROLE_CLIENT ?
801 "CLIENT rx ack: " : "server rx ack: ";
757#endif 802#endif
758 dccp_pr_debug("%sACK vector 0, len=%d, ack_seqno=%llu, ack_ackno=%llu, ACKED!\n", 803 dccp_pr_debug("%sACK vector 0, len=%d, "
804 "ack_seqno=%llu, ack_ackno=%llu, "
805 "ACKED!\n",
759 debug_prefix, len, 806 debug_prefix, len,
760 (unsigned long long) 807 (unsigned long long)
761 ap->dccpap_ack_seqno, 808 ap->dccpap_ack_seqno,
@@ -764,13 +811,13 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
764 dccp_ackpkts_trow_away_ack_record(ap); 811 dccp_ackpkts_trow_away_ack_record(ap);
765 } 812 }
766 /* 813 /*
767 * If dccpap_ack_seqno was not received, no problem we'll 814 * If dccpap_ack_seqno was not received, no problem
768 * send another ACK vector. 815 * we'll send another ACK vector.
769 */ 816 */
770 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; 817 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
771 break; 818 break;
772 } 819 }
773 // dccp_pr_debug_cat("no\n"); 820 /* dccp_pr_debug_cat("no\n"); */
774 821
775 dccp_set_seqno(&ackno, ackno_end_rl - 1); 822 dccp_set_seqno(&ackno, ackno_end_rl - 1);
776 ++vector; 823 ++vector;