sctp.h revision 170094
1/*-
2 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 *   this list of conditions and the following disclaimer.
9 *
10 * b) Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *   the documentation and/or other materials provided with the distribution.
13 *
14 * c) Neither the name of Cisco Systems, Inc. nor the names of its
15 *    contributors may be used to endorse or promote products derived
16 *    from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/* $KAME: sctp.h,v 1.18 2005/03/06 16:04:16 itojun Exp $	 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 170094 2007-05-29 11:53:27Z rrs $");
34
35#ifndef _NETINET_SCTP_H_
36#define _NETINET_SCTP_H_
37
38#include <sys/types.h>
39
40/*
41 * SCTP protocol - RFC2960.
42 */
43
44struct sctphdr {
45	uint16_t src_port;	/* source port */
46	uint16_t dest_port;	/* destination port */
47	uint32_t v_tag;		/* verification tag of packet */
48	uint32_t checksum;	/* Adler32 C-Sum */
49	/* chunks follow... */
50};
51
52/*
53 * SCTP Chunks
54 */
55struct sctp_chunkhdr {
56	uint8_t chunk_type;	/* chunk type */
57	uint8_t chunk_flags;	/* chunk flags */
58	uint16_t chunk_length;	/* chunk length */
59	/* optional params follow */
60};
61
62/*
63 * SCTP chunk parameters
64 */
65struct sctp_paramhdr {
66	uint16_t param_type;	/* parameter type */
67	uint16_t param_length;	/* parameter length */
68};
69
70/*
71 * user socket options: socket API defined
72 */
73/*
74 * read-write options
75 */
76#define SCTP_RTOINFO			0x00000001
77#define SCTP_ASSOCINFO			0x00000002
78#define SCTP_INITMSG			0x00000003
79#define SCTP_NODELAY			0x00000004
80#define SCTP_AUTOCLOSE			0x00000005
81#define SCTP_SET_PEER_PRIMARY_ADDR	0x00000006
82#define SCTP_PRIMARY_ADDR		0x00000007
83#define SCTP_ADAPTATION_LAYER		0x00000008
84/* same as above */
85#define SCTP_ADAPTION_LAYER		0x00000008
86#define SCTP_DISABLE_FRAGMENTS		0x00000009
87#define SCTP_PEER_ADDR_PARAMS 		0x0000000a
88#define SCTP_DEFAULT_SEND_PARAM		0x0000000b
89/* ancillary data/notification interest options */
90#define SCTP_EVENTS			0x0000000c
91/* Without this applied we will give V4 and V6 addresses on a V6 socket */
92#define SCTP_I_WANT_MAPPED_V4_ADDR	0x0000000d
93#define SCTP_MAXSEG 			0x0000000e
94#define SCTP_DELAYED_SACK               0x0000000f
95#define SCTP_FRAGMENT_INTERLEAVE        0x00000010
96#define SCTP_PARTIAL_DELIVERY_POINT     0x00000011
97/* authentication support */
98#define SCTP_AUTH_CHUNK 		0x00000012
99#define SCTP_AUTH_KEY 			0x00000013
100#define SCTP_HMAC_IDENT 		0x00000014
101#define SCTP_AUTH_ACTIVE_KEY 		0x00000015
102#define SCTP_AUTH_DELETE_KEY 		0x00000016
103#define SCTP_USE_EXT_RCVINFO		0x00000017
104#define SCTP_AUTO_ASCONF		0x00000018	/* rw */
105#define SCTP_MAXBURST			0x00000019	/* rw */
106#define SCTP_MAX_BURST			0x00000019	/* rw */
107/* assoc level context */
108#define SCTP_CONTEXT                    0x0000001a	/* rw */
109/* explict EOR signalling */
110#define SCTP_EXPLICIT_EOR               0x0000001b
111
112/*
113 * read-only options
114 */
115#define SCTP_STATUS			0x00000100
116#define SCTP_GET_PEER_ADDR_INFO		0x00000101
117/* authentication support */
118#define SCTP_PEER_AUTH_CHUNKS 		0x00000102
119#define SCTP_LOCAL_AUTH_CHUNKS 		0x00000103
120#define SCTP_GET_ASSOC_NUMBER           0x00000104	/* ro */
121#define SCTP_GET_ASSOC_ID_LIST          0x00000105	/* ro */
122
123/*
124 * user socket options: BSD implementation specific
125 */
126/*
127 * Blocking I/O is enabled on any TCP type socket by default. For the UDP
128 * model if this is turned on then the socket buffer is shared for send
129 * resources amongst all associations.  The default for the UDP model is that
130 * is SS_NBIO is set.  Which means all associations have a seperate send
131 * limit BUT they will NOT ever BLOCK instead you will get an error back
132 * EAGAIN if you try to send to much. If you want the blocking symantics you
133 * set this option at the cost of sharing one socket send buffer size amongst
134 * all associations. Peeled off sockets turn this option off and block. But
135 * since both TCP and peeled off sockets have only one assoc per socket this
136 * is fine. It probably does NOT make sense to set this on SS_NBIO on a TCP
137 * model OR peeled off UDP model, but we do allow you to do so. You just use
138 * the normal syscall to toggle SS_NBIO the way you want.
139 *
140 * Blocking I/O is controled by the SS_NBIO flag on the socket state so_state
141 * field.
142 */
143
144/* these should probably go into sockets API */
145#define SCTP_RESET_STREAMS		0x00001004	/* wo */
146
147
148/* here on down are more implementation specific */
149#define SCTP_SET_DEBUG_LEVEL		0x00001005
150#define SCTP_CLR_STAT_LOG               0x00001007
151/* CMT ON/OFF socket option */
152#define SCTP_CMT_ON_OFF                 0x00001200
153#define SCTP_CMT_USE_DAC                0x00001201
154
155/* read only */
156#define SCTP_GET_SNDBUF_USE		0x00001101
157#define SCTP_GET_STAT_LOG		0x00001103
158#define SCTP_PCB_STATUS			0x00001104
159#define SCTP_GET_NONCE_VALUES           0x00001105
160
161
162/* Special hook for dynamically setting primary for all assoc's,
163 * this is a write only option that requires root privledge.
164 */
165#define SCTP_SET_DYNAMIC_PRIMARY        0x00002001
166
167/* VRF (virtual router feature) and multi-VRF support
168 * options. VRF's provide splits within a router
169 * that give the views of multiple routers. A
170 * standard host, without VRF support, is just
171 * a single VRF. If VRF's are supported then
172 * the transport must be VRF aware. This means
173 * that every socket call coming in must be directed
174 * within the endpoint to one of the VRF's it belongs
175 * to. The endpoint, before binding, may select
176 * the "default" VRF it is in by using a set socket
177 * option with SCTP_VRF_ID. This will also
178 * get propegated to the default VRF. Once the
179 * endpoint binds an address then it CANNOT add
180 * additional VRF's to become a Multi-VRF endpoint.
181 *
182 * Before BINDING additional VRF's can be added with
183 * the SCTP_ADD_VRF_ID call or deleted with
184 * SCTP_DEL_VRF_ID.
185 *
186 * Associations are ALWAYS contained inside a single
187 * VRF. They cannot reside in two (or more) VRF's. Incoming
188 * packets, assuming the router is VRF aware, can always
189 * tell us what VRF they arrived on. A host not supporting
190 * any VRF's will find that the packets always arrived on the
191 * single VRF that the host has.
192 *
193 */
194
195#define SCTP_VRF_ID			0x00003001
196#define SCTP_ADD_VRF_ID			0x00003002
197#define SCTP_GET_VRF_IDS		0x00003003
198#define SCTP_GET_ASOC_VRF               0x00003004
199#define SCTP_DEL_VRF_ID                 0x00003005
200
201/*
202 * If you enable packet logging you can get
203 * a poor mans ethereal output in binary
204 * form. Note this is a compile option to
205 * the kernel,  SCTP_PACKET_LOGGING, and
206 * without it in your kernel you
207 * will get a EOPNOTSUPP
208 */
209#define SCTP_GET_PACKET_LOG             0x00004001
210
211/*
212 * hidden implementation specific options these are NOT user visible (should
213 * move out of sctp.h)
214 */
215/* sctp_bindx() flags as hidden socket options */
216#define SCTP_BINDX_ADD_ADDR		0x00008001
217#define SCTP_BINDX_REM_ADDR		0x00008002
218/* Hidden socket option that gets the addresses */
219#define SCTP_GET_PEER_ADDRESSES		0x00008003
220#define SCTP_GET_LOCAL_ADDRESSES	0x00008004
221/* return the total count in bytes needed to hold all local addresses bound */
222#define SCTP_GET_LOCAL_ADDR_SIZE	0x00008005
223/* Return the total count in bytes needed to hold the remote address */
224#define SCTP_GET_REMOTE_ADDR_SIZE	0x00008006
225/* hidden option for connectx */
226#define SCTP_CONNECT_X			0x00008007
227/* hidden option for connectx_delayed, part of sendx */
228#define SCTP_CONNECT_X_DELAYED		0x00008008
229#define SCTP_CONNECT_X_COMPLETE         0x00008009
230/* hidden socket option based sctp_peeloff */
231#define SCTP_PEELOFF                    0x0000800a
232/* the real worker for sctp_getaddrlen() */
233#define SCTP_GET_ADDR_LEN               0x0000800b
234/* temporary workaround for Apple listen() issue, no args used */
235#define SCTP_LISTEN_FIX			0x0000800c
236/* Debug things that need to be purged */
237#define SCTP_SET_INITIAL_DBG_SEQ	0x00009f00
238
239
240/* fragment interleave constants
241 * setting must be one of these or
242 * EINVAL returned.
243 */
244#define SCTP_FRAG_LEVEL_0    0x00000000
245#define SCTP_FRAG_LEVEL_1    0x00000001
246#define SCTP_FRAG_LEVEL_2    0x00000002
247
248/*
249 * user state values
250 */
251#define SCTP_CLOSED			0x0000
252#define SCTP_BOUND			0x1000
253#define SCTP_LISTEN			0x2000
254#define SCTP_COOKIE_WAIT		0x0002
255#define SCTP_COOKIE_ECHOED		0x0004
256#define SCTP_ESTABLISHED		0x0008
257#define SCTP_SHUTDOWN_SENT		0x0010
258#define SCTP_SHUTDOWN_RECEIVED		0x0020
259#define SCTP_SHUTDOWN_ACK_SENT		0x0040
260#define SCTP_SHUTDOWN_PENDING		0x0080
261
262/*
263 * SCTP operational error codes (user visible)
264 */
265#define SCTP_CAUSE_NO_ERROR		0x0000
266#define SCTP_CAUSE_INVALID_STREAM	0x0001
267#define SCTP_CAUSE_MISSING_PARAM	0x0002
268#define SCTP_CAUSE_STALE_COOKIE		0x0003
269#define SCTP_CAUSE_OUT_OF_RESC		0x0004
270#define SCTP_CAUSE_UNRESOLVABLE_ADDR	0x0005
271#define SCTP_CAUSE_UNRECOG_CHUNK	0x0006
272#define SCTP_CAUSE_INVALID_PARAM	0x0007
273#define SCTP_CAUSE_UNRECOG_PARAM	0x0008
274#define SCTP_CAUSE_NO_USER_DATA		0x0009
275#define SCTP_CAUSE_COOKIE_IN_SHUTDOWN	0x000a
276#define SCTP_CAUSE_RESTART_W_NEWADDR	0x000b
277#define SCTP_CAUSE_USER_INITIATED_ABT	0x000c
278#define SCTP_CAUSE_PROTOCOL_VIOLATION	0x000d
279
280/* Error causes from draft-ietf-tsvwg-addip-sctp */
281#define SCTP_CAUSE_DELETING_LAST_ADDR	0x0100
282#define SCTP_CAUSE_RESOURCE_SHORTAGE	0x0101
283#define SCTP_CAUSE_DELETING_SRC_ADDR	0x0102
284#define SCTP_CAUSE_ILLEGAL_ASCONF_ACK	0x0103
285#define SCTP_CAUSE_REQUEST_REFUSED	0x0104
286
287/* Error causes from draft-ietf-tsvwg-sctp-auth */
288#define SCTP_CAUSE_UNSUPPORTED_HMACID	0x0105
289
290/*
291 * error cause parameters (user visisble)
292 */
293struct sctp_error_cause {
294	uint16_t code;
295	uint16_t length;
296	/* optional cause-specific info may follow */
297};
298
299struct sctp_error_invalid_stream {
300	struct sctp_error_cause cause;	/* code=SCTP_ERROR_INVALID_STREAM */
301	uint16_t stream_id;	/* stream id of the DATA in error */
302	uint16_t reserved;
303};
304
305struct sctp_error_missing_param {
306	struct sctp_error_cause cause;	/* code=SCTP_ERROR_MISSING_PARAM */
307	uint32_t num_missing_params;	/* number of missing parameters */
308	/* uint16_t param_type's follow */
309};
310
311struct sctp_error_stale_cookie {
312	struct sctp_error_cause cause;	/* code=SCTP_ERROR_STALE_COOKIE */
313	uint32_t stale_time;	/* time in usec of staleness */
314};
315
316struct sctp_error_out_of_resource {
317	struct sctp_error_cause cause;	/* code=SCTP_ERROR_OUT_OF_RESOURCES */
318};
319
320struct sctp_error_unresolv_addr {
321	struct sctp_error_cause cause;	/* code=SCTP_ERROR_UNRESOLVABLE_ADDR */
322
323};
324
325struct sctp_error_unrecognized_chunk {
326	struct sctp_error_cause cause;	/* code=SCTP_ERROR_UNRECOG_CHUNK */
327	struct sctp_chunkhdr ch;/* header from chunk in error */
328};
329
330#define HAVE_SCTP			1
331#define HAVE_KERNEL_SCTP		1
332#define HAVE_SCTP_PRSCTP		1
333#define HAVE_SCTP_ADDIP			1
334#define HAVE_SCTP_CANSET_PRIMARY	1
335#define HAVE_SCTP_SAT_CAPABILITY	1
336#define HAVE_SCTP_MULTIBUF              1
337#define HAVE_SCTP_NOCONNECT             0
338#define HAVE_SCTP_ECN_NONCE             1	/* ECN Nonce option */
339#define HAVE_SCTP_AUTH			1
340#define HAVE_SCTP_EXT_RCVINFO		1
341#define HAVE_SCTP_CONNECTX              1
342/*
343 * Main SCTP chunk types we place these here so natd and f/w's in user land
344 * can find them.
345 */
346/************0x00 series ***********/
347#define SCTP_DATA		0x00
348#define SCTP_INITIATION		0x01
349#define SCTP_INITIATION_ACK	0x02
350#define SCTP_SELECTIVE_ACK	0x03
351#define SCTP_HEARTBEAT_REQUEST	0x04
352#define SCTP_HEARTBEAT_ACK	0x05
353#define SCTP_ABORT_ASSOCIATION	0x06
354#define SCTP_SHUTDOWN		0x07
355#define SCTP_SHUTDOWN_ACK	0x08
356#define SCTP_OPERATION_ERROR	0x09
357#define SCTP_COOKIE_ECHO	0x0a
358#define SCTP_COOKIE_ACK		0x0b
359#define SCTP_ECN_ECHO		0x0c
360#define SCTP_ECN_CWR		0x0d
361#define SCTP_SHUTDOWN_COMPLETE	0x0e
362/* draft-ietf-tsvwg-sctp-auth */
363#define SCTP_AUTHENTICATION     0x0f
364/************0x40 series ***********/
365/************0x80 series ***********/
366/* draft-ietf-tsvwg-addip-sctp */
367#define	SCTP_ASCONF_ACK		0x80
368/* draft-ietf-stewart-pktdrpsctp */
369#define SCTP_PACKET_DROPPED	0x81
370/* draft-ietf-stewart-strreset-xxx */
371#define SCTP_STREAM_RESET       0x82
372/************0xc0 series ***********/
373/* RFC3758 */
374#define SCTP_FORWARD_CUM_TSN	0xc0
375/* draft-ietf-tsvwg-addip-sctp */
376#define SCTP_ASCONF		0xc1
377
378
379/* ABORT and SHUTDOWN COMPLETE FLAG */
380#define SCTP_HAD_NO_TCB		0x01
381
382/* Packet dropped flags */
383#define SCTP_FROM_MIDDLE_BOX	SCTP_HAD_NO_TCB
384#define SCTP_BADCRC		0x02
385#define SCTP_PACKET_TRUNCATED	0x04
386
387#define SCTP_SAT_NETWORK_MIN	400	/* min ms for RTT to set satellite
388					 * time */
389#define SCTP_SAT_NETWORK_BURST_INCR  2	/* how many times to multiply maxburst
390					 * in sat */
391
392/* Data Chuck Specific Flags */
393#define SCTP_DATA_FRAG_MASK	0x03
394#define SCTP_DATA_MIDDLE_FRAG	0x00
395#define SCTP_DATA_LAST_FRAG	0x01
396#define SCTP_DATA_FIRST_FRAG	0x02
397#define SCTP_DATA_NOT_FRAG	0x03
398#define SCTP_DATA_UNORDERED	0x04
399
400/* ECN Nonce: SACK Chunk Specific Flags */
401#define SCTP_SACK_NONCE_SUM     0x01
402
403/* CMT DAC algorithm SACK flag */
404#define SCTP_SACK_CMT_DAC       0x80
405
406/*
407 * PCB flags (in sctp_flags bitmask).
408 * Note the features and flags are meant
409 * for use by netstat.
410 */
411#define SCTP_PCB_FLAGS_UDPTYPE		0x00000001
412#define SCTP_PCB_FLAGS_TCPTYPE		0x00000002
413#define SCTP_PCB_FLAGS_BOUNDALL		0x00000004
414#define SCTP_PCB_FLAGS_ACCEPTING	0x00000008
415#define SCTP_PCB_FLAGS_UNBOUND		0x00000010
416#define SCTP_PCB_FLAGS_LISTENING	0x00000020
417#define SCTP_PCB_FLAGS_CLOSE_IP         0x00040000
418#define SCTP_PCB_FLAGS_WAS_CONNECTED    0x00080000
419#define SCTP_PCB_FLAGS_WAS_ABORTED      0x00100000
420/* TCP model support */
421
422#define SCTP_PCB_FLAGS_CONNECTED	0x00200000
423#define SCTP_PCB_FLAGS_IN_TCPPOOL	0x00400000
424#define SCTP_PCB_FLAGS_DONT_WAKE	0x00800000
425#define SCTP_PCB_FLAGS_WAKEOUTPUT	0x01000000
426#define SCTP_PCB_FLAGS_WAKEINPUT	0x02000000
427#define SCTP_PCB_FLAGS_BOUND_V6		0x04000000
428#define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4	0x08000000
429#define SCTP_PCB_FLAGS_BLOCKING_IO	0x10000000
430#define SCTP_PCB_FLAGS_SOCKET_GONE	0x20000000
431#define SCTP_PCB_FLAGS_SOCKET_ALLGONE	0x40000000
432/* flags to copy to new PCB */
433#define SCTP_PCB_COPY_FLAGS		0x0e000004
434
435
436/*
437 * PCB Features (in sctp_features bitmask)
438 */
439#define SCTP_PCB_FLAGS_EXT_RCVINFO      0x00000002
440#define SCTP_PCB_FLAGS_DONOT_HEARTBEAT  0x00000004
441#define SCTP_PCB_FLAGS_FRAG_INTERLEAVE  0x00000008
442#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS	0x00000010
443#define SCTP_PCB_FLAGS_DO_ASCONF	0x00000020
444#define SCTP_PCB_FLAGS_AUTO_ASCONF	0x00000040
445#define SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE 0x00000080
446
447/* socket options */
448#define SCTP_PCB_FLAGS_NODELAY		0x00000100
449#define SCTP_PCB_FLAGS_AUTOCLOSE	0x00000200
450#define SCTP_PCB_FLAGS_RECVDATAIOEVNT	0x00000400
451#define SCTP_PCB_FLAGS_RECVASSOCEVNT	0x00000800
452#define SCTP_PCB_FLAGS_RECVPADDREVNT	0x00001000
453#define SCTP_PCB_FLAGS_RECVPEERERR	0x00002000
454#define SCTP_PCB_FLAGS_RECVSENDFAILEVNT	0x00004000
455#define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT	0x00008000
456#define SCTP_PCB_FLAGS_ADAPTATIONEVNT	0x00010000
457#define SCTP_PCB_FLAGS_PDAPIEVNT	0x00020000
458#define SCTP_PCB_FLAGS_AUTHEVNT		0x00040000
459#define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00080000
460#define SCTP_PCB_FLAGS_NO_FRAGMENT	0x00100000
461#define SCTP_PCB_FLAGS_EXPLICIT_EOR     0x00400000
462
463#define SCTP_SMALLEST_PMTU 512	/* smallest pmtu allowed when disabling PMTU
464				 * discovery */
465
466#include <netinet/sctp_uio.h>
467
468#define SCTP_PACKET_LOG_SIZE 65536
469
470
471#endif				/* !_NETINET_SCTP_H_ */
472