dccp.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_LINUX_DCCP_H
  3. #define _UAPI_LINUX_DCCP_H
  4. #include <linux/types.h>
  5. #include <asm/byteorder.h>
  6. /**
  7. * struct dccp_hdr - generic part of DCCP packet header
  8. *
  9. * @dccph_sport - Relevant port on the endpoint that sent this packet
  10. * @dccph_dport - Relevant port on the other endpoint
  11. * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
  12. * @dccph_ccval - Used by the HC-Sender CCID
  13. * @dccph_cscov - Parts of the packet that are covered by the Checksum field
  14. * @dccph_checksum - Internet checksum, depends on dccph_cscov
  15. * @dccph_x - 0 = 24 bit sequence number, 1 = 48
  16. * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
  17. * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
  18. */
  19. struct dccp_hdr {
  20. __be16 dccph_sport,
  21. dccph_dport;
  22. __u8 dccph_doff;
  23. #if defined(__LITTLE_ENDIAN_BITFIELD)
  24. __u8 dccph_cscov:4,
  25. dccph_ccval:4;
  26. #elif defined(__BIG_ENDIAN_BITFIELD)
  27. __u8 dccph_ccval:4,
  28. dccph_cscov:4;
  29. #else
  30. #error "Adjust your <asm/byteorder.h> defines"
  31. #endif
  32. __sum16 dccph_checksum;
  33. #if defined(__LITTLE_ENDIAN_BITFIELD)
  34. __u8 dccph_x:1,
  35. dccph_type:4,
  36. dccph_reserved:3;
  37. #elif defined(__BIG_ENDIAN_BITFIELD)
  38. __u8 dccph_reserved:3,
  39. dccph_type:4,
  40. dccph_x:1;
  41. #else
  42. #error "Adjust your <asm/byteorder.h> defines"
  43. #endif
  44. __u8 dccph_seq2;
  45. __be16 dccph_seq;
  46. };
  47. /**
  48. * struct dccp_hdr_ext - the low bits of a 48 bit seq packet
  49. *
  50. * @dccph_seq_low - low 24 bits of a 48 bit seq packet
  51. */
  52. struct dccp_hdr_ext {
  53. __be32 dccph_seq_low;
  54. };
  55. /**
  56. * struct dccp_hdr_request - Connection initiation request header
  57. *
  58. * @dccph_req_service - Service to which the client app wants to connect
  59. */
  60. struct dccp_hdr_request {
  61. __be32 dccph_req_service;
  62. };
  63. /**
  64. * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
  65. *
  66. * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
  67. * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
  68. */
  69. struct dccp_hdr_ack_bits {
  70. __be16 dccph_reserved1;
  71. __be16 dccph_ack_nr_high;
  72. __be32 dccph_ack_nr_low;
  73. };
  74. /**
  75. * struct dccp_hdr_response - Connection initiation response header
  76. *
  77. * @dccph_resp_ack - 48 bit Acknowledgment Number Subheader (5.3)
  78. * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
  79. */
  80. struct dccp_hdr_response {
  81. struct dccp_hdr_ack_bits dccph_resp_ack;
  82. __be32 dccph_resp_service;
  83. };
  84. /**
  85. * struct dccp_hdr_reset - Unconditionally shut down a connection
  86. *
  87. * @dccph_reset_ack - 48 bit Acknowledgment Number Subheader (5.6)
  88. * @dccph_reset_code - one of %dccp_reset_codes
  89. * @dccph_reset_data - the Data 1 ... Data 3 fields from 5.6
  90. */
  91. struct dccp_hdr_reset {
  92. struct dccp_hdr_ack_bits dccph_reset_ack;
  93. __u8 dccph_reset_code,
  94. dccph_reset_data[3];
  95. };
  96. enum dccp_pkt_type {
  97. DCCP_PKT_REQUEST = 0,
  98. DCCP_PKT_RESPONSE,
  99. DCCP_PKT_DATA,
  100. DCCP_PKT_ACK,
  101. DCCP_PKT_DATAACK,
  102. DCCP_PKT_CLOSEREQ,
  103. DCCP_PKT_CLOSE,
  104. DCCP_PKT_RESET,
  105. DCCP_PKT_SYNC,
  106. DCCP_PKT_SYNCACK,
  107. DCCP_PKT_INVALID,
  108. };
  109. #define DCCP_NR_PKT_TYPES DCCP_PKT_INVALID
  110. static inline unsigned int dccp_packet_hdr_len(const __u8 type)
  111. {
  112. if (type == DCCP_PKT_DATA)
  113. return 0;
  114. if (type == DCCP_PKT_DATAACK ||
  115. type == DCCP_PKT_ACK ||
  116. type == DCCP_PKT_SYNC ||
  117. type == DCCP_PKT_SYNCACK ||
  118. type == DCCP_PKT_CLOSE ||
  119. type == DCCP_PKT_CLOSEREQ)
  120. return sizeof(struct dccp_hdr_ack_bits);
  121. if (type == DCCP_PKT_REQUEST)
  122. return sizeof(struct dccp_hdr_request);
  123. if (type == DCCP_PKT_RESPONSE)
  124. return sizeof(struct dccp_hdr_response);
  125. return sizeof(struct dccp_hdr_reset);
  126. }
  127. enum dccp_reset_codes {
  128. DCCP_RESET_CODE_UNSPECIFIED = 0,
  129. DCCP_RESET_CODE_CLOSED,
  130. DCCP_RESET_CODE_ABORTED,
  131. DCCP_RESET_CODE_NO_CONNECTION,
  132. DCCP_RESET_CODE_PACKET_ERROR,
  133. DCCP_RESET_CODE_OPTION_ERROR,
  134. DCCP_RESET_CODE_MANDATORY_ERROR,
  135. DCCP_RESET_CODE_CONNECTION_REFUSED,
  136. DCCP_RESET_CODE_BAD_SERVICE_CODE,
  137. DCCP_RESET_CODE_TOO_BUSY,
  138. DCCP_RESET_CODE_BAD_INIT_COOKIE,
  139. DCCP_RESET_CODE_AGGRESSION_PENALTY,
  140. DCCP_MAX_RESET_CODES /* Leave at the end! */
  141. };
  142. /* DCCP options */
  143. enum {
  144. DCCPO_PADDING = 0,
  145. DCCPO_MANDATORY = 1,
  146. DCCPO_MIN_RESERVED = 3,
  147. DCCPO_MAX_RESERVED = 31,
  148. DCCPO_CHANGE_L = 32,
  149. DCCPO_CONFIRM_L = 33,
  150. DCCPO_CHANGE_R = 34,
  151. DCCPO_CONFIRM_R = 35,
  152. DCCPO_NDP_COUNT = 37,
  153. DCCPO_ACK_VECTOR_0 = 38,
  154. DCCPO_ACK_VECTOR_1 = 39,
  155. DCCPO_TIMESTAMP = 41,
  156. DCCPO_TIMESTAMP_ECHO = 42,
  157. DCCPO_ELAPSED_TIME = 43,
  158. DCCPO_MAX = 45,
  159. DCCPO_MIN_RX_CCID_SPECIFIC = 128, /* from sender to receiver */
  160. DCCPO_MAX_RX_CCID_SPECIFIC = 191,
  161. DCCPO_MIN_TX_CCID_SPECIFIC = 192, /* from receiver to sender */
  162. DCCPO_MAX_TX_CCID_SPECIFIC = 255,
  163. };
  164. /* maximum size of a single TLV-encoded DCCP option (sans type/len bytes) */
  165. #define DCCP_SINGLE_OPT_MAXLEN 253
  166. /* DCCP CCIDS */
  167. enum {
  168. DCCPC_CCID2 = 2,
  169. DCCPC_CCID3 = 3,
  170. };
  171. /* DCCP features (RFC 4340 section 6.4) */
  172. enum dccp_feature_numbers {
  173. DCCPF_RESERVED = 0,
  174. DCCPF_CCID = 1,
  175. DCCPF_SHORT_SEQNOS = 2,
  176. DCCPF_SEQUENCE_WINDOW = 3,
  177. DCCPF_ECN_INCAPABLE = 4,
  178. DCCPF_ACK_RATIO = 5,
  179. DCCPF_SEND_ACK_VECTOR = 6,
  180. DCCPF_SEND_NDP_COUNT = 7,
  181. DCCPF_MIN_CSUM_COVER = 8,
  182. DCCPF_DATA_CHECKSUM = 9,
  183. /* 10-127 reserved */
  184. DCCPF_MIN_CCID_SPECIFIC = 128,
  185. DCCPF_SEND_LEV_RATE = 192, /* RFC 4342, sec. 8.4 */
  186. DCCPF_MAX_CCID_SPECIFIC = 255,
  187. };
  188. /* DCCP socket control message types for cmsg */
  189. enum dccp_cmsg_type {
  190. DCCP_SCM_PRIORITY = 1,
  191. DCCP_SCM_QPOLICY_MAX = 0xFFFF,
  192. /* ^-- Up to here reserved exclusively for qpolicy parameters */
  193. DCCP_SCM_MAX
  194. };
  195. /* DCCP priorities for outgoing/queued packets */
  196. enum dccp_packet_dequeueing_policy {
  197. DCCPQ_POLICY_SIMPLE,
  198. DCCPQ_POLICY_PRIO,
  199. DCCPQ_POLICY_MAX
  200. };
  201. /* DCCP socket options */
  202. #define DCCP_SOCKOPT_PACKET_SIZE 1 /* XXX deprecated, without effect */
  203. #define DCCP_SOCKOPT_SERVICE 2
  204. #define DCCP_SOCKOPT_CHANGE_L 3
  205. #define DCCP_SOCKOPT_CHANGE_R 4
  206. #define DCCP_SOCKOPT_GET_CUR_MPS 5
  207. #define DCCP_SOCKOPT_SERVER_TIMEWAIT 6
  208. #define DCCP_SOCKOPT_SEND_CSCOV 10
  209. #define DCCP_SOCKOPT_RECV_CSCOV 11
  210. #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12
  211. #define DCCP_SOCKOPT_CCID 13
  212. #define DCCP_SOCKOPT_TX_CCID 14
  213. #define DCCP_SOCKOPT_RX_CCID 15
  214. #define DCCP_SOCKOPT_QPOLICY_ID 16
  215. #define DCCP_SOCKOPT_QPOLICY_TXQLEN 17
  216. #define DCCP_SOCKOPT_CCID_RX_INFO 128
  217. #define DCCP_SOCKOPT_CCID_TX_INFO 192
  218. /* maximum number of services provided on the same listening port */
  219. #define DCCP_SERVICE_LIST_MAX_LEN 32
  220. #endif /* _UAPI_LINUX_DCCP_H */