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 14*b20a9c24SGerrit Renker #include <linux/dccp.h> 15ae31c339SArnaldo Carvalho de Melo #include <linux/compiler.h> 16b8bda9d7SArnaldo Carvalho de Melo #include <linux/ktime.h> 1702bcf28cSAndrea Bittau #include <linux/list.h> 18ae31c339SArnaldo Carvalho de Melo #include <linux/types.h> 19ae31c339SArnaldo Carvalho de Melo 20bdf13d20SAndrea Bittau /* We can spread an ack vector across multiple options */ 21*b20a9c24SGerrit Renker #define DCCP_MAX_ACKVEC_LEN (DCCP_SINGLE_OPT_MAXLEN * 2) 22ae31c339SArnaldo Carvalho de Melo 23ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_RECEIVED 0 24ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6) 25ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6) 26ae31c339SArnaldo Carvalho de Melo 27ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */ 28ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */ 29ae31c339SArnaldo Carvalho de Melo 30ae31c339SArnaldo Carvalho de Melo /** struct dccp_ackvec - ack vector 31ae31c339SArnaldo Carvalho de Melo * 320e64e94eSGerrit Renker * This data structure is the one defined in RFC 4340, Appendix A. 33ae31c339SArnaldo Carvalho de Melo * 34a47c5104SGerrit Renker * @av_buf_head - circular buffer head 35a47c5104SGerrit Renker * @av_buf_tail - circular buffer tail 36a47c5104SGerrit Renker * @av_buf_ackno - ack # of the most recent packet acknowledgeable in the 37a47c5104SGerrit Renker * buffer (i.e. %av_buf_head) 38a47c5104SGerrit Renker * @av_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 * 45a47c5104SGerrit Renker * @av_records - list of dccp_ackvec_record 46a47c5104SGerrit Renker * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. 47ae31c339SArnaldo Carvalho de Melo * 48a47c5104SGerrit Renker * @av_time - the time in usecs 49a47c5104SGerrit Renker * @av_buf - circular buffer of acknowledgeable packets 50ae31c339SArnaldo Carvalho de Melo */ 51ae31c339SArnaldo Carvalho de Melo struct dccp_ackvec { 52a47c5104SGerrit Renker u64 av_buf_ackno; 53a47c5104SGerrit Renker struct list_head av_records; 54a47c5104SGerrit Renker ktime_t av_time; 55a47c5104SGerrit Renker u16 av_buf_head; 56a47c5104SGerrit Renker u16 av_vec_len; 57a47c5104SGerrit Renker u8 av_buf_nonce; 58a47c5104SGerrit Renker u8 av_ack_nonce; 59a47c5104SGerrit Renker u8 av_buf[DCCP_MAX_ACKVEC_LEN]; 60ae31c339SArnaldo Carvalho de Melo }; 61ae31c339SArnaldo Carvalho de Melo 6202bcf28cSAndrea Bittau /** struct dccp_ackvec_record - ack vector record 6302bcf28cSAndrea Bittau * 6402bcf28cSAndrea Bittau * ACK vector record as defined in Appendix A of spec. 6502bcf28cSAndrea Bittau * 66a47c5104SGerrit Renker * The list is sorted by avr_ack_seqno 6702bcf28cSAndrea Bittau * 68a47c5104SGerrit Renker * @avr_node - node in av_records 69a47c5104SGerrit Renker * @avr_ack_seqno - sequence number of the packet this record was sent on 70a47c5104SGerrit Renker * @avr_ack_ackno - sequence number being acknowledged 71a47c5104SGerrit Renker * @avr_ack_ptr - pointer into av_buf where this record starts 72a47c5104SGerrit Renker * @avr_ack_nonce - av_ack_nonce at the time this record was sent 73a47c5104SGerrit Renker * @avr_sent_len - lenght of the record in av_buf 7402bcf28cSAndrea Bittau */ 7502bcf28cSAndrea Bittau struct dccp_ackvec_record { 76a47c5104SGerrit Renker struct list_head avr_node; 77a47c5104SGerrit Renker u64 avr_ack_seqno; 78a47c5104SGerrit Renker u64 avr_ack_ackno; 79a47c5104SGerrit Renker u16 avr_ack_ptr; 80a47c5104SGerrit Renker u16 avr_sent_len; 81a47c5104SGerrit Renker u8 avr_ack_nonce; 8202bcf28cSAndrea Bittau }; 8302bcf28cSAndrea Bittau 84ae31c339SArnaldo Carvalho de Melo struct sock; 85ae31c339SArnaldo Carvalho de Melo struct sk_buff; 86ae31c339SArnaldo Carvalho de Melo 87ae31c339SArnaldo Carvalho de Melo #ifdef CONFIG_IP_DCCP_ACKVEC 889b07ef5dSArnaldo Carvalho de Melo extern int dccp_ackvec_init(void); 899b07ef5dSArnaldo Carvalho de Melo extern void dccp_ackvec_exit(void); 909b07ef5dSArnaldo Carvalho de Melo 917400d781SArnaldo Carvalho de Melo extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); 92ae31c339SArnaldo Carvalho de Melo extern void dccp_ackvec_free(struct dccp_ackvec *av); 93ae31c339SArnaldo Carvalho de Melo 94ae31c339SArnaldo Carvalho de Melo extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, 95ae31c339SArnaldo Carvalho de Melo const u64 ackno, const u8 state); 96ae31c339SArnaldo Carvalho de Melo 97ae31c339SArnaldo Carvalho de Melo extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, 98ae31c339SArnaldo Carvalho de Melo struct sock *sk, const u64 ackno); 99ae31c339SArnaldo Carvalho de Melo extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 100bdf13d20SAndrea Bittau u64 *ackno, const u8 opt, 101bdf13d20SAndrea Bittau const u8 *value, const u8 len); 102ae31c339SArnaldo Carvalho de Melo 103ae31c339SArnaldo Carvalho de Melo extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); 104ae31c339SArnaldo Carvalho de Melo 105ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) 106ae31c339SArnaldo Carvalho de Melo { 107a47c5104SGerrit Renker return av->av_vec_len; 108ae31c339SArnaldo Carvalho de Melo } 109ae31c339SArnaldo Carvalho de Melo #else /* CONFIG_IP_DCCP_ACKVEC */ 1109b07ef5dSArnaldo Carvalho de Melo static inline int dccp_ackvec_init(void) 1119b07ef5dSArnaldo Carvalho de Melo { 1129b07ef5dSArnaldo Carvalho de Melo return 0; 1139b07ef5dSArnaldo Carvalho de Melo } 1149b07ef5dSArnaldo Carvalho de Melo 1159b07ef5dSArnaldo Carvalho de Melo static inline void dccp_ackvec_exit(void) 1169b07ef5dSArnaldo Carvalho de Melo { 1179b07ef5dSArnaldo Carvalho de Melo } 1189b07ef5dSArnaldo Carvalho de Melo 1197400d781SArnaldo Carvalho de Melo static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority) 120ae31c339SArnaldo Carvalho de Melo { 121ae31c339SArnaldo Carvalho de Melo return NULL; 122ae31c339SArnaldo Carvalho de Melo } 123ae31c339SArnaldo Carvalho de Melo 124ae31c339SArnaldo Carvalho de Melo static inline void dccp_ackvec_free(struct dccp_ackvec *av) 125ae31c339SArnaldo Carvalho de Melo { 126ae31c339SArnaldo Carvalho de Melo } 127ae31c339SArnaldo Carvalho de Melo 128ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, 129ae31c339SArnaldo Carvalho de Melo const u64 ackno, const u8 state) 130ae31c339SArnaldo Carvalho de Melo { 131ae31c339SArnaldo Carvalho de Melo return -1; 132ae31c339SArnaldo Carvalho de Melo } 133ae31c339SArnaldo Carvalho de Melo 134ae31c339SArnaldo Carvalho de Melo static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, 135ae31c339SArnaldo Carvalho de Melo struct sock *sk, const u64 ackno) 136ae31c339SArnaldo Carvalho de Melo { 137ae31c339SArnaldo Carvalho de Melo } 138ae31c339SArnaldo Carvalho de Melo 139ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 140bdf13d20SAndrea Bittau const u64 *ackno, const u8 opt, 141bdf13d20SAndrea Bittau const u8 *value, const u8 len) 142ae31c339SArnaldo Carvalho de Melo { 143ae31c339SArnaldo Carvalho de Melo return -1; 144ae31c339SArnaldo Carvalho de Melo } 145ae31c339SArnaldo Carvalho de Melo 146ae31c339SArnaldo Carvalho de Melo static inline int dccp_insert_option_ackvec(const struct sock *sk, 147ae31c339SArnaldo Carvalho de Melo const struct sk_buff *skb) 148ae31c339SArnaldo Carvalho de Melo { 149ae31c339SArnaldo Carvalho de Melo return -1; 150ae31c339SArnaldo Carvalho de Melo } 151ae31c339SArnaldo Carvalho de Melo 152ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) 153ae31c339SArnaldo Carvalho de Melo { 154ae31c339SArnaldo Carvalho de Melo return 0; 155ae31c339SArnaldo Carvalho de Melo } 156ae31c339SArnaldo Carvalho de Melo #endif /* CONFIG_IP_DCCP_ACKVEC */ 157ae31c339SArnaldo Carvalho de Melo #endif /* _ACKVEC_H */ 158