aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:34 -0400
commit47a61e7b433a014296971ea1226eb1adb6310ab4 (patch)
tree16207d30fa2434c61d3fcb52be79c8c4fbd38770 /net/dccp/ccids
parent63b3a73bb85daf441f964aaf9b3fc89be4209c23 (diff)
dccp ccid-3: Simplify and consolidate tx_parse_options
This simplifies and consolidates the TX option-parsing code: 1. The Loss Intervals option is not currently used, so dead code related to this option is removed. I am aware of no plans to support the option, but if someone wants to implement it (e.g. for inter-op tests), it is better to start afresh than having to also update currently unused code. 2. The Loss Event and Receive Rate options have a lot of code in common (both are 32 bit, both have same length etc.), so this is consolidated. 3. The test against GSR is not necessary, because - on first loading CCID3, ccid_new() zeroes out all fields in the socket; - ccid3_hc_tx_packet_recv() treats 0 and ~0U equivalently, due to pinv = opt_recv->ccid3or_loss_event_rate; if (pinv == ~0U || pinv == 0) hctx->p = 0; - as a result, the sequence number field is removed from opt_recv. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid3.c57
-rw-r--r--net/dccp/ccids/ccid3.h3
2 files changed, 14 insertions, 46 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index f74e58d9793f..12b601f11bfd 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -487,60 +487,31 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
487 unsigned char len, u16 idx, 487 unsigned char len, u16 idx,
488 unsigned char *value) 488 unsigned char *value)
489{ 489{
490 int rc = 0;
491 const struct dccp_sock *dp = dccp_sk(sk);
492 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 490 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
493 struct ccid3_options_received *opt_recv = &hctx->options_received; 491 struct ccid3_options_received *opt_recv = &hctx->options_received;
494 __be32 opt_val; 492 __be32 opt_val;
495 493
496 if (opt_recv->ccid3or_seqno != dp->dccps_gsr) {
497 opt_recv->ccid3or_seqno = dp->dccps_gsr;
498 opt_recv->ccid3or_loss_event_rate = ~0;
499 opt_recv->ccid3or_loss_intervals_idx = 0;
500 opt_recv->ccid3or_loss_intervals_len = 0;
501 opt_recv->ccid3or_receive_rate = 0;
502 }
503
504 switch (option) { 494 switch (option) {
495 case TFRC_OPT_RECEIVE_RATE:
505 case TFRC_OPT_LOSS_EVENT_RATE: 496 case TFRC_OPT_LOSS_EVENT_RATE:
506 if (unlikely(len != 4)) { 497 if (unlikely(len != 4)) {
507 DCCP_WARN("%s(%p), invalid len %d " 498 DCCP_WARN("%s(%p), invalid len %d for %u\n",
508 "for TFRC_OPT_LOSS_EVENT_RATE\n", 499 dccp_role(sk), sk, len, option);
509 dccp_role(sk), sk, len); 500 return -EINVAL;
510 rc = -EINVAL;
511 } else {
512 opt_val = get_unaligned((__be32 *)value);
513 opt_recv->ccid3or_loss_event_rate = ntohl(opt_val);
514 ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
515 dccp_role(sk), sk,
516 opt_recv->ccid3or_loss_event_rate);
517 } 501 }
518 break; 502 opt_val = ntohl(get_unaligned((__be32 *)value));
519 case TFRC_OPT_LOSS_INTERVALS: 503
520 opt_recv->ccid3or_loss_intervals_idx = idx; 504 if (option == TFRC_OPT_RECEIVE_RATE) {
521 opt_recv->ccid3or_loss_intervals_len = len; 505 opt_recv->ccid3or_receive_rate = opt_val;
522 ccid3_pr_debug("%s(%p), LOSS_INTERVALS=(%u, %u)\n",
523 dccp_role(sk), sk,
524 opt_recv->ccid3or_loss_intervals_idx,
525 opt_recv->ccid3or_loss_intervals_len);
526 break;
527 case TFRC_OPT_RECEIVE_RATE:
528 if (unlikely(len != 4)) {
529 DCCP_WARN("%s(%p), invalid len %d "
530 "for TFRC_OPT_RECEIVE_RATE\n",
531 dccp_role(sk), sk, len);
532 rc = -EINVAL;
533 } else {
534 opt_val = get_unaligned((__be32 *)value);
535 opt_recv->ccid3or_receive_rate = ntohl(opt_val);
536 ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n", 506 ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n",
537 dccp_role(sk), sk, 507 dccp_role(sk), sk, opt_val);
538 opt_recv->ccid3or_receive_rate); 508 } else {
509 opt_recv->ccid3or_loss_event_rate = opt_val;
510 ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
511 dccp_role(sk), sk, opt_val);
539 } 512 }
540 break;
541 } 513 }
542 514 return 0;
543 return rc;
544} 515}
545 516
546static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) 517static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 92a5e1688a07..2268785ae8ee 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -71,9 +71,6 @@ enum ccid3_options {
71}; 71};
72 72
73struct ccid3_options_received { 73struct ccid3_options_received {
74 u64 ccid3or_seqno:48,
75 ccid3or_loss_intervals_idx:16;
76 u16 ccid3or_loss_intervals_len;
77 u32 ccid3or_loss_event_rate; 74 u32 ccid3or_loss_event_rate;
78 u32 ccid3or_receive_rate; 75 u32 ccid3or_receive_rate;
79}; 76};