Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 1 | #ifndef _ACKVEC_H |
| 2 | #define _ACKVEC_H |
| 3 | /* |
| 4 | * net/dccp/ackvec.h |
| 5 | * |
| 6 | * An implementation of the DCCP protocol |
| 7 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@mandriva.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 14 | #include <linux/compiler.h> |
Arnaldo Carvalho de Melo | b8bda9d | 2007-08-19 17:17:25 -0700 | [diff] [blame] | 15 | #include <linux/ktime.h> |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 16 | #include <linux/list.h> |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 17 | #include <linux/types.h> |
| 18 | |
| 19 | /* Read about the ECN nonce to see why it is 253 */ |
Andrea Bittau | bdf13d2 | 2006-11-24 13:02:42 -0200 | [diff] [blame] | 20 | #define DCCP_MAX_ACKVEC_OPT_LEN 253 |
| 21 | /* We can spread an ack vector across multiple options */ |
| 22 | #define DCCP_MAX_ACKVEC_LEN (DCCP_MAX_ACKVEC_OPT_LEN * 2) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 23 | |
| 24 | #define DCCP_ACKVEC_STATE_RECEIVED 0 |
| 25 | #define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6) |
| 26 | #define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6) |
| 27 | |
| 28 | #define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */ |
| 29 | #define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */ |
| 30 | |
| 31 | /** struct dccp_ackvec - ack vector |
| 32 | * |
Gerrit Renker | 0e64e94 | 2006-10-24 16:17:51 -0700 | [diff] [blame] | 33 | * This data structure is the one defined in RFC 4340, Appendix A. |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 34 | * |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 35 | * @av_buf_head - circular buffer head |
| 36 | * @av_buf_tail - circular buffer tail |
| 37 | * @av_buf_ackno - ack # of the most recent packet acknowledgeable in the |
| 38 | * buffer (i.e. %av_buf_head) |
| 39 | * @av_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 40 | * by the buffer with State 0 |
| 41 | * |
| 42 | * Additionally, the HC-Receiver must keep some information about the |
| 43 | * Ack Vectors it has recently sent. For each packet sent carrying an |
| 44 | * Ack Vector, it remembers four variables: |
| 45 | * |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 46 | * @av_records - list of dccp_ackvec_record |
| 47 | * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 48 | * |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 49 | * @av_time - the time in usecs |
| 50 | * @av_buf - circular buffer of acknowledgeable packets |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 51 | */ |
| 52 | struct dccp_ackvec { |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 53 | u64 av_buf_ackno; |
| 54 | struct list_head av_records; |
| 55 | ktime_t av_time; |
| 56 | u16 av_buf_head; |
| 57 | u16 av_vec_len; |
| 58 | u8 av_buf_nonce; |
| 59 | u8 av_ack_nonce; |
| 60 | u8 av_buf[DCCP_MAX_ACKVEC_LEN]; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 63 | /** struct dccp_ackvec_record - ack vector record |
| 64 | * |
| 65 | * ACK vector record as defined in Appendix A of spec. |
| 66 | * |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 67 | * The list is sorted by avr_ack_seqno |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 68 | * |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 69 | * @avr_node - node in av_records |
| 70 | * @avr_ack_seqno - sequence number of the packet this record was sent on |
| 71 | * @avr_ack_ackno - sequence number being acknowledged |
| 72 | * @avr_ack_ptr - pointer into av_buf where this record starts |
| 73 | * @avr_ack_nonce - av_ack_nonce at the time this record was sent |
| 74 | * @avr_sent_len - lenght of the record in av_buf |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 75 | */ |
| 76 | struct dccp_ackvec_record { |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 77 | struct list_head avr_node; |
| 78 | u64 avr_ack_seqno; |
| 79 | u64 avr_ack_ackno; |
| 80 | u16 avr_ack_ptr; |
| 81 | u16 avr_sent_len; |
| 82 | u8 avr_ack_nonce; |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 83 | }; |
| 84 | |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 85 | struct sock; |
| 86 | struct sk_buff; |
| 87 | |
| 88 | #ifdef CONFIG_IP_DCCP_ACKVEC |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame] | 89 | extern int dccp_ackvec_init(void); |
| 90 | extern void dccp_ackvec_exit(void); |
| 91 | |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 92 | extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 93 | extern void dccp_ackvec_free(struct dccp_ackvec *av); |
| 94 | |
| 95 | extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, |
| 96 | const u64 ackno, const u8 state); |
| 97 | |
| 98 | extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, |
| 99 | struct sock *sk, const u64 ackno); |
| 100 | extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, |
Andrea Bittau | bdf13d2 | 2006-11-24 13:02:42 -0200 | [diff] [blame] | 101 | u64 *ackno, const u8 opt, |
| 102 | const u8 *value, const u8 len); |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 103 | |
| 104 | extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); |
| 105 | |
| 106 | static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) |
| 107 | { |
Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 108 | return av->av_vec_len; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 109 | } |
| 110 | #else /* CONFIG_IP_DCCP_ACKVEC */ |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame] | 111 | static inline int dccp_ackvec_init(void) |
| 112 | { |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | static inline void dccp_ackvec_exit(void) |
| 117 | { |
| 118 | } |
| 119 | |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 120 | static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 121 | { |
| 122 | return NULL; |
| 123 | } |
| 124 | |
| 125 | static inline void dccp_ackvec_free(struct dccp_ackvec *av) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, |
| 130 | const u64 ackno, const u8 state) |
| 131 | { |
| 132 | return -1; |
| 133 | } |
| 134 | |
| 135 | static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, |
| 136 | struct sock *sk, const u64 ackno) |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, |
Andrea Bittau | bdf13d2 | 2006-11-24 13:02:42 -0200 | [diff] [blame] | 141 | const u64 *ackno, const u8 opt, |
| 142 | const u8 *value, const u8 len) |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 143 | { |
| 144 | return -1; |
| 145 | } |
| 146 | |
| 147 | static inline int dccp_insert_option_ackvec(const struct sock *sk, |
| 148 | const struct sk_buff *skb) |
| 149 | { |
| 150 | return -1; |
| 151 | } |
| 152 | |
| 153 | static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) |
| 154 | { |
| 155 | return 0; |
| 156 | } |
| 157 | #endif /* CONFIG_IP_DCCP_ACKVEC */ |
| 158 | #endif /* _ACKVEC_H */ |