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 14b20a9c24SGerrit 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 */ 21b20a9c24SGerrit Renker #define DCCP_MAX_ACKVEC_LEN (DCCP_SINGLE_OPT_MAXLEN * 2) 22ae31c339SArnaldo Carvalho de Melo 23*361a5c1dSGerrit Renker /* Estimated minimum average Ack Vector length - used for updating MPS */ 24*361a5c1dSGerrit Renker #define DCCPAV_MIN_OPTLEN 16 25*361a5c1dSGerrit Renker 26ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_RECEIVED 0 27ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6) 28ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6) 29ae31c339SArnaldo Carvalho de Melo 30ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */ 31ae31c339SArnaldo Carvalho de Melo #define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */ 32ae31c339SArnaldo Carvalho de Melo 33ae31c339SArnaldo Carvalho de Melo /** struct dccp_ackvec - ack vector 34ae31c339SArnaldo Carvalho de Melo * 350e64e94eSGerrit Renker * This data structure is the one defined in RFC 4340, Appendix A. 36ae31c339SArnaldo Carvalho de Melo * 37a47c5104SGerrit Renker * @av_buf_head - circular buffer head 38a47c5104SGerrit Renker * @av_buf_tail - circular buffer tail 39a47c5104SGerrit Renker * @av_buf_ackno - ack # of the most recent packet acknowledgeable in the 40a47c5104SGerrit Renker * buffer (i.e. %av_buf_head) 41a47c5104SGerrit Renker * @av_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked 42ae31c339SArnaldo Carvalho de Melo * by the buffer with State 0 43ae31c339SArnaldo Carvalho de Melo * 44ae31c339SArnaldo Carvalho de Melo * Additionally, the HC-Receiver must keep some information about the 45ae31c339SArnaldo Carvalho de Melo * Ack Vectors it has recently sent. For each packet sent carrying an 46ae31c339SArnaldo Carvalho de Melo * Ack Vector, it remembers four variables: 47ae31c339SArnaldo Carvalho de Melo * 48a47c5104SGerrit Renker * @av_records - list of dccp_ackvec_record 49a47c5104SGerrit Renker * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. 50ae31c339SArnaldo Carvalho de Melo * 51a47c5104SGerrit Renker * @av_time - the time in usecs 52a47c5104SGerrit Renker * @av_buf - circular buffer of acknowledgeable packets 53ae31c339SArnaldo Carvalho de Melo */ 54ae31c339SArnaldo Carvalho de Melo struct dccp_ackvec { 55a47c5104SGerrit Renker u64 av_buf_ackno; 56a47c5104SGerrit Renker struct list_head av_records; 57a47c5104SGerrit Renker ktime_t av_time; 58a47c5104SGerrit Renker u16 av_buf_head; 59a47c5104SGerrit Renker u16 av_vec_len; 60a47c5104SGerrit Renker u8 av_buf_nonce; 61a47c5104SGerrit Renker u8 av_ack_nonce; 62a47c5104SGerrit Renker u8 av_buf[DCCP_MAX_ACKVEC_LEN]; 63ae31c339SArnaldo Carvalho de Melo }; 64ae31c339SArnaldo Carvalho de Melo 6502bcf28cSAndrea Bittau /** struct dccp_ackvec_record - ack vector record 6602bcf28cSAndrea Bittau * 6702bcf28cSAndrea Bittau * ACK vector record as defined in Appendix A of spec. 6802bcf28cSAndrea Bittau * 69a47c5104SGerrit Renker * The list is sorted by avr_ack_seqno 7002bcf28cSAndrea Bittau * 71a47c5104SGerrit Renker * @avr_node - node in av_records 72a47c5104SGerrit Renker * @avr_ack_seqno - sequence number of the packet this record was sent on 73a47c5104SGerrit Renker * @avr_ack_ackno - sequence number being acknowledged 74a47c5104SGerrit Renker * @avr_ack_ptr - pointer into av_buf where this record starts 75a47c5104SGerrit Renker * @avr_ack_nonce - av_ack_nonce at the time this record was sent 76a47c5104SGerrit Renker * @avr_sent_len - lenght of the record in av_buf 7702bcf28cSAndrea Bittau */ 7802bcf28cSAndrea Bittau struct dccp_ackvec_record { 79a47c5104SGerrit Renker struct list_head avr_node; 80a47c5104SGerrit Renker u64 avr_ack_seqno; 81a47c5104SGerrit Renker u64 avr_ack_ackno; 82a47c5104SGerrit Renker u16 avr_ack_ptr; 83a47c5104SGerrit Renker u16 avr_sent_len; 84a47c5104SGerrit Renker u8 avr_ack_nonce; 8502bcf28cSAndrea Bittau }; 8602bcf28cSAndrea Bittau 87ae31c339SArnaldo Carvalho de Melo struct sock; 88ae31c339SArnaldo Carvalho de Melo struct sk_buff; 89ae31c339SArnaldo Carvalho de Melo 909b07ef5dSArnaldo Carvalho de Melo extern int dccp_ackvec_init(void); 919b07ef5dSArnaldo Carvalho de Melo extern void dccp_ackvec_exit(void); 929b07ef5dSArnaldo Carvalho de Melo 937400d781SArnaldo Carvalho de Melo extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); 94ae31c339SArnaldo Carvalho de Melo extern void dccp_ackvec_free(struct dccp_ackvec *av); 95ae31c339SArnaldo Carvalho de Melo 96ae31c339SArnaldo Carvalho de Melo extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, 97ae31c339SArnaldo Carvalho de Melo const u64 ackno, const u8 state); 98ae31c339SArnaldo Carvalho de Melo 99ae31c339SArnaldo Carvalho de Melo extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, 100ae31c339SArnaldo Carvalho de Melo struct sock *sk, const u64 ackno); 101ae31c339SArnaldo Carvalho de Melo extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 102bdf13d20SAndrea Bittau u64 *ackno, const u8 opt, 103bdf13d20SAndrea Bittau const u8 *value, const u8 len); 104ae31c339SArnaldo Carvalho de Melo 105ae31c339SArnaldo Carvalho de Melo extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); 106ae31c339SArnaldo Carvalho de Melo 107ae31c339SArnaldo Carvalho de Melo static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) 108ae31c339SArnaldo Carvalho de Melo { 109a47c5104SGerrit Renker return av->av_vec_len; 110ae31c339SArnaldo Carvalho de Melo } 111ae31c339SArnaldo Carvalho de Melo #endif /* _ACKVEC_H */ 112