1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2012 David Hoeppner. All rights reserved. 14 */ 15 16 #ifndef _INET_DCCP_H 17 #define _INET_DCCP_H 18 19 #include <sys/inttypes.h> 20 #include <sys/socket.h> 21 #include <sys/socket_proto.h> 22 23 #include <netinet/in.h> 24 #include <netinet/ip6.h> 25 #include <netinet/dccp.h> 26 27 #include <inet/common.h> 28 #include <inet/dccp_stack.h> 29 #include <inet/ip.h> 30 #include <inet/ip6.h> 31 #include <inet/optcom.h> 32 #include <inet/tunables.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* 39 * DCCP states 40 */ 41 #define DCCPS_CLOSED 1 42 #define DCCPS_BOUND 2 43 #define DCCPS_REQUEST 3 44 #define DCCPS_LISTEN 4 45 #define DCCPS_PARTOPEN 5 46 #define DCCPS_RESPOND 6 47 #define DCCPS_OPEN 7 48 #define DCCPS_CLOSING 8 49 #define DCCPS_CLOSEREQ 9 50 #define DCCPS_TIMEWAIT 10 51 52 /* 53 * DCCP header structures. 54 */ 55 56 /* Generic protocol header (RFC 4340, Section 5.1.) */ 57 typedef struct dccphdr_s { 58 uint8_t dh_lport[2]; 59 uint8_t dh_fport[2]; 60 uint8_t dh_offset; 61 uint8_t dh_ccval:4, 62 dh_cscov:4; 63 uint8_t db_sum[2]; 64 uint8_t dh_reserved:3, 65 dh_type:4, 66 dh_x:1; 67 uint8_t dh_res_seq; 68 uint8_t dh_seq[2]; 69 } dccph_t; 70 71 #define DCCP_HDR_LENGTH(dccph) \ 72 (((dccph_t *)dccph)->dh_offset * 4) /* XXX >> 2 */ 73 #define DCCP_MAX_HDR_LENGTH 1020 74 #define DCCP_MIN_HEADER_LENGTH 12 75 76 /* Generic protocol header aligned (RFC 4340, Section 5.1.) */ 77 typedef struct dccphdra_s { 78 in_port_t dha_lport; /* Source port */ 79 in_port_t dha_fport; /* Destination port */ 80 uint8_t dha_offset; /* Data offset */ 81 uint8_t dha_ccval:4, /* */ 82 dha_cscov:4; /* */ 83 uint16_t dha_sum; /* Checksum */ 84 uint8_t dha_x:1, /* Reserved */ 85 dha_type:4, /* Packet type */ 86 dha_reserved:3; /* Header type */ 87 uint8_t dha_res_seq; 88 uint16_t dha_seq; /* Partial sequence number */ 89 } dccpha_t; 90 91 typedef struct dccphdra_ext_s { 92 uint32_t dha_ext_seq; 93 } dccpha_ext_t; 94 95 /* Acknowledgement number */ 96 typedef struct dccphdra_ack { 97 uint16_t dha_ack_reserved; 98 uint16_t dha_ack_high; 99 uint32_t dha_ack_low; 100 } dccpha_ack_t; 101 102 /* Service number */ 103 typedef struct dccphdra_srv { 104 uint32_t dha_srv_code; 105 } dccpha_srv_t; 106 107 /* Reset data */ 108 typedef struct dccphdra_reset { 109 uint8_t dha_reset_code; 110 uint8_t dha_reset_data[3]; 111 } dccpha_reset_t; 112 113 /* 114 * Control structure for each open TCP stream, 115 * defined only within the kernel or for a kmem user. 116 * NOTE: tcp_reinit_values MUST have a line for each field in this structure! 117 */ 118 #if (defined(_KERNEL) || defined(_KMEMUSER)) 119 120 /* Internal DCCP structure */ 121 typedef struct dccp_s { 122 123 conn_t *dccp_connp; /* Backpointer to conn_t */ 124 dccp_stack_t *dccp_dccps; /* Backpointer to dccp_stack_t */ 125 126 int32_t dccp_state; 127 128 uint64_t dccp_last_rcv_lbolt; 129 130 uint32_t dccp_ibsegs; /* Inbound segments on this stream */ 131 uint32_t dccp_obsegs; /* Outbound segments on this stream */ 132 133 uint32_t 134 dccp_loopback: 1, /* Src and dst are the same machine */ 135 dccp_localnet: 1, /* Src and dst are on the same subnet */ 136 dccp_active_open: 1, /* This is a active open */ 137 dccp_detached : 1, /* If we're detached from a stream */ 138 dccp_dummy: 1; 139 140 uint32_t 141 dccp_allow_short_seqnos: 1, 142 dccp_ecn_incapable: 1; 143 /* 144 * Timers and timestamps. 145 */ 146 mblk_t *dccp_timercache; /* Timer cache */ 147 timeout_id_t dccp_timer_tid; /* Timer service id */ 148 149 int64_t dccp_timestamp_init; /* Time reference */ 150 int32_t dccp_timestamp_echo; /* Timestamp found in options */ 151 int64_t dccp_timestamp; 152 153 /* 154 * Bind related. 155 */ 156 struct dccp_s *dccp_bind_hash; /* Bind hash chain */ 157 struct dccp_s *dccp_bind_hash_port; /* Bound to the same port */ 158 struct dccp_s **dccp_ptpbhn; 159 160 struct dccphdra_s *dccp_dccpha; /* Template header */ 161 162 mblk_t *dccp_xmit_head; 163 164 /* 165 * Pointers into the header template. 166 */ 167 ipha_t *dccp_ipha; 168 ip6_t *dccp_ip6h; 169 170 t_uscalar_t dccp_acceptor_id; /* ACCEPTOR_id */ 171 172 sock_connid_t dccp_connid; 173 174 /* Incrementing pending conn req ID */ 175 t_scalar_t dccp_conn_req_seqnum; 176 177 boolean_t dccp_issocket; /* This is a socket dccp */ 178 179 /* List of features being negotiated */ 180 list_t dccp_features; 181 182 struct dccp_s *dccp_listener; /* Our listener */ 183 struct dccp_s *dccp_saved_listener; /* Saved listener */ 184 185 /* 186 * Sequence numbers (Section 7.1.) 187 */ 188 uint64_t dccp_swl; /* Sequence number window low */ 189 uint64_t dccp_swh; /* Sequence number window high */ 190 uint64_t dccp_awl; /* Ack number window low */ 191 uint64_t dccp_awh; /* Ack number window high */ 192 uint64_t dccp_iss; /* Initial sequence number sent */ 193 uint64_t dccp_isr; /* Initial sequence number received */ 194 uint64_t dccp_osr; /* First OPEN sequence number */ 195 uint64_t dccp_gss; /* Greatest sequence number sent */ 196 uint64_t dccp_gsr; /* Greatest sequence */ 197 /* number received */ 198 uint64_t dccp_gar; /* Greatest acknowledgement */ 199 /* number received */ 200 201 uint8_t dccp_reset_code; 202 uint8_t dccp_reset_data[3]; 203 } dccp_t; 204 205 typedef struct dccp_df_s { 206 struct dccp_s *df_dccp; 207 kmutex_t df_lock; 208 uchar_t df_pad[TF_CACHEL_PAD - (sizeof (dccp_t *) + 209 sizeof (kmutex_t))]; 210 } dccp_df_t; 211 212 #endif /* _KERNEL */ 213 214 #ifdef __cplusplus 215 } 216 #endif 217 218 #endif /* _INET_DCCP_H */