2 * net/dccp/ccids/ccid2.c
4 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
6 * Changes to meet Linux coding standards, and DCCP infrastructure fixes.
8 * Copyright (c) 2006 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * This implementation should follow: draft-ietf-dccp-ccid2-10.txt
29 * - sequence number wrapping
33 #include <linux/config.h>
38 static int ccid2_debug;
45 #define ccid2_pr_debug(format, a...) \
46 do { if (ccid2_debug) \
47 printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \
50 #define ccid2_pr_debug(format, a...)
53 static const int ccid2_seq_len = 128;
55 static inline struct ccid2_hc_tx_sock *ccid2_hc_tx_sk(const struct sock *sk)
57 return dccp_sk(sk)->dccps_hc_tx_ccid_private;
60 static inline struct ccid2_hc_rx_sock *ccid2_hc_rx_sk(const struct sock *sk)
62 return dccp_sk(sk)->dccps_hc_rx_ccid_private;
66 static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
69 struct ccid2_seq *seqp;
72 seqp = hctx->ccid2hctx_seqh;
74 /* there is data in the chain */
75 if (seqp != hctx->ccid2hctx_seqt) {
76 seqp = seqp->ccid2s_prev;
78 if (!seqp->ccid2s_acked)
81 while (seqp != hctx->ccid2hctx_seqt) {
82 struct ccid2_seq *prev;
84 prev = seqp->ccid2s_prev;
86 if (!prev->ccid2s_acked)
89 /* packets are sent sequentially */
90 BUG_ON(seqp->ccid2s_seq <= prev->ccid2s_seq);
91 BUG_ON(seqp->ccid2s_sent < prev->ccid2s_sent);
92 BUG_ON(len > ccid2_seq_len);
98 BUG_ON(pipe != hctx->ccid2hctx_pipe);
99 ccid2_pr_debug("len of chain=%d\n", len);
102 seqp = seqp->ccid2s_prev;
104 BUG_ON(len > ccid2_seq_len);
105 } while(seqp != hctx->ccid2hctx_seqh);
107 BUG_ON(len != ccid2_seq_len);
108 ccid2_pr_debug("total len=%d\n", len);
111 #define ccid2_hc_tx_check_sanity(hctx) do {} while (0)
114 static int ccid2_hc_tx_send_packet(struct sock *sk,
115 struct sk_buff *skb, int len)
117 struct ccid2_hc_tx_sock *hctx;
119 switch (DCCP_SKB_CB(skb)->dccpd_type) {
120 case 0: /* XXX data packets from userland come through like this */
122 case DCCP_PKT_DATAACK:
124 /* No congestion control on other packets */
129 hctx = ccid2_hc_tx_sk(sk);
131 ccid2_pr_debug("pipe=%d cwnd=%d\n", hctx->ccid2hctx_pipe,
132 hctx->ccid2hctx_cwnd);
134 if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd) {
135 /* OK we can send... make sure previous packet was sent off */
136 if (!hctx->ccid2hctx_sendwait) {
137 hctx->ccid2hctx_sendwait = 1;
142 return 100; /* XXX */
145 static void ccid2_change_l_ack_ratio(struct sock *sk, int val)
147 struct dccp_sock *dp = dccp_sk(sk);
149 * XXX I don't really agree with val != 2. If cwnd is 1, ack ratio
150 * should be 1... it shouldn't be allowed to become 2.
154 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
155 int max = hctx->ccid2hctx_cwnd / 2;
158 if (hctx->ccid2hctx_cwnd & 1)
165 ccid2_pr_debug("changing local ack ratio to %d\n", val);
167 dp->dccps_l_ack_ratio = val;
170 static void ccid2_change_cwnd(struct sock *sk, int val)
172 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
177 /* XXX do we need to change ack ratio? */
178 ccid2_pr_debug("change cwnd to %d\n", val);
181 hctx->ccid2hctx_cwnd = val;
184 static void ccid2_start_rto_timer(struct sock *sk);
186 static void ccid2_hc_tx_rto_expire(unsigned long data)
188 struct sock *sk = (struct sock *)data;
189 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
192 /* XXX I don't think i'm locking correctly
196 if (sock_owned_by_user(sk)) {
197 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
202 ccid2_pr_debug("RTO_EXPIRE\n");
204 ccid2_hc_tx_check_sanity(hctx);
207 hctx->ccid2hctx_rto <<= 1;
209 s = hctx->ccid2hctx_rto / HZ;
211 hctx->ccid2hctx_rto = 60 * HZ;
213 ccid2_start_rto_timer(sk);
215 /* adjust pipe, cwnd etc */
216 hctx->ccid2hctx_pipe = 0;
217 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd >> 1;
218 if (hctx->ccid2hctx_ssthresh < 2)
219 hctx->ccid2hctx_ssthresh = 2;
220 ccid2_change_cwnd(sk, 1);
222 /* clear state about stuff we sent */
223 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
224 hctx->ccid2hctx_ssacks = 0;
225 hctx->ccid2hctx_acks = 0;
226 hctx->ccid2hctx_sent = 0;
228 /* clear ack ratio state. */
229 hctx->ccid2hctx_arsent = 0;
230 hctx->ccid2hctx_ackloss = 0;
231 hctx->ccid2hctx_rpseq = 0;
232 hctx->ccid2hctx_rpdupack = -1;
233 ccid2_change_l_ack_ratio(sk, 1);
234 ccid2_hc_tx_check_sanity(hctx);
240 static void ccid2_start_rto_timer(struct sock *sk)
242 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
244 ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto);
246 BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer));
247 sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer,
248 jiffies + hctx->ccid2hctx_rto);
251 static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len)
253 struct dccp_sock *dp = dccp_sk(sk);
254 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
257 ccid2_hc_tx_check_sanity(hctx);
259 BUG_ON(!hctx->ccid2hctx_sendwait);
260 hctx->ccid2hctx_sendwait = 0;
261 hctx->ccid2hctx_pipe++;
262 BUG_ON(hctx->ccid2hctx_pipe < 0);
264 /* There is an issue. What if another packet is sent between
265 * packet_send() and packet_sent(). Then the sequence number would be
271 hctx->ccid2hctx_seqh->ccid2s_seq = seq;
272 hctx->ccid2hctx_seqh->ccid2s_acked = 0;
273 hctx->ccid2hctx_seqh->ccid2s_sent = jiffies;
274 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqh->ccid2s_next;
276 ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd,
277 hctx->ccid2hctx_pipe);
279 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt) {
280 /* XXX allocate more space */
284 hctx->ccid2hctx_sent++;
286 /* Ack Ratio. Need to maintain a concept of how many windows we sent */
287 hctx->ccid2hctx_arsent++;
288 /* We had an ack loss in this window... */
289 if (hctx->ccid2hctx_ackloss) {
290 if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) {
291 hctx->ccid2hctx_arsent = 0;
292 hctx->ccid2hctx_ackloss = 0;
295 /* No acks lost up to now... */
297 /* decrease ack ratio if enough packets were sent */
298 if (dp->dccps_l_ack_ratio > 1) {
299 /* XXX don't calculate denominator each time */
302 denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio -
303 dp->dccps_l_ack_ratio;
304 denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom;
306 if (hctx->ccid2hctx_arsent >= denom) {
307 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1);
308 hctx->ccid2hctx_arsent = 0;
311 /* we can't increase ack ratio further [1] */
313 hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/
317 /* setup RTO timer */
318 if (!timer_pending(&hctx->ccid2hctx_rtotimer)) {
319 ccid2_start_rto_timer(sk);
322 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
323 ccid2_pr_debug("Sent: seq=%llu\n", seq);
325 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
327 while (seqp != hctx->ccid2hctx_seqh) {
328 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
329 seqp->ccid2s_seq, seqp->ccid2s_acked,
331 seqp = seqp->ccid2s_next;
334 ccid2_pr_debug("=========\n");
335 ccid2_hc_tx_check_sanity(hctx);
339 /* XXX Lame code duplication!
340 * returns -1 if none was found.
341 * else returns the next offset to use in the function call.
343 static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
344 unsigned char **vec, unsigned char *veclen)
346 const struct dccp_hdr *dh = dccp_hdr(skb);
347 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
348 unsigned char *opt_ptr;
349 const unsigned char *opt_end = (unsigned char *)dh +
350 (dh->dccph_doff * 4);
351 unsigned char opt, len;
352 unsigned char *value;
357 if (opt_ptr >= opt_end)
360 while (opt_ptr != opt_end) {
365 /* Check if this isn't a single byte option */
366 if (opt > DCCPO_MAX_RESERVED) {
367 if (opt_ptr == opt_end)
368 goto out_invalid_option;
372 goto out_invalid_option;
374 * Remove the type and len fields, leaving
375 * just the value size
381 if (opt_ptr > opt_end)
382 goto out_invalid_option;
386 case DCCPO_ACK_VECTOR_0:
387 case DCCPO_ACK_VECTOR_1:
390 return offset + (opt_ptr - options);
398 BUG_ON(1); /* should never happen... options were previously parsed ! */
402 static void ccid2_hc_tx_kill_rto_timer(struct sock *sk)
404 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
406 sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer);
407 ccid2_pr_debug("deleted RTO timer\n");
410 static inline void ccid2_new_ack(struct sock *sk,
411 struct ccid2_seq *seqp,
412 unsigned int *maxincr)
414 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
417 if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) {
418 hctx->ccid2hctx_acks = 0;
420 /* We can increase cwnd at most maxincr [ack_ratio/2] */
422 /* increase every 2 acks */
423 hctx->ccid2hctx_ssacks++;
424 if (hctx->ccid2hctx_ssacks == 2) {
425 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd + 1);
426 hctx->ccid2hctx_ssacks = 0;
427 *maxincr = *maxincr - 1;
430 /* increased cwnd enough for this single ack */
432 hctx->ccid2hctx_ssacks = 0;
436 hctx->ccid2hctx_ssacks = 0;
437 hctx->ccid2hctx_acks++;
439 if (hctx->ccid2hctx_acks >= hctx->ccid2hctx_cwnd) {
440 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd + 1);
441 hctx->ccid2hctx_acks = 0;
446 if (hctx->ccid2hctx_srtt == -1 ||
447 (jiffies - hctx->ccid2hctx_lastrtt) >= hctx->ccid2hctx_srtt) {
448 unsigned long r = jiffies - seqp->ccid2s_sent;
451 /* first measurement */
452 if (hctx->ccid2hctx_srtt == -1) {
453 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
454 r, jiffies, seqp->ccid2s_seq);
455 hctx->ccid2hctx_srtt = r;
456 hctx->ccid2hctx_rttvar = r >> 1;
460 long tmp = hctx->ccid2hctx_srtt - r;
465 hctx->ccid2hctx_rttvar *= 3;
466 hctx->ccid2hctx_rttvar >>= 2;
467 hctx->ccid2hctx_rttvar += tmp;
470 hctx->ccid2hctx_srtt *= 7;
471 hctx->ccid2hctx_srtt >>= 3;
473 hctx->ccid2hctx_srtt += tmp;
475 s = hctx->ccid2hctx_rttvar << 2;
476 /* clock granularity is 1 when based on jiffies */
479 hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s;
481 /* must be at least a second */
482 s = hctx->ccid2hctx_rto / HZ;
483 /* DCCP doesn't require this [but I like it cuz my code sux] */
486 hctx->ccid2hctx_rto = HZ;
490 hctx->ccid2hctx_rto = HZ * 60;
492 hctx->ccid2hctx_lastrtt = jiffies;
494 ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n",
495 hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar,
496 hctx->ccid2hctx_rto, HZ, r);
497 hctx->ccid2hctx_sent = 0;
500 /* we got a new ack, so re-start RTO timer */
501 ccid2_hc_tx_kill_rto_timer(sk);
502 ccid2_start_rto_timer(sk);
505 static void ccid2_hc_tx_dec_pipe(struct sock *sk)
507 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
509 hctx->ccid2hctx_pipe--;
510 BUG_ON(hctx->ccid2hctx_pipe < 0);
512 if (hctx->ccid2hctx_pipe == 0)
513 ccid2_hc_tx_kill_rto_timer(sk);
516 static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
518 struct dccp_sock *dp = dccp_sk(sk);
519 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
521 struct ccid2_seq *seqp;
522 unsigned char *vector;
523 unsigned char veclen;
527 unsigned int maxincr = 0;
529 ccid2_hc_tx_check_sanity(hctx);
530 /* check reverse path congestion */
531 seqno = DCCP_SKB_CB(skb)->dccpd_seq;
533 /* XXX this whole "algorithm" is broken. Need to fix it to keep track
534 * of the seqnos of the dupacks so that rpseq and rpdupack are correct
537 /* need to bootstrap */
538 if (hctx->ccid2hctx_rpdupack == -1) {
539 hctx->ccid2hctx_rpdupack = 0;
540 hctx->ccid2hctx_rpseq = seqno;
543 /* check if packet is consecutive */
544 if ((hctx->ccid2hctx_rpseq + 1) == seqno) {
545 hctx->ccid2hctx_rpseq++;
547 /* it's a later packet */
548 else if (after48(seqno, hctx->ccid2hctx_rpseq)) {
549 hctx->ccid2hctx_rpdupack++;
551 /* check if we got enough dupacks */
552 if (hctx->ccid2hctx_rpdupack >=
553 hctx->ccid2hctx_numdupack) {
555 hctx->ccid2hctx_rpdupack = -1; /* XXX lame */
556 hctx->ccid2hctx_rpseq = 0;
558 ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio << 1);
563 /* check forward path congestion */
564 /* still didn't send out new data packets */
565 if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt)
568 switch (DCCP_SKB_CB(skb)->dccpd_type) {
570 case DCCP_PKT_DATAACK:
577 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
578 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
580 /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for
581 * this single ack. I round up.
584 maxincr = dp->dccps_l_ack_ratio >> 1;
587 /* go through all ack vectors */
588 while ((offset = ccid2_ackvector(sk, skb, offset,
589 &vector, &veclen)) != -1) {
590 /* go through this ack vector */
592 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
595 dccp_set_seqno(&ackno_end_rl, ackno - rl);
596 ccid2_pr_debug("ackvec start:%llu end:%llu\n", ackno,
598 /* if the seqno we are analyzing is larger than the
599 * current ackno, then move towards the tail of our
602 while (after48(seqp->ccid2s_seq, ackno)) {
603 if (seqp == hctx->ccid2hctx_seqt) {
607 seqp = seqp->ccid2s_prev;
612 /* check all seqnos in the range of the vector
615 while (between48(seqp->ccid2s_seq,ackno_end_rl,ackno)) {
616 const u8 state = (*vector &
617 DCCP_ACKVEC_STATE_MASK) >> 6;
619 /* new packet received or marked */
620 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED &&
621 !seqp->ccid2s_acked) {
623 DCCP_ACKVEC_STATE_ECN_MARKED) {
627 ccid2_new_ack(sk, seqp,
631 seqp->ccid2s_acked = 1;
632 ccid2_pr_debug("Got ack for %llu\n",
634 ccid2_hc_tx_dec_pipe(sk);
636 if (seqp == hctx->ccid2hctx_seqt) {
640 seqp = seqp->ccid2s_next;
646 dccp_set_seqno(&ackno, ackno_end_rl - 1);
653 /* The state about what is acked should be correct now
654 * Check for NUMDUPACK
656 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
659 if (seqp->ccid2s_acked) {
661 if (done == hctx->ccid2hctx_numdupack) {
665 if (seqp == hctx->ccid2hctx_seqt) {
668 seqp = seqp->ccid2s_prev;
671 /* If there are at least 3 acknowledgements, anything unacknowledged
672 * below the last sequence number is considered lost
674 if (done == hctx->ccid2hctx_numdupack) {
675 struct ccid2_seq *last_acked = seqp;
677 /* check for lost packets */
679 if (!seqp->ccid2s_acked) {
681 ccid2_hc_tx_dec_pipe(sk);
683 if (seqp == hctx->ccid2hctx_seqt)
685 seqp = seqp->ccid2s_prev;
688 hctx->ccid2hctx_seqt = last_acked;
691 /* trim acked packets in tail */
692 while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) {
693 if (!hctx->ccid2hctx_seqt->ccid2s_acked)
696 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next;
700 /* XXX do bit shifts guarantee a 0 as the new bit? */
701 ccid2_change_cwnd(sk, hctx->ccid2hctx_cwnd >> 1);
702 hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd;
703 if (hctx->ccid2hctx_ssthresh < 2)
704 hctx->ccid2hctx_ssthresh = 2;
707 ccid2_hc_tx_check_sanity(hctx);
710 static int ccid2_hc_tx_init(struct sock *sk)
712 struct dccp_sock *dp = dccp_sk(sk);
713 struct ccid2_hc_tx_sock *hctx;
714 int seqcount = ccid2_seq_len;
717 dp->dccps_hc_tx_ccid_private = kzalloc(sizeof(*hctx), gfp_any());
718 if (dp->dccps_hc_tx_ccid_private == NULL)
721 hctx = ccid2_hc_tx_sk(sk);
723 /* XXX init variables with proper values */
724 hctx->ccid2hctx_cwnd = 1;
725 hctx->ccid2hctx_ssthresh = 10;
726 hctx->ccid2hctx_numdupack = 3;
728 /* XXX init ~ to window size... */
729 hctx->ccid2hctx_seqbuf = kmalloc(sizeof(*hctx->ccid2hctx_seqbuf) *
730 seqcount, gfp_any());
731 if (hctx->ccid2hctx_seqbuf == NULL) {
732 kfree(dp->dccps_hc_tx_ccid_private);
733 dp->dccps_hc_tx_ccid_private = NULL;
736 for (i = 0; i < (seqcount - 1); i++) {
737 hctx->ccid2hctx_seqbuf[i].ccid2s_next =
738 &hctx->ccid2hctx_seqbuf[i + 1];
739 hctx->ccid2hctx_seqbuf[i + 1].ccid2s_prev =
740 &hctx->ccid2hctx_seqbuf[i];
742 hctx->ccid2hctx_seqbuf[seqcount - 1].ccid2s_next =
743 hctx->ccid2hctx_seqbuf;
744 hctx->ccid2hctx_seqbuf->ccid2s_prev =
745 &hctx->ccid2hctx_seqbuf[seqcount - 1];
747 hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqbuf;
748 hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh;
749 hctx->ccid2hctx_sent = 0;
750 hctx->ccid2hctx_rto = 3 * HZ;
751 hctx->ccid2hctx_srtt = -1;
752 hctx->ccid2hctx_rttvar = -1;
753 hctx->ccid2hctx_lastrtt = 0;
754 hctx->ccid2hctx_rpdupack = -1;
756 hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
757 hctx->ccid2hctx_rtotimer.data = (unsigned long)sk;
758 init_timer(&hctx->ccid2hctx_rtotimer);
760 ccid2_hc_tx_check_sanity(hctx);
764 static void ccid2_hc_tx_exit(struct sock *sk)
766 struct dccp_sock *dp = dccp_sk(sk);
767 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
769 ccid2_hc_tx_kill_rto_timer(sk);
771 kfree(hctx->ccid2hctx_seqbuf);
773 kfree(dp->dccps_hc_tx_ccid_private);
774 dp->dccps_hc_tx_ccid_private = NULL;
777 static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
779 const struct dccp_sock *dp = dccp_sk(sk);
780 struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk);
782 switch (DCCP_SKB_CB(skb)->dccpd_type) {
784 case DCCP_PKT_DATAACK:
785 hcrx->ccid2hcrx_data++;
786 if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) {
788 hcrx->ccid2hcrx_data = 0;
794 static int ccid2_hc_rx_init(struct sock *sk)
796 struct dccp_sock *dp = dccp_sk(sk);
797 dp->dccps_hc_rx_ccid_private = kzalloc(sizeof(struct ccid2_hc_rx_sock),
799 return dp->dccps_hc_rx_ccid_private == NULL ? -ENOMEM : 0;
802 static void ccid2_hc_rx_exit(struct sock *sk)
804 struct dccp_sock *dp = dccp_sk(sk);
806 kfree(dp->dccps_hc_rx_ccid_private);
807 dp->dccps_hc_rx_ccid_private = NULL;
810 static struct ccid ccid2 = {
812 .ccid_name = "ccid2",
813 .ccid_owner = THIS_MODULE,
814 .ccid_hc_tx_init = ccid2_hc_tx_init,
815 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
816 .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet,
817 .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent,
818 .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv,
819 .ccid_hc_rx_init = ccid2_hc_rx_init,
820 .ccid_hc_rx_exit = ccid2_hc_rx_exit,
821 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
824 module_param(ccid2_debug, int, 0444);
825 MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
827 static __init int ccid2_module_init(void)
829 return ccid_register(&ccid2);
831 module_init(ccid2_module_init);
833 static __exit void ccid2_module_exit(void)
835 ccid_unregister(&ccid2);
837 module_exit(ccid2_module_exit);
839 MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
840 MODULE_DESCRIPTION("DCCP TCP CCID2 CCID");
841 MODULE_LICENSE("GPL");
842 MODULE_ALIAS("net-dccp-ccid-2");