blob: 4ccee030524e403abac5cec98e340307937021b1 [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
Gerrit Renkerb20a9c22008-11-23 16:02:31 -080014#include <linux/dccp.h>
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070015#include <linux/compiler.h>
Arnaldo Carvalho de Melob8bda9d2007-08-19 17:17:25 -070016#include <linux/ktime.h>
Andrea Bittau02bcf282006-03-20 17:19:55 -080017#include <linux/list.h>
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070018#include <linux/types.h>
19
Andrea Bittaubdf13d22006-11-24 13:02:42 -020020/* We can spread an ack vector across multiple options */
Gerrit Renkerb20a9c22008-11-23 16:02:31 -080021#define DCCP_MAX_ACKVEC_LEN (DCCP_SINGLE_OPT_MAXLEN * 2)
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070022
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 *
Gerrit Renker0e64e942006-10-24 16:17:51 -070032 * This data structure is the one defined in RFC 4340, Appendix A.
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070033 *
Gerrit Renkera47c5102007-12-30 04:19:31 -080034 * @av_buf_head - circular buffer head
35 * @av_buf_tail - circular buffer tail
36 * @av_buf_ackno - ack # of the most recent packet acknowledgeable in the
37 * buffer (i.e. %av_buf_head)
38 * @av_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070039 * 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 *
Gerrit Renkera47c5102007-12-30 04:19:31 -080045 * @av_records - list of dccp_ackvec_record
46 * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070047 *
Gerrit Renkera47c5102007-12-30 04:19:31 -080048 * @av_time - the time in usecs
49 * @av_buf - circular buffer of acknowledgeable packets
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070050 */
51struct dccp_ackvec {
Gerrit Renkera47c5102007-12-30 04:19:31 -080052 u64 av_buf_ackno;
53 struct list_head av_records;
54 ktime_t av_time;
55 u16 av_buf_head;
56 u16 av_vec_len;
57 u8 av_buf_nonce;
58 u8 av_ack_nonce;
59 u8 av_buf[DCCP_MAX_ACKVEC_LEN];
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070060};
61
Andrea Bittau02bcf282006-03-20 17:19:55 -080062/** struct dccp_ackvec_record - ack vector record
63 *
64 * ACK vector record as defined in Appendix A of spec.
65 *
Gerrit Renkera47c5102007-12-30 04:19:31 -080066 * The list is sorted by avr_ack_seqno
Andrea Bittau02bcf282006-03-20 17:19:55 -080067 *
Gerrit Renkera47c5102007-12-30 04:19:31 -080068 * @avr_node - node in av_records
69 * @avr_ack_seqno - sequence number of the packet this record was sent on
70 * @avr_ack_ackno - sequence number being acknowledged
71 * @avr_ack_ptr - pointer into av_buf where this record starts
72 * @avr_ack_nonce - av_ack_nonce at the time this record was sent
73 * @avr_sent_len - lenght of the record in av_buf
Andrea Bittau02bcf282006-03-20 17:19:55 -080074 */
75struct dccp_ackvec_record {
Gerrit Renkera47c5102007-12-30 04:19:31 -080076 struct list_head avr_node;
77 u64 avr_ack_seqno;
78 u64 avr_ack_ackno;
79 u16 avr_ack_ptr;
80 u16 avr_sent_len;
81 u8 avr_ack_nonce;
Andrea Bittau02bcf282006-03-20 17:19:55 -080082};
83
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070084struct sock;
85struct sk_buff;
86
87#ifdef CONFIG_IP_DCCP_ACKVEC
Arnaldo Carvalho de Melo9b07ef52006-03-20 17:16:17 -080088extern int dccp_ackvec_init(void);
89extern void dccp_ackvec_exit(void);
90
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -080091extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -070092extern void dccp_ackvec_free(struct dccp_ackvec *av);
93
94extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
95 const u64 ackno, const u8 state);
96
97extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
98 struct sock *sk, const u64 ackno);
99extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
Andrea Bittaubdf13d22006-11-24 13:02:42 -0200100 u64 *ackno, const u8 opt,
101 const u8 *value, const u8 len);
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700102
103extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
104
105static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
106{
Gerrit Renkera47c5102007-12-30 04:19:31 -0800107 return av->av_vec_len;
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700108}
109#else /* CONFIG_IP_DCCP_ACKVEC */
Arnaldo Carvalho de Melo9b07ef52006-03-20 17:16:17 -0800110static inline int dccp_ackvec_init(void)
111{
112 return 0;
113}
114
115static inline void dccp_ackvec_exit(void)
116{
117}
118
Arnaldo Carvalho de Melo7400d782006-03-20 17:15:42 -0800119static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700120{
121 return NULL;
122}
123
124static inline void dccp_ackvec_free(struct dccp_ackvec *av)
125{
126}
127
128static 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
134static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
135 struct sock *sk, const u64 ackno)
136{
137}
138
139static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
Andrea Bittaubdf13d22006-11-24 13:02:42 -0200140 const u64 *ackno, const u8 opt,
141 const u8 *value, const u8 len)
Arnaldo Carvalho de Meloae31c332005-09-18 00:17:51 -0700142{
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 */