Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_DCCP_H
0003 #define _UAPI_LINUX_DCCP_H
0004 
0005 #include <linux/types.h>
0006 #include <asm/byteorder.h>
0007 
0008 /**
0009  * struct dccp_hdr - generic part of DCCP packet header
0010  *
0011  * @dccph_sport - Relevant port on the endpoint that sent this packet
0012  * @dccph_dport - Relevant port on the other endpoint
0013  * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
0014  * @dccph_ccval - Used by the HC-Sender CCID
0015  * @dccph_cscov - Parts of the packet that are covered by the Checksum field
0016  * @dccph_checksum - Internet checksum, depends on dccph_cscov
0017  * @dccph_x - 0 = 24 bit sequence number, 1 = 48
0018  * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
0019  * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
0020  */
0021 struct dccp_hdr {
0022     __be16  dccph_sport,
0023         dccph_dport;
0024     __u8    dccph_doff;
0025 #if defined(__LITTLE_ENDIAN_BITFIELD)
0026     __u8    dccph_cscov:4,
0027         dccph_ccval:4;
0028 #elif defined(__BIG_ENDIAN_BITFIELD)
0029     __u8    dccph_ccval:4,
0030         dccph_cscov:4;
0031 #else
0032 #error  "Adjust your <asm/byteorder.h> defines"
0033 #endif
0034     __sum16 dccph_checksum;
0035 #if defined(__LITTLE_ENDIAN_BITFIELD)
0036     __u8    dccph_x:1,
0037         dccph_type:4,
0038         dccph_reserved:3;
0039 #elif defined(__BIG_ENDIAN_BITFIELD)
0040     __u8    dccph_reserved:3,
0041         dccph_type:4,
0042         dccph_x:1;
0043 #else
0044 #error  "Adjust your <asm/byteorder.h> defines"
0045 #endif
0046     __u8    dccph_seq2;
0047     __be16  dccph_seq;
0048 };
0049 
0050 /**
0051  * struct dccp_hdr_ext - the low bits of a 48 bit seq packet
0052  *
0053  * @dccph_seq_low - low 24 bits of a 48 bit seq packet
0054  */
0055 struct dccp_hdr_ext {
0056     __be32  dccph_seq_low;
0057 };
0058 
0059 /**
0060  * struct dccp_hdr_request - Connection initiation request header
0061  *
0062  * @dccph_req_service - Service to which the client app wants to connect
0063  */
0064 struct dccp_hdr_request {
0065     __be32  dccph_req_service;
0066 };
0067 /**
0068  * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
0069  *
0070  * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
0071  * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
0072  */
0073 struct dccp_hdr_ack_bits {
0074     __be16  dccph_reserved1;
0075     __be16  dccph_ack_nr_high;
0076     __be32  dccph_ack_nr_low;
0077 };
0078 /**
0079  * struct dccp_hdr_response - Connection initiation response header
0080  *
0081  * @dccph_resp_ack - 48 bit Acknowledgment Number Subheader (5.3)
0082  * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
0083  */
0084 struct dccp_hdr_response {
0085     struct dccp_hdr_ack_bits    dccph_resp_ack;
0086     __be32              dccph_resp_service;
0087 };
0088 
0089 /**
0090  * struct dccp_hdr_reset - Unconditionally shut down a connection
0091  *
0092  * @dccph_reset_ack - 48 bit Acknowledgment Number Subheader (5.6)
0093  * @dccph_reset_code - one of %dccp_reset_codes
0094  * @dccph_reset_data - the Data 1 ... Data 3 fields from 5.6
0095  */
0096 struct dccp_hdr_reset {
0097     struct dccp_hdr_ack_bits    dccph_reset_ack;
0098     __u8                dccph_reset_code,
0099                     dccph_reset_data[3];
0100 };
0101 
0102 enum dccp_pkt_type {
0103     DCCP_PKT_REQUEST = 0,
0104     DCCP_PKT_RESPONSE,
0105     DCCP_PKT_DATA,
0106     DCCP_PKT_ACK,
0107     DCCP_PKT_DATAACK,
0108     DCCP_PKT_CLOSEREQ,
0109     DCCP_PKT_CLOSE,
0110     DCCP_PKT_RESET,
0111     DCCP_PKT_SYNC,
0112     DCCP_PKT_SYNCACK,
0113     DCCP_PKT_INVALID,
0114 };
0115 
0116 #define DCCP_NR_PKT_TYPES DCCP_PKT_INVALID
0117 
0118 static inline unsigned int dccp_packet_hdr_len(const __u8 type)
0119 {
0120     if (type == DCCP_PKT_DATA)
0121         return 0;
0122     if (type == DCCP_PKT_DATAACK    ||
0123         type == DCCP_PKT_ACK    ||
0124         type == DCCP_PKT_SYNC   ||
0125         type == DCCP_PKT_SYNCACK    ||
0126         type == DCCP_PKT_CLOSE  ||
0127         type == DCCP_PKT_CLOSEREQ)
0128         return sizeof(struct dccp_hdr_ack_bits);
0129     if (type == DCCP_PKT_REQUEST)
0130         return sizeof(struct dccp_hdr_request);
0131     if (type == DCCP_PKT_RESPONSE)
0132         return sizeof(struct dccp_hdr_response);
0133     return sizeof(struct dccp_hdr_reset);
0134 }
0135 enum dccp_reset_codes {
0136     DCCP_RESET_CODE_UNSPECIFIED = 0,
0137     DCCP_RESET_CODE_CLOSED,
0138     DCCP_RESET_CODE_ABORTED,
0139     DCCP_RESET_CODE_NO_CONNECTION,
0140     DCCP_RESET_CODE_PACKET_ERROR,
0141     DCCP_RESET_CODE_OPTION_ERROR,
0142     DCCP_RESET_CODE_MANDATORY_ERROR,
0143     DCCP_RESET_CODE_CONNECTION_REFUSED,
0144     DCCP_RESET_CODE_BAD_SERVICE_CODE,
0145     DCCP_RESET_CODE_TOO_BUSY,
0146     DCCP_RESET_CODE_BAD_INIT_COOKIE,
0147     DCCP_RESET_CODE_AGGRESSION_PENALTY,
0148 
0149     DCCP_MAX_RESET_CODES        /* Leave at the end!  */
0150 };
0151 
0152 /* DCCP options */
0153 enum {
0154     DCCPO_PADDING = 0,
0155     DCCPO_MANDATORY = 1,
0156     DCCPO_MIN_RESERVED = 3,
0157     DCCPO_MAX_RESERVED = 31,
0158     DCCPO_CHANGE_L = 32,
0159     DCCPO_CONFIRM_L = 33,
0160     DCCPO_CHANGE_R = 34,
0161     DCCPO_CONFIRM_R = 35,
0162     DCCPO_NDP_COUNT = 37,
0163     DCCPO_ACK_VECTOR_0 = 38,
0164     DCCPO_ACK_VECTOR_1 = 39,
0165     DCCPO_TIMESTAMP = 41,
0166     DCCPO_TIMESTAMP_ECHO = 42,
0167     DCCPO_ELAPSED_TIME = 43,
0168     DCCPO_MAX = 45,
0169     DCCPO_MIN_RX_CCID_SPECIFIC = 128,   /* from sender to receiver */
0170     DCCPO_MAX_RX_CCID_SPECIFIC = 191,
0171     DCCPO_MIN_TX_CCID_SPECIFIC = 192,   /* from receiver to sender */
0172     DCCPO_MAX_TX_CCID_SPECIFIC = 255,
0173 };
0174 /* maximum size of a single TLV-encoded DCCP option (sans type/len bytes) */
0175 #define DCCP_SINGLE_OPT_MAXLEN  253
0176 
0177 /* DCCP CCIDS */
0178 enum {
0179     DCCPC_CCID2 = 2,
0180     DCCPC_CCID3 = 3,
0181 };
0182 
0183 /* DCCP features (RFC 4340 section 6.4) */
0184 enum dccp_feature_numbers {
0185     DCCPF_RESERVED = 0,
0186     DCCPF_CCID = 1,
0187     DCCPF_SHORT_SEQNOS = 2,
0188     DCCPF_SEQUENCE_WINDOW = 3,
0189     DCCPF_ECN_INCAPABLE = 4,
0190     DCCPF_ACK_RATIO = 5,
0191     DCCPF_SEND_ACK_VECTOR = 6,
0192     DCCPF_SEND_NDP_COUNT = 7,
0193     DCCPF_MIN_CSUM_COVER = 8,
0194     DCCPF_DATA_CHECKSUM = 9,
0195     /* 10-127 reserved */
0196     DCCPF_MIN_CCID_SPECIFIC = 128,
0197     DCCPF_SEND_LEV_RATE = 192,  /* RFC 4342, sec. 8.4 */
0198     DCCPF_MAX_CCID_SPECIFIC = 255,
0199 };
0200 
0201 /* DCCP socket control message types for cmsg */
0202 enum dccp_cmsg_type {
0203     DCCP_SCM_PRIORITY = 1,
0204     DCCP_SCM_QPOLICY_MAX = 0xFFFF,
0205     /* ^-- Up to here reserved exclusively for qpolicy parameters */
0206     DCCP_SCM_MAX
0207 };
0208 
0209 /* DCCP priorities for outgoing/queued packets */
0210 enum dccp_packet_dequeueing_policy {
0211     DCCPQ_POLICY_SIMPLE,
0212     DCCPQ_POLICY_PRIO,
0213     DCCPQ_POLICY_MAX
0214 };
0215 
0216 /* DCCP socket options */
0217 #define DCCP_SOCKOPT_PACKET_SIZE    1 /* XXX deprecated, without effect */
0218 #define DCCP_SOCKOPT_SERVICE        2
0219 #define DCCP_SOCKOPT_CHANGE_L       3
0220 #define DCCP_SOCKOPT_CHANGE_R       4
0221 #define DCCP_SOCKOPT_GET_CUR_MPS    5
0222 #define DCCP_SOCKOPT_SERVER_TIMEWAIT    6
0223 #define DCCP_SOCKOPT_SEND_CSCOV     10
0224 #define DCCP_SOCKOPT_RECV_CSCOV     11
0225 #define DCCP_SOCKOPT_AVAILABLE_CCIDS    12
0226 #define DCCP_SOCKOPT_CCID       13
0227 #define DCCP_SOCKOPT_TX_CCID        14
0228 #define DCCP_SOCKOPT_RX_CCID        15
0229 #define DCCP_SOCKOPT_QPOLICY_ID     16
0230 #define DCCP_SOCKOPT_QPOLICY_TXQLEN 17
0231 #define DCCP_SOCKOPT_CCID_RX_INFO   128
0232 #define DCCP_SOCKOPT_CCID_TX_INFO   192
0233 
0234 /* maximum number of services provided on the same listening port */
0235 #define DCCP_SERVICE_LIST_MAX_LEN      32
0236 
0237 
0238 #endif /* _UAPI_LINUX_DCCP_H */