1 /* $KAME: sctp.h,v 1.17 2004/08/17 04:06:15 itojun Exp $ */
2 /* $DragonFly: src/sys/netinet/sctp.h,v 1.1 2005/07/15 14:46:16 eirikn Exp $ */
4 #ifndef _NETINET_SCTP_H_
5 #define _NETINET_SCTP_H_
8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Cisco Systems, Inc.
22 * 4. Neither the name of the project nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include <sys/types.h>
41 * SCTP protocol - RFC2960.
45 u_int16_t src_port; /* source port */
46 u_int16_t dest_port; /* destination port */
47 u_int32_t v_tag; /* verification tag of packet */
48 u_int32_t checksum; /* Adler32 C-Sum */
49 /* chunks follow... */
55 struct sctp_chunkhdr {
56 u_int8_t chunk_type; /* chunk type */
57 u_int8_t chunk_flags; /* chunk flags */
58 u_int16_t chunk_length; /* chunk length */
59 /* optional params follow */
63 * SCTP chunk parameters
65 struct sctp_paramhdr {
66 u_int16_t param_type; /* parameter type */
67 u_int16_t param_length; /* parameter length */
73 /* read-write options */
74 #define SCTP_NODELAY 0x00000001
75 #define SCTP_MAXSEG 0x00000002
76 #define SCTP_ASSOCINFO 0x00000003
78 #define SCTP_INITMSG 0x00000004
79 #define SCTP_AUTOCLOSE 0x00000005
80 #define SCTP_SET_PEER_PRIMARY_ADDR 0x00000006
81 #define SCTP_PRIMARY_ADDR 0x00000007
83 /* read-only options */
84 #define SCTP_STATUS 0x00000008
85 #define SCTP_PCB_STATUS 0x00000009
87 /* ancillary data/notification interest options */
88 #define SCTP_EVENTS 0x0000000a
89 /* sctp_opt_info params */
90 #define SCTP_PEER_ADDR_PARAMS 0x0000000b
91 #define SCTP_GET_PEER_ADDR_INFO 0x0000000c
92 /* Hidden socket option that gets the addresses */
93 #define SCTP_GET_PEER_ADDRESSES 0x0000000d
94 #define SCTP_GET_LOCAL_ADDRESSES 0x0000000e
96 * Blocking I/O is enabled on any TCP type socket by default.
97 * For the UDP model if this is turned on then the socket buffer is
98 * shared for send resources amongst all associations. The default
99 * for the UDP model is that is SS_NBIO is set. Which means all associations
100 * have a seperate send limit BUT they will NOT ever BLOCK instead
101 * you will get an error back EAGAIN if you try to send to much. If
102 * you want the blocking symantics you set this option at the cost
103 * of sharing one socket send buffer size amongst all associations.
104 * Peeled off sockets turn this option off and block... but since both TCP and
105 * peeled off sockets have only one assoc per socket this is fine.
106 * It probably does NOT make sense to set this on SS_NBIO on a TCP model OR
107 * peeled off UDP model, but we do allow you to do so. You just use
108 * the normal syscall to toggle SS_NBIO the way you want.
110 /* Blocking I/O is controled by the SS_NBIO flag on the
111 * socket state so_state field.
113 #define SCTP_GET_SNDBUF_USE 0x0000000f
114 /* latter added read/write */
115 #define SCTP_ADAPTION_LAYER 0x00000010
116 #define SCTP_DISABLE_FRAGMENTS 0x00000011
117 /* sctp_bindx() flags as socket options */
118 #define SCTP_BINDX_ADD_ADDR 0x00000012
119 #define SCTP_BINDX_REM_ADDR 0x00000013
120 /* return the total count in bytes needed to hold all local addresses bound */
121 #define SCTP_GET_LOCAL_ADDR_SIZE 0x00000014
122 /* Without this applied we will give V4 and V6 addresses on a V6 socket */
123 #define SCTP_I_WANT_MAPPED_V4_ADDR 0x00000015
124 /* Return the total count in bytes needed to hold the remote address */
125 #define SCTP_GET_REMOTE_ADDR_SIZE 0x00000016
126 #define SCTP_GET_PEGS 0x00000017
127 #define SCTP_DEFAULT_SEND_PARAM 0x00000018
128 #define SCTP_SET_DEBUG_LEVEL 0x00000019
129 #define SCTP_RTOINFO 0x0000001a
130 #define SCTP_AUTO_ASCONF 0x0000001b
131 #define SCTP_MAXBURST 0x0000001c
132 #define SCTP_GET_STAT_LOG 0x0000001d
133 #define SCTP_CONNECT_X 0x0000001e /* hidden opt for connectx */
134 #define SCTP_RESET_STREAMS 0x0000001f
135 #define SCTP_CONNECT_X_DELAYED 0x00000020 /* hidden opt for connectx_delayed
136 * part of sctp_sendx()
138 #define SCTP_CONNECT_X_COMPLETE 0x00000021
139 #define SCTP_GET_ASOC_ID_LIST 0x00000022
141 /* Other BSD items */
142 #define SCTP_GET_NONCE_VALUES 0x00000023
143 #define SCTP_DELAYED_ACK_TIME 0x00000024
145 /* Things for the AUTH draft possibly */
146 #define SCTP_PEER_PUBLIC_KEY 0x00000100 /* get the peers public key */
147 #define SCTP_MY_PUBLIC_KEY 0x00000101 /* get/set my endpoints public key */
148 #define SCTP_SET_AUTH_SECRET 0x00000102 /* get/set my shared secret */
149 #define SCTP_SET_AUTH_CHUNKS 0x00000103/* specify what chunks you want
150 * the system may have additional requirments
151 * as well. I.e. probably ASCONF/ASCONF-ACK no matter
152 * if you want it or not.
154 /* Debug things that need to be purged */
155 #define SCTP_SET_INITIAL_DBG_SEQ 0x00001f00
156 #define SCTP_RESET_PEGS 0x00002000
157 #define SCTP_CLR_STAT_LOG 0x00002100
162 #define SCTP_CLOSED 0x0000
163 #define SCTP_BOUND 0x1000
164 #define SCTP_LISTEN 0x2000
165 #define SCTP_COOKIE_WAIT 0x0002
166 #define SCTP_COOKIE_ECHOED 0x0004
167 #define SCTP_ESTABLISHED 0x0008
168 #define SCTP_SHUTDOWN_SENT 0x0010
169 #define SCTP_SHUTDOWN_RECEIVED 0x0020
170 #define SCTP_SHUTDOWN_ACK_SENT 0x0040
171 #define SCTP_SHUTDOWN_PENDING 0x0080
174 * SCTP operational error codes (user visible)
176 #define SCTP_ERROR_NO_ERROR 0x0000
177 #define SCTP_ERROR_INVALID_STREAM 0x0001
178 #define SCTP_ERROR_MISSING_PARAM 0x0002
179 #define SCTP_ERROR_STALE_COOKIE 0x0003
180 #define SCTP_ERROR_OUT_OF_RESOURCES 0x0004
181 #define SCTP_ERROR_UNRESOLVABLE_ADDR 0x0005
182 #define SCTP_ERROR_UNRECOG_CHUNK 0x0006
183 #define SCTP_ERROR_INVALID_PARAM 0x0007
184 #define SCTP_ERROR_UNRECOG_PARAM 0x0008
185 #define SCTP_ERROR_NO_USER_DATA 0x0009
186 #define SCTP_ERROR_COOKIE_IN_SHUTDOWN 0x000a
187 /* draft-ietf-tsvwg-sctpimpguide */
188 #define SCTP_ERROR_RESTART_NEWADDRS 0x000b
189 /* draft-ietf-tsvwg-addip-sctp */
190 #define SCTP_ERROR_DELETE_LAST_ADDR 0x0100
191 #define SCTP_ERROR_RESOURCE_SHORTAGE 0x0101
192 #define SCTP_ERROR_DELETE_SOURCE_ADDR 0x0102
193 #define SCTP_ERROR_ILLEGAL_ASCONF_ACK 0x0103
196 * error cause parameters (user visisble)
198 struct sctp_error_cause {
201 /* optional cause-specific info may follow */
204 struct sctp_error_invalid_stream {
205 struct sctp_error_cause cause; /* code=SCTP_ERROR_INVALID_STREAM */
206 u_int16_t stream_id; /* stream id of the DATA in error */
210 struct sctp_error_missing_param {
211 struct sctp_error_cause cause; /* code=SCTP_ERROR_MISSING_PARAM */
212 u_int32_t num_missing_params; /* number of missing parameters */
213 /* u_int16_t param_type's follow */
216 struct sctp_error_stale_cookie {
217 struct sctp_error_cause cause; /* code=SCTP_ERROR_STALE_COOKIE */
218 u_int32_t stale_time; /* time in usec of staleness */
221 struct sctp_error_out_of_resource {
222 struct sctp_error_cause cause; /* code=SCTP_ERROR_OUT_OF_RESOURCES */
225 struct sctp_error_unresolv_addr {
226 struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRESOLVABLE_ADDR */
230 struct sctp_error_unrecognized_chunk {
231 struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRECOG_CHUNK */
232 struct sctp_chunkhdr ch; /* header from chunk in error */
236 #define HAVE_KERNEL_SCTP 1
237 #define HAVE_SCTP_PRSCTP 1
238 #define HAVE_SCTP_ADDIP 1
239 #define HAVE_SCTP_CANSET_PRIMARY 1
240 #define HAVE_SCTP_SAT_NETWORK_CAPABILITY1
241 #define HAVE_SCTP_MULTIBUF 1
242 #define HAVE_SCTP_NOCONNECT 0
243 #define HAVE_SCTP_ECN_NONCE 1 /* ECN Nonce option */
245 /* Main SCTP chunk types, we place
246 * these here since that way natd and f/w's
247 * in user land can find them.
249 #define SCTP_DATA 0x00
250 #define SCTP_INITIATION 0x01
251 #define SCTP_INITIATION_ACK 0x02
252 #define SCTP_SELECTIVE_ACK 0x03
253 #define SCTP_HEARTBEAT_REQUEST 0x04
254 #define SCTP_HEARTBEAT_ACK 0x05
255 #define SCTP_ABORT_ASSOCIATION 0x06
256 #define SCTP_SHUTDOWN 0x07
257 #define SCTP_SHUTDOWN_ACK 0x08
258 #define SCTP_OPERATION_ERROR 0x09
259 #define SCTP_COOKIE_ECHO 0x0a
260 #define SCTP_COOKIE_ACK 0x0b
261 #define SCTP_ECN_ECHO 0x0c
262 #define SCTP_ECN_CWR 0x0d
263 #define SCTP_SHUTDOWN_COMPLETE 0x0e
265 /* draft-ietf-tsvwg-addip-sctp */
266 #define SCTP_ASCONF 0xc1
267 #define SCTP_ASCONF_ACK 0x80
269 /* draft-ietf-stewart-prsctp */
270 #define SCTP_FORWARD_CUM_TSN 0xc0
272 /* draft-ietf-stewart-pktdrpsctp */
273 #define SCTP_PACKET_DROPPED 0x81
275 /* draft-ietf-stewart-strreset-xxx */
276 #define SCTP_STREAM_RESET 0x82
278 /* ABORT and SHUTDOWN COMPLETE FLAG */
279 #define SCTP_HAD_NO_TCB 0x01
281 /* Packet dropped flags */
282 #define SCTP_FROM_MIDDLE_BOX SCTP_HAD_NO_TCB
283 #define SCTP_BADCRC 0x02
284 #define SCTP_PACKET_TRUNCATED 0x04
286 #define SCTP_SAT_NETWORK_MIN 400 /* min ms for RTT to set satellite time */
287 #define SCTP_SAT_NETWORK_BURST_INCR 2 /* how many times to multiply maxburst in sat */
288 /* Data Chuck Specific Flags */
289 #define SCTP_DATA_FRAG_MASK 0x03
290 #define SCTP_DATA_MIDDLE_FRAG 0x00
291 #define SCTP_DATA_LAST_FRAG 0x01
292 #define SCTP_DATA_FIRST_FRAG 0x02
293 #define SCTP_DATA_NOT_FRAG 0x03
294 #define SCTP_DATA_UNORDERED 0x04
296 /* ECN Nonce: SACK Chunk Specific Flags */
297 #define SCTP_SACK_NONCE_SUM 0x01
299 #include <netinet/sctp_uio.h>
301 #endif /* !_NETINET_SCTP_H_ */