blob: f083daf4200c38980ec580181737f0467671f502 [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>
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 *
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 *
45 * @dccpav_ack_seqno - the Sequence Number used for the packet
46 * (HC-Receiver seqno)
47 * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
48 * @dccpav_ack_ackno - the Acknowledgement Number used for the packet
49 * (HC-Sender seqno)
50 * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
51 *
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070052 * @dccpav_time - the time in usecs
53 * @dccpav_buf - circular buffer of acknowledgeable packets
54 */
55struct dccp_ackvec {
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070056 u64 dccpav_buf_ackno;
57 u64 dccpav_ack_seqno;
58 u64 dccpav_ack_ackno;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070059 struct timeval dccpav_time;
Arnaldo Carvalho de Meloe4dfd4492006-01-04 01:46:34 -020060 u8 dccpav_buf_head;
61 u8 dccpav_buf_tail;
62 u8 dccpav_ack_ptr;
63 u8 dccpav_sent_len;
64 u8 dccpav_vec_len;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070065 u8 dccpav_buf_nonce;
66 u8 dccpav_ack_nonce;
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080067 u8 dccpav_buf[DCCP_MAX_ACKVEC_LEN];
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070068};
69
70struct sock;
71struct sk_buff;
72
73#ifdef CONFIG_IP_DCCP_ACKVEC
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080074extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070075extern void dccp_ackvec_free(struct dccp_ackvec *av);
76
77extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
78 const u64 ackno, const u8 state);
79
80extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
81 struct sock *sk, const u64 ackno);
82extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
83 const u8 opt, const u8 *value, const u8 len);
84
85extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
86
87static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
88{
89 return av->dccpav_sent_len != av->dccpav_vec_len;
90}
91#else /* CONFIG_IP_DCCP_ACKVEC */
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080092static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070093{
94 return NULL;
95}
96
97static inline void dccp_ackvec_free(struct dccp_ackvec *av)
98{
99}
100
101static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
102 const u64 ackno, const u8 state)
103{
104 return -1;
105}
106
107static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
108 struct sock *sk, const u64 ackno)
109{
110}
111
112static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
113 const u8 opt, const u8 *value, const u8 len)
114{
115 return -1;
116}
117
118static inline int dccp_insert_option_ackvec(const struct sock *sk,
119 const struct sk_buff *skb)
120{
121 return -1;
122}
123
124static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
125{
126 return 0;
127}
128#endif /* CONFIG_IP_DCCP_ACKVEC */
129#endif /* _ACKVEC_H */