linux/net/dccp/ackvec.h
<<
>>
Prefs
   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 <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
  14#include <linux/dccp.h>
  15#include <linux/compiler.h>
  16#include <linux/ktime.h>
  17#include <linux/list.h>
  18#include <linux/types.h>
  19
  20/* We can spread an ack vector across multiple options */
  21#define DCCP_MAX_ACKVEC_LEN (DCCP_SINGLE_OPT_MAXLEN * 2)
  22
  23/* Estimated minimum average Ack Vector length - used for updating MPS */
  24#define DCCPAV_MIN_OPTLEN       16
  25
  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 *
  35 * This data structure is the one defined in RFC 4340, Appendix A.
  36 *
  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
  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 *
  48 * @av_records - list of dccp_ackvec_record
  49 * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
  50 *
  51 * @av_time - the time in usecs
  52 * @av_buf - circular buffer of acknowledgeable packets
  53 */
  54struct dccp_ackvec {
  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];
  63};
  64
  65/** struct dccp_ackvec_record - ack vector record
  66 *
  67 * ACK vector record as defined in Appendix A of spec.
  68 *
  69 * The list is sorted by avr_ack_seqno
  70 *
  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
  77 */
  78struct dccp_ackvec_record {
  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;
  85};
  86
  87struct sock;
  88struct sk_buff;
  89
  90extern int dccp_ackvec_init(void);
  91extern void dccp_ackvec_exit(void);
  92
  93extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority);
  94extern void dccp_ackvec_free(struct dccp_ackvec *av);
  95
  96extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
  97                           const u64 ackno, const u8 state);
  98
  99extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
 100                                        struct sock *sk, const u64 ackno);
 101extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
 102                             u64 *ackno, const u8 opt,
 103                             const u8 *value, const u8 len);
 104
 105extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
 106
 107static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
 108{
 109        return av->av_vec_len;
 110}
 111#endif /* _ACKVEC_H */
 112