blob: 2424effac7f690d4c7679f18c70c9cb14ee71ea6 [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
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070014#include <linux/compiler.h>
Andrea Bittau02bcf282006-03-20 17:19:55 -080015#include <linux/list.h>
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070016#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 *
31 * This data structure is the one defined in the DCCP draft
32 * Appendix A.
33 *
34 * @dccpav_buf_head - circular buffer head
35 * @dccpav_buf_tail - circular buffer tail
36 * @dccpav_buf_ackno - ack # of the most recent packet acknowledgeable in the
37 * buffer (i.e. %dccpav_buf_head)
38 * @dccpav_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
39 * by the buffer with State 0
40 *
41 * Additionally, the HC-Receiver must keep some information about the
42 * Ack Vectors it has recently sent. For each packet sent carrying an
43 * Ack Vector, it remembers four variables:
44 *
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070045 * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
Andrea Bittau02bcf282006-03-20 17:19:55 -080046 * @dccpav_records - list of dccp_ackvec_record
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070047 * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
48 *
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070049 * @dccpav_time - the time in usecs
50 * @dccpav_buf - circular buffer of acknowledgeable packets
51 */
52struct dccp_ackvec {
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070053 u64 dccpav_buf_ackno;
Andrea Bittau02bcf282006-03-20 17:19:55 -080054 struct list_head dccpav_records;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070055 struct timeval dccpav_time;
Arnaldo Carvalho de Meloe4dfd442006-01-04 01:46:34 -020056 u8 dccpav_buf_head;
Arnaldo Carvalho de Meloe4dfd442006-01-04 01:46:34 -020057 u8 dccpav_ack_ptr;
Arnaldo Carvalho de Meloe4dfd442006-01-04 01:46:34 -020058 u8 dccpav_vec_len;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070059 u8 dccpav_buf_nonce;
60 u8 dccpav_ack_nonce;
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080061 u8 dccpav_buf[DCCP_MAX_ACKVEC_LEN];
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070062};
63
Andrea Bittau02bcf282006-03-20 17:19:55 -080064/** struct dccp_ackvec_record - ack vector record
65 *
66 * ACK vector record as defined in Appendix A of spec.
67 *
68 * The list is sorted by dccpavr_ack_seqno
69 *
70 * @dccpavr_node - node in dccpav_records
71 * @dccpavr_ack_seqno - sequence number of the packet this record was sent on
72 * @dccpavr_ack_ackno - sequence number being acknowledged
73 * @dccpavr_ack_ptr - pointer into dccpav_buf where this record starts
74 * @dccpavr_ack_nonce - dccpav_ack_nonce at the time this record was sent
75 * @dccpavr_sent_len - lenght of the record in dccpav_buf
76 */
77struct dccp_ackvec_record {
78 struct list_head dccpavr_node;
79 u64 dccpavr_ack_seqno;
80 u64 dccpavr_ack_ackno;
81 u8 dccpavr_ack_ptr;
82 u8 dccpavr_ack_nonce;
83 u8 dccpavr_sent_len;
84};
85
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070086struct sock;
87struct sk_buff;
88
89#ifdef CONFIG_IP_DCCP_ACKVEC
Arnaldo Carvalho de Melo9b07ef52006-03-20 17:16:17 -080090extern int dccp_ackvec_init(void);
91extern void dccp_ackvec_exit(void);
92
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080093extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070094extern void dccp_ackvec_free(struct dccp_ackvec *av);
95
96extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
97 const u64 ackno, const u8 state);
98
99extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
100 struct sock *sk, const u64 ackno);
101extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
102 const u8 opt, const u8 *value, const u8 len);
103
104extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
105
106static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
107{
Andrea Bittau4a0a50fb42006-09-19 13:06:16 -0700108 return av->dccpav_vec_len;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700109}
110#else /* CONFIG_IP_DCCP_ACKVEC */
Arnaldo Carvalho de Melo9b07ef52006-03-20 17:16:17 -0800111static inline int dccp_ackvec_init(void)
112{
113 return 0;
114}
115
116static inline void dccp_ackvec_exit(void)
117{
118}
119
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -0800120static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700121{
122 return NULL;
123}
124
125static inline void dccp_ackvec_free(struct dccp_ackvec *av)
126{
127}
128
129static 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
135static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
136 struct sock *sk, const u64 ackno)
137{
138}
139
140static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
141 const u8 opt, const u8 *value, const u8 len)
142{
143 return -1;
144}
145
146static inline int dccp_insert_option_ackvec(const struct sock *sk,
147 const struct sk_buff *skb)
148{
149 return -1;
150}
151
152static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
153{
154 return 0;
155}
156#endif /* CONFIG_IP_DCCP_ACKVEC */
157#endif /* _ACKVEC_H */