ackvec.h 3.3 KB

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