sctp_constants.h revision 189790
1163953Srrs/*-
2185694Srrs * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3163953Srrs *
4163953Srrs * Redistribution and use in source and binary forms, with or without
5163953Srrs * modification, are permitted provided that the following conditions are met:
6163953Srrs *
7163953Srrs * a) Redistributions of source code must retain the above copyright notice,
8163953Srrs *   this list of conditions and the following disclaimer.
9163953Srrs *
10163953Srrs * b) Redistributions in binary form must reproduce the above copyright
11163953Srrs *    notice, this list of conditions and the following disclaimer in
12163953Srrs *   the documentation and/or other materials provided with the distribution.
13163953Srrs *
14163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its
15163953Srrs *    contributors may be used to endorse or promote products derived
16163953Srrs *    from this software without specific prior written permission.
17163953Srrs *
18163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28163953Srrs * THE POSSIBILITY OF SUCH DAMAGE.
29163953Srrs */
30163953Srrs
31163953Srrs/* $KAME: sctp_constants.h,v 1.17 2005/03/06 16:04:17 itojun Exp $	 */
32163953Srrs
33163953Srrs#include <sys/cdefs.h>
34163953Srrs__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 189790 2009-03-14 13:42:13Z rrs $");
35163953Srrs
36163953Srrs#ifndef __sctp_constants_h__
37163953Srrs#define __sctp_constants_h__
38163953Srrs
39179157Srrs/* IANA assigned port number for SCTP over UDP encapsulation */
40188067Srrs/* For freebsd we cannot bind the port at
41188067Srrs * startup. Otherwise what will happen is
42188067Srrs * we really won't be bound. The user must
43188067Srrs * put it into the sysctl... or we need
44188067Srrs * to build a special timer for this to allow
45188067Srrs * us to wait 1 second or so after the system
46188067Srrs * comes up.
47188067Srrs */
48188067Srrs#define SCTP_OVER_UDP_TUNNELING_PORT 0
49167598Srrs/* Number of packets to get before sack sent by default */
50167598Srrs#define SCTP_DEFAULT_SACK_FREQ 2
51163953Srrs
52167598Srrs/* Address limit - This variable is calculated
53168299Srrs * based on an 65535 byte max ip packet. We take out 100 bytes
54167598Srrs * for the cookie, 40 bytes for a v6 header and 32
55167598Srrs * bytes for the init structure. A second init structure
56167598Srrs * for the init-ack and then finally a third one for the
57167598Srrs * imbedded init. This yeilds 100+40+(3 * 32) = 236 bytes.
58168299Srrs * This leaves 65299 bytes for addresses. We throw out the 299 bytes.
59168299Srrs * Now whatever we send in the INIT() we need to allow to get back in the
60167598Srrs * INIT-ACK plus all the values from INIT and INIT-ACK
61167598Srrs * listed in the cookie. Plus we need some overhead for
62167598Srrs * maybe copied parameters in the COOKIE. If we
63168299Srrs * allow 1080 addresses, and each side has 1080 V6 addresses
64168299Srrs * that will be 21600 bytes. In the INIT-ACK we will
65168299Srrs * see the INIT-ACK 21600 + 43200 in the cookie. This leaves
66168299Srrs * about 500 bytes slack for misc things in the cookie.
67167598Srrs */
68168299Srrs#define SCTP_ADDRESS_LIMIT 1080
69167598Srrs
70171990Srrs/* We need at least 2k of space for us, inits
71171990Srrs * larger than that lets abort.
72171990Srrs */
73171990Srrs#define SCTP_LARGEST_INIT_ACCEPTED (65535 - 2048)
74171990Srrs
75167598Srrs/* Number of addresses where we just skip the counting */
76167598Srrs#define SCTP_COUNT_LIMIT 40
77167598Srrs
78170056Srrs#define SCTP_ZERO_COPY_TICK_DELAY (((100 * hz) + 999) / 1000)
79170181Srrs#define SCTP_ZERO_COPY_SENDQ_TICK_DELAY (((100 * hz) + 999) / 1000)
80170056Srrs
81167598Srrs/* Number of ticks to delay before running
82167598Srrs * iterator on an address change.
83167598Srrs */
84167598Srrs#define SCTP_ADDRESS_TICK_DELAY 2
85167598Srrs
86163953Srrs#define SCTP_VERSION_STRING "KAME-BSD 1.1"
87163953Srrs/* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */
88163953Srrs#define SCTP_AUDIT_SIZE 256
89163953Srrs
90167598Srrs#define SCTP_USE_THREAD_BASED_ITERATOR 1
91167598Srrs
92167598Srrs#define SCTP_KTRHEAD_NAME "sctp_iterator"
93167598Srrs#define SCTP_KTHREAD_PAGES 2
94167598Srrs
95167598Srrs
96167598Srrs/* If you support Multi-VRF how big to
97167598Srrs * make the initial array of VRF's to.
98167598Srrs */
99167598Srrs#define SCTP_DEFAULT_VRF_SIZE 4
100167598Srrs
101171477Srrs/* constants for rto calc */
102171477Srrs#define sctp_align_safe_nocopy 0
103171477Srrs#define sctp_align_unsafe_makecopy 1
104171477Srrs
105171440Srrs/* JRS - Values defined for the HTCP algorithm */
106171440Srrs#define ALPHA_BASE	(1<<7)	/* 1.0 with shift << 7 */
107171440Srrs#define BETA_MIN	(1<<6)	/* 0.5 with shift << 7 */
108171440Srrs#define BETA_MAX	102	/* 0.8 with shift << 7 */
109171440Srrs
110163953Srrs/* Places that CWND log can happen from */
111163953Srrs#define SCTP_CWND_LOG_FROM_FR	1
112163953Srrs#define SCTP_CWND_LOG_FROM_RTX	2
113163953Srrs#define SCTP_CWND_LOG_FROM_BRST	3
114163953Srrs#define SCTP_CWND_LOG_FROM_SS	4
115163953Srrs#define SCTP_CWND_LOG_FROM_CA	5
116163953Srrs#define SCTP_CWND_LOG_FROM_SAT	6
117163953Srrs#define SCTP_BLOCK_LOG_INTO_BLK 7
118163953Srrs#define SCTP_BLOCK_LOG_OUTOF_BLK 8
119163953Srrs#define SCTP_BLOCK_LOG_CHECK     9
120163953Srrs#define SCTP_STR_LOG_FROM_INTO_STRD 10
121163953Srrs#define SCTP_STR_LOG_FROM_IMMED_DEL 11
122163953Srrs#define SCTP_STR_LOG_FROM_INSERT_HD 12
123163953Srrs#define SCTP_STR_LOG_FROM_INSERT_MD 13
124163953Srrs#define SCTP_STR_LOG_FROM_INSERT_TL 14
125163953Srrs#define SCTP_STR_LOG_FROM_MARK_TSN  15
126163953Srrs#define SCTP_STR_LOG_FROM_EXPRS_DEL 16
127163953Srrs#define SCTP_FR_LOG_BIGGEST_TSNS    17
128163953Srrs#define SCTP_FR_LOG_STRIKE_TEST     18
129163953Srrs#define SCTP_FR_LOG_STRIKE_CHUNK    19
130163953Srrs#define SCTP_FR_T3_TIMEOUT          20
131163953Srrs#define SCTP_MAP_PREPARE_SLIDE      21
132163953Srrs#define SCTP_MAP_SLIDE_FROM         22
133163953Srrs#define SCTP_MAP_SLIDE_RESULT       23
134163953Srrs#define SCTP_MAP_SLIDE_CLEARED	    24
135163953Srrs#define SCTP_MAP_SLIDE_NONE         25
136163953Srrs#define SCTP_FR_T3_MARK_TIME        26
137163953Srrs#define SCTP_FR_T3_MARKED           27
138163953Srrs#define SCTP_FR_T3_STOPPED          28
139163953Srrs#define SCTP_FR_MARKED              30
140163953Srrs#define SCTP_CWND_LOG_NOADV_SS      31
141163953Srrs#define SCTP_CWND_LOG_NOADV_CA      32
142163953Srrs#define SCTP_MAX_BURST_APPLIED      33
143163953Srrs#define SCTP_MAX_IFP_APPLIED        34
144163953Srrs#define SCTP_MAX_BURST_ERROR_STOP   35
145163953Srrs#define SCTP_INCREASE_PEER_RWND     36
146163953Srrs#define SCTP_DECREASE_PEER_RWND     37
147163953Srrs#define SCTP_SET_PEER_RWND_VIA_SACK 38
148163953Srrs#define SCTP_LOG_MBCNT_INCREASE     39
149163953Srrs#define SCTP_LOG_MBCNT_DECREASE     40
150163953Srrs#define SCTP_LOG_MBCNT_CHKSET       41
151163953Srrs#define SCTP_LOG_NEW_SACK           42
152163953Srrs#define SCTP_LOG_TSN_ACKED          43
153163953Srrs#define SCTP_LOG_TSN_REVOKED        44
154163953Srrs#define SCTP_LOG_LOCK_TCB           45
155163953Srrs#define SCTP_LOG_LOCK_INP           46
156163953Srrs#define SCTP_LOG_LOCK_SOCK          47
157163953Srrs#define SCTP_LOG_LOCK_SOCKBUF_R     48
158163953Srrs#define SCTP_LOG_LOCK_SOCKBUF_S     49
159163953Srrs#define SCTP_LOG_LOCK_CREATE        50
160163953Srrs#define SCTP_LOG_INITIAL_RTT        51
161163953Srrs#define SCTP_LOG_RTTVAR             52
162163953Srrs#define SCTP_LOG_SBALLOC            53
163163953Srrs#define SCTP_LOG_SBFREE             54
164163953Srrs#define SCTP_LOG_SBRESULT           55
165163953Srrs#define SCTP_FR_DUPED               56
166163953Srrs#define SCTP_FR_MARKED_EARLY        57
167163953Srrs#define SCTP_FR_CWND_REPORT         58
168163953Srrs#define SCTP_FR_CWND_REPORT_START   59
169163953Srrs#define SCTP_FR_CWND_REPORT_STOP    60
170163953Srrs#define SCTP_CWND_LOG_FROM_SEND     61
171163953Srrs#define SCTP_CWND_INITIALIZATION    62
172163953Srrs#define SCTP_CWND_LOG_FROM_T3       63
173163953Srrs#define SCTP_CWND_LOG_FROM_SACK     64
174163953Srrs#define SCTP_CWND_LOG_NO_CUMACK     65
175163953Srrs#define SCTP_CWND_LOG_FROM_RESEND   66
176163953Srrs#define SCTP_FR_LOG_CHECK_STRIKE    67
177163953Srrs#define SCTP_SEND_NOW_COMPLETES     68
178163953Srrs#define SCTP_CWND_LOG_FILL_OUTQ_CALLED 69
179163953Srrs#define SCTP_CWND_LOG_FILL_OUTQ_FILLS  70
180163953Srrs#define SCTP_LOG_FREE_SENT             71
181163953Srrs#define SCTP_NAGLE_APPLIED          72
182163953Srrs#define SCTP_NAGLE_SKIPPED          73
183163953Srrs#define SCTP_WAKESND_FROM_SACK      74
184163953Srrs#define SCTP_WAKESND_FROM_FWDTSN    75
185163953Srrs#define SCTP_NOWAKE_FROM_SACK       76
186163953Srrs#define SCTP_CWNDLOG_PRESEND        77
187163953Srrs#define SCTP_CWNDLOG_ENDSEND        78
188163953Srrs#define SCTP_AT_END_OF_SACK         79
189163953Srrs#define SCTP_REASON_FOR_SC          80
190163953Srrs#define SCTP_BLOCK_LOG_INTO_BLKA    81
191163953Srrs#define SCTP_ENTER_USER_RECV        82
192163953Srrs#define SCTP_USER_RECV_SACKS        83
193163953Srrs#define SCTP_SORECV_BLOCKSA         84
194163953Srrs#define SCTP_SORECV_BLOCKSB         85
195163953Srrs#define SCTP_SORECV_DONE            86
196163953Srrs#define SCTP_SACK_RWND_UPDATE       87
197163953Srrs#define SCTP_SORECV_ENTER           88
198163953Srrs#define SCTP_SORECV_ENTERPL         89
199163953Srrs#define SCTP_MBUF_INPUT             90
200163953Srrs#define SCTP_MBUF_IALLOC            91
201163953Srrs#define SCTP_MBUF_IFREE             92
202163953Srrs#define SCTP_MBUF_ICOPY             93
203178197Srrs#define SCTP_MBUF_SPLIT             94
204178197Srrs#define SCTP_SORCV_FREECTL          95
205178197Srrs#define SCTP_SORCV_DOESCPY          96
206178197Srrs#define SCTP_SORCV_DOESLCK          97
207178197Srrs#define SCTP_SORCV_DOESADJ          98
208178197Srrs#define SCTP_SORCV_BOTWHILE         99
209178197Srrs#define SCTP_SORCV_PASSBF          100
210178197Srrs#define SCTP_SORCV_ADJD            101
211178197Srrs#define SCTP_UNKNOWN_MAX           102
212178197Srrs#define SCTP_RANDY_STUFF           103
213178197Srrs#define SCTP_RANDY_STUFF1          104
214178197Srrs#define SCTP_STRMOUT_LOG_ASSIGN	   105
215178197Srrs#define SCTP_STRMOUT_LOG_SEND	   106
216178197Srrs#define SCTP_FLIGHT_LOG_DOWN_CA    107
217178197Srrs#define SCTP_FLIGHT_LOG_UP         108
218178197Srrs#define SCTP_FLIGHT_LOG_DOWN_GAP   109
219178197Srrs#define SCTP_FLIGHT_LOG_DOWN_RSND  110
220178197Srrs#define SCTP_FLIGHT_LOG_UP_RSND    111
221178197Srrs#define SCTP_FLIGHT_LOG_DOWN_RSND_TO    112
222178197Srrs#define SCTP_FLIGHT_LOG_DOWN_WP    113
223178197Srrs#define SCTP_FLIGHT_LOG_UP_REVOKE  114
224178197Srrs#define SCTP_FLIGHT_LOG_DOWN_PDRP  115
225178197Srrs#define SCTP_FLIGHT_LOG_DOWN_PMTU  116
226178197Srrs#define SCTP_SACK_LOG_NORMAL	   117
227178197Srrs#define SCTP_SACK_LOG_EXPRESS	   118
228178197Srrs#define SCTP_MAP_TSN_ENTERS        119
229178197Srrs#define SCTP_THRESHOLD_CLEAR       120
230178197Srrs#define SCTP_THRESHOLD_INCR        121
231189371Srrs#define SCTP_FLIGHT_LOG_DWN_WP_FWD 122
232189790Srrs#define SCTP_FWD_TSN_CHECK         123
233189790Srrs#define SCTP_LOG_MAX_TYPES 124
234163953Srrs/*
235170744Srrs * To turn on various logging, you must first enable 'options KTR' and
236170744Srrs * you might want to bump the entires 'options KTR_ENTRIES=80000'.
237170744Srrs * To get something to log you define one of the logging defines.
238170744Srrs * (see LINT).
239163953Srrs *
240170744Srrs * This gets the compile in place, but you still need to turn the
241170744Srrs * logging flag on too in the sysctl (see in sctp.h).
242163953Srrs */
243171943Srrs
244163953Srrs#define SCTP_LOG_EVENT_UNKNOWN 0
245163953Srrs#define SCTP_LOG_EVENT_CWND  1
246163953Srrs#define SCTP_LOG_EVENT_BLOCK 2
247163953Srrs#define SCTP_LOG_EVENT_STRM  3
248163953Srrs#define SCTP_LOG_EVENT_FR    4
249163953Srrs#define SCTP_LOG_EVENT_MAP   5
250163953Srrs#define SCTP_LOG_EVENT_MAXBURST 6
251163953Srrs#define SCTP_LOG_EVENT_RWND  7
252163953Srrs#define SCTP_LOG_EVENT_MBCNT 8
253163953Srrs#define SCTP_LOG_EVENT_SACK  9
254163953Srrs#define SCTP_LOG_LOCK_EVENT 10
255163953Srrs#define SCTP_LOG_EVENT_RTT  11
256163953Srrs#define SCTP_LOG_EVENT_SB   12
257163953Srrs#define SCTP_LOG_EVENT_NAGLE 13
258163953Srrs#define SCTP_LOG_EVENT_WAKE 14
259163953Srrs#define SCTP_LOG_MISC_EVENT 15
260163953Srrs#define SCTP_LOG_EVENT_CLOSE 16
261163953Srrs#define SCTP_LOG_EVENT_MBUF 17
262170744Srrs#define SCTP_LOG_CHUNK_PROC 18
263170744Srrs#define SCTP_LOG_ERROR_RET  19
264163953Srrs
265170744Srrs#define SCTP_LOG_MAX_EVENT 20
266163953Srrs
267163953Srrs#define SCTP_LOCK_UNKNOWN 2
268163953Srrs
269163953Srrs
270163953Srrs/* number of associations by default for zone allocation */
271163953Srrs#define SCTP_MAX_NUM_OF_ASOC	40000
272163953Srrs/* how many addresses per assoc remote and local */
273163953Srrs#define SCTP_SCALE_FOR_ADDR	2
274163953Srrs
275163953Srrs/* default AUTO_ASCONF mode enable(1)/disable(0) value (sysctl) */
276167598Srrs#if defined (__APPLE__) && !defined(SCTP_APPLE_AUTO_ASCONF)
277167598Srrs#define SCTP_DEFAULT_AUTO_ASCONF        0
278167598Srrs#else
279167598Srrs#define SCTP_DEFAULT_AUTO_ASCONF	1
280167598Srrs#endif
281163953Srrs
282179157Srrs/* default MULTIPLE_ASCONF mode enable(1)/disable(0) value (sysctl) */
283179157Srrs#define SCTP_DEFAULT_MULTIPLE_ASCONFS	0
284179157Srrs
285171990Srrs/* default MOBILITY_BASE mode enable(1)/disable(0) value (sysctl) */
286171990Srrs#if defined (__APPLE__) && !defined(SCTP_APPLE_MOBILITY_BASE)
287171990Srrs#define SCTP_DEFAULT_MOBILITY_BASE      0
288171990Srrs#else
289171990Srrs#define SCTP_DEFAULT_MOBILITY_BASE	0
290171990Srrs#endif
291171990Srrs
292171990Srrs/* default MOBILITY_FASTHANDOFF mode enable(1)/disable(0) value (sysctl) */
293171990Srrs#if defined (__APPLE__) && !defined(SCTP_APPLE_MOBILITY_FASTHANDOFF)
294171990Srrs#define SCTP_DEFAULT_MOBILITY_FASTHANDOFF	0
295171990Srrs#else
296171990Srrs#define SCTP_DEFAULT_MOBILITY_FASTHANDOFF	0
297171990Srrs#endif
298171990Srrs
299163953Srrs/*
300163953Srrs * Theshold for rwnd updates, we have to read (sb_hiwat >>
301163953Srrs * SCTP_RWND_HIWAT_SHIFT) before we will look to see if we need to send a
302163953Srrs * window update sack. When we look, we compare the last rwnd we sent vs the
303163953Srrs * current rwnd. It too must be greater than this value. Using 3 divdes the
304163953Srrs * hiwat by 8, so for 200k rwnd we need to read 24k. For a 64k rwnd we need
305163953Srrs * to read 8k. This seems about right.. I hope :-D.. we do set a
306163953Srrs * min of a MTU on it so if the rwnd is real small we will insist
307163953Srrs * on a full MTU of 1500 bytes.
308163953Srrs */
309163953Srrs#define SCTP_RWND_HIWAT_SHIFT 3
310163953Srrs
311163953Srrs/* How much of the rwnd must the
312163953Srrs * message be taking up to start partial delivery.
313163953Srrs * We calculate this by shifing the hi_water (recv_win)
314163953Srrs * left the following .. set to 1, when a message holds
315163953Srrs * 1/2 the rwnd. If we set it to 2 when a message holds
316163953Srrs * 1/4 the rwnd...etc..
317163953Srrs */
318163953Srrs
319163953Srrs#define SCTP_PARTIAL_DELIVERY_SHIFT 1
320163953Srrs
321163953Srrs/*
322163953Srrs * default HMAC for cookies, etc... use one of the AUTH HMAC id's
323163953Srrs * SCTP_HMAC is the HMAC_ID to use
324163953Srrs * SCTP_SIGNATURE_SIZE is the digest length
325163953Srrs */
326163953Srrs#define SCTP_HMAC		SCTP_AUTH_HMAC_ID_SHA1
327163953Srrs#define SCTP_SIGNATURE_SIZE	SCTP_AUTH_DIGEST_LEN_SHA1
328163953Srrs#define SCTP_SIGNATURE_ALOC_SIZE SCTP_SIGNATURE_SIZE
329163953Srrs
330163953Srrs/*
331163953Srrs * the SCTP protocol signature this includes the version number encoded in
332163953Srrs * the last 4 bits of the signature.
333163953Srrs */
334163953Srrs#define PROTO_SIGNATURE_A	0x30000000
335163953Srrs#define SCTP_VERSION_NUMBER	0x3
336163953Srrs
337163953Srrs#define MAX_TSN	0xffffffff
338163953Srrs#define MAX_SEQ	0xffff
339163953Srrs
340163953Srrs/* how many executions every N tick's */
341163953Srrs#define SCTP_ITERATOR_MAX_AT_ONCE 20
342163953Srrs
343163953Srrs/* number of clock ticks between iterator executions */
344163953Srrs#define SCTP_ITERATOR_TICKS 1
345163953Srrs
346163953Srrs/*
347163953Srrs * option: If you comment out the following you will receive the old behavior
348163953Srrs * of obeying cwnd for the fast retransmit algorithm. With this defined a FR
349163953Srrs * happens right away with-out waiting for the flightsize to drop below the
350163953Srrs * cwnd value (which is reduced by the FR to 1/2 the inflight packets).
351163953Srrs */
352163953Srrs#define SCTP_IGNORE_CWND_ON_FR 1
353163953Srrs
354163953Srrs/*
355163953Srrs * Adds implementors guide behavior to only use newest highest update in SACK
356163953Srrs * gap ack's to figure out if you need to stroke a chunk for FR.
357163953Srrs */
358163953Srrs#define SCTP_NO_FR_UNLESS_SEGMENT_SMALLER 1
359163953Srrs
360163953Srrs/* default max I can burst out after a fast retransmit */
361163953Srrs#define SCTP_DEF_MAX_BURST 4
362163953Srrs/* IP hdr (20/40) + 12+2+2 (enet) + sctp common 12 */
363163953Srrs#define SCTP_FIRST_MBUF_RESV 68
364163953Srrs/* Packet transmit states in the sent field */
365163953Srrs#define SCTP_DATAGRAM_UNSENT		0
366163953Srrs#define SCTP_DATAGRAM_SENT		1
367163953Srrs#define SCTP_DATAGRAM_RESEND1		2	/* not used (in code, but may
368163953Srrs						 * hit this value) */
369163953Srrs#define SCTP_DATAGRAM_RESEND2		3	/* not used (in code, but may
370163953Srrs						 * hit this value) */
371163953Srrs#define SCTP_DATAGRAM_RESEND		4
372163953Srrs#define SCTP_DATAGRAM_ACKED		10010
373185694Srrs/* EY
374185694Srrs * If a tsn is nr-gapped, its first tagged as NR_MARKED and then NR_ACKED
375185694Srrs * When yet another nr-sack is received, if a particular TSN's sent tag
376185694Srrs * is observed to be NR_ACKED after gap-ack info is processed, this implies
377185694Srrs * that particular TSN is reneged
378185694Srrs*/
379185694Srrs#define SCTP_DATAGRAM_NR_ACKED 		10020
380185694Srrs#define SCTP_DATAGRAM_NR_MARKED		20005
381163953Srrs#define SCTP_DATAGRAM_MARKED		20010
382163953Srrs#define SCTP_FORWARD_TSN_SKIP		30010
383163953Srrs
384163953Srrs/* chunk output send from locations */
385163953Srrs#define SCTP_OUTPUT_FROM_USR_SEND       0
386163953Srrs#define SCTP_OUTPUT_FROM_T3       	1
387163953Srrs#define SCTP_OUTPUT_FROM_INPUT_ERROR    2
388163953Srrs#define SCTP_OUTPUT_FROM_CONTROL_PROC   3
389163953Srrs#define SCTP_OUTPUT_FROM_SACK_TMR       4
390163953Srrs#define SCTP_OUTPUT_FROM_SHUT_TMR       5
391163953Srrs#define SCTP_OUTPUT_FROM_HB_TMR         6
392163953Srrs#define SCTP_OUTPUT_FROM_SHUT_ACK_TMR   7
393163953Srrs#define SCTP_OUTPUT_FROM_ASCONF_TMR     8
394163953Srrs#define SCTP_OUTPUT_FROM_STRRST_TMR     9
395163953Srrs#define SCTP_OUTPUT_FROM_AUTOCLOSE_TMR  10
396163953Srrs#define SCTP_OUTPUT_FROM_EARLY_FR_TMR   11
397163953Srrs#define SCTP_OUTPUT_FROM_STRRST_REQ     12
398163953Srrs#define SCTP_OUTPUT_FROM_USR_RCVD       13
399164205Srrs#define SCTP_OUTPUT_FROM_COOKIE_ACK     14
400167598Srrs#define SCTP_OUTPUT_FROM_DRAIN          15
401171990Srrs#define SCTP_OUTPUT_FROM_CLOSING        16
402163953Srrs/* SCTP chunk types are moved sctp.h for application (NAT, FW) use */
403163953Srrs
404163953Srrs/* align to 32-bit sizes */
405163953Srrs#define SCTP_SIZE32(x)	((((x)+3) >> 2) << 2)
406163953Srrs
407163953Srrs#define IS_SCTP_CONTROL(a) ((a)->chunk_type != SCTP_DATA)
408163953Srrs#define IS_SCTP_DATA(a) ((a)->chunk_type == SCTP_DATA)
409163953Srrs
410163953Srrs
411163953Srrs/* SCTP parameter types */
412163953Srrs/*************0x0000 series*************/
413163953Srrs#define SCTP_HEARTBEAT_INFO		0x0001
414163953Srrs#define SCTP_IPV4_ADDRESS		0x0005
415163953Srrs#define SCTP_IPV6_ADDRESS		0x0006
416163953Srrs#define SCTP_STATE_COOKIE		0x0007
417163953Srrs#define SCTP_UNRECOG_PARAM		0x0008
418163953Srrs#define SCTP_COOKIE_PRESERVE		0x0009
419163953Srrs#define SCTP_HOSTNAME_ADDRESS		0x000b
420163953Srrs#define SCTP_SUPPORTED_ADDRTYPE		0x000c
421163953Srrs
422188854Srrs/* draft-ietf-stewart-tsvwg-strreset-xxx */
423163953Srrs#define SCTP_STR_RESET_OUT_REQUEST	0x000d
424163953Srrs#define SCTP_STR_RESET_IN_REQUEST	0x000e
425163953Srrs#define SCTP_STR_RESET_TSN_REQUEST	0x000f
426163953Srrs#define SCTP_STR_RESET_RESPONSE		0x0010
427188854Srrs#define SCTP_STR_RESET_ADD_STREAMS  0x0011
428163953Srrs
429163953Srrs#define SCTP_MAX_RESET_PARAMS 2
430163953Srrs#define SCTP_STREAM_RESET_TSN_DELTA    0x1000
431163953Srrs
432163953Srrs/*************0x4000 series*************/
433163953Srrs
434163953Srrs/*************0x8000 series*************/
435163953Srrs#define SCTP_ECN_CAPABLE		0x8000
436163953Srrs/* ECN Nonce: draft-ladha-sctp-ecn-nonce */
437163953Srrs#define SCTP_ECN_NONCE_SUPPORTED	0x8001
438163953Srrs/* draft-ietf-tsvwg-auth-xxx */
439163953Srrs#define SCTP_RANDOM			0x8002
440163953Srrs#define SCTP_CHUNK_LIST			0x8003
441163953Srrs#define SCTP_HMAC_LIST			0x8004
442163953Srrs/*
443163953Srrs * draft-ietf-tsvwg-addip-sctp-xx param=0x8008  len=0xNNNN Byte | Byte | Byte
444163953Srrs * | Byte Byte | Byte ...
445163953Srrs *
446163953Srrs * Where each byte is a chunk type extension supported. For example, to support
447163953Srrs * all chunks one would have (in hex):
448163953Srrs *
449163953Srrs * 80 01 00 09 C0 C1 80 81 82 00 00 00
450163953Srrs *
451163953Srrs * Has the parameter. C0 = PR-SCTP    (RFC3758) C1, 80 = ASCONF (addip draft) 81
452163953Srrs * = Packet Drop 82 = Stream Reset 83 = Authentication
453163953Srrs */
454163953Srrs#define SCTP_SUPPORTED_CHUNK_EXT    0x8008
455163953Srrs
456163953Srrs/*************0xC000 series*************/
457163953Srrs#define SCTP_PRSCTP_SUPPORTED		0xc000
458163953Srrs/* draft-ietf-tsvwg-addip-sctp */
459163953Srrs#define SCTP_ADD_IP_ADDRESS		0xc001
460163953Srrs#define SCTP_DEL_IP_ADDRESS		0xc002
461163953Srrs#define SCTP_ERROR_CAUSE_IND		0xc003
462163953Srrs#define SCTP_SET_PRIM_ADDR		0xc004
463163953Srrs#define SCTP_SUCCESS_REPORT		0xc005
464163953Srrs#define SCTP_ULP_ADAPTATION		0xc006
465185694Srrs/* behave-nat-draft */
466185694Srrs#define SCTP_HAS_NAT_SUPPORT            0xc007
467185694Srrs#define SCTP_NAT_VTAGS                  0xc008
468163953Srrs
469163953Srrs/* Notification error codes */
470163953Srrs#define SCTP_NOTIFY_DATAGRAM_UNSENT	0x0001
471163953Srrs#define SCTP_NOTIFY_DATAGRAM_SENT	0x0002
472163953Srrs#define SCTP_FAILED_THRESHOLD		0x0004
473163953Srrs#define SCTP_HEARTBEAT_SUCCESS		0x0008
474172091Srrs#define SCTP_RESPONSE_TO_USER_REQ	0x0010
475172091Srrs#define SCTP_INTERNAL_ERROR		0x0020
476172091Srrs#define SCTP_SHUTDOWN_GUARD_EXPIRES	0x0040
477172091Srrs#define SCTP_RECEIVED_SACK		0x0080
478172091Srrs#define SCTP_PEER_FAULTY		0x0100
479172091Srrs#define SCTP_ICMP_REFUSED		0x0200
480163953Srrs
481163953Srrs/* bits for TOS field */
482163953Srrs#define SCTP_ECT0_BIT		0x02
483163953Srrs#define SCTP_ECT1_BIT		0x01
484163953Srrs#define SCTP_CE_BITS		0x03
485163953Srrs
486163953Srrs/* below turns off above */
487163953Srrs#define SCTP_FLEXIBLE_ADDRESS	0x20
488163953Srrs#define SCTP_NO_HEARTBEAT	0x40
489163953Srrs
490163953Srrs/* mask to get sticky */
491163953Srrs#define SCTP_STICKY_OPTIONS_MASK	0x0c
492163953Srrs
493163953Srrs
494163953Srrs/*
495163953Srrs * SCTP states for internal state machine XXX (should match "user" values)
496163953Srrs */
497163953Srrs#define SCTP_STATE_EMPTY		0x0000
498163953Srrs#define SCTP_STATE_INUSE		0x0001
499163953Srrs#define SCTP_STATE_COOKIE_WAIT		0x0002
500163953Srrs#define SCTP_STATE_COOKIE_ECHOED	0x0004
501163953Srrs#define SCTP_STATE_OPEN			0x0008
502163953Srrs#define SCTP_STATE_SHUTDOWN_SENT	0x0010
503163953Srrs#define SCTP_STATE_SHUTDOWN_RECEIVED	0x0020
504163953Srrs#define SCTP_STATE_SHUTDOWN_ACK_SENT	0x0040
505163953Srrs#define SCTP_STATE_SHUTDOWN_PENDING	0x0080
506163953Srrs#define SCTP_STATE_CLOSED_SOCKET	0x0100
507163953Srrs#define SCTP_STATE_ABOUT_TO_BE_FREED    0x0200
508163953Srrs#define SCTP_STATE_PARTIAL_MSG_LEFT     0x0400
509171745Srrs#define SCTP_STATE_WAS_ABORTED          0x0800
510163953Srrs#define SCTP_STATE_MASK			0x007f
511163953Srrs
512163953Srrs#define SCTP_GET_STATE(asoc)	((asoc)->state & SCTP_STATE_MASK)
513171943Srrs#define SCTP_SET_STATE(asoc, newstate)  ((asoc)->state = ((asoc)->state & ~SCTP_STATE_MASK) |  newstate)
514172703Srrs#define SCTP_CLEAR_SUBSTATE(asoc, substate) ((asoc)->state &= ~substate)
515172703Srrs#define SCTP_ADD_SUBSTATE(asoc, substate) ((asoc)->state |= substate)
516163953Srrs
517163953Srrs/* SCTP reachability state for each address */
518163953Srrs#define SCTP_ADDR_REACHABLE		0x001
519163953Srrs#define SCTP_ADDR_NOT_REACHABLE		0x002
520163953Srrs#define SCTP_ADDR_NOHB			0x004
521163953Srrs#define SCTP_ADDR_BEING_DELETED		0x008
522163953Srrs#define SCTP_ADDR_NOT_IN_ASSOC		0x010
523163953Srrs#define SCTP_ADDR_WAS_PRIMARY		0x020
524163953Srrs#define SCTP_ADDR_SWITCH_PRIMARY	0x040
525163953Srrs#define SCTP_ADDR_OUT_OF_SCOPE		0x080
526163953Srrs#define SCTP_ADDR_DOUBLE_SWITCH		0x100
527163953Srrs#define SCTP_ADDR_UNCONFIRMED		0x200
528167598Srrs#define SCTP_ADDR_REQ_PRIMARY           0x400
529171440Srrs/* JRS 5/13/07 - Added potentially failed state for CMT PF */
530171440Srrs#define SCTP_ADDR_PF            0x800
531163953Srrs#define SCTP_REACHABLE_MASK		0x203
532163953Srrs
533163953Srrs/* bound address types (e.g. valid address types to allow) */
534163953Srrs#define SCTP_BOUND_V6		0x01
535163953Srrs#define SCTP_BOUND_V4		0x02
536163953Srrs
537163953Srrs/*
538163953Srrs * what is the default number of mbufs in a chain I allow before switching to
539163953Srrs * a cluster
540163953Srrs */
541163953Srrs#define SCTP_DEFAULT_MBUFS_IN_CHAIN 5
542163953Srrs
543169655Srrs/* How long a cookie lives in milli-seconds */
544169655Srrs#define SCTP_DEFAULT_COOKIE_LIFE	60000
545163953Srrs
546163953Srrs/* resource limit of streams */
547163953Srrs#define MAX_SCTP_STREAMS	2048
548163953Srrs
549163953Srrs/* Maximum the mapping array will  grow to (TSN mapping array) */
550163953Srrs#define SCTP_MAPPING_ARRAY	512
551163953Srrs
552163953Srrs/* size of the inital malloc on the mapping array */
553163953Srrs#define SCTP_INITIAL_MAPPING_ARRAY  16
554163953Srrs/* how much we grow the mapping array each call */
555163953Srrs#define SCTP_MAPPING_ARRAY_INCR     32
556185694Srrs/* EY 05/13/08 - nr_sack version of the previous 3 constants */
557185694Srrs/* Maximum the nr mapping array will  grow to (TSN mapping array) */
558185694Srrs#define SCTP_NR_MAPPING_ARRAY	512
559185694Srrs/* size of the inital malloc on the nr mapping array */
560185694Srrs#define SCTP_INITIAL_NR_MAPPING_ARRAY  16
561185694Srrs/* how much we grow the nr mapping array each call */
562185694Srrs#define SCTP_NR_MAPPING_ARRAY_INCR     32
563163953Srrs/*
564163953Srrs * Here we define the timer types used by the implementation as arguments in
565163953Srrs * the set/get timer type calls.
566163953Srrs */
567163953Srrs#define SCTP_TIMER_INIT 	0
568163953Srrs#define SCTP_TIMER_RECV 	1
569163953Srrs#define SCTP_TIMER_SEND 	2
570163953Srrs#define SCTP_TIMER_HEARTBEAT	3
571163953Srrs#define SCTP_TIMER_PMTU		4
572163953Srrs#define SCTP_TIMER_MAXSHUTDOWN	5
573163953Srrs#define SCTP_TIMER_SIGNATURE	6
574163953Srrs/*
575163953Srrs * number of timer types in the base SCTP structure used in the set/get and
576163953Srrs * has the base default.
577163953Srrs */
578163953Srrs#define SCTP_NUM_TMRS	7
579163953Srrs
580163953Srrs/* timer types */
581163953Srrs#define SCTP_TIMER_TYPE_NONE		0
582163953Srrs#define SCTP_TIMER_TYPE_SEND		1
583163953Srrs#define SCTP_TIMER_TYPE_INIT		2
584163953Srrs#define SCTP_TIMER_TYPE_RECV		3
585163953Srrs#define SCTP_TIMER_TYPE_SHUTDOWN	4
586163953Srrs#define SCTP_TIMER_TYPE_HEARTBEAT	5
587163953Srrs#define SCTP_TIMER_TYPE_COOKIE		6
588163953Srrs#define SCTP_TIMER_TYPE_NEWCOOKIE	7
589163953Srrs#define SCTP_TIMER_TYPE_PATHMTURAISE	8
590163953Srrs#define SCTP_TIMER_TYPE_SHUTDOWNACK	9
591163953Srrs#define SCTP_TIMER_TYPE_ASCONF		10
592163953Srrs#define SCTP_TIMER_TYPE_SHUTDOWNGUARD	11
593163953Srrs#define SCTP_TIMER_TYPE_AUTOCLOSE	12
594163953Srrs#define SCTP_TIMER_TYPE_EVENTWAKE	13
595163953Srrs#define SCTP_TIMER_TYPE_STRRESET        14
596163953Srrs#define SCTP_TIMER_TYPE_INPKILL         15
597163953Srrs#define SCTP_TIMER_TYPE_ITERATOR        16
598163953Srrs#define SCTP_TIMER_TYPE_EARLYFR         17
599163953Srrs#define SCTP_TIMER_TYPE_ASOCKILL        18
600163953Srrs#define SCTP_TIMER_TYPE_ADDR_WQ         19
601170056Srrs#define SCTP_TIMER_TYPE_ZERO_COPY       20
602170181Srrs#define SCTP_TIMER_TYPE_ZCOPY_SENDQ     21
603172091Srrs#define SCTP_TIMER_TYPE_PRIM_DELETED    22
604163953Srrs/* add new timers here - and increment LAST */
605172091Srrs#define SCTP_TIMER_TYPE_LAST            23
606163953Srrs
607163953Srrs#define SCTP_IS_TIMER_TYPE_VALID(t)	(((t) > SCTP_TIMER_TYPE_NONE) && \
608163953Srrs					 ((t) < SCTP_TIMER_TYPE_LAST))
609163953Srrs
610163953Srrs
611163953Srrs
612163953Srrs/* max number of TSN's dup'd that I will hold */
613163953Srrs#define SCTP_MAX_DUP_TSNS	20
614163953Srrs
615163953Srrs/*
616163953Srrs * Here we define the types used when setting the retry amounts.
617163953Srrs */
618163953Srrs/* How many drop re-attempts we make on  INIT/COOKIE-ECHO */
619163953Srrs#define SCTP_RETRY_DROPPED_THRESH 4
620163953Srrs
621163953Srrs/*
622163953Srrs * Maxmium number of chunks a single association can have on it. Note that
623163953Srrs * this is a squishy number since the count can run over this if the user
624163953Srrs * sends a large message down .. the fragmented chunks don't count until
625163953Srrs * AFTER the message is on queue.. it would be the next send that blocks
626163953Srrs * things. This number will get tuned up at boot in the sctp_init and use the
627163953Srrs * number of clusters as a base. This way high bandwidth environments will
628163953Srrs * not get impacted by the lower bandwidth sending a bunch of 1 byte chunks
629163953Srrs */
630163953Srrs#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512
631163953Srrs
632172091Srrs
633167598Srrs/* The conversion from time to ticks and vice versa is done by rounding
634167598Srrs * upwards. This way we can test in the code the time to be positive and
635167598Srrs * know that this corresponds to a positive number of ticks.
636167598Srrs */
637167598Srrs#define MSEC_TO_TICKS(x) ((hz == 1000) ? x : ((((x) * hz) + 999) / 1000))
638167598Srrs#define TICKS_TO_MSEC(x) ((hz == 1000) ? x : ((((x) * 1000) + (hz - 1)) / hz))
639163953Srrs
640163953Srrs#define SEC_TO_TICKS(x) ((x) * hz)
641167598Srrs#define TICKS_TO_SEC(x) (((x) + (hz - 1)) / hz)
642163953Srrs
643163953Srrs/*
644163953Srrs * Basically the minimum amount of time before I do a early FR. Making this
645163953Srrs * value to low will cause duplicate retransmissions.
646163953Srrs */
647163953Srrs#define SCTP_MINFR_MSEC_TIMER 250
648163953Srrs/* The floor this value is allowed to fall to when starting a timer. */
649163953Srrs#define SCTP_MINFR_MSEC_FLOOR 20
650163953Srrs
651163953Srrs/* init timer def = 1 sec */
652163953Srrs#define SCTP_INIT_SEC	1
653163953Srrs
654163953Srrs/* send timer def = 1 seconds */
655163953Srrs#define SCTP_SEND_SEC	1
656163953Srrs
657163953Srrs/* recv timer def = 200ms  */
658163953Srrs#define SCTP_RECV_MSEC	200
659163953Srrs
660163953Srrs/* 30 seconds + RTO (in ms) */
661163953Srrs#define SCTP_HB_DEFAULT_MSEC	30000
662163953Srrs
663163953Srrs/* Max time I will wait for Shutdown to complete */
664163953Srrs#define SCTP_DEF_MAX_SHUTDOWN_SEC 180
665163953Srrs
666163953Srrs
667163953Srrs/*
668163953Srrs * This is how long a secret lives, NOT how long a cookie lives how many
669163953Srrs * ticks the current secret will live.
670163953Srrs */
671163953Srrs#define SCTP_DEFAULT_SECRET_LIFE_SEC 3600
672163953Srrs
673163953Srrs#define SCTP_RTO_UPPER_BOUND	(60000)	/* 60 sec in ms */
674163953Srrs#define SCTP_RTO_UPPER_BOUND_SEC 60	/* for the init timer */
675163953Srrs#define SCTP_RTO_LOWER_BOUND	(1000)	/* 1 sec in ms */
676163953Srrs#define SCTP_RTO_INITIAL	(3000)	/* 3 sec in ms */
677163953Srrs
678163953Srrs
679163953Srrs#define SCTP_INP_KILL_TIMEOUT 20/* number of ms to retry kill of inpcb */
680163953Srrs#define SCTP_ASOC_KILL_TIMEOUT 10	/* number of ms to retry kill of inpcb */
681163953Srrs
682163953Srrs#define SCTP_DEF_MAX_INIT	8
683163953Srrs#define SCTP_DEF_MAX_SEND	10
684170056Srrs#define SCTP_DEF_MAX_PATH_RTX	5
685163953Srrs
686163953Srrs#define SCTP_DEF_PMTU_RAISE_SEC	600	/* 10 min between raise attempts */
687163953Srrs
688170056Srrs
689163953Srrs/* How many streams I request initally by default */
690163953Srrs#define SCTP_OSTREAM_INITIAL 10
691163953Srrs
692163953Srrs/*
693163953Srrs * How many smallest_mtu's need to increase before a window update sack is
694163953Srrs * sent (should be a power of 2).
695163953Srrs */
696163953Srrs/* Send window update (incr * this > hiwat). Should be a power of 2 */
697163953Srrs#define SCTP_MINIMAL_RWND		(4096)	/* minimal rwnd */
698163953Srrs
699170606Srrs#define SCTP_ADDRMAX		24
700163953Srrs
701163953Srrs/* SCTP DEBUG Switch parameters */
702163953Srrs#define SCTP_DEBUG_TIMER1	0x00000001
703170181Srrs#define SCTP_DEBUG_TIMER2	0x00000002	/* unused */
704170181Srrs#define SCTP_DEBUG_TIMER3	0x00000004	/* unused */
705163953Srrs#define SCTP_DEBUG_TIMER4	0x00000008
706163953Srrs#define SCTP_DEBUG_OUTPUT1	0x00000010
707163953Srrs#define SCTP_DEBUG_OUTPUT2	0x00000020
708163953Srrs#define SCTP_DEBUG_OUTPUT3	0x00000040
709163953Srrs#define SCTP_DEBUG_OUTPUT4	0x00000080
710163953Srrs#define SCTP_DEBUG_UTIL1	0x00000100
711170181Srrs#define SCTP_DEBUG_UTIL2	0x00000200	/* unused */
712163953Srrs#define SCTP_DEBUG_AUTH1	0x00000400
713170181Srrs#define SCTP_DEBUG_AUTH2	0x00000800	/* unused */
714163953Srrs#define SCTP_DEBUG_INPUT1	0x00001000
715163953Srrs#define SCTP_DEBUG_INPUT2	0x00002000
716163953Srrs#define SCTP_DEBUG_INPUT3	0x00004000
717170181Srrs#define SCTP_DEBUG_INPUT4	0x00008000	/* unused */
718163953Srrs#define SCTP_DEBUG_ASCONF1	0x00010000
719163953Srrs#define SCTP_DEBUG_ASCONF2	0x00020000
720170181Srrs#define SCTP_DEBUG_OUTPUT5	0x00040000	/* unused */
721170181Srrs#define SCTP_DEBUG_XXX		0x00080000	/* unused */
722163953Srrs#define SCTP_DEBUG_PCB1		0x00100000
723170181Srrs#define SCTP_DEBUG_PCB2		0x00200000	/* unused */
724163953Srrs#define SCTP_DEBUG_PCB3		0x00400000
725172266Srrs#define SCTP_DEBUG_PCB4		0x00800000
726163953Srrs#define SCTP_DEBUG_INDATA1	0x01000000
727170181Srrs#define SCTP_DEBUG_INDATA2	0x02000000	/* unused */
728170181Srrs#define SCTP_DEBUG_INDATA3	0x04000000	/* unused */
729188067Srrs#define SCTP_DEBUG_CRCOFFLOAD	0x08000000	/* unused */
730170181Srrs#define SCTP_DEBUG_USRREQ1	0x10000000	/* unused */
731170181Srrs#define SCTP_DEBUG_USRREQ2	0x20000000	/* unused */
732163953Srrs#define SCTP_DEBUG_PEEL1	0x40000000
733170181Srrs#define SCTP_DEBUG_XXXXX	0x80000000	/* unused */
734163953Srrs#define SCTP_DEBUG_ALL		0x7ff3ffff
735163953Srrs#define SCTP_DEBUG_NOISY	0x00040000
736163953Srrs
737163953Srrs/* What sender needs to see to avoid SWS or we consider peers rwnd 0 */
738163953Srrs#define SCTP_SWS_SENDER_DEF	1420
739163953Srrs
740163953Srrs/*
741163953Srrs * SWS is scaled to the sb_hiwat of the socket. A value of 2 is hiwat/4, 1
742163953Srrs * would be hiwat/2 etc.
743163953Srrs */
744163953Srrs/* What receiver needs to see in sockbuf or we tell peer its 1 */
745163953Srrs#define SCTP_SWS_RECEIVER_DEF	3000
746163953Srrs
747163953Srrs#define SCTP_INITIAL_CWND 4380
748163953Srrs
749188067Srrs#define SCTP_DEFAULT_MTU 1500	/* emergency default MTU */
750163953Srrs/* amount peer is obligated to have in rwnd or I will abort */
751163953Srrs#define SCTP_MIN_RWND	1500
752163953Srrs
753163953Srrs#define SCTP_DEFAULT_MAXSEGMENT 65535
754163953Srrs
755170642Srrs#define SCTP_CHUNK_BUFFER_SIZE	512
756166675Srrs#define SCTP_PARAM_BUFFER_SIZE	512
757163953Srrs
758171990Srrs/* small chunk store for looking at chunk_list in auth */
759171990Srrs#define SCTP_SMALL_CHUNK_STORE 260
760171990Srrs
761163953Srrs#define SCTP_DEFAULT_MINSEGMENT 512	/* MTU size ... if no mtu disc */
762163953Srrs#define SCTP_HOW_MANY_SECRETS	2	/* how many secrets I keep */
763163953Srrs
764163953Srrs#define SCTP_NUMBER_OF_SECRETS	8	/* or 8 * 4 = 32 octets */
765163953Srrs#define SCTP_SECRET_SIZE	32	/* number of octets in a 256 bits */
766163953Srrs
767163953Srrs
768163953Srrs/*
769163953Srrs * SCTP upper layer notifications
770163953Srrs */
771185694Srrs#define SCTP_NOTIFY_ASSOC_UP                     1
772185694Srrs#define SCTP_NOTIFY_ASSOC_DOWN                   2
773185694Srrs#define SCTP_NOTIFY_INTERFACE_DOWN               3
774185694Srrs#define SCTP_NOTIFY_INTERFACE_UP                 4
775185694Srrs#define SCTP_NOTIFY_DG_FAIL                      5
776185694Srrs#define SCTP_NOTIFY_STRDATA_ERR                  6
777185694Srrs#define SCTP_NOTIFY_ASSOC_ABORTED                7
778185694Srrs#define SCTP_NOTIFY_PEER_OPENED_STREAM           8
779185694Srrs#define SCTP_NOTIFY_STREAM_OPENED_OK             9
780185694Srrs#define SCTP_NOTIFY_ASSOC_RESTART               10
781185694Srrs#define SCTP_NOTIFY_HB_RESP                     11
782185694Srrs#define SCTP_NOTIFY_ASCONF_SUCCESS              12
783185694Srrs#define SCTP_NOTIFY_ASCONF_FAILED               13
784185694Srrs#define SCTP_NOTIFY_PEER_SHUTDOWN               14
785185694Srrs#define SCTP_NOTIFY_ASCONF_ADD_IP               15
786185694Srrs#define SCTP_NOTIFY_ASCONF_DELETE_IP            16
787185694Srrs#define SCTP_NOTIFY_ASCONF_SET_PRIMARY          17
788163953Srrs#define SCTP_NOTIFY_PARTIAL_DELVIERY_INDICATION 18
789185694Srrs#define SCTP_NOTIFY_INTERFACE_CONFIRMED         20
790185694Srrs#define SCTP_NOTIFY_STR_RESET_RECV              21
791185694Srrs#define SCTP_NOTIFY_STR_RESET_SEND              22
792185694Srrs#define SCTP_NOTIFY_STR_RESET_FAILED_OUT        23
793185694Srrs#define SCTP_NOTIFY_STR_RESET_FAILED_IN         24
794185694Srrs#define SCTP_NOTIFY_AUTH_NEW_KEY                25
795185694Srrs#define SCTP_NOTIFY_AUTH_FREE_KEY               26
796185694Srrs#define SCTP_NOTIFY_SPECIAL_SP_FAIL             27
797185694Srrs#define SCTP_NOTIFY_NO_PEER_AUTH                28
798185694Srrs#define SCTP_NOTIFY_SENDER_DRY                  29
799188854Srrs#define SCTP_NOTIFY_STR_RESET_ADD_OK            30
800188854Srrs#define SCTP_NOTIFY_STR_RESET_ADD_FAIL          31
801188854Srrs#define SCTP_NOTIFY_STR_RESET_INSTREAM_ADD_OK   32
802188854Srrs#define SCTP_NOTIFY_MAX                         32
803163953Srrs
804188854Srrs
805163953Srrs/* This is the value for messages that are NOT completely
806163953Srrs * copied down where we will start to split the message.
807163953Srrs * So, with our default, we split only if the piece we
808163953Srrs * want to take will fill up a full MTU (assuming
809163953Srrs * a 1500 byte MTU).
810163953Srrs */
811168124Srrs#define SCTP_DEFAULT_SPLIT_POINT_MIN 2904
812163953Srrs
813165220Srrs/* ABORT CODES and other tell-tale location
814165220Srrs * codes are generated by adding the below
815165220Srrs * to the instance id.
816165220Srrs */
817165220Srrs
818165220Srrs/* File defines */
819165220Srrs#define SCTP_FROM_SCTP_INPUT   0x10000000
820165220Srrs#define SCTP_FROM_SCTP_PCB     0x20000000
821165220Srrs#define SCTP_FROM_SCTP_INDATA  0x30000000
822165220Srrs#define SCTP_FROM_SCTP_TIMER   0x40000000
823165220Srrs#define SCTP_FROM_SCTP_USRREQ  0x50000000
824165220Srrs#define SCTP_FROM_SCTPUTIL     0x60000000
825165220Srrs#define SCTP_FROM_SCTP6_USRREQ 0x70000000
826165220Srrs#define SCTP_FROM_SCTP_ASCONF  0x80000000
827165220Srrs#define SCTP_FROM_SCTP_OUTPUT  0x90000000
828165220Srrs#define SCTP_FROM_SCTP_PEELOFF 0xa0000000
829170056Srrs#define SCTP_FROM_SCTP_PANDA   0xb0000000
830171943Srrs#define SCTP_FROM_SCTP_SYSCTL  0xc0000000
831165220Srrs
832165220Srrs/* Location ID's */
833165220Srrs#define SCTP_LOC_1  0x00000001
834165220Srrs#define SCTP_LOC_2  0x00000002
835165220Srrs#define SCTP_LOC_3  0x00000003
836165220Srrs#define SCTP_LOC_4  0x00000004
837165220Srrs#define SCTP_LOC_5  0x00000005
838165220Srrs#define SCTP_LOC_6  0x00000006
839165220Srrs#define SCTP_LOC_7  0x00000007
840165220Srrs#define SCTP_LOC_8  0x00000008
841165220Srrs#define SCTP_LOC_9  0x00000009
842165220Srrs#define SCTP_LOC_10 0x0000000a
843165220Srrs#define SCTP_LOC_11 0x0000000b
844165220Srrs#define SCTP_LOC_12 0x0000000c
845165220Srrs#define SCTP_LOC_13 0x0000000d
846165220Srrs#define SCTP_LOC_14 0x0000000e
847165220Srrs#define SCTP_LOC_15 0x0000000f
848165220Srrs#define SCTP_LOC_16 0x00000010
849165220Srrs#define SCTP_LOC_17 0x00000011
850165220Srrs#define SCTP_LOC_18 0x00000012
851165220Srrs#define SCTP_LOC_19 0x00000013
852165220Srrs#define SCTP_LOC_20 0x00000014
853165220Srrs#define SCTP_LOC_21 0x00000015
854165220Srrs#define SCTP_LOC_22 0x00000016
855165220Srrs#define SCTP_LOC_23 0x00000017
856165220Srrs#define SCTP_LOC_24 0x00000018
857165220Srrs#define SCTP_LOC_25 0x00000019
858165220Srrs#define SCTP_LOC_26 0x0000001a
859165220Srrs#define SCTP_LOC_27 0x0000001b
860165220Srrs#define SCTP_LOC_28 0x0000001c
861165220Srrs#define SCTP_LOC_29 0x0000001d
862165220Srrs#define SCTP_LOC_30 0x0000001e
863165220Srrs#define SCTP_LOC_31 0x0000001f
864165220Srrs#define SCTP_LOC_32 0x00000020
865169352Srrs#define SCTP_LOC_33 0x00000021
866165220Srrs
867165220Srrs
868165220Srrs/* Free assoc codes */
869165220Srrs#define SCTP_NORMAL_PROC      0
870165220Srrs#define SCTP_PCBFREE_NOFORCE  1
871165220Srrs#define SCTP_PCBFREE_FORCE    2
872165220Srrs
873165220Srrs/* From codes for adding addresses */
874165220Srrs#define SCTP_ADDR_IS_CONFIRMED 8
875165220Srrs#define SCTP_ADDR_DYNAMIC_ADDED 6
876165220Srrs#define SCTP_IN_COOKIE_PROC 100
877165220Srrs#define SCTP_ALLOC_ASOC  1
878165220Srrs#define SCTP_LOAD_ADDR_2 2
879165220Srrs#define SCTP_LOAD_ADDR_3 3
880165220Srrs#define SCTP_LOAD_ADDR_4 4
881165220Srrs#define SCTP_LOAD_ADDR_5 5
882165220Srrs
883165220Srrs#define SCTP_DONOT_SETSCOPE 0
884165220Srrs#define SCTP_DO_SETSCOPE 1
885165220Srrs
886165220Srrs
887163953Srrs/* This value determines the default for when
888163953Srrs * we try to add more on the send queue., if
889163953Srrs * there is room. This prevents us from cycling
890163953Srrs * into the copy_resume routine to often if
891163953Srrs * we have not got enough space to add a decent
892163953Srrs * enough size message. Note that if we have enough
893163953Srrs * space to complete the message copy we will always
894163953Srrs * add to the message, no matter what the size. Its
895163953Srrs * only when we reach the point that we have some left
896163953Srrs * to add, there is only room for part of it that we
897163953Srrs * will use this threshold. Its also a sysctl.
898163953Srrs */
899163953Srrs#define SCTP_DEFAULT_ADD_MORE 1452
900163953Srrs
901163953Srrs#ifndef SCTP_PCBHASHSIZE
902163953Srrs/* default number of association hash buckets in each endpoint */
903163953Srrs#define SCTP_PCBHASHSIZE 256
904163953Srrs#endif
905163953Srrs#ifndef SCTP_TCBHASHSIZE
906163953Srrs#define SCTP_TCBHASHSIZE 1024
907163953Srrs#endif
908163953Srrs
909163953Srrs#ifndef SCTP_CHUNKQUEUE_SCALE
910163953Srrs#define SCTP_CHUNKQUEUE_SCALE 10
911163953Srrs#endif
912163953Srrs
913163953Srrs/* clock variance is 1 ms */
914163953Srrs#define SCTP_CLOCK_GRANULARITY	1
915163953Srrs#define IP_HDR_SIZE 40		/* we use the size of a IP6 header here this
916163953Srrs				 * detracts a small amount for ipv4 but it
917163953Srrs				 * simplifies the ipv6 addition */
918163953Srrs
919169380Srrs/* Argument magic number for sctp_inpcb_free() */
920169380Srrs
921169380Srrs/* third argument */
922169380Srrs#define SCTP_CALLED_DIRECTLY_NOCMPSET     0
923169380Srrs#define SCTP_CALLED_AFTER_CMPSET_OFCLOSE  1
924169380Srrs
925169380Srrs/* second argument */
926169380Srrs#define SCTP_FREE_SHOULD_USE_ABORT          1
927169380Srrs#define SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE 0
928169380Srrs
929163953Srrs#ifndef IPPROTO_SCTP
930163953Srrs#define IPPROTO_SCTP 132	/* the Official IANA number :-) */
931163953Srrs#endif				/* !IPPROTO_SCTP */
932163953Srrs
933163953Srrs#define SCTP_MAX_DATA_BUNDLING		256
934163953Srrs
935163953Srrs/* modular comparison */
936163953Srrs/* True if a > b (mod = M) */
937163953Srrs#define compare_with_wrap(a, b, M) (((a > b) && ((a - b) < ((M >> 1) + 1))) || \
938163953Srrs              ((b > a) && ((b - a) > ((M >> 1) + 1))))
939163953Srrs
940163953Srrs
941163953Srrs/* Mapping array manipulation routines */
942163953Srrs#define SCTP_IS_TSN_PRESENT(arry, gap) ((arry[(gap >> 3)] >> (gap & 0x07)) & 0x01)
943163953Srrs#define SCTP_SET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] |= (0x01 << ((gap & 0x07))))
944163953Srrs#define SCTP_UNSET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] &= ((~(0x01 << ((gap & 0x07)))) & 0xff))
945163953Srrs
946163953Srrs
947168124Srrs#define SCTP_RETRAN_DONE -1
948168124Srrs#define SCTP_RETRAN_EXIT -2
949168124Srrs
950163953Srrs/*
951163953Srrs * This value defines the number of vtag block time wait entry's per list
952163953Srrs * element.  Each entry will take 2 4 byte ints (and of course the overhead
953163953Srrs * of the next pointer as well). Using 15 as an example will yield * ((8 *
954163953Srrs * 15) + 8) or 128 bytes of overhead for each timewait block that gets
955163953Srrs * initialized. Increasing it to 31 would yeild 256 bytes per block.
956163953Srrs */
957163953Srrs#define SCTP_NUMBER_IN_VTAG_BLOCK 15
958163953Srrs/*
959163953Srrs * If we use the STACK option, we have an array of this size head pointers.
960163953Srrs * This array is mod'd the with the size to find which bucket and then all
961163953Srrs * entries must be searched to see if the tag is in timed wait. If so we
962163953Srrs * reject it.
963163953Srrs */
964184883Srrs#define SCTP_STACK_VTAG_HASH_SIZE   32
965163953Srrs
966163953Srrs/*
967173179Srrs * Number of seconds of time wait for a vtag.
968163953Srrs */
969173179Srrs#define SCTP_TIME_WAIT 60
970163953Srrs
971163953Srrs/* The system retains a cache of free chunks such to
972163953Srrs * cut down on calls the memory allocation system. There
973163953Srrs * is a per association limit of free items and a overall
974163953Srrs * system limit. If either one gets hit then the resource
975163953Srrs * stops being cached.
976163953Srrs */
977163953Srrs
978163953Srrs#define SCTP_DEF_ASOC_RESC_LIMIT 10
979163953Srrs#define SCTP_DEF_SYSTEM_RESC_LIMIT 1000
980163953Srrs
981172090Srrs/*-
982172090Srrs * defines for socket lock states.
983172090Srrs * Used by __APPLE__ and SCTP_SO_LOCK_TESTING
984172090Srrs */
985172090Srrs#define SCTP_SO_LOCKED		1
986172090Srrs#define SCTP_SO_NOT_LOCKED	0
987163953Srrs
988172090Srrs
989172396Srrs#define SCTP_HOLDS_LOCK 1
990172396Srrs#define SCTP_NOT_LOCKED 0
991172396Srrs
992172091Srrs/*-
993172091Srrs * For address locks, do we hold the lock?
994172091Srrs */
995172091Srrs#define SCTP_ADDR_LOCKED 1
996172091Srrs#define SCTP_ADDR_NOT_LOCKED 0
997172091Srrs
998163953Srrs#define IN4_ISPRIVATE_ADDRESS(a) \
999166675Srrs   ((((uint8_t *)&(a)->s_addr)[0] == 10) || \
1000166675Srrs    ((((uint8_t *)&(a)->s_addr)[0] == 172) && \
1001166675Srrs     (((uint8_t *)&(a)->s_addr)[1] >= 16) && \
1002166675Srrs     (((uint8_t *)&(a)->s_addr)[1] <= 32)) || \
1003166675Srrs    ((((uint8_t *)&(a)->s_addr)[0] == 192) && \
1004166675Srrs     (((uint8_t *)&(a)->s_addr)[1] == 168)))
1005163953Srrs
1006163953Srrs#define IN4_ISLOOPBACK_ADDRESS(a) \
1007166675Srrs    ((((uint8_t *)&(a)->s_addr)[0] == 127) && \
1008166675Srrs     (((uint8_t *)&(a)->s_addr)[1] == 0) && \
1009166675Srrs     (((uint8_t *)&(a)->s_addr)[2] == 0) && \
1010166675Srrs     (((uint8_t *)&(a)->s_addr)[3] == 1))
1011163953Srrs
1012163953Srrs
1013163953Srrs#if defined(_KERNEL)
1014163953Srrs
1015163953Srrs#define SCTP_GETTIME_TIMEVAL(x)	(getmicrouptime(x))
1016163953Srrs#define SCTP_GETPTIME_TIMEVAL(x)	(microuptime(x))
1017180387Srrs#endif
1018163953Srrs/*#if defined(__FreeBSD__) || defined(__APPLE__)*/
1019163953Srrs/*#define SCTP_GETTIME_TIMEVAL(x) { \*/
1020163953Srrs/*	(x)->tv_sec = ticks / 1000; \*/
1021163953Srrs/*	(x)->tv_usec = (ticks % 1000) * 1000; \*/
1022163953Srrs/*}*/
1023163953Srrs
1024163953Srrs/*#else*/
1025163953Srrs/*#define SCTP_GETTIME_TIMEVAL(x)	(microtime(x))*/
1026163953Srrs/*#endif				 __FreeBSD__ */
1027163953Srrs
1028180387Srrs#if defined(_KERNEL) || defined(__Userspace__)
1029163953Srrs#define sctp_sowwakeup(inp, so) \
1030163953Srrsdo { \
1031163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1032163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
1033163953Srrs	} else { \
1034163953Srrs		sowwakeup(so); \
1035163953Srrs	} \
1036163953Srrs} while (0)
1037163953Srrs
1038163953Srrs#define sctp_sowwakeup_locked(inp, so) \
1039163953Srrsdo { \
1040163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1041163953Srrs                SOCKBUF_UNLOCK(&((so)->so_snd)); \
1042163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
1043163953Srrs	} else { \
1044163953Srrs		sowwakeup_locked(so); \
1045163953Srrs	} \
1046163953Srrs} while (0)
1047163953Srrs
1048163953Srrs#define sctp_sorwakeup(inp, so) \
1049163953Srrsdo { \
1050163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1051163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
1052163953Srrs	} else { \
1053163953Srrs		sorwakeup(so); \
1054163953Srrs	} \
1055163953Srrs} while (0)
1056163953Srrs
1057163953Srrs#define sctp_sorwakeup_locked(inp, so) \
1058163953Srrsdo { \
1059163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1060163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
1061163953Srrs                SOCKBUF_UNLOCK(&((so)->so_rcv)); \
1062163953Srrs	} else { \
1063163953Srrs		sorwakeup_locked(so); \
1064163953Srrs	} \
1065163953Srrs} while (0)
1066163953Srrs
1067180387Srrs#endif				/* _KERNEL || __Userspace__ */
1068163953Srrs#endif
1069