I'm growing tired of having to add #include lines for header files that
[dragonfly.git] / sys / netinet / sctp.h
1 /*      $KAME: sctp.h,v 1.17 2004/08/17 04:06:15 itojun Exp $   */
2 /*      $DragonFly: src/sys/netinet/sctp.h,v 1.2 2006/05/20 02:42:12 dillon Exp $       */
3
4 #ifndef _NETINET_SCTP_H_
5 #define _NETINET_SCTP_H_
6
7 /*
8  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
9  * All rights reserved.
10  *
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.
25  *
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.
37  */
38 #ifndef _SYS_TYPES_H_
39 #include <sys/types.h>
40 #endif
41
42 /*
43  * SCTP protocol - RFC2960.
44  */
45
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... */
52 };
53
54 /*
55  * SCTP Chunks
56  */
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 */
62 };
63
64 /*
65  * SCTP chunk parameters
66  */
67 struct sctp_paramhdr {
68         u_int16_t param_type;           /* parameter type */
69         u_int16_t param_length;         /* parameter length */
70 };
71
72 /*
73  * user socket options
74  */
75 /* read-write options */
76 #define SCTP_NODELAY                    0x00000001
77 #define SCTP_MAXSEG                     0x00000002
78 #define SCTP_ASSOCINFO                  0x00000003
79
80 #define SCTP_INITMSG                    0x00000004
81 #define SCTP_AUTOCLOSE                  0x00000005
82 #define SCTP_SET_PEER_PRIMARY_ADDR      0x00000006
83 #define SCTP_PRIMARY_ADDR               0x00000007
84
85 /* read-only options */
86 #define SCTP_STATUS                     0x00000008
87 #define SCTP_PCB_STATUS                 0x00000009
88
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
97 /*
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.
111  */
112 /* Blocking I/O is controled by the SS_NBIO flag on the
113  * socket state so_state field.
114  */
115 #define SCTP_GET_SNDBUF_USE             0x0000000f
116 /* latter added read/write */
117 #define SCTP_ADAPTION_LAYER             0x00000010
118 #define SCTP_DISABLE_FRAGMENTS          0x00000011
119 /* sctp_bindx() flags as socket options */
120 #define SCTP_BINDX_ADD_ADDR             0x00000012
121 #define SCTP_BINDX_REM_ADDR             0x00000013
122 /* return the total count in bytes needed to hold all local addresses bound */
123 #define SCTP_GET_LOCAL_ADDR_SIZE        0x00000014
124 /* Without this applied we will give V4 and V6 addresses on a V6 socket */
125 #define SCTP_I_WANT_MAPPED_V4_ADDR      0x00000015
126 /* Return the total count in bytes needed to hold the remote address */
127 #define SCTP_GET_REMOTE_ADDR_SIZE       0x00000016
128 #define SCTP_GET_PEGS                   0x00000017
129 #define SCTP_DEFAULT_SEND_PARAM         0x00000018
130 #define SCTP_SET_DEBUG_LEVEL            0x00000019
131 #define SCTP_RTOINFO                    0x0000001a
132 #define SCTP_AUTO_ASCONF                0x0000001b
133 #define SCTP_MAXBURST                   0x0000001c
134 #define SCTP_GET_STAT_LOG               0x0000001d
135 #define SCTP_CONNECT_X                  0x0000001e      /* hidden opt for connectx */
136 #define SCTP_RESET_STREAMS              0x0000001f
137 #define SCTP_CONNECT_X_DELAYED          0x00000020      /* hidden opt for connectx_delayed
138                                                          * part of sctp_sendx()
139                                                          */
140 #define SCTP_CONNECT_X_COMPLETE         0x00000021
141 #define SCTP_GET_ASOC_ID_LIST           0x00000022
142
143 /* Other BSD items */
144 #define SCTP_GET_NONCE_VALUES           0x00000023
145 #define SCTP_DELAYED_ACK_TIME           0x00000024
146
147 /* Things for the AUTH draft possibly */
148 #define SCTP_PEER_PUBLIC_KEY            0x00000100 /* get the peers public key */
149 #define SCTP_MY_PUBLIC_KEY              0x00000101 /* get/set my endpoints public key */
150 #define SCTP_SET_AUTH_SECRET            0x00000102 /* get/set my shared secret */
151 #define SCTP_SET_AUTH_CHUNKS            0x00000103/* specify what chunks you want
152                                                     * the system may have additional requirments
153                                                      * as well. I.e. probably ASCONF/ASCONF-ACK no matter
154                                                      * if you want it or not.
155                                                      */
156 /* Debug things that need to be purged */
157 #define SCTP_SET_INITIAL_DBG_SEQ        0x00001f00
158 #define SCTP_RESET_PEGS                 0x00002000
159 #define SCTP_CLR_STAT_LOG               0x00002100
160
161 /*
162  * user state values
163  */
164 #define SCTP_CLOSED                     0x0000
165 #define SCTP_BOUND                      0x1000
166 #define SCTP_LISTEN                     0x2000
167 #define SCTP_COOKIE_WAIT                0x0002
168 #define SCTP_COOKIE_ECHOED              0x0004
169 #define SCTP_ESTABLISHED                0x0008
170 #define SCTP_SHUTDOWN_SENT              0x0010
171 #define SCTP_SHUTDOWN_RECEIVED          0x0020
172 #define SCTP_SHUTDOWN_ACK_SENT          0x0040
173 #define SCTP_SHUTDOWN_PENDING           0x0080
174
175 /*
176  * SCTP operational error codes (user visible)
177  */
178 #define SCTP_ERROR_NO_ERROR             0x0000
179 #define SCTP_ERROR_INVALID_STREAM       0x0001
180 #define SCTP_ERROR_MISSING_PARAM        0x0002
181 #define SCTP_ERROR_STALE_COOKIE         0x0003
182 #define SCTP_ERROR_OUT_OF_RESOURCES     0x0004
183 #define SCTP_ERROR_UNRESOLVABLE_ADDR    0x0005
184 #define SCTP_ERROR_UNRECOG_CHUNK        0x0006
185 #define SCTP_ERROR_INVALID_PARAM        0x0007
186 #define SCTP_ERROR_UNRECOG_PARAM        0x0008
187 #define SCTP_ERROR_NO_USER_DATA         0x0009
188 #define SCTP_ERROR_COOKIE_IN_SHUTDOWN   0x000a
189 /* draft-ietf-tsvwg-sctpimpguide */
190 #define SCTP_ERROR_RESTART_NEWADDRS     0x000b
191 /* draft-ietf-tsvwg-addip-sctp */
192 #define SCTP_ERROR_DELETE_LAST_ADDR     0x0100
193 #define SCTP_ERROR_RESOURCE_SHORTAGE    0x0101
194 #define SCTP_ERROR_DELETE_SOURCE_ADDR   0x0102
195 #define SCTP_ERROR_ILLEGAL_ASCONF_ACK   0x0103
196
197 /*
198  * error cause parameters (user visisble)
199  */
200 struct sctp_error_cause {
201         u_int16_t code;
202         u_int16_t length;
203         /* optional cause-specific info may follow */
204 };
205
206 struct sctp_error_invalid_stream {
207         struct sctp_error_cause cause;  /* code=SCTP_ERROR_INVALID_STREAM */
208         u_int16_t stream_id;            /* stream id of the DATA in error */
209         u_int16_t reserved;
210 };
211
212 struct sctp_error_missing_param {
213         struct sctp_error_cause cause;  /* code=SCTP_ERROR_MISSING_PARAM */
214         u_int32_t num_missing_params;   /* number of missing parameters */
215         /* u_int16_t param_type's follow */
216 };
217
218 struct sctp_error_stale_cookie {
219         struct sctp_error_cause cause;  /* code=SCTP_ERROR_STALE_COOKIE */
220         u_int32_t stale_time;           /* time in usec of staleness */
221 };
222
223 struct sctp_error_out_of_resource {
224         struct sctp_error_cause cause;  /* code=SCTP_ERROR_OUT_OF_RESOURCES */
225 };
226
227 struct sctp_error_unresolv_addr {
228         struct sctp_error_cause cause;  /* code=SCTP_ERROR_UNRESOLVABLE_ADDR */
229
230 };
231
232 struct sctp_error_unrecognized_chunk {
233         struct sctp_error_cause cause;  /* code=SCTP_ERROR_UNRECOG_CHUNK */
234         struct sctp_chunkhdr ch;        /* header from chunk in error */
235 };
236
237 #define HAVE_SCTP                       1
238 #define HAVE_KERNEL_SCTP                1
239 #define HAVE_SCTP_PRSCTP                1
240 #define HAVE_SCTP_ADDIP                 1
241 #define HAVE_SCTP_CANSET_PRIMARY        1
242 #define HAVE_SCTP_SAT_NETWORK_CAPABILITY1
243 #define HAVE_SCTP_MULTIBUF              1
244 #define HAVE_SCTP_NOCONNECT             0
245 #define HAVE_SCTP_ECN_NONCE             1  /* ECN Nonce option */
246
247 /* Main SCTP chunk types, we place
248  * these here since that way natd and f/w's
249  * in user land can find them.
250  */
251 #define SCTP_DATA               0x00
252 #define SCTP_INITIATION         0x01
253 #define SCTP_INITIATION_ACK     0x02
254 #define SCTP_SELECTIVE_ACK      0x03
255 #define SCTP_HEARTBEAT_REQUEST  0x04
256 #define SCTP_HEARTBEAT_ACK      0x05
257 #define SCTP_ABORT_ASSOCIATION  0x06
258 #define SCTP_SHUTDOWN           0x07
259 #define SCTP_SHUTDOWN_ACK       0x08
260 #define SCTP_OPERATION_ERROR    0x09
261 #define SCTP_COOKIE_ECHO        0x0a
262 #define SCTP_COOKIE_ACK         0x0b
263 #define SCTP_ECN_ECHO           0x0c
264 #define SCTP_ECN_CWR            0x0d
265 #define SCTP_SHUTDOWN_COMPLETE  0x0e
266
267 /* draft-ietf-tsvwg-addip-sctp */
268 #define SCTP_ASCONF             0xc1
269 #define SCTP_ASCONF_ACK         0x80
270
271 /* draft-ietf-stewart-prsctp */
272 #define SCTP_FORWARD_CUM_TSN    0xc0
273
274 /* draft-ietf-stewart-pktdrpsctp */
275 #define SCTP_PACKET_DROPPED     0x81
276
277 /* draft-ietf-stewart-strreset-xxx */
278 #define SCTP_STREAM_RESET       0x82
279
280 /* ABORT and SHUTDOWN COMPLETE FLAG */
281 #define SCTP_HAD_NO_TCB         0x01
282
283 /* Packet dropped flags */
284 #define SCTP_FROM_MIDDLE_BOX    SCTP_HAD_NO_TCB
285 #define SCTP_BADCRC             0x02
286 #define SCTP_PACKET_TRUNCATED   0x04
287
288 #define SCTP_SAT_NETWORK_MIN         400        /* min ms for RTT to set satellite time */
289 #define SCTP_SAT_NETWORK_BURST_INCR  2          /* how many times to multiply maxburst in sat */
290 /* Data Chuck Specific Flags */
291 #define SCTP_DATA_FRAG_MASK     0x03
292 #define SCTP_DATA_MIDDLE_FRAG   0x00
293 #define SCTP_DATA_LAST_FRAG     0x01
294 #define SCTP_DATA_FIRST_FRAG    0x02
295 #define SCTP_DATA_NOT_FRAG      0x03
296 #define SCTP_DATA_UNORDERED     0x04
297
298 /* ECN Nonce: SACK Chunk Specific Flags */
299 #define SCTP_SACK_NONCE_SUM     0x01
300
301 #include <netinet/sctp_uio.h>
302
303 #endif /* !_NETINET_SCTP_H_ */