xref: /linux/net/dccp/ackvec.h (revision 9b07ef5ddaced1e822b1a1fb1da088eb15c45cb4)
1ae31c339SArnaldo Carvalho de Melo #ifndef _ACKVEC_H
2ae31c339SArnaldo Carvalho de Melo #define _ACKVEC_H
3ae31c339SArnaldo Carvalho de Melo /*
4ae31c339SArnaldo Carvalho de Melo  *  net/dccp/ackvec.h
5ae31c339SArnaldo Carvalho de Melo  *
6ae31c339SArnaldo Carvalho de Melo  *  An implementation of the DCCP protocol
7ae31c339SArnaldo Carvalho de Melo  *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@mandriva.com>
8ae31c339SArnaldo Carvalho de Melo  *
9ae31c339SArnaldo Carvalho de Melo  *	This program is free software; you can redistribute it and/or modify it
10ae31c339SArnaldo Carvalho de Melo  *	under the terms of the GNU General Public License version 2 as
11ae31c339SArnaldo Carvalho de Melo  *	published by the Free Software Foundation.
12ae31c339SArnaldo Carvalho de Melo  */
13ae31c339SArnaldo Carvalho de Melo 
14ae31c339SArnaldo Carvalho de Melo #include <linux/config.h>
15ae31c339SArnaldo Carvalho de Melo #include <linux/compiler.h>
16ae31c339SArnaldo Carvalho de Melo #include <linux/time.h>
17ae31c339SArnaldo Carvalho de Melo #include <linux/types.h>
18ae31c339SArnaldo Carvalho de Melo 
19ae31c339SArnaldo Carvalho de Melo /* Read about the ECN nonce to see why it is 253 */
20ae31c339SArnaldo Carvalho de Melo #define DCCP_MAX_ACKVEC_LEN 253
21ae31c339SArnaldo Carvalho de Melo 
22ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_RECEIVED	0
23ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_ECN_MARKED	(1 << 6)
24ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_NOT_RECEIVED	(3 << 6)
25ae31c339SArnaldo Carvalho de Melo 
26ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_MASK		0xC0 /* 11000000 */
27ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_LEN_MASK		0x3F /* 00111111 */
28ae31c339SArnaldo Carvalho de Melo 
29ae31c339SArnaldo Carvalho de Melo /** struct dccp_ackvec - ack vector
30ae31c339SArnaldo Carvalho de Melo  *
31ae31c339SArnaldo Carvalho de Melo  * This data structure is the one defined in the DCCP draft
32ae31c339SArnaldo Carvalho de Melo  * Appendix A.
33ae31c339SArnaldo Carvalho de Melo  *
34ae31c339SArnaldo Carvalho de Melo  * @dccpav_buf_head - circular buffer head
35ae31c339SArnaldo Carvalho de Melo  * @dccpav_buf_tail - circular buffer tail
36ae31c339SArnaldo Carvalho de Melo  * @dccpav_buf_ackno - ack # of the most recent packet acknowledgeable in the
37ae31c339SArnaldo Carvalho de Melo  * 		       buffer (i.e. %dccpav_buf_head)
38ae31c339SArnaldo Carvalho de Melo  * @dccpav_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
39ae31c339SArnaldo Carvalho de Melo  * 		       by the buffer with State 0
40ae31c339SArnaldo Carvalho de Melo  *
41ae31c339SArnaldo Carvalho de Melo  * Additionally, the HC-Receiver must keep some information about the
42ae31c339SArnaldo Carvalho de Melo  * Ack Vectors it has recently sent. For each packet sent carrying an
43ae31c339SArnaldo Carvalho de Melo  * Ack Vector, it remembers four variables:
44ae31c339SArnaldo Carvalho de Melo  *
45ae31c339SArnaldo Carvalho de Melo  * @dccpav_ack_seqno - the Sequence Number used for the packet
46ae31c339SArnaldo Carvalho de Melo  * 		       (HC-Receiver seqno)
47ae31c339SArnaldo Carvalho de Melo  * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
48ae31c339SArnaldo Carvalho de Melo  * @dccpav_ack_ackno - the Acknowledgement Number used for the packet
49ae31c339SArnaldo Carvalho de Melo  * 		       (HC-Sender seqno)
50ae31c339SArnaldo Carvalho de Melo  * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
51ae31c339SArnaldo Carvalho de Melo  *
52ae31c339SArnaldo Carvalho de Melo  * @dccpav_time		- the time in usecs
53ae31c339SArnaldo Carvalho de Melo  * @dccpav_buf - circular buffer of acknowledgeable packets
54ae31c339SArnaldo Carvalho de Melo  */
55ae31c339SArnaldo Carvalho de Melo struct dccp_ackvec {
56ae31c339SArnaldo Carvalho de Melo 	u64		dccpav_buf_ackno;
57ae31c339SArnaldo Carvalho de Melo 	u64		dccpav_ack_seqno;
58ae31c339SArnaldo Carvalho de Melo 	u64		dccpav_ack_ackno;
59ae31c339SArnaldo Carvalho de Melo 	struct timeval	dccpav_time;
60e4dfd449SArnaldo Carvalho de Melo 	u8		dccpav_buf_head;
61e4dfd449SArnaldo Carvalho de Melo 	u8		dccpav_buf_tail;
62e4dfd449SArnaldo Carvalho de Melo 	u8		dccpav_ack_ptr;
63e4dfd449SArnaldo Carvalho de Melo 	u8		dccpav_sent_len;
64e4dfd449SArnaldo Carvalho de Melo 	u8		dccpav_vec_len;
65ae31c339SArnaldo Carvalho de Melo 	u8		dccpav_buf_nonce;
66ae31c339SArnaldo Carvalho de Melo 	u8		dccpav_ack_nonce;
677400d781SArnaldo Carvalho de Melo 	u8		dccpav_buf[DCCP_MAX_ACKVEC_LEN];
68ae31c339SArnaldo Carvalho de Melo };
69ae31c339SArnaldo Carvalho de Melo 
70ae31c339SArnaldo Carvalho de Melo struct sock;
71ae31c339SArnaldo Carvalho de Melo struct sk_buff;
72ae31c339SArnaldo Carvalho de Melo 
73ae31c339SArnaldo Carvalho de Melo #ifdef CONFIG_IP_DCCP_ACKVEC
74*9b07ef5dSArnaldo Carvalho de Melo extern int dccp_ackvec_init(void);
75*9b07ef5dSArnaldo Carvalho de Melo extern void dccp_ackvec_exit(void);
76*9b07ef5dSArnaldo Carvalho de Melo 
777400d781SArnaldo Carvalho de Melo extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
78ae31c339SArnaldo Carvalho de Melo extern void dccp_ackvec_free(struct dccp_ackvec *av);
79ae31c339SArnaldo Carvalho de Melo 
80ae31c339SArnaldo Carvalho de Melo extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
81ae31c339SArnaldo Carvalho de Melo 			   const u64 ackno, const u8 state);
82ae31c339SArnaldo Carvalho de Melo 
83ae31c339SArnaldo Carvalho de Melo extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
84ae31c339SArnaldo Carvalho de Melo 					struct sock *sk, const u64 ackno);
85ae31c339SArnaldo Carvalho de Melo extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
86ae31c339SArnaldo Carvalho de Melo 			     const u8 opt, const u8 *value, const u8 len);
87ae31c339SArnaldo Carvalho de Melo 
88ae31c339SArnaldo Carvalho de Melo extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
89ae31c339SArnaldo Carvalho de Melo 
90ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
91ae31c339SArnaldo Carvalho de Melo {
92ae31c339SArnaldo Carvalho de Melo 	return av->dccpav_sent_len != av->dccpav_vec_len;
93ae31c339SArnaldo Carvalho de Melo }
94ae31c339SArnaldo Carvalho de Melo #else /* CONFIG_IP_DCCP_ACKVEC */
95*9b07ef5dSArnaldo Carvalho de Melo static inline int dccp_ackvec_init(void)
96*9b07ef5dSArnaldo Carvalho de Melo {
97*9b07ef5dSArnaldo Carvalho de Melo 	return 0;
98*9b07ef5dSArnaldo Carvalho de Melo }
99*9b07ef5dSArnaldo Carvalho de Melo 
100*9b07ef5dSArnaldo Carvalho de Melo static inline void dccp_ackvec_exit(void)
101*9b07ef5dSArnaldo Carvalho de Melo {
102*9b07ef5dSArnaldo Carvalho de Melo }
103*9b07ef5dSArnaldo Carvalho de Melo 
1047400d781SArnaldo Carvalho de Melo static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
105ae31c339SArnaldo Carvalho de Melo {
106ae31c339SArnaldo Carvalho de Melo 	return NULL;
107ae31c339SArnaldo Carvalho de Melo }
108ae31c339SArnaldo Carvalho de Melo 
109ae31c339SArnaldo Carvalho de Melo static inline void dccp_ackvec_free(struct dccp_ackvec *av)
110ae31c339SArnaldo Carvalho de Melo {
111ae31c339SArnaldo Carvalho de Melo }
112ae31c339SArnaldo Carvalho de Melo 
113ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
114ae31c339SArnaldo Carvalho de Melo 				  const u64 ackno, const u8 state)
115ae31c339SArnaldo Carvalho de Melo {
116ae31c339SArnaldo Carvalho de Melo 	return -1;
117ae31c339SArnaldo Carvalho de Melo }
118ae31c339SArnaldo Carvalho de Melo 
119ae31c339SArnaldo Carvalho de Melo static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
120ae31c339SArnaldo Carvalho de Melo 					       struct sock *sk, const u64 ackno)
121ae31c339SArnaldo Carvalho de Melo {
122ae31c339SArnaldo Carvalho de Melo }
123ae31c339SArnaldo Carvalho de Melo 
124ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
125ae31c339SArnaldo Carvalho de Melo 				    const u8 opt, const u8 *value, const u8 len)
126ae31c339SArnaldo Carvalho de Melo {
127ae31c339SArnaldo Carvalho de Melo 	return -1;
128ae31c339SArnaldo Carvalho de Melo }
129ae31c339SArnaldo Carvalho de Melo 
130ae31c339SArnaldo Carvalho de Melo static inline int dccp_insert_option_ackvec(const struct sock *sk,
131ae31c339SArnaldo Carvalho de Melo 					    const struct sk_buff *skb)
132ae31c339SArnaldo Carvalho de Melo {
133ae31c339SArnaldo Carvalho de Melo 	return -1;
134ae31c339SArnaldo Carvalho de Melo }
135ae31c339SArnaldo Carvalho de Melo 
136ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
137ae31c339SArnaldo Carvalho de Melo {
138ae31c339SArnaldo Carvalho de Melo 	return 0;
139ae31c339SArnaldo Carvalho de Melo }
140ae31c339SArnaldo Carvalho de Melo #endif /* CONFIG_IP_DCCP_ACKVEC */
141ae31c339SArnaldo Carvalho de Melo #endif /* _ACKVEC_H */
142