]>
Commit | Line | Data |
---|---|---|
ae31c339 ACM |
1 | #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 <[email protected]> | |
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 | ||
b20a9c24 | 14 | #include <linux/dccp.h> |
ae31c339 | 15 | #include <linux/compiler.h> |
b8bda9d7 | 16 | #include <linux/ktime.h> |
02bcf28c | 17 | #include <linux/list.h> |
ae31c339 ACM |
18 | #include <linux/types.h> |
19 | ||
bdf13d20 | 20 | /* We can spread an ack vector across multiple options */ |
b20a9c24 | 21 | #define DCCP_MAX_ACKVEC_LEN (DCCP_SINGLE_OPT_MAXLEN * 2) |
ae31c339 | 22 | |
361a5c1d GR |
23 | /* Estimated minimum average Ack Vector length - used for updating MPS */ |
24 | #define DCCPAV_MIN_OPTLEN 16 | |
25 | ||
ae31c339 ACM |
26 | #define DCCP_ACKVEC_STATE_RECEIVED 0 |
27 | #define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6) | |
28 | #define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6) | |
29 | ||
30 | #define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */ | |
31 | #define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */ | |
32 | ||
33 | /** struct dccp_ackvec - ack vector | |
34 | * | |
0e64e94e | 35 | * This data structure is the one defined in RFC 4340, Appendix A. |
ae31c339 | 36 | * |
a47c5104 GR |
37 | * @av_buf_head - circular buffer head |
38 | * @av_buf_tail - circular buffer tail | |
39 | * @av_buf_ackno - ack # of the most recent packet acknowledgeable in the | |
40 | * buffer (i.e. %av_buf_head) | |
41 | * @av_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked | |
ae31c339 ACM |
42 | * by the buffer with State 0 |
43 | * | |
44 | * Additionally, the HC-Receiver must keep some information about the | |
45 | * Ack Vectors it has recently sent. For each packet sent carrying an | |
46 | * Ack Vector, it remembers four variables: | |
47 | * | |
a47c5104 GR |
48 | * @av_records - list of dccp_ackvec_record |
49 | * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. | |
ae31c339 | 50 | * |
a47c5104 GR |
51 | * @av_time - the time in usecs |
52 | * @av_buf - circular buffer of acknowledgeable packets | |
ae31c339 ACM |
53 | */ |
54 | struct dccp_ackvec { | |
a47c5104 GR |
55 | u64 av_buf_ackno; |
56 | struct list_head av_records; | |
57 | ktime_t av_time; | |
58 | u16 av_buf_head; | |
59 | u16 av_vec_len; | |
60 | u8 av_buf_nonce; | |
61 | u8 av_ack_nonce; | |
62 | u8 av_buf[DCCP_MAX_ACKVEC_LEN]; | |
ae31c339 ACM |
63 | }; |
64 | ||
02bcf28c AB |
65 | /** struct dccp_ackvec_record - ack vector record |
66 | * | |
67 | * ACK vector record as defined in Appendix A of spec. | |
68 | * | |
a47c5104 | 69 | * The list is sorted by avr_ack_seqno |
02bcf28c | 70 | * |
a47c5104 GR |
71 | * @avr_node - node in av_records |
72 | * @avr_ack_seqno - sequence number of the packet this record was sent on | |
73 | * @avr_ack_ackno - sequence number being acknowledged | |
74 | * @avr_ack_ptr - pointer into av_buf where this record starts | |
75 | * @avr_ack_nonce - av_ack_nonce at the time this record was sent | |
76 | * @avr_sent_len - lenght of the record in av_buf | |
02bcf28c AB |
77 | */ |
78 | struct dccp_ackvec_record { | |
a47c5104 GR |
79 | struct list_head avr_node; |
80 | u64 avr_ack_seqno; | |
81 | u64 avr_ack_ackno; | |
82 | u16 avr_ack_ptr; | |
83 | u16 avr_sent_len; | |
84 | u8 avr_ack_nonce; | |
02bcf28c AB |
85 | }; |
86 | ||
ae31c339 ACM |
87 | struct sock; |
88 | struct sk_buff; | |
89 | ||
9b07ef5d ACM |
90 | extern int dccp_ackvec_init(void); |
91 | extern void dccp_ackvec_exit(void); | |
92 | ||
7400d781 | 93 | extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); |
ae31c339 ACM |
94 | extern void dccp_ackvec_free(struct dccp_ackvec *av); |
95 | ||
96 | extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, | |
97 | const u64 ackno, const u8 state); | |
98 | ||
99 | extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, | |
100 | struct sock *sk, const u64 ackno); | |
101 | extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, | |
bdf13d20 AB |
102 | u64 *ackno, const u8 opt, |
103 | const u8 *value, const u8 len); | |
ae31c339 ACM |
104 | |
105 | extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); | |
106 | ||
107 | static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) | |
108 | { | |
a47c5104 | 109 | return av->av_vec_len; |
ae31c339 | 110 | } |
ae31c339 | 111 | #endif /* _ACKVEC_H */ |