HAMMER 60I/Many: Mirroring
[dragonfly.git] / sys / netinet / sctp.h
blob2aad2396aaa0083a14ffb48e8cc7d05518ac3f32
1 /* $KAME: sctp.h,v 1.17 2004/08/17 04:06:15 itojun Exp $ */
2 /* $DragonFly: src/sys/netinet/sctp.h,v 1.3 2006/06/13 08:12:03 dillon Exp $ */
4 #ifndef _NETINET_SCTP_H_
5 #define _NETINET_SCTP_H_
7 /*
8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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
36 * SUCH DAMAGE.
38 #ifndef _SYS_TYPES_H_
39 #include <sys/types.h>
40 #endif
43 * SCTP protocol - RFC2960.
46 struct sctphdr {
47 u_int16_t src_port; /* source port */
48 u_int16_t dest_port; /* destination port */
49 u_int32_t v_tag; /* verification tag of packet */
50 u_int32_t checksum; /* Adler32 C-Sum */
51 /* chunks follow... */
55 * SCTP Chunks
57 struct sctp_chunkhdr {
58 u_int8_t chunk_type; /* chunk type */
59 u_int8_t chunk_flags; /* chunk flags */
60 u_int16_t chunk_length; /* chunk length */
61 /* optional params follow */
65 * SCTP chunk parameters
67 struct sctp_paramhdr {
68 u_int16_t param_type; /* parameter type */
69 u_int16_t param_length; /* parameter length */
73 * user socket options
75 /* read-write options */
76 #define SCTP_NODELAY 0x00000001
77 #define SCTP_MAXSEG 0x00000002
78 #define SCTP_ASSOCINFO 0x00000003
80 #define SCTP_INITMSG 0x00000004
81 #define SCTP_AUTOCLOSE 0x00000005
82 #define SCTP_SET_PEER_PRIMARY_ADDR 0x00000006
83 #define SCTP_PRIMARY_ADDR 0x00000007
85 /* read-only options */
86 #define SCTP_STATUS 0x00000008
87 #define SCTP_PCB_STATUS 0x00000009
89 /* ancillary data/notification interest options */
90 #define SCTP_EVENTS 0x0000000a
91 /* sctp_opt_info params */
92 #define SCTP_PEER_ADDR_PARAMS 0x0000000b
93 #define SCTP_GET_PEER_ADDR_INFO 0x0000000c
94 /* Hidden socket option that gets the addresses */
95 #define SCTP_GET_PEER_ADDRESSES 0x0000000d
96 #define SCTP_GET_LOCAL_ADDRESSES 0x0000000e
98 * Blocking I/O is enabled on any TCP type socket by default.
99 * For the UDP model if this is turned on then the socket buffer is
100 * shared for send resources amongst all associations. The default
101 * for the UDP model is that is SS_NBIO is set. Which means all associations
102 * have a seperate send limit BUT they will NOT ever BLOCK instead
103 * you will get an error back EAGAIN if you try to send to much. If
104 * you want the blocking symantics you set this option at the cost
105 * of sharing one socket send buffer size amongst all associations.
106 * Peeled off sockets turn this option off and block... but since both TCP and
107 * peeled off sockets have only one assoc per socket this is fine.
108 * It probably does NOT make sense to set this on SS_NBIO on a TCP model OR
109 * peeled off UDP model, but we do allow you to do so. You just use
110 * the normal syscall to toggle SS_NBIO the way you want.
112 /* Blocking I/O is controled by the SS_NBIO flag on the
113 * socket state so_state field.
115 * XXX SS_NBIO no longer exists on DragonFly. Why is SCTP trying to set
116 * the blocking/non-blocking default state? We really need to present a
117 * uniform interface to the user program, so we do not actually try to
118 * do this any more.
120 #define SCTP_GET_SNDBUF_USE 0x0000000f
121 /* latter added read/write */
122 #define SCTP_ADAPTION_LAYER 0x00000010
123 #define SCTP_DISABLE_FRAGMENTS 0x00000011
124 /* sctp_bindx() flags as socket options */
125 #define SCTP_BINDX_ADD_ADDR 0x00000012
126 #define SCTP_BINDX_REM_ADDR 0x00000013
127 /* return the total count in bytes needed to hold all local addresses bound */
128 #define SCTP_GET_LOCAL_ADDR_SIZE 0x00000014
129 /* Without this applied we will give V4 and V6 addresses on a V6 socket */
130 #define SCTP_I_WANT_MAPPED_V4_ADDR 0x00000015
131 /* Return the total count in bytes needed to hold the remote address */
132 #define SCTP_GET_REMOTE_ADDR_SIZE 0x00000016
133 #define SCTP_GET_PEGS 0x00000017
134 #define SCTP_DEFAULT_SEND_PARAM 0x00000018
135 #define SCTP_SET_DEBUG_LEVEL 0x00000019
136 #define SCTP_RTOINFO 0x0000001a
137 #define SCTP_AUTO_ASCONF 0x0000001b
138 #define SCTP_MAXBURST 0x0000001c
139 #define SCTP_GET_STAT_LOG 0x0000001d
140 #define SCTP_CONNECT_X 0x0000001e /* hidden opt for connectx */
141 #define SCTP_RESET_STREAMS 0x0000001f
142 #define SCTP_CONNECT_X_DELAYED 0x00000020 /* hidden opt for connectx_delayed
143 * part of sctp_sendx()
145 #define SCTP_CONNECT_X_COMPLETE 0x00000021
146 #define SCTP_GET_ASOC_ID_LIST 0x00000022
148 /* Other BSD items */
149 #define SCTP_GET_NONCE_VALUES 0x00000023
150 #define SCTP_DELAYED_ACK_TIME 0x00000024
152 /* Things for the AUTH draft possibly */
153 #define SCTP_PEER_PUBLIC_KEY 0x00000100 /* get the peers public key */
154 #define SCTP_MY_PUBLIC_KEY 0x00000101 /* get/set my endpoints public key */
155 #define SCTP_SET_AUTH_SECRET 0x00000102 /* get/set my shared secret */
156 #define SCTP_SET_AUTH_CHUNKS 0x00000103/* specify what chunks you want
157 * the system may have additional requirments
158 * as well. I.e. probably ASCONF/ASCONF-ACK no matter
159 * if you want it or not.
161 /* Debug things that need to be purged */
162 #define SCTP_SET_INITIAL_DBG_SEQ 0x00001f00
163 #define SCTP_RESET_PEGS 0x00002000
164 #define SCTP_CLR_STAT_LOG 0x00002100
167 * user state values
169 #define SCTP_CLOSED 0x0000
170 #define SCTP_BOUND 0x1000
171 #define SCTP_LISTEN 0x2000
172 #define SCTP_COOKIE_WAIT 0x0002
173 #define SCTP_COOKIE_ECHOED 0x0004
174 #define SCTP_ESTABLISHED 0x0008
175 #define SCTP_SHUTDOWN_SENT 0x0010
176 #define SCTP_SHUTDOWN_RECEIVED 0x0020
177 #define SCTP_SHUTDOWN_ACK_SENT 0x0040
178 #define SCTP_SHUTDOWN_PENDING 0x0080
181 * SCTP operational error codes (user visible)
183 #define SCTP_ERROR_NO_ERROR 0x0000
184 #define SCTP_ERROR_INVALID_STREAM 0x0001
185 #define SCTP_ERROR_MISSING_PARAM 0x0002
186 #define SCTP_ERROR_STALE_COOKIE 0x0003
187 #define SCTP_ERROR_OUT_OF_RESOURCES 0x0004
188 #define SCTP_ERROR_UNRESOLVABLE_ADDR 0x0005
189 #define SCTP_ERROR_UNRECOG_CHUNK 0x0006
190 #define SCTP_ERROR_INVALID_PARAM 0x0007
191 #define SCTP_ERROR_UNRECOG_PARAM 0x0008
192 #define SCTP_ERROR_NO_USER_DATA 0x0009
193 #define SCTP_ERROR_COOKIE_IN_SHUTDOWN 0x000a
194 /* draft-ietf-tsvwg-sctpimpguide */
195 #define SCTP_ERROR_RESTART_NEWADDRS 0x000b
196 /* draft-ietf-tsvwg-addip-sctp */
197 #define SCTP_ERROR_DELETE_LAST_ADDR 0x0100
198 #define SCTP_ERROR_RESOURCE_SHORTAGE 0x0101
199 #define SCTP_ERROR_DELETE_SOURCE_ADDR 0x0102
200 #define SCTP_ERROR_ILLEGAL_ASCONF_ACK 0x0103
203 * error cause parameters (user visisble)
205 struct sctp_error_cause {
206 u_int16_t code;
207 u_int16_t length;
208 /* optional cause-specific info may follow */
211 struct sctp_error_invalid_stream {
212 struct sctp_error_cause cause; /* code=SCTP_ERROR_INVALID_STREAM */
213 u_int16_t stream_id; /* stream id of the DATA in error */
214 u_int16_t reserved;
217 struct sctp_error_missing_param {
218 struct sctp_error_cause cause; /* code=SCTP_ERROR_MISSING_PARAM */
219 u_int32_t num_missing_params; /* number of missing parameters */
220 /* u_int16_t param_type's follow */
223 struct sctp_error_stale_cookie {
224 struct sctp_error_cause cause; /* code=SCTP_ERROR_STALE_COOKIE */
225 u_int32_t stale_time; /* time in usec of staleness */
228 struct sctp_error_out_of_resource {
229 struct sctp_error_cause cause; /* code=SCTP_ERROR_OUT_OF_RESOURCES */
232 struct sctp_error_unresolv_addr {
233 struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRESOLVABLE_ADDR */
237 struct sctp_error_unrecognized_chunk {
238 struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRECOG_CHUNK */
239 struct sctp_chunkhdr ch; /* header from chunk in error */
242 #define HAVE_SCTP 1
243 #define HAVE_KERNEL_SCTP 1
244 #define HAVE_SCTP_PRSCTP 1
245 #define HAVE_SCTP_ADDIP 1
246 #define HAVE_SCTP_CANSET_PRIMARY 1
247 #define HAVE_SCTP_SAT_NETWORK_CAPABILITY1
248 #define HAVE_SCTP_MULTIBUF 1
249 #define HAVE_SCTP_NOCONNECT 0
250 #define HAVE_SCTP_ECN_NONCE 1 /* ECN Nonce option */
252 /* Main SCTP chunk types, we place
253 * these here since that way natd and f/w's
254 * in user land can find them.
256 #define SCTP_DATA 0x00
257 #define SCTP_INITIATION 0x01
258 #define SCTP_INITIATION_ACK 0x02
259 #define SCTP_SELECTIVE_ACK 0x03
260 #define SCTP_HEARTBEAT_REQUEST 0x04
261 #define SCTP_HEARTBEAT_ACK 0x05
262 #define SCTP_ABORT_ASSOCIATION 0x06
263 #define SCTP_SHUTDOWN 0x07
264 #define SCTP_SHUTDOWN_ACK 0x08
265 #define SCTP_OPERATION_ERROR 0x09
266 #define SCTP_COOKIE_ECHO 0x0a
267 #define SCTP_COOKIE_ACK 0x0b
268 #define SCTP_ECN_ECHO 0x0c
269 #define SCTP_ECN_CWR 0x0d
270 #define SCTP_SHUTDOWN_COMPLETE 0x0e
272 /* draft-ietf-tsvwg-addip-sctp */
273 #define SCTP_ASCONF 0xc1
274 #define SCTP_ASCONF_ACK 0x80
276 /* draft-ietf-stewart-prsctp */
277 #define SCTP_FORWARD_CUM_TSN 0xc0
279 /* draft-ietf-stewart-pktdrpsctp */
280 #define SCTP_PACKET_DROPPED 0x81
282 /* draft-ietf-stewart-strreset-xxx */
283 #define SCTP_STREAM_RESET 0x82
285 /* ABORT and SHUTDOWN COMPLETE FLAG */
286 #define SCTP_HAD_NO_TCB 0x01
288 /* Packet dropped flags */
289 #define SCTP_FROM_MIDDLE_BOX SCTP_HAD_NO_TCB
290 #define SCTP_BADCRC 0x02
291 #define SCTP_PACKET_TRUNCATED 0x04
293 #define SCTP_SAT_NETWORK_MIN 400 /* min ms for RTT to set satellite time */
294 #define SCTP_SAT_NETWORK_BURST_INCR 2 /* how many times to multiply maxburst in sat */
295 /* Data Chuck Specific Flags */
296 #define SCTP_DATA_FRAG_MASK 0x03
297 #define SCTP_DATA_MIDDLE_FRAG 0x00
298 #define SCTP_DATA_LAST_FRAG 0x01
299 #define SCTP_DATA_FIRST_FRAG 0x02
300 #define SCTP_DATA_NOT_FRAG 0x03
301 #define SCTP_DATA_UNORDERED 0x04
303 /* ECN Nonce: SACK Chunk Specific Flags */
304 #define SCTP_SACK_NONCE_SUM 0x01
306 #include <netinet/sctp_uio.h>
308 #endif /* !_NETINET_SCTP_H_ */