options.c (7d870936602533836bba821bd5c679c62c52a95f) options.c (b3d14bff12a38ad13a174eb0cc83d2ac7169eee4)
1/*
2 * net/dccp/options.c
3 *
4 * An implementation of the DCCP protocol
5 * Copyright (c) 2005 Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
6 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
7 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz>
8 *

--- 415 unchanged lines hidden (view full) ---

424
425 return 0;
426}
427
428static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
429{
430 struct dccp_sock *dp = dccp_sk(sk);
431 struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
1/*
2 * net/dccp/options.c
3 *
4 * An implementation of the DCCP protocol
5 * Copyright (c) 2005 Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
6 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
7 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz>
8 *

--- 415 unchanged lines hidden (view full) ---

424
425 return 0;
426}
427
428static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
429{
430 struct dccp_sock *dp = dccp_sk(sk);
431 struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
432 const u16 buflen = dccp_ackvec_buflen(av);
432 /* Figure out how many options do we need to represent the ackvec */
433 /* Figure out how many options do we need to represent the ackvec */
433 const u8 nr_opts = DIV_ROUND_UP(av->av_vec_len, DCCP_SINGLE_OPT_MAXLEN);
434 u16 len = av->av_vec_len + 2 * nr_opts;
434 const u8 nr_opts = DIV_ROUND_UP(buflen, DCCP_SINGLE_OPT_MAXLEN);
435 u16 len = buflen + 2 * nr_opts;
435 u8 i, nonce = 0;
436 const unsigned char *tail, *from;
437 unsigned char *to;
438
439 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
440 return -1;
441
442 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
443
444 to = skb_push(skb, len);
436 u8 i, nonce = 0;
437 const unsigned char *tail, *from;
438 unsigned char *to;
439
440 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
441 return -1;
442
443 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
444
445 to = skb_push(skb, len);
445 len = av->av_vec_len;
446 len = buflen;
446 from = av->av_buf + av->av_buf_head;
447 tail = av->av_buf + DCCPAV_MAX_ACKVEC_LEN;
448
449 for (i = 0; i < nr_opts; ++i) {
450 int copylen = len;
451
452 if (len > DCCP_SINGLE_OPT_MAXLEN)
453 copylen = DCCP_SINGLE_OPT_MAXLEN;

--- 121 unchanged lines hidden (view full) ---

575 if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_REQUEST) {
576 /*
577 * Obtain RTT sample from Request/Response exchange.
578 * This is currently used for TFRC initialisation.
579 */
580 if (dccp_insert_option_timestamp(skb))
581 return -1;
582
447 from = av->av_buf + av->av_buf_head;
448 tail = av->av_buf + DCCPAV_MAX_ACKVEC_LEN;
449
450 for (i = 0; i < nr_opts; ++i) {
451 int copylen = len;
452
453 if (len > DCCP_SINGLE_OPT_MAXLEN)
454 copylen = DCCP_SINGLE_OPT_MAXLEN;

--- 121 unchanged lines hidden (view full) ---

576 if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_REQUEST) {
577 /*
578 * Obtain RTT sample from Request/Response exchange.
579 * This is currently used for TFRC initialisation.
580 */
581 if (dccp_insert_option_timestamp(skb))
582 return -1;
583
583 } else if (dp->dccps_hc_rx_ackvec != NULL &&
584 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec) &&
584 } else if (dccp_ackvec_pending(sk) &&
585 dccp_insert_option_ackvec(sk, skb)) {
586 return -1;
587 }
588 }
589
590 if (dp->dccps_hc_rx_insert_options) {
591 if (ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb))
592 return -1;

--- 29 unchanged lines hidden ---
585 dccp_insert_option_ackvec(sk, skb)) {
586 return -1;
587 }
588 }
589
590 if (dp->dccps_hc_rx_insert_options) {
591 if (ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb))
592 return -1;

--- 29 unchanged lines hidden ---