blob: ec7a89bb7b396ceaeaac47c2714b00fe05848318 [file] [log] [blame]
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -07001#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
14#include <linux/config.h>
15#include <linux/compiler.h>
Andrea Bittau02bcf282006-03-20 17:19:55 -080016#include <linux/list.h>
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070017#include <linux/time.h>
18#include <linux/types.h>
19
20/* Read about the ECN nonce to see why it is 253 */
21#define DCCP_MAX_ACKVEC_LEN 253
22
23#define DCCP_ACKVEC_STATE_RECEIVED 0
24#define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6)
25#define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6)
26
27#define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */
28#define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */
29
30/** struct dccp_ackvec - ack vector
31 *
32 * This data structure is the one defined in the DCCP draft
33 * Appendix A.
34 *
35 * @dccpav_buf_head - circular buffer head
36 * @dccpav_buf_tail - circular buffer tail
37 * @dccpav_buf_ackno - ack # of the most recent packet acknowledgeable in the
38 * buffer (i.e. %dccpav_buf_head)
39 * @dccpav_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
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 *
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070046 * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
Andrea Bittau02bcf282006-03-20 17:19:55 -080047 * @dccpav_records - list of dccp_ackvec_record
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070048 * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
49 *
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070050 * @dccpav_time - the time in usecs
51 * @dccpav_buf - circular buffer of acknowledgeable packets
52 */
53struct dccp_ackvec {
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070054 u64 dccpav_buf_ackno;
Andrea Bittau02bcf282006-03-20 17:19:55 -080055 struct list_head dccpav_records;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070056 struct timeval dccpav_time;
Arnaldo Carvalho de Meloe4dfd4492006-01-04 01:46:34 -020057 u8 dccpav_buf_head;
58 u8 dccpav_buf_tail;
59 u8 dccpav_ack_ptr;
60 u8 dccpav_sent_len;
61 u8 dccpav_vec_len;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070062 u8 dccpav_buf_nonce;
63 u8 dccpav_ack_nonce;
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080064 u8 dccpav_buf[DCCP_MAX_ACKVEC_LEN];
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070065};
66
Andrea Bittau02bcf282006-03-20 17:19:55 -080067/** struct dccp_ackvec_record - ack vector record
68 *
69 * ACK vector record as defined in Appendix A of spec.
70 *
71 * The list is sorted by dccpavr_ack_seqno
72 *
73 * @dccpavr_node - node in dccpav_records
74 * @dccpavr_ack_seqno - sequence number of the packet this record was sent on
75 * @dccpavr_ack_ackno - sequence number being acknowledged
76 * @dccpavr_ack_ptr - pointer into dccpav_buf where this record starts
77 * @dccpavr_ack_nonce - dccpav_ack_nonce at the time this record was sent
78 * @dccpavr_sent_len - lenght of the record in dccpav_buf
79 */
80struct dccp_ackvec_record {
81 struct list_head dccpavr_node;
82 u64 dccpavr_ack_seqno;
83 u64 dccpavr_ack_ackno;
84 u8 dccpavr_ack_ptr;
85 u8 dccpavr_ack_nonce;
86 u8 dccpavr_sent_len;
87};
88
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070089struct sock;
90struct sk_buff;
91
92#ifdef CONFIG_IP_DCCP_ACKVEC
Arnaldo Carvalho de Melo9b07ef52006-03-20 17:16:17 -080093extern int dccp_ackvec_init(void);
94extern void dccp_ackvec_exit(void);
95
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080096extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070097extern void dccp_ackvec_free(struct dccp_ackvec *av);
98
99extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
100 const u64 ackno, const u8 state);
101
102extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
103 struct sock *sk, const u64 ackno);
104extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
105 const u8 opt, const u8 *value, const u8 len);
106
107extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
108
109static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
110{
111 return av->dccpav_sent_len != av->dccpav_vec_len;
112}
113#else /* CONFIG_IP_DCCP_ACKVEC */
Arnaldo Carvalho de Melo9b07ef52006-03-20 17:16:17 -0800114static inline int dccp_ackvec_init(void)
115{
116 return 0;
117}
118
119static inline void dccp_ackvec_exit(void)
120{
121}
122
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -0800123static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700124{
125 return NULL;
126}
127
128static inline void dccp_ackvec_free(struct dccp_ackvec *av)
129{
130}
131
132static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
133 const u64 ackno, const u8 state)
134{
135 return -1;
136}
137
138static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
139 struct sock *sk, const u64 ackno)
140{
141}
142
143static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
144 const u8 opt, const u8 *value, const u8 len)
145{
146 return -1;
147}
148
149static inline int dccp_insert_option_ackvec(const struct sock *sk,
150 const struct sk_buff *skb)
151{
152 return -1;
153}
154
155static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
156{
157 return 0;
158}
159#endif /* CONFIG_IP_DCCP_ACKVEC */
160#endif /* _ACKVEC_H */