ackvec.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/config.h>
  14. #include <linux/compiler.h>
  15. #include <linux/time.h>
  16. #include <linux/types.h>
  17. /* Read about the ECN nonce to see why it is 253 */
  18. #define DCCP_MAX_ACKVEC_LEN 253
  19. #define DCCP_ACKVEC_STATE_RECEIVED 0
  20. #define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6)
  21. #define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6)
  22. #define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */
  23. #define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */
  24. /** struct dccp_ackvec - ack vector
  25. *
  26. * This data structure is the one defined in the DCCP draft
  27. * Appendix A.
  28. *
  29. * @dccpav_buf_head - circular buffer head
  30. * @dccpav_buf_tail - circular buffer tail
  31. * @dccpav_buf_ackno - ack # of the most recent packet acknowledgeable in the
  32. * buffer (i.e. %dccpav_buf_head)
  33. * @dccpav_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
  34. * by the buffer with State 0
  35. *
  36. * Additionally, the HC-Receiver must keep some information about the
  37. * Ack Vectors it has recently sent. For each packet sent carrying an
  38. * Ack Vector, it remembers four variables:
  39. *
  40. * @dccpav_ack_seqno - the Sequence Number used for the packet
  41. * (HC-Receiver seqno)
  42. * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
  43. * @dccpav_ack_ackno - the Acknowledgement Number used for the packet
  44. * (HC-Sender seqno)
  45. * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
  46. *
  47. * @dccpav_buf_len - circular buffer length
  48. * @dccpav_time - the time in usecs
  49. * @dccpav_buf - circular buffer of acknowledgeable packets
  50. */
  51. struct dccp_ackvec {
  52. u64 dccpav_buf_ackno;
  53. u64 dccpav_ack_seqno;
  54. u64 dccpav_ack_ackno;
  55. struct timeval dccpav_time;
  56. u8 dccpav_buf_head;
  57. u8 dccpav_buf_tail;
  58. u8 dccpav_ack_ptr;
  59. u8 dccpav_sent_len;
  60. u8 dccpav_vec_len;
  61. u8 dccpav_buf_len;
  62. u8 dccpav_buf_nonce;
  63. u8 dccpav_ack_nonce;
  64. u8 dccpav_buf[0];
  65. };
  66. struct sock;
  67. struct sk_buff;
  68. #ifdef CONFIG_IP_DCCP_ACKVEC
  69. extern struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len,
  70. const gfp_t priority);
  71. extern void dccp_ackvec_free(struct dccp_ackvec *av);
  72. extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
  73. const u64 ackno, const u8 state);
  74. extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
  75. struct sock *sk, const u64 ackno);
  76. extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
  77. const u8 opt, const u8 *value, const u8 len);
  78. extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
  79. static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
  80. {
  81. return av->dccpav_sent_len != av->dccpav_vec_len;
  82. }
  83. #else /* CONFIG_IP_DCCP_ACKVEC */
  84. static inline struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len,
  85. const gfp_t priority)
  86. {
  87. return NULL;
  88. }
  89. static inline void dccp_ackvec_free(struct dccp_ackvec *av)
  90. {
  91. }
  92. static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
  93. const u64 ackno, const u8 state)
  94. {
  95. return -1;
  96. }
  97. static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
  98. struct sock *sk, const u64 ackno)
  99. {
  100. }
  101. static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
  102. const u8 opt, const u8 *value, const u8 len)
  103. {
  104. return -1;
  105. }
  106. static inline int dccp_insert_option_ackvec(const struct sock *sk,
  107. const struct sk_buff *skb)
  108. {
  109. return -1;
  110. }
  111. static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
  112. {
  113. return 0;
  114. }
  115. #endif /* CONFIG_IP_DCCP_ACKVEC */
  116. #endif /* _ACKVEC_H */