sctp_constants.h revision 168124
1234370Sjasone/*-
2234370Sjasone * Copyright (c) 2001-2007, Cisco Systems, Inc. All rights reserved.
3234370Sjasone *
4234370Sjasone * Redistribution and use in source and binary forms, with or without
5234370Sjasone * modification, are permitted provided that the following conditions are met:
6234370Sjasone *
7234370Sjasone * a) Redistributions of source code must retain the above copyright notice,
8234370Sjasone *   this list of conditions and the following disclaimer.
9234370Sjasone *
10234370Sjasone * b) Redistributions in binary form must reproduce the above copyright
11234370Sjasone *    notice, this list of conditions and the following disclaimer in
12234370Sjasone *   the documentation and/or other materials provided with the distribution.
13234370Sjasone *
14234370Sjasone * c) Neither the name of Cisco Systems, Inc. nor the names of its
15234370Sjasone *    contributors may be used to endorse or promote products derived
16234370Sjasone *    from this software without specific prior written permission.
17234370Sjasone *
18234370Sjasone * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19234370Sjasone * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20234370Sjasone * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21234370Sjasone * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22234370Sjasone * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23234370Sjasone * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24234370Sjasone * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25234370Sjasone * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26234370Sjasone * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27234370Sjasone * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28234370Sjasone * THE POSSIBILITY OF SUCH DAMAGE.
29234370Sjasone */
30234370Sjasone
31234370Sjasone/* $KAME: sctp_constants.h,v 1.17 2005/03/06 16:04:17 itojun Exp $	 */
32234370Sjasone
33234370Sjasone#include <sys/cdefs.h>
34234370Sjasone__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 168124 2007-03-31 11:47:30Z rrs $");
35234370Sjasone
36234370Sjasone#ifndef __sctp_constants_h__
37234370Sjasone#define __sctp_constants_h__
38234370Sjasone
39234370Sjasone/* Number of packets to get before sack sent by default */
40234370Sjasone#define SCTP_DEFAULT_SACK_FREQ 2
41242844Sjasone
42242844Sjasone/* Address limit - This variable is calculated
43234370Sjasone * based on an 1500 byte mtu. We take out 100 bytes
44242844Sjasone * for the cookie, 40 bytes for a v6 header and 32
45234370Sjasone * bytes for the init structure. A second init structure
46234370Sjasone * for the init-ack and then finally a third one for the
47234370Sjasone * imbedded init. This yeilds 100+40+(3 * 32) = 236 bytes.
48234370Sjasone * This leaves 1264 bytes for addresses. Now whatever we
49234370Sjasone * send in the INIT() we need to allow to get back in the
50234370Sjasone * INIT-ACK plus all the values from INIT and INIT-ACK
51234370Sjasone * listed in the cookie. Plus we need some overhead for
52234370Sjasone * maybe copied parameters in the COOKIE. If we
53234370Sjasone * allow 20 addresses, and each side has 20 V6 addresses
54234370Sjasone * that will be 400 bytes. In the INIT-ACK we will
55234370Sjasone * see the INIT-ACK 400 + 800 in the cookie. This leaves
56234370Sjasone * 64 bytes slack for misc things in the cookie. Otherwise
57234370Sjasone * we need to allow IP fragmentation.. which I believe
58234370Sjasone * the INIT-ACK and COOKIE do, I don't think we do that
59234370Sjasone * to the INIT though. So the max you could make this
60234370Sjasone * value is 60 addresses.
61234370Sjasone */
62234370Sjasone#define SCTP_ADDRESS_LIMIT 20
63234370Sjasone
64234370Sjasone/* Number of addresses where we just skip the counting */
65234370Sjasone#define SCTP_COUNT_LIMIT 40
66234370Sjasone
67234370Sjasone/* Number of ticks to delay before running
68234370Sjasone * iterator on an address change.
69234370Sjasone */
70234370Sjasone#define SCTP_ADDRESS_TICK_DELAY 2
71234370Sjasone
72242844Sjasone#define SCTP_VERSION_STRING "KAME-BSD 1.1"
73234370Sjasone/* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */
74234370Sjasone#define SCTP_AUDIT_SIZE 256
75234370Sjasone#define SCTP_STAT_LOG_SIZE 80000
76234370Sjasone
77234370Sjasone#define SCTP_USE_THREAD_BASED_ITERATOR 1
78234370Sjasone
79234370Sjasone#define SCTP_KTRHEAD_NAME "sctp_iterator"
80234370Sjasone#define SCTP_KTHREAD_PAGES 2
81234370Sjasone
82234370Sjasone
83234370Sjasone/* If you support Multi-VRF how big to
84234370Sjasone * make the initial array of VRF's to.
85234370Sjasone */
86234370Sjasone#define SCTP_DEFAULT_VRF_SIZE 4
87234370Sjasone
88234370Sjasone/* Places that CWND log can happen from */
89234370Sjasone#define SCTP_CWND_LOG_FROM_FR	1
90234370Sjasone#define SCTP_CWND_LOG_FROM_RTX	2
91234370Sjasone#define SCTP_CWND_LOG_FROM_BRST	3
92234370Sjasone#define SCTP_CWND_LOG_FROM_SS	4
93234370Sjasone#define SCTP_CWND_LOG_FROM_CA	5
94234370Sjasone#define SCTP_CWND_LOG_FROM_SAT	6
95234370Sjasone#define SCTP_BLOCK_LOG_INTO_BLK 7
96235322Sjasone#define SCTP_BLOCK_LOG_OUTOF_BLK 8
97234370Sjasone#define SCTP_BLOCK_LOG_CHECK     9
98234370Sjasone#define SCTP_STR_LOG_FROM_INTO_STRD 10
99234370Sjasone#define SCTP_STR_LOG_FROM_IMMED_DEL 11
100234370Sjasone#define SCTP_STR_LOG_FROM_INSERT_HD 12
101234370Sjasone#define SCTP_STR_LOG_FROM_INSERT_MD 13
102235322Sjasone#define SCTP_STR_LOG_FROM_INSERT_TL 14
103234370Sjasone#define SCTP_STR_LOG_FROM_MARK_TSN  15
104234370Sjasone#define SCTP_STR_LOG_FROM_EXPRS_DEL 16
105234370Sjasone#define SCTP_FR_LOG_BIGGEST_TSNS    17
106234370Sjasone#define SCTP_FR_LOG_STRIKE_TEST     18
107234370Sjasone#define SCTP_FR_LOG_STRIKE_CHUNK    19
108234370Sjasone#define SCTP_FR_T3_TIMEOUT          20
109234370Sjasone#define SCTP_MAP_PREPARE_SLIDE      21
110234370Sjasone#define SCTP_MAP_SLIDE_FROM         22
111234370Sjasone#define SCTP_MAP_SLIDE_RESULT       23
112235238Sjasone#define SCTP_MAP_SLIDE_CLEARED	    24
113235238Sjasone#define SCTP_MAP_SLIDE_NONE         25
114234370Sjasone#define SCTP_FR_T3_MARK_TIME        26
115234370Sjasone#define SCTP_FR_T3_MARKED           27
116234370Sjasone#define SCTP_FR_T3_STOPPED          28
117234370Sjasone#define SCTP_FR_MARKED              30
118234370Sjasone#define SCTP_CWND_LOG_NOADV_SS      31
119234370Sjasone#define SCTP_CWND_LOG_NOADV_CA      32
120234370Sjasone#define SCTP_MAX_BURST_APPLIED      33
121235322Sjasone#define SCTP_MAX_IFP_APPLIED        34
122235238Sjasone#define SCTP_MAX_BURST_ERROR_STOP   35
123235322Sjasone#define SCTP_INCREASE_PEER_RWND     36
124234370Sjasone#define SCTP_DECREASE_PEER_RWND     37
125234370Sjasone#define SCTP_SET_PEER_RWND_VIA_SACK 38
126235322Sjasone#define SCTP_LOG_MBCNT_INCREASE     39
127235238Sjasone#define SCTP_LOG_MBCNT_DECREASE     40
128235322Sjasone#define SCTP_LOG_MBCNT_CHKSET       41
129234370Sjasone#define SCTP_LOG_NEW_SACK           42
130234370Sjasone#define SCTP_LOG_TSN_ACKED          43
131235238Sjasone#define SCTP_LOG_TSN_REVOKED        44
132235238Sjasone#define SCTP_LOG_LOCK_TCB           45
133235238Sjasone#define SCTP_LOG_LOCK_INP           46
134234370Sjasone#define SCTP_LOG_LOCK_SOCK          47
135234370Sjasone#define SCTP_LOG_LOCK_SOCKBUF_R     48
136235322Sjasone#define SCTP_LOG_LOCK_SOCKBUF_S     49
137235238Sjasone#define SCTP_LOG_LOCK_CREATE        50
138235322Sjasone#define SCTP_LOG_INITIAL_RTT        51
139234370Sjasone#define SCTP_LOG_RTTVAR             52
140234370Sjasone#define SCTP_LOG_SBALLOC            53
141235238Sjasone#define SCTP_LOG_SBFREE             54
142234370Sjasone#define SCTP_LOG_SBRESULT           55
143234370Sjasone#define SCTP_FR_DUPED               56
144235322Sjasone#define SCTP_FR_MARKED_EARLY        57
145234370Sjasone#define SCTP_FR_CWND_REPORT         58
146234370Sjasone#define SCTP_FR_CWND_REPORT_START   59
147235238Sjasone#define SCTP_FR_CWND_REPORT_STOP    60
148235238Sjasone#define SCTP_CWND_LOG_FROM_SEND     61
149235238Sjasone#define SCTP_CWND_INITIALIZATION    62
150235238Sjasone#define SCTP_CWND_LOG_FROM_T3       63
151235238Sjasone#define SCTP_CWND_LOG_FROM_SACK     64
152235238Sjasone#define SCTP_CWND_LOG_NO_CUMACK     65
153234370Sjasone#define SCTP_CWND_LOG_FROM_RESEND   66
154234370Sjasone#define SCTP_FR_LOG_CHECK_STRIKE    67
155234370Sjasone#define SCTP_SEND_NOW_COMPLETES     68
156234370Sjasone#define SCTP_CWND_LOG_FILL_OUTQ_CALLED 69
157234370Sjasone#define SCTP_CWND_LOG_FILL_OUTQ_FILLS  70
158234370Sjasone#define SCTP_LOG_FREE_SENT             71
159234370Sjasone#define SCTP_NAGLE_APPLIED          72
160234370Sjasone#define SCTP_NAGLE_SKIPPED          73
161234370Sjasone#define SCTP_WAKESND_FROM_SACK      74
162234370Sjasone#define SCTP_WAKESND_FROM_FWDTSN    75
163234370Sjasone#define SCTP_NOWAKE_FROM_SACK       76
164234370Sjasone#define SCTP_CWNDLOG_PRESEND        77
165242844Sjasone#define SCTP_CWNDLOG_ENDSEND        78
166234370Sjasone#define SCTP_AT_END_OF_SACK         79
167242844Sjasone#define SCTP_REASON_FOR_SC          80
168242844Sjasone#define SCTP_BLOCK_LOG_INTO_BLKA    81
169234370Sjasone#define SCTP_ENTER_USER_RECV        82
170234370Sjasone#define SCTP_USER_RECV_SACKS        83
171242844Sjasone#define SCTP_SORECV_BLOCKSA         84
172234370Sjasone#define SCTP_SORECV_BLOCKSB         85
173242844Sjasone#define SCTP_SORECV_DONE            86
174242844Sjasone#define SCTP_SACK_RWND_UPDATE       87
175242844Sjasone#define SCTP_SORECV_ENTER           88
176234370Sjasone#define SCTP_SORECV_ENTERPL         89
177242844Sjasone#define SCTP_MBUF_INPUT             90
178242844Sjasone#define SCTP_MBUF_IALLOC            91
179242844Sjasone#define SCTP_MBUF_IFREE             92
180242844Sjasone#define SCTP_MBUF_ICOPY             93
181242844Sjasone#define SCTP_SORCV_FREECTL          94
182242844Sjasone#define SCTP_SORCV_DOESCPY          95
183242844Sjasone#define SCTP_SORCV_DOESLCK          96
184242844Sjasone#define SCTP_SORCV_DOESADJ          97
185234370Sjasone#define SCTP_SORCV_BOTWHILE         98
186234370Sjasone#define SCTP_SORCV_PASSBF           99
187234370Sjasone#define SCTP_SORCV_ADJD            100
188234370Sjasone#define SCTP_UNKNOWN_MAX           101
189234370Sjasone#define SCTP_RANDY_STUFF           102
190242844Sjasone#define SCTP_RANDY_STUFF1          103
191234370Sjasone#define SCTP_STRMOUT_LOG_ASSIGN	   104
192234370Sjasone#define SCTP_STRMOUT_LOG_SEND	   105
193234370Sjasone#define SCTP_FLIGHT_LOG_DOWN       106
194234370Sjasone#define SCTP_FLIGHT_LOG_UP         107
195234370Sjasone#define SCTP_LOG_MAX_TYPES 108
196234370Sjasone/*
197234370Sjasone * To turn on various logging, you must first define SCTP_STAT_LOGGING. Then
198234370Sjasone * to get something to log you define one of the logging defines i.e.
199234370Sjasone *
200234370Sjasone * SCTP_CWND_LOGGING SCTP_BLK_LOGGING SCTP_STR_LOGGING SCTP_FR_LOGGING
201234370Sjasone *
202234370Sjasone * Any one or a combination of the logging can be turned on.
203234370Sjasone */
204234370Sjasone#define SCTP_LOG_EVENT_UNKNOWN 0
205234370Sjasone#define SCTP_LOG_EVENT_CWND  1
206234370Sjasone#define SCTP_LOG_EVENT_BLOCK 2
207234370Sjasone#define SCTP_LOG_EVENT_STRM  3
208234370Sjasone#define SCTP_LOG_EVENT_FR    4
209234370Sjasone#define SCTP_LOG_EVENT_MAP   5
210234370Sjasone#define SCTP_LOG_EVENT_MAXBURST 6
211234370Sjasone#define SCTP_LOG_EVENT_RWND  7
212234370Sjasone#define SCTP_LOG_EVENT_MBCNT 8
213234370Sjasone#define SCTP_LOG_EVENT_SACK  9
214234370Sjasone#define SCTP_LOG_LOCK_EVENT 10
215234370Sjasone#define SCTP_LOG_EVENT_RTT  11
216234370Sjasone#define SCTP_LOG_EVENT_SB   12
217234370Sjasone#define SCTP_LOG_EVENT_NAGLE 13
218234370Sjasone#define SCTP_LOG_EVENT_WAKE 14
219234370Sjasone#define SCTP_LOG_MISC_EVENT 15
220234370Sjasone#define SCTP_LOG_EVENT_CLOSE 16
221234370Sjasone#define SCTP_LOG_EVENT_MBUF 17
222234370Sjasone
223234370Sjasone#define SCTP_LOG_MAX_EVENT 18
224234370Sjasone
225234370Sjasone#define SCTP_LOCK_UNKNOWN 2
226234370Sjasone
227234370Sjasone
228234370Sjasone/* number of associations by default for zone allocation */
229234370Sjasone#define SCTP_MAX_NUM_OF_ASOC	40000
230234370Sjasone/* how many addresses per assoc remote and local */
231234370Sjasone#define SCTP_SCALE_FOR_ADDR	2
232234370Sjasone
233234370Sjasone/* default AUTO_ASCONF mode enable(1)/disable(0) value (sysctl) */
234234370Sjasone#if defined (__APPLE__) && !defined(SCTP_APPLE_AUTO_ASCONF)
235234370Sjasone#define SCTP_DEFAULT_AUTO_ASCONF        0
236234370Sjasone#else
237234370Sjasone#define SCTP_DEFAULT_AUTO_ASCONF	1
238234370Sjasone#endif
239234370Sjasone
240234370Sjasone/*
241234370Sjasone * Theshold for rwnd updates, we have to read (sb_hiwat >>
242234370Sjasone * SCTP_RWND_HIWAT_SHIFT) before we will look to see if we need to send a
243234370Sjasone * window update sack. When we look, we compare the last rwnd we sent vs the
244234370Sjasone * current rwnd. It too must be greater than this value. Using 3 divdes the
245234370Sjasone * hiwat by 8, so for 200k rwnd we need to read 24k. For a 64k rwnd we need
246234370Sjasone * to read 8k. This seems about right.. I hope :-D.. we do set a
247234370Sjasone * min of a MTU on it so if the rwnd is real small we will insist
248234370Sjasone * on a full MTU of 1500 bytes.
249234370Sjasone */
250234370Sjasone#define SCTP_RWND_HIWAT_SHIFT 3
251234370Sjasone
252234370Sjasone/* How much of the rwnd must the
253234370Sjasone * message be taking up to start partial delivery.
254234370Sjasone * We calculate this by shifing the hi_water (recv_win)
255234370Sjasone * left the following .. set to 1, when a message holds
256234370Sjasone * 1/2 the rwnd. If we set it to 2 when a message holds
257234370Sjasone * 1/4 the rwnd...etc..
258234370Sjasone */
259234370Sjasone
260234370Sjasone#define SCTP_PARTIAL_DELIVERY_SHIFT 1
261234370Sjasone
262234370Sjasone/* Minimum number of bytes read by user before we
263234370Sjasone * condsider doing a rwnd update
264234370Sjasone */
265234370Sjasone#define SCTP_MIN_READ_BEFORE_CONSIDERING  3000
266234370Sjasone
267234370Sjasone/*
268234370Sjasone * default HMAC for cookies, etc... use one of the AUTH HMAC id's
269234370Sjasone * SCTP_HMAC is the HMAC_ID to use
270234370Sjasone * SCTP_SIGNATURE_SIZE is the digest length
271234370Sjasone */
272234370Sjasone#define SCTP_HMAC		SCTP_AUTH_HMAC_ID_SHA1
273234370Sjasone#define SCTP_SIGNATURE_SIZE	SCTP_AUTH_DIGEST_LEN_SHA1
274234370Sjasone#define SCTP_SIGNATURE_ALOC_SIZE SCTP_SIGNATURE_SIZE
275234370Sjasone
276234370Sjasone/* DEFINE HERE WHAT CRC YOU WANT TO USE */
277234370Sjasone#define SCTP_USECRC_RFC2960  1
278234370Sjasone/* #define SCTP_USECRC_FLETCHER 1 */
279234370Sjasone/* #define SCTP_USECRC_SSHCRC32 1 */
280234370Sjasone/* #define SCTP_USECRC_FASTCRC32 1 */
281234370Sjasone/* #define SCTP_USECRC_CRC32 1 */
282234370Sjasone/* #define SCTP_USECRC_TCP32 1 */
283234370Sjasone/* #define SCTP_USECRC_CRC16SMAL 1 */
284234370Sjasone/* #define SCTP_USECRC_CRC16 1 */
285234370Sjasone/* #define SCTP_USECRC_MODADLER 1 */
286234370Sjasone
287234370Sjasone#ifndef SCTP_ADLER32_BASE
288234370Sjasone#define SCTP_ADLER32_BASE 65521
289234370Sjasone#endif
290234370Sjasone
291234370Sjasone/*
292234370Sjasone * the SCTP protocol signature this includes the version number encoded in
293234370Sjasone * the last 4 bits of the signature.
294234370Sjasone */
295234370Sjasone#define PROTO_SIGNATURE_A	0x30000000
296234370Sjasone#define SCTP_VERSION_NUMBER	0x3
297234370Sjasone
298234370Sjasone#define MAX_TSN	0xffffffff
299234370Sjasone#define MAX_SEQ	0xffff
300234370Sjasone
301234370Sjasone/* how many executions every N tick's */
302234370Sjasone#define SCTP_ITERATOR_MAX_AT_ONCE 20
303234370Sjasone
304234370Sjasone/* number of clock ticks between iterator executions */
305234370Sjasone#define SCTP_ITERATOR_TICKS 1
306234370Sjasone
307234370Sjasone/*
308234370Sjasone * option: If you comment out the following you will receive the old behavior
309234370Sjasone * of obeying cwnd for the fast retransmit algorithm. With this defined a FR
310234370Sjasone * happens right away with-out waiting for the flightsize to drop below the
311234370Sjasone * cwnd value (which is reduced by the FR to 1/2 the inflight packets).
312234370Sjasone */
313234370Sjasone#define SCTP_IGNORE_CWND_ON_FR 1
314234370Sjasone
315234370Sjasone/*
316234370Sjasone * Adds implementors guide behavior to only use newest highest update in SACK
317234370Sjasone * gap ack's to figure out if you need to stroke a chunk for FR.
318234370Sjasone */
319234370Sjasone#define SCTP_NO_FR_UNLESS_SEGMENT_SMALLER 1
320234370Sjasone
321234370Sjasone/* default max I can burst out after a fast retransmit */
322234370Sjasone#define SCTP_DEF_MAX_BURST 4
323234370Sjasone/* IP hdr (20/40) + 12+2+2 (enet) + sctp common 12 */
324234370Sjasone#define SCTP_FIRST_MBUF_RESV 68
325234370Sjasone/* Packet transmit states in the sent field */
326234370Sjasone#define SCTP_DATAGRAM_UNSENT		0
327234370Sjasone#define SCTP_DATAGRAM_SENT		1
328234370Sjasone#define SCTP_DATAGRAM_RESEND1		2	/* not used (in code, but may
329234370Sjasone						 * hit this value) */
330234370Sjasone#define SCTP_DATAGRAM_RESEND2		3	/* not used (in code, but may
331234370Sjasone						 * hit this value) */
332234370Sjasone#define SCTP_DATAGRAM_RESEND		4
333234370Sjasone#define SCTP_DATAGRAM_ACKED		10010
334234370Sjasone#define SCTP_DATAGRAM_INBOUND		10011
335234370Sjasone#define SCTP_READY_TO_TRANSMIT		10012
336234370Sjasone#define SCTP_DATAGRAM_MARKED		20010
337234370Sjasone#define SCTP_FORWARD_TSN_SKIP		30010
338242844Sjasone
339234370Sjasone/* chunk output send from locations */
340242844Sjasone#define SCTP_OUTPUT_FROM_USR_SEND       0
341242844Sjasone#define SCTP_OUTPUT_FROM_T3       	1
342242844Sjasone#define SCTP_OUTPUT_FROM_INPUT_ERROR    2
343234370Sjasone#define SCTP_OUTPUT_FROM_CONTROL_PROC   3
344234370Sjasone#define SCTP_OUTPUT_FROM_SACK_TMR       4
345234370Sjasone#define SCTP_OUTPUT_FROM_SHUT_TMR       5
346234370Sjasone#define SCTP_OUTPUT_FROM_HB_TMR         6
347234370Sjasone#define SCTP_OUTPUT_FROM_SHUT_ACK_TMR   7
348234370Sjasone#define SCTP_OUTPUT_FROM_ASCONF_TMR     8
349234370Sjasone#define SCTP_OUTPUT_FROM_STRRST_TMR     9
350234370Sjasone#define SCTP_OUTPUT_FROM_AUTOCLOSE_TMR  10
351234370Sjasone#define SCTP_OUTPUT_FROM_EARLY_FR_TMR   11
352234370Sjasone#define SCTP_OUTPUT_FROM_STRRST_REQ     12
353234370Sjasone#define SCTP_OUTPUT_FROM_USR_RCVD       13
354234370Sjasone#define SCTP_OUTPUT_FROM_COOKIE_ACK     14
355234370Sjasone#define SCTP_OUTPUT_FROM_DRAIN          15
356234370Sjasone/* SCTP chunk types are moved sctp.h for application (NAT, FW) use */
357234370Sjasone
358234370Sjasone/* align to 32-bit sizes */
359234370Sjasone#define SCTP_SIZE32(x)	((((x)+3) >> 2) << 2)
360234370Sjasone
361234370Sjasone#define IS_SCTP_CONTROL(a) ((a)->chunk_type != SCTP_DATA)
362234370Sjasone#define IS_SCTP_DATA(a) ((a)->chunk_type == SCTP_DATA)
363234370Sjasone
364234370Sjasone
365234370Sjasone/* SCTP parameter types */
366234370Sjasone/*************0x0000 series*************/
367234370Sjasone#define SCTP_HEARTBEAT_INFO		0x0001
368234370Sjasone#define SCTP_IPV4_ADDRESS		0x0005
369234370Sjasone#define SCTP_IPV6_ADDRESS		0x0006
370234370Sjasone#define SCTP_STATE_COOKIE		0x0007
371234370Sjasone#define SCTP_UNRECOG_PARAM		0x0008
372234370Sjasone#define SCTP_COOKIE_PRESERVE		0x0009
373234370Sjasone#define SCTP_HOSTNAME_ADDRESS		0x000b
374234370Sjasone#define SCTP_SUPPORTED_ADDRTYPE		0x000c
375234370Sjasone
376242844Sjasone/* draft-ietf-stewart-strreset-xxx */
377234370Sjasone#define SCTP_STR_RESET_OUT_REQUEST	0x000d
378242844Sjasone#define SCTP_STR_RESET_IN_REQUEST	0x000e
379234370Sjasone#define SCTP_STR_RESET_TSN_REQUEST	0x000f
380234370Sjasone#define SCTP_STR_RESET_RESPONSE		0x0010
381234370Sjasone
382234370Sjasone#define SCTP_MAX_RESET_PARAMS 2
383234370Sjasone#define SCTP_STREAM_RESET_TSN_DELTA    0x1000
384234370Sjasone
385234370Sjasone/*************0x4000 series*************/
386234370Sjasone
387234370Sjasone/*************0x8000 series*************/
388234370Sjasone#define SCTP_ECN_CAPABLE		0x8000
389234370Sjasone/* ECN Nonce: draft-ladha-sctp-ecn-nonce */
390234370Sjasone#define SCTP_ECN_NONCE_SUPPORTED	0x8001
391234370Sjasone/* draft-ietf-tsvwg-auth-xxx */
392234370Sjasone#define SCTP_RANDOM			0x8002
393234370Sjasone#define SCTP_CHUNK_LIST			0x8003
394234370Sjasone#define SCTP_HMAC_LIST			0x8004
395234370Sjasone/*
396234370Sjasone * draft-ietf-tsvwg-addip-sctp-xx param=0x8008  len=0xNNNN Byte | Byte | Byte
397234370Sjasone * | Byte Byte | Byte ...
398234370Sjasone *
399234370Sjasone * Where each byte is a chunk type extension supported. For example, to support
400234370Sjasone * all chunks one would have (in hex):
401234370Sjasone *
402234370Sjasone * 80 01 00 09 C0 C1 80 81 82 00 00 00
403234370Sjasone *
404234370Sjasone * Has the parameter. C0 = PR-SCTP    (RFC3758) C1, 80 = ASCONF (addip draft) 81
405234370Sjasone * = Packet Drop 82 = Stream Reset 83 = Authentication
406234370Sjasone */
407234370Sjasone#define SCTP_SUPPORTED_CHUNK_EXT    0x8008
408234370Sjasone
409234370Sjasone/*************0xC000 series*************/
410234370Sjasone#define SCTP_PRSCTP_SUPPORTED		0xc000
411234370Sjasone/* draft-ietf-tsvwg-addip-sctp */
412235238Sjasone#define SCTP_ADD_IP_ADDRESS		0xc001
413235238Sjasone#define SCTP_DEL_IP_ADDRESS		0xc002
414234370Sjasone#define SCTP_ERROR_CAUSE_IND		0xc003
415235238Sjasone#define SCTP_SET_PRIM_ADDR		0xc004
416235238Sjasone#define SCTP_SUCCESS_REPORT		0xc005
417235238Sjasone#define SCTP_ULP_ADAPTATION		0xc006
418235238Sjasone
419235238Sjasone/* Notification error codes */
420234370Sjasone#define SCTP_NOTIFY_DATAGRAM_UNSENT	0x0001
421234370Sjasone#define SCTP_NOTIFY_DATAGRAM_SENT	0x0002
422234370Sjasone#define SCTP_FAILED_THRESHOLD		0x0004
423242844Sjasone#define SCTP_HEARTBEAT_SUCCESS		0x0008
424242844Sjasone#define SCTP_RESPONSE_TO_USER_REQ	0x000f
425242844Sjasone#define SCTP_INTERNAL_ERROR		0x0010
426242844Sjasone#define SCTP_SHUTDOWN_GUARD_EXPIRES	0x0020
427242844Sjasone#define SCTP_RECEIVED_SACK		0x0040
428242844Sjasone#define SCTP_PEER_FAULTY		0x0080
429242844Sjasone
430242844Sjasone/* bits for TOS field */
431234370Sjasone#define SCTP_ECT0_BIT		0x02
432234370Sjasone#define SCTP_ECT1_BIT		0x01
433234370Sjasone#define SCTP_CE_BITS		0x03
434234370Sjasone
435234370Sjasone/* below turns off above */
436234370Sjasone#define SCTP_FLEXIBLE_ADDRESS	0x20
437234370Sjasone#define SCTP_NO_HEARTBEAT	0x40
438234370Sjasone
439234370Sjasone/* mask to get sticky */
440234370Sjasone#define SCTP_STICKY_OPTIONS_MASK	0x0c
441234370Sjasone
442235238Sjasone
443235238Sjasone/*
444235238Sjasone * SCTP states for internal state machine XXX (should match "user" values)
445235238Sjasone */
446235238Sjasone#define SCTP_STATE_EMPTY		0x0000
447235238Sjasone#define SCTP_STATE_INUSE		0x0001
448235238Sjasone#define SCTP_STATE_COOKIE_WAIT		0x0002
449235238Sjasone#define SCTP_STATE_COOKIE_ECHOED	0x0004
450235238Sjasone#define SCTP_STATE_OPEN			0x0008
451235238Sjasone#define SCTP_STATE_SHUTDOWN_SENT	0x0010
452235238Sjasone#define SCTP_STATE_SHUTDOWN_RECEIVED	0x0020
453235238Sjasone#define SCTP_STATE_SHUTDOWN_ACK_SENT	0x0040
454235238Sjasone#define SCTP_STATE_SHUTDOWN_PENDING	0x0080
455235238Sjasone#define SCTP_STATE_CLOSED_SOCKET	0x0100
456235238Sjasone#define SCTP_STATE_ABOUT_TO_BE_FREED    0x0200
457235238Sjasone#define SCTP_STATE_PARTIAL_MSG_LEFT     0x0400
458235238Sjasone#define SCTP_STATE_MASK			0x007f
459235238Sjasone
460235238Sjasone#define SCTP_GET_STATE(asoc)	((asoc)->state & SCTP_STATE_MASK)
461235238Sjasone
462235238Sjasone/* SCTP reachability state for each address */
463235238Sjasone#define SCTP_ADDR_REACHABLE		0x001
464235238Sjasone#define SCTP_ADDR_NOT_REACHABLE		0x002
465235238Sjasone#define SCTP_ADDR_NOHB			0x004
466251300Sjasone#define SCTP_ADDR_BEING_DELETED		0x008
467251300Sjasone#define SCTP_ADDR_NOT_IN_ASSOC		0x010
468251300Sjasone#define SCTP_ADDR_WAS_PRIMARY		0x020
469235238Sjasone#define SCTP_ADDR_SWITCH_PRIMARY	0x040
470234370Sjasone#define SCTP_ADDR_OUT_OF_SCOPE		0x080
471234370Sjasone#define SCTP_ADDR_DOUBLE_SWITCH		0x100
472234370Sjasone#define SCTP_ADDR_UNCONFIRMED		0x200
473234370Sjasone#define SCTP_ADDR_REQ_PRIMARY           0x400
474234370Sjasone#define SCTP_REACHABLE_MASK		0x203
475234370Sjasone
476234543Sjasone/* bound address types (e.g. valid address types to allow) */
477234370Sjasone#define SCTP_BOUND_V6		0x01
478234370Sjasone#define SCTP_BOUND_V4		0x02
479234370Sjasone
480234370Sjasone/*
481234370Sjasone * what is the default number of mbufs in a chain I allow before switching to
482235238Sjasone * a cluster
483245868Sjasone */
484235238Sjasone#define SCTP_DEFAULT_MBUFS_IN_CHAIN 5
485235238Sjasone
486235238Sjasone/* How long a cookie lives in seconds */
487235238Sjasone#define SCTP_DEFAULT_COOKIE_LIFE	60
488235238Sjasone
489235238Sjasone/* resource limit of streams */
490235238Sjasone#define MAX_SCTP_STREAMS	2048
491235238Sjasone
492235238Sjasone/* Maximum the mapping array will  grow to (TSN mapping array) */
493245868Sjasone#define SCTP_MAPPING_ARRAY	512
494235238Sjasone
495235238Sjasone/* size of the inital malloc on the mapping array */
496235238Sjasone#define SCTP_INITIAL_MAPPING_ARRAY  16
497235238Sjasone/* how much we grow the mapping array each call */
498235238Sjasone#define SCTP_MAPPING_ARRAY_INCR     32
499235238Sjasone
500245868Sjasone/*
501235238Sjasone * Here we define the timer types used by the implementation as arguments in
502235238Sjasone * the set/get timer type calls.
503235238Sjasone */
504235238Sjasone#define SCTP_TIMER_INIT 	0
505235238Sjasone#define SCTP_TIMER_RECV 	1
506235238Sjasone#define SCTP_TIMER_SEND 	2
507245868Sjasone#define SCTP_TIMER_HEARTBEAT	3
508235238Sjasone#define SCTP_TIMER_PMTU		4
509235238Sjasone#define SCTP_TIMER_MAXSHUTDOWN	5
510235238Sjasone#define SCTP_TIMER_SIGNATURE	6
511235238Sjasone/*
512235238Sjasone * number of timer types in the base SCTP structure used in the set/get and
513235238Sjasone * has the base default.
514235238Sjasone */
515235238Sjasone#define SCTP_NUM_TMRS	7
516235238Sjasone
517245868Sjasone/* timer types */
518235238Sjasone#define SCTP_TIMER_TYPE_NONE		0
519235238Sjasone#define SCTP_TIMER_TYPE_SEND		1
520235238Sjasone#define SCTP_TIMER_TYPE_INIT		2
521235238Sjasone#define SCTP_TIMER_TYPE_RECV		3
522235238Sjasone#define SCTP_TIMER_TYPE_SHUTDOWN	4
523235238Sjasone#define SCTP_TIMER_TYPE_HEARTBEAT	5
524235238Sjasone#define SCTP_TIMER_TYPE_COOKIE		6
525235238Sjasone#define SCTP_TIMER_TYPE_NEWCOOKIE	7
526235238Sjasone#define SCTP_TIMER_TYPE_PATHMTURAISE	8
527235238Sjasone#define SCTP_TIMER_TYPE_SHUTDOWNACK	9
528245868Sjasone#define SCTP_TIMER_TYPE_ASCONF		10
529235238Sjasone#define SCTP_TIMER_TYPE_SHUTDOWNGUARD	11
530235238Sjasone#define SCTP_TIMER_TYPE_AUTOCLOSE	12
531235238Sjasone#define SCTP_TIMER_TYPE_EVENTWAKE	13
532235238Sjasone#define SCTP_TIMER_TYPE_STRRESET        14
533235238Sjasone#define SCTP_TIMER_TYPE_INPKILL         15
534235238Sjasone#define SCTP_TIMER_TYPE_ITERATOR        16
535235238Sjasone#define SCTP_TIMER_TYPE_EARLYFR         17
536235238Sjasone#define SCTP_TIMER_TYPE_ASOCKILL        18
537235238Sjasone#define SCTP_TIMER_TYPE_ADDR_WQ         19
538235238Sjasone/* add new timers here - and increment LAST */
539245868Sjasone#define SCTP_TIMER_TYPE_LAST            20
540235238Sjasone
541235238Sjasone#define SCTP_IS_TIMER_TYPE_VALID(t)	(((t) > SCTP_TIMER_TYPE_NONE) && \
542235238Sjasone					 ((t) < SCTP_TIMER_TYPE_LAST))
543235238Sjasone
544235238Sjasone
545235238Sjasone
546235238Sjasone/*
547235238Sjasone * Number of ticks before the soxwakeup() event that is delayed is sent AFTER
548235238Sjasone * the accept() call
549235238Sjasone */
550235238Sjasone#define SCTP_EVENTWAKEUP_WAIT_TICKS	3000
551245868Sjasone
552235238Sjasone/*
553235238Sjasone * Of course we really don't collect stale cookies, being folks of decerning
554235238Sjasone * taste. However we do count them, if we get too many before the association
555235238Sjasone * comes up.. we give up. Below is the constant that dictates when we give it
556235238Sjasone * up...this is a implemenation dependent treatment. In ours we do not ask
557235238Sjasone * for a extension of time, but just retry this many times...
558235238Sjasone */
559235238Sjasone#define SCTP_MAX_STALE_COOKIES_I_COLLECT 10
560245868Sjasone
561235238Sjasone/* max number of TSN's dup'd that I will hold */
562235238Sjasone#define SCTP_MAX_DUP_TSNS	20
563235238Sjasone
564235238Sjasone/*
565235238Sjasone * Here we define the types used when setting the retry amounts.
566235238Sjasone */
567235238Sjasone/* constants for type of set */
568235238Sjasone#define SCTP_MAXATTEMPT_INIT	2
569245868Sjasone#define SCTP_MAXATTEMPT_SEND	3
570235238Sjasone
571235238Sjasone/* Maximum TSN's we will summarize in a drop report */
572235238Sjasone#define SCTP_MAX_DROP_REPORT 16
573235238Sjasone
574235238Sjasone/* How many drop re-attempts we make on  INIT/COOKIE-ECHO */
575235238Sjasone#define SCTP_RETRY_DROPPED_THRESH 4
576235238Sjasone
577235238Sjasone/*
578245868Sjasone * And the max we will keep a history of in the tcb which MUST be lower than
579235238Sjasone * 256.
580235238Sjasone */
581235238Sjasone#define SCTP_MAX_DROP_SAVE_REPORT 16
582235238Sjasone
583235238Sjasone/*
584235238Sjasone * Here we define the default timers and the default number of attemts we
585235238Sjasone * make for each respective side (send/init).
586235238Sjasone */
587245868Sjasone
588235238Sjasone/*
589235238Sjasone * Maxmium number of chunks a single association can have on it. Note that
590235238Sjasone * this is a squishy number since the count can run over this if the user
591235238Sjasone * sends a large message down .. the fragmented chunks don't count until
592235238Sjasone * AFTER the message is on queue.. it would be the next send that blocks
593235238Sjasone * things. This number will get tuned up at boot in the sctp_init and use the
594235238Sjasone * number of clusters as a base. This way high bandwidth environments will
595235238Sjasone * not get impacted by the lower bandwidth sending a bunch of 1 byte chunks
596235322Sjasone */
597235238Sjasone#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512
598235238Sjasone
599235238Sjasone/* The conversion from time to ticks and vice versa is done by rounding
600245868Sjasone * upwards. This way we can test in the code the time to be positive and
601235238Sjasone * know that this corresponds to a positive number of ticks.
602235238Sjasone */
603235238Sjasone#define MSEC_TO_TICKS(x) ((hz == 1000) ? x : ((((x) * hz) + 999) / 1000))
604235238Sjasone#define TICKS_TO_MSEC(x) ((hz == 1000) ? x : ((((x) * 1000) + (hz - 1)) / hz))
605235238Sjasone
606235238Sjasone#define SEC_TO_TICKS(x) ((x) * hz)
607235238Sjasone#define TICKS_TO_SEC(x) (((x) + (hz - 1)) / hz)
608235238Sjasone
609235238Sjasone/*
610235238Sjasone * Basically the minimum amount of time before I do a early FR. Making this
611235238Sjasone * value to low will cause duplicate retransmissions.
612245868Sjasone */
613235238Sjasone#define SCTP_MINFR_MSEC_TIMER 250
614235238Sjasone/* The floor this value is allowed to fall to when starting a timer. */
615235238Sjasone#define SCTP_MINFR_MSEC_FLOOR 20
616235238Sjasone
617235322Sjasone/* init timer def = 1 sec */
618235238Sjasone#define SCTP_INIT_SEC	1
619235238Sjasone
620235238Sjasone/* send timer def = 1 seconds */
621235322Sjasone#define SCTP_SEND_SEC	1
622235322Sjasone
623235322Sjasone/* recv timer def = 200ms  */
624235322Sjasone#define SCTP_RECV_MSEC	200
625235238Sjasone
626235238Sjasone/* 30 seconds + RTO (in ms) */
627245868Sjasone#define SCTP_HB_DEFAULT_MSEC	30000
628235238Sjasone
629235238Sjasone/* Max time I will wait for Shutdown to complete */
630235238Sjasone#define SCTP_DEF_MAX_SHUTDOWN_SEC 180
631235238Sjasone
632235238Sjasone
633235238Sjasone/*
634235238Sjasone * This is how long a secret lives, NOT how long a cookie lives how many
635235238Sjasone * ticks the current secret will live.
636235238Sjasone */
637235238Sjasone#define SCTP_DEFAULT_SECRET_LIFE_SEC 3600
638235238Sjasone
639235238Sjasone#define SCTP_RTO_UPPER_BOUND	(60000)	/* 60 sec in ms */
640245868Sjasone#define SCTP_RTO_UPPER_BOUND_SEC 60	/* for the init timer */
641235238Sjasone#define SCTP_RTO_LOWER_BOUND	(1000)	/* 1 sec in ms */
642235238Sjasone#define SCTP_RTO_INITIAL	(3000)	/* 3 sec in ms */
643235238Sjasone
644235238Sjasone
645235322Sjasone#define SCTP_INP_KILL_TIMEOUT 20/* number of ms to retry kill of inpcb */
646235238Sjasone#define SCTP_ASOC_KILL_TIMEOUT 10	/* number of ms to retry kill of inpcb */
647235238Sjasone
648235238Sjasone#define SCTP_DEF_MAX_INIT	8
649235238Sjasone#define SCTP_DEF_MAX_SEND	10
650235322Sjasone#define SCTP_DEF_MAX_PATH_RTX	4
651235322Sjasone
652235238Sjasone#define SCTP_DEF_PMTU_RAISE_SEC	600	/* 10 min between raise attempts */
653235322Sjasone#define SCTP_DEF_PMTU_MIN	600
654235238Sjasone
655235238Sjasone#define SCTP_MSEC_IN_A_SEC	1000
656245868Sjasone#define SCTP_USEC_IN_A_SEC	1000000
657235238Sjasone#define SCTP_NSEC_IN_A_SEC	1000000000
658235238Sjasone
659235238Sjasone#define SCTP_MAX_OUTSTANDING_DG	10000
660235238Sjasone
661235238Sjasone/* How many streams I request initally by default */
662235238Sjasone#define SCTP_OSTREAM_INITIAL 10
663235238Sjasone
664235238Sjasone/*
665235238Sjasone * How many smallest_mtu's need to increase before a window update sack is
666251300Sjasone * sent (should be a power of 2).
667245868Sjasone */
668245868Sjasone#define SCTP_SEG_TO_RWND_UPD 32
669245868Sjasone/* Send window update (incr * this > hiwat). Should be a power of 2 */
670245868Sjasone#define SCTP_SCALE_OF_RWND_TO_UPD       4
671245868Sjasone#define SCTP_MINIMAL_RWND		(4096)	/* minimal rwnd */
672245868Sjasone
673245868Sjasone#define SCTP_ADDRMAX		20
674245868Sjasone
675245868Sjasone/* SCTP DEBUG Switch parameters */
676251300Sjasone#define SCTP_DEBUG_TIMER1	0x00000001
677245868Sjasone#define SCTP_DEBUG_TIMER2	0x00000002
678251300Sjasone#define SCTP_DEBUG_TIMER3	0x00000004
679245868Sjasone#define SCTP_DEBUG_TIMER4	0x00000008
680245868Sjasone#define SCTP_DEBUG_OUTPUT1	0x00000010
681251300Sjasone#define SCTP_DEBUG_OUTPUT2	0x00000020
682245868Sjasone#define SCTP_DEBUG_OUTPUT3	0x00000040
683245868Sjasone#define SCTP_DEBUG_OUTPUT4	0x00000080
684245868Sjasone#define SCTP_DEBUG_UTIL1	0x00000100
685245868Sjasone#define SCTP_DEBUG_UTIL2	0x00000200
686245868Sjasone#define SCTP_DEBUG_AUTH1	0x00000400
687245868Sjasone#define SCTP_DEBUG_AUTH2	0x00000800
688251300Sjasone#define SCTP_DEBUG_INPUT1	0x00001000
689251300Sjasone#define SCTP_DEBUG_INPUT2	0x00002000
690245868Sjasone#define SCTP_DEBUG_INPUT3	0x00004000
691245868Sjasone#define SCTP_DEBUG_INPUT4	0x00008000
692251300Sjasone#define SCTP_DEBUG_ASCONF1	0x00010000
693245868Sjasone#define SCTP_DEBUG_ASCONF2	0x00020000
694245868Sjasone#define SCTP_DEBUG_OUTPUT5	0x00040000
695245868Sjasone#define SCTP_DEBUG_XXX		0x00080000
696245868Sjasone#define SCTP_DEBUG_PCB1		0x00100000
697245868Sjasone#define SCTP_DEBUG_PCB2		0x00200000
698245868Sjasone#define SCTP_DEBUG_PCB3		0x00400000
699251300Sjasone#define SCTP_DEBUG_PCB4		0x00800000
700251300Sjasone#define SCTP_DEBUG_INDATA1	0x01000000
701251300Sjasone#define SCTP_DEBUG_INDATA2	0x02000000
702251300Sjasone#define SCTP_DEBUG_INDATA3	0x04000000
703251300Sjasone#define SCTP_DEBUG_INDATA4	0x08000000
704251300Sjasone#define SCTP_DEBUG_USRREQ1	0x10000000
705251300Sjasone#define SCTP_DEBUG_USRREQ2	0x20000000
706251300Sjasone#define SCTP_DEBUG_PEEL1	0x40000000
707251300Sjasone#define SCTP_DEBUG_XXXXX	0x80000000
708251300Sjasone#define SCTP_DEBUG_ALL		0x7ff3ffff
709245868Sjasone#define SCTP_DEBUG_NOISY	0x00040000
710245868Sjasone
711245868Sjasone/* What sender needs to see to avoid SWS or we consider peers rwnd 0 */
712235238Sjasone#define SCTP_SWS_SENDER_DEF	1420
713235238Sjasone
714235238Sjasone/*
715235238Sjasone * SWS is scaled to the sb_hiwat of the socket. A value of 2 is hiwat/4, 1
716235238Sjasone * would be hiwat/2 etc.
717235238Sjasone */
718235238Sjasone/* What receiver needs to see in sockbuf or we tell peer its 1 */
719235238Sjasone#define SCTP_SWS_RECEIVER_DEF	3000
720235238Sjasone
721235238Sjasone#define SCTP_INITIAL_CWND 4380
722235238Sjasone
723235238Sjasone/* amount peer is obligated to have in rwnd or I will abort */
724235238Sjasone#define SCTP_MIN_RWND	1500
725235238Sjasone
726235238Sjasone#define SCTP_WINDOW_MIN	1500	/* smallest rwnd can be */
727235238Sjasone#define SCTP_WINDOW_MAX 1048576	/* biggest I can grow rwnd to My playing
728235238Sjasone				 * around suggests a value greater than 64k
729235238Sjasone				 * does not do much, I guess via the kernel
730235238Sjasone				 * limitations on the stream/socket. */
731235238Sjasone
732235238Sjasone/* I can handle a 1meg re-assembly */
733235238Sjasone#define SCTP_DEFAULT_MAXMSGREASM 1048576
734235238Sjasone
735235238Sjasone#define SCTP_DEFAULT_MAXSEGMENT 65535
736235238Sjasone
737235238Sjasone#define SCTP_CHUNK_BUFFER_SIZE	2048
738235238Sjasone#define SCTP_PARAM_BUFFER_SIZE	512
739235238Sjasone
740235238Sjasone#define SCTP_DEFAULT_MINSEGMENT 512	/* MTU size ... if no mtu disc */
741235238Sjasone#define SCTP_HOW_MANY_SECRETS	2	/* how many secrets I keep */
742235238Sjasone
743235238Sjasone#define SCTP_NUMBER_OF_SECRETS	8	/* or 8 * 4 = 32 octets */
744235238Sjasone#define SCTP_SECRET_SIZE	32	/* number of octets in a 256 bits */
745235238Sjasone
746235238Sjasone
747235238Sjasone/*
748235238Sjasone * SCTP upper layer notifications
749235238Sjasone */
750235238Sjasone#define SCTP_NOTIFY_ASSOC_UP		1
751235238Sjasone#define SCTP_NOTIFY_ASSOC_DOWN		2
752235238Sjasone#define SCTP_NOTIFY_INTERFACE_DOWN	3
753235238Sjasone#define SCTP_NOTIFY_INTERFACE_UP	4
754234370Sjasone#define SCTP_NOTIFY_DG_FAIL		5
755234370Sjasone#define SCTP_NOTIFY_STRDATA_ERR 	6
756234370Sjasone#define SCTP_NOTIFY_ASSOC_ABORTED	7
757234370Sjasone#define SCTP_NOTIFY_PEER_OPENED_STREAM	8
758234370Sjasone#define SCTP_NOTIFY_STREAM_OPENED_OK	9
759234370Sjasone#define SCTP_NOTIFY_ASSOC_RESTART	10
760234370Sjasone#define SCTP_NOTIFY_HB_RESP             11
761234370Sjasone#define SCTP_NOTIFY_ASCONF_SUCCESS	12
762234370Sjasone#define SCTP_NOTIFY_ASCONF_FAILED	13
763234370Sjasone#define SCTP_NOTIFY_PEER_SHUTDOWN	14
764234370Sjasone#define SCTP_NOTIFY_ASCONF_ADD_IP	15
765234370Sjasone#define SCTP_NOTIFY_ASCONF_DELETE_IP	16
766234370Sjasone#define SCTP_NOTIFY_ASCONF_SET_PRIMARY	17
767234370Sjasone#define SCTP_NOTIFY_PARTIAL_DELVIERY_INDICATION 18
768234370Sjasone#define SCTP_NOTIFY_ADAPTATION_INDICATION       19
769234370Sjasone/* same as above */
770234370Sjasone#define SCTP_NOTIFY_ADAPTION_INDICATION         19
771234370Sjasone#define SCTP_NOTIFY_INTERFACE_CONFIRMED 20
772234370Sjasone#define SCTP_NOTIFY_STR_RESET_RECV      21
773234370Sjasone#define SCTP_NOTIFY_STR_RESET_SEND      22
774234370Sjasone#define SCTP_NOTIFY_STR_RESET_FAILED_OUT 23
775234370Sjasone#define SCTP_NOTIFY_STR_RESET_FAILED_IN 24
776234370Sjasone#define SCTP_NOTIFY_AUTH_NEW_KEY	25
777234370Sjasone#define SCTP_NOTIFY_AUTH_KEY_CONFLICT	26
778234370Sjasone#define SCTP_NOTIFY_SPECIAL_SP_FAIL     27
779234370Sjasone#define SCTP_NOTIFY_MAX			27
780234370Sjasone
781234370Sjasone/* This is the value for messages that are NOT completely
782234370Sjasone * copied down where we will start to split the message.
783234370Sjasone * So, with our default, we split only if the piece we
784234370Sjasone * want to take will fill up a full MTU (assuming
785234370Sjasone * a 1500 byte MTU).
786234370Sjasone */
787234370Sjasone#define SCTP_DEFAULT_SPLIT_POINT_MIN 2904
788234370Sjasone
789234370Sjasone/* ABORT CODES and other tell-tale location
790234370Sjasone * codes are generated by adding the below
791234370Sjasone * to the instance id.
792234370Sjasone */
793234370Sjasone
794234370Sjasone/* File defines */
795234370Sjasone#define SCTP_FROM_SCTP_INPUT   0x10000000
796234370Sjasone#define SCTP_FROM_SCTP_PCB     0x20000000
797234370Sjasone#define SCTP_FROM_SCTP_INDATA  0x30000000
798234370Sjasone#define SCTP_FROM_SCTP_TIMER   0x40000000
799234370Sjasone#define SCTP_FROM_SCTP_USRREQ  0x50000000
800234370Sjasone#define SCTP_FROM_SCTPUTIL     0x60000000
801234370Sjasone#define SCTP_FROM_SCTP6_USRREQ 0x70000000
802234370Sjasone#define SCTP_FROM_SCTP_ASCONF  0x80000000
803234370Sjasone#define SCTP_FROM_SCTP_OUTPUT  0x90000000
804234370Sjasone#define SCTP_FROM_SCTP_PEELOFF 0xa0000000
805234370Sjasone
806234370Sjasone/* Location ID's */
807234370Sjasone#define SCTP_LOC_1  0x00000001
808234370Sjasone#define SCTP_LOC_2  0x00000002
809234370Sjasone#define SCTP_LOC_3  0x00000003
810234370Sjasone#define SCTP_LOC_4  0x00000004
811234370Sjasone#define SCTP_LOC_5  0x00000005
812234370Sjasone#define SCTP_LOC_6  0x00000006
813234370Sjasone#define SCTP_LOC_7  0x00000007
814234370Sjasone#define SCTP_LOC_8  0x00000008
815234370Sjasone#define SCTP_LOC_9  0x00000009
816234370Sjasone#define SCTP_LOC_10 0x0000000a
817234370Sjasone#define SCTP_LOC_11 0x0000000b
818234370Sjasone#define SCTP_LOC_12 0x0000000c
819234370Sjasone#define SCTP_LOC_13 0x0000000d
820234370Sjasone#define SCTP_LOC_14 0x0000000e
821234370Sjasone#define SCTP_LOC_15 0x0000000f
822234370Sjasone#define SCTP_LOC_16 0x00000010
823234370Sjasone#define SCTP_LOC_17 0x00000011
824234370Sjasone#define SCTP_LOC_18 0x00000012
825234370Sjasone#define SCTP_LOC_19 0x00000013
826234370Sjasone#define SCTP_LOC_20 0x00000014
827234370Sjasone#define SCTP_LOC_21 0x00000015
828234370Sjasone#define SCTP_LOC_22 0x00000016
829234370Sjasone#define SCTP_LOC_23 0x00000017
830234370Sjasone#define SCTP_LOC_24 0x00000018
831234370Sjasone#define SCTP_LOC_25 0x00000019
832234370Sjasone#define SCTP_LOC_26 0x0000001a
833234370Sjasone#define SCTP_LOC_27 0x0000001b
834234370Sjasone#define SCTP_LOC_28 0x0000001c
835234370Sjasone#define SCTP_LOC_29 0x0000001d
836234370Sjasone#define SCTP_LOC_30 0x0000001e
837234370Sjasone#define SCTP_LOC_31 0x0000001f
838234370Sjasone#define SCTP_LOC_32 0x00000020
839234370Sjasone
840234370Sjasone
841234370Sjasone/* Free assoc codes */
842234370Sjasone#define SCTP_NORMAL_PROC      0
843234370Sjasone#define SCTP_PCBFREE_NOFORCE  1
844234370Sjasone#define SCTP_PCBFREE_FORCE    2
845234370Sjasone
846235238Sjasone/* From codes for adding addresses */
847234370Sjasone#define SCTP_ADDR_IS_CONFIRMED 8
848234370Sjasone#define SCTP_ADDR_DYNAMIC_ADDED 6
849234370Sjasone#define SCTP_IN_COOKIE_PROC 100
850234370Sjasone#define SCTP_ALLOC_ASOC  1
851234370Sjasone#define SCTP_LOAD_ADDR_2 2
852234370Sjasone#define SCTP_LOAD_ADDR_3 3
853234370Sjasone#define SCTP_LOAD_ADDR_4 4
854234370Sjasone#define SCTP_LOAD_ADDR_5 5
855235238Sjasone
856235238Sjasone#define SCTP_DONOT_SETSCOPE 0
857234370Sjasone#define SCTP_DO_SETSCOPE 1
858234370Sjasone
859234370Sjasone
860234370Sjasone/* This value determines the default for when
861234370Sjasone * we try to add more on the send queue., if
862234370Sjasone * there is room. This prevents us from cycling
863234370Sjasone * into the copy_resume routine to often if
864234370Sjasone * we have not got enough space to add a decent
865234370Sjasone * enough size message. Note that if we have enough
866235238Sjasone * space to complete the message copy we will always
867234370Sjasone * add to the message, no matter what the size. Its
868234370Sjasone * only when we reach the point that we have some left
869234370Sjasone * to add, there is only room for part of it that we
870234370Sjasone * will use this threshold. Its also a sysctl.
871234370Sjasone */
872234370Sjasone#define SCTP_DEFAULT_ADD_MORE 1452
873234370Sjasone
874234370Sjasone#ifndef SCTP_PCBHASHSIZE
875234370Sjasone/* default number of association hash buckets in each endpoint */
876234370Sjasone#define SCTP_PCBHASHSIZE 256
877234370Sjasone#endif
878234370Sjasone#ifndef SCTP_TCBHASHSIZE
879234370Sjasone#define SCTP_TCBHASHSIZE 1024
880234370Sjasone#endif
881234370Sjasone
882234370Sjasone#ifndef SCTP_CHUNKQUEUE_SCALE
883235238Sjasone#define SCTP_CHUNKQUEUE_SCALE 10
884234370Sjasone#endif
885234370Sjasone
886234370Sjasone/* clock variance is 1 ms */
887234370Sjasone#define SCTP_CLOCK_GRANULARITY	1
888234370Sjasone#define IP_HDR_SIZE 40		/* we use the size of a IP6 header here this
889234370Sjasone				 * detracts a small amount for ipv4 but it
890234370Sjasone				 * simplifies the ipv6 addition */
891234370Sjasone
892234370Sjasone#ifndef IPPROTO_SCTP
893234370Sjasone#define IPPROTO_SCTP 132	/* the Official IANA number :-) */
894235238Sjasone#endif				/* !IPPROTO_SCTP */
895234370Sjasone
896234370Sjasone#define SCTP_MAX_DATA_BUNDLING		256
897234370Sjasone#define SCTP_MAX_CONTROL_BUNDLING	20
898234370Sjasone
899234370Sjasone/* modular comparison */
900234370Sjasone/* True if a > b (mod = M) */
901234370Sjasone#define compare_with_wrap(a, b, M) (((a > b) && ((a - b) < ((M >> 1) + 1))) || \
902234370Sjasone              ((b > a) && ((b - a) > ((M >> 1) + 1))))
903235238Sjasone
904234370Sjasone
905234370Sjasone/* Mapping array manipulation routines */
906245868Sjasone#define SCTP_IS_TSN_PRESENT(arry, gap) ((arry[(gap >> 3)] >> (gap & 0x07)) & 0x01)
907234370Sjasone#define SCTP_SET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] |= (0x01 << ((gap & 0x07))))
908234370Sjasone#define SCTP_UNSET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] &= ((~(0x01 << ((gap & 0x07)))) & 0xff))
909234370Sjasone
910234370Sjasone
911234370Sjasone#define SCTP_RETRAN_DONE -1
912234370Sjasone#define SCTP_RETRAN_EXIT -2
913234370Sjasone
914234370Sjasone/*
915234370Sjasone * This value defines the number of vtag block time wait entry's per list
916234370Sjasone * element.  Each entry will take 2 4 byte ints (and of course the overhead
917234370Sjasone * of the next pointer as well). Using 15 as an example will yield * ((8 *
918234370Sjasone * 15) + 8) or 128 bytes of overhead for each timewait block that gets
919234370Sjasone * initialized. Increasing it to 31 would yeild 256 bytes per block.
920234370Sjasone */
921234370Sjasone#define SCTP_NUMBER_IN_VTAG_BLOCK 15
922234370Sjasone/*
923234370Sjasone * If we use the STACK option, we have an array of this size head pointers.
924234370Sjasone * This array is mod'd the with the size to find which bucket and then all
925234370Sjasone * entries must be searched to see if the tag is in timed wait. If so we
926234370Sjasone * reject it.
927234370Sjasone */
928234370Sjasone#define SCTP_STACK_VTAG_HASH_SIZE 31
929234370Sjasone
930234370Sjasone/*
931234370Sjasone * If we use the per-endpoint model than we do not have a hash table of
932234370Sjasone * entries but instead have a single head pointer and we must crawl through
933234370Sjasone * the entire list.
934234370Sjasone */
935234370Sjasone
936234543Sjasone/*
937245868Sjasone * Number of seconds of time wait, tied to MSL value (2 minutes), so 2 * MSL
938234543Sjasone * = 4 minutes or 480 seconds.
939234543Sjasone */
940234543Sjasone#define SCTP_TIME_WAIT 480
941234543Sjasone
942235238Sjasone/* This time wait is the same as the default cookie life
943234543Sjasone * since we now enter a tag in every time we send a cookie.
944234543Sjasone * We want this shorter to avoid vtag depletion.
945234543Sjasone */
946234543Sjasone#define SCTP_TIME_WAIT_SHORT 60
947234543Sjasone
948234543Sjasone/* The system retains a cache of free chunks such to
949235238Sjasone * cut down on calls the memory allocation system. There
950235238Sjasone * is a per association limit of free items and a overall
951235238Sjasone * system limit. If either one gets hit then the resource
952235238Sjasone * stops being cached.
953235238Sjasone */
954235238Sjasone
955235238Sjasone#define SCTP_DEF_ASOC_RESC_LIMIT 10
956235238Sjasone#define SCTP_DEF_SYSTEM_RESC_LIMIT 1000
957235238Sjasone
958235238Sjasone
959234543Sjasone#define IN4_ISPRIVATE_ADDRESS(a) \
960235238Sjasone   ((((uint8_t *)&(a)->s_addr)[0] == 10) || \
961234543Sjasone    ((((uint8_t *)&(a)->s_addr)[0] == 172) && \
962235238Sjasone     (((uint8_t *)&(a)->s_addr)[1] >= 16) && \
963235238Sjasone     (((uint8_t *)&(a)->s_addr)[1] <= 32)) || \
964235238Sjasone    ((((uint8_t *)&(a)->s_addr)[0] == 192) && \
965235238Sjasone     (((uint8_t *)&(a)->s_addr)[1] == 168)))
966235238Sjasone
967235238Sjasone#define IN4_ISLOOPBACK_ADDRESS(a) \
968235238Sjasone    ((((uint8_t *)&(a)->s_addr)[0] == 127) && \
969235238Sjasone     (((uint8_t *)&(a)->s_addr)[1] == 0) && \
970235238Sjasone     (((uint8_t *)&(a)->s_addr)[2] == 0) && \
971235238Sjasone     (((uint8_t *)&(a)->s_addr)[3] == 1))
972235238Sjasone
973235238Sjasone
974235238Sjasone#if defined(_KERNEL)
975235238Sjasone
976235238Sjasone#define SCTP_GETTIME_TIMEVAL(x)	(getmicrouptime(x))
977235238Sjasone#define SCTP_GETPTIME_TIMEVAL(x)	(microuptime(x))
978234543Sjasone/*#if defined(__FreeBSD__) || defined(__APPLE__)*/
979234543Sjasone/*#define SCTP_GETTIME_TIMEVAL(x) { \*/
980234543Sjasone/*	(x)->tv_sec = ticks / 1000; \*/
981234543Sjasone/*	(x)->tv_usec = (ticks % 1000) * 1000; \*/
982234543Sjasone/*}*/
983245868Sjasone
984234370Sjasone/*#else*/
985234370Sjasone/*#define SCTP_GETTIME_TIMEVAL(x)	(microtime(x))*/
986235238Sjasone/*#endif				 __FreeBSD__ */
987234370Sjasone
988234370Sjasone#define sctp_sowwakeup(inp, so) \
989234370Sjasonedo { \
990234370Sjasone	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
991234370Sjasone		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
992234370Sjasone	} else { \
993234370Sjasone		sowwakeup(so); \
994234370Sjasone	} \
995235238Sjasone} while (0)
996235238Sjasone
997235238Sjasone#define sctp_sowwakeup_locked(inp, so) \
998234370Sjasonedo { \
999235238Sjasone	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1000235238Sjasone                SOCKBUF_UNLOCK(&((so)->so_snd)); \
1001234370Sjasone		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
1002235238Sjasone	} else { \
1003235238Sjasone		sowwakeup_locked(so); \
1004235238Sjasone	} \
1005235238Sjasone} while (0)
1006234370Sjasone
1007235238Sjasone#define sctp_sorwakeup(inp, so) \
1008234370Sjasonedo { \
1009234370Sjasone	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1010234370Sjasone		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
1011234370Sjasone	} else { \
1012234370Sjasone		sorwakeup(so); \
1013234370Sjasone	} \
1014235238Sjasone} while (0)
1015234370Sjasone
1016234370Sjasone#define sctp_sorwakeup_locked(inp, so) \
1017234370Sjasonedo { \
1018235238Sjasone	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1019234370Sjasone		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
1020234370Sjasone                SOCKBUF_UNLOCK(&((so)->so_rcv)); \
1021234370Sjasone	} else { \
1022234370Sjasone		sorwakeup_locked(so); \
1023	} \
1024} while (0)
1025
1026#endif				/* _KERNEL */
1027#endif
1028