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> |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 15 | #include <linux/list.h> |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 16 | #include <linux/time.h> |
| 17 | #include <linux/types.h> |
| 18 | |
| 19 | /* Read about the ECN nonce to see why it is 253 */ |
| 20 | #define DCCP_MAX_ACKVEC_LEN 253 |
| 21 | |
| 22 | #define DCCP_ACKVEC_STATE_RECEIVED 0 |
| 23 | #define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6) |
| 24 | #define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6) |
| 25 | |
| 26 | #define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */ |
| 27 | #define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */ |
| 28 | |
| 29 | /** struct dccp_ackvec - ack vector |
| 30 | * |
Gerrit Renker | 0e64e94 | 2006-10-24 16:17:51 -0700 | [diff] [blame] | 31 | * 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] | 32 | * |
| 33 | * @dccpav_buf_head - circular buffer head |
| 34 | * @dccpav_buf_tail - circular buffer tail |
| 35 | * @dccpav_buf_ackno - ack # of the most recent packet acknowledgeable in the |
| 36 | * buffer (i.e. %dccpav_buf_head) |
| 37 | * @dccpav_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked |
| 38 | * by the buffer with State 0 |
| 39 | * |
| 40 | * Additionally, the HC-Receiver must keep some information about the |
| 41 | * Ack Vectors it has recently sent. For each packet sent carrying an |
| 42 | * Ack Vector, it remembers four variables: |
| 43 | * |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 44 | * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement. |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 45 | * @dccpav_records - list of dccp_ackvec_record |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 46 | * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. |
| 47 | * |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 48 | * @dccpav_time - the time in usecs |
| 49 | * @dccpav_buf - circular buffer of acknowledgeable packets |
| 50 | */ |
| 51 | struct dccp_ackvec { |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 52 | u64 dccpav_buf_ackno; |
Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 53 | struct list_head dccpav_records; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 54 | struct timeval dccpav_time; |
Arnaldo Carvalho de Melo | e4dfd449 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 55 | u8 dccpav_buf_head; |
Arnaldo Carvalho de Melo | e4dfd449 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 56 | u8 dccpav_ack_ptr; |
Arnaldo Carvalho de Melo | e4dfd449 | 2006-01-04 01:46:34 -0200 | [diff] [blame] | 57 | u8 dccpav_vec_len; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 58 | u8 dccpav_buf_nonce; |
| 59 | u8 dccpav_ack_nonce; |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 60 | u8 dccpav_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 | * |
| 67 | * The list is sorted by dccpavr_ack_seqno |
| 68 | * |
| 69 | * @dccpavr_node - node in dccpav_records |
| 70 | * @dccpavr_ack_seqno - sequence number of the packet this record was sent on |
| 71 | * @dccpavr_ack_ackno - sequence number being acknowledged |
| 72 | * @dccpavr_ack_ptr - pointer into dccpav_buf where this record starts |
| 73 | * @dccpavr_ack_nonce - dccpav_ack_nonce at the time this record was sent |
| 74 | * @dccpavr_sent_len - lenght of the record in dccpav_buf |
| 75 | */ |
| 76 | struct dccp_ackvec_record { |
| 77 | struct list_head dccpavr_node; |
| 78 | u64 dccpavr_ack_seqno; |
| 79 | u64 dccpavr_ack_ackno; |
| 80 | u8 dccpavr_ack_ptr; |
| 81 | u8 dccpavr_ack_nonce; |
| 82 | u8 dccpavr_sent_len; |
| 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, |
| 101 | const u8 opt, const u8 *value, const u8 len); |
| 102 | |
| 103 | extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); |
| 104 | |
| 105 | static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) |
| 106 | { |
Andrea Bittau | 4a0a50fb4 | 2006-09-19 13:06:16 -0700 | [diff] [blame] | 107 | return av->dccpav_vec_len; |
Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 108 | } |
| 109 | #else /* CONFIG_IP_DCCP_ACKVEC */ |
Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame] | 110 | static inline int dccp_ackvec_init(void) |
| 111 | { |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | static inline void dccp_ackvec_exit(void) |
| 116 | { |
| 117 | } |
| 118 | |
Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 119 | 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] | 120 | { |
| 121 | return NULL; |
| 122 | } |
| 123 | |
| 124 | static inline void dccp_ackvec_free(struct dccp_ackvec *av) |
| 125 | { |
| 126 | } |
| 127 | |
| 128 | static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, |
| 129 | const u64 ackno, const u8 state) |
| 130 | { |
| 131 | return -1; |
| 132 | } |
| 133 | |
| 134 | static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, |
| 135 | struct sock *sk, const u64 ackno) |
| 136 | { |
| 137 | } |
| 138 | |
| 139 | static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, |
| 140 | const u8 opt, const u8 *value, const u8 len) |
| 141 | { |
| 142 | return -1; |
| 143 | } |
| 144 | |
| 145 | static inline int dccp_insert_option_ackvec(const struct sock *sk, |
| 146 | const struct sk_buff *skb) |
| 147 | { |
| 148 | return -1; |
| 149 | } |
| 150 | |
| 151 | static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) |
| 152 | { |
| 153 | return 0; |
| 154 | } |
| 155 | #endif /* CONFIG_IP_DCCP_ACKVEC */ |
| 156 | #endif /* _ACKVEC_H */ |