1163953Srrs/*-
2185694Srrs * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3237896Stuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4237896Stuexen * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5163953Srrs *
6163953Srrs * Redistribution and use in source and binary forms, with or without
7163953Srrs * modification, are permitted provided that the following conditions are met:
8163953Srrs *
9163953Srrs * a) Redistributions of source code must retain the above copyright notice,
10231038Stuexen *    this list of conditions and the following disclaimer.
11163953Srrs *
12163953Srrs * b) Redistributions in binary form must reproduce the above copyright
13163953Srrs *    notice, this list of conditions and the following disclaimer in
14231038Stuexen *    the documentation and/or other materials provided with the distribution.
15163953Srrs *
16163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its
17163953Srrs *    contributors may be used to endorse or promote products derived
18163953Srrs *    from this software without specific prior written permission.
19163953Srrs *
20163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30163953Srrs * THE POSSIBILITY OF SUCH DAMAGE.
31163953Srrs */
32163953Srrs
33163953Srrs#include <sys/cdefs.h>
34163953Srrs__FBSDID("$FreeBSD$");
35163953Srrs
36237896Stuexen#ifndef _NETINET_SCTP_CONSTANTS_H_
37237896Stuexen#define _NETINET_SCTP_CONSTANTS_H_
38163953Srrs
39266182Stuexen
40179157Srrs/* IANA assigned port number for SCTP over UDP encapsulation */
41266182Stuexen#define SCTP_OVER_UDP_TUNNELING_PORT 9899
42266182Stuexen
43167598Srrs/* Number of packets to get before sack sent by default */
44167598Srrs#define SCTP_DEFAULT_SACK_FREQ 2
45163953Srrs
46167598Srrs/* Address limit - This variable is calculated
47168299Srrs * based on an 65535 byte max ip packet. We take out 100 bytes
48167598Srrs * for the cookie, 40 bytes for a v6 header and 32
49167598Srrs * bytes for the init structure. A second init structure
50167598Srrs * for the init-ack and then finally a third one for the
51167598Srrs * imbedded init. This yeilds 100+40+(3 * 32) = 236 bytes.
52168299Srrs * This leaves 65299 bytes for addresses. We throw out the 299 bytes.
53168299Srrs * Now whatever we send in the INIT() we need to allow to get back in the
54167598Srrs * INIT-ACK plus all the values from INIT and INIT-ACK
55167598Srrs * listed in the cookie. Plus we need some overhead for
56167598Srrs * maybe copied parameters in the COOKIE. If we
57168299Srrs * allow 1080 addresses, and each side has 1080 V6 addresses
58168299Srrs * that will be 21600 bytes. In the INIT-ACK we will
59168299Srrs * see the INIT-ACK 21600 + 43200 in the cookie. This leaves
60168299Srrs * about 500 bytes slack for misc things in the cookie.
61167598Srrs */
62168299Srrs#define SCTP_ADDRESS_LIMIT 1080
63167598Srrs
64171990Srrs/* We need at least 2k of space for us, inits
65171990Srrs * larger than that lets abort.
66171990Srrs */
67171990Srrs#define SCTP_LARGEST_INIT_ACCEPTED (65535 - 2048)
68171990Srrs
69167598Srrs/* Number of addresses where we just skip the counting */
70167598Srrs#define SCTP_COUNT_LIMIT 40
71167598Srrs
72170056Srrs#define SCTP_ZERO_COPY_TICK_DELAY (((100 * hz) + 999) / 1000)
73170181Srrs#define SCTP_ZERO_COPY_SENDQ_TICK_DELAY (((100 * hz) + 999) / 1000)
74170056Srrs
75167598Srrs/* Number of ticks to delay before running
76167598Srrs * iterator on an address change.
77167598Srrs */
78167598Srrs#define SCTP_ADDRESS_TICK_DELAY 2
79167598Srrs
80163953Srrs#define SCTP_VERSION_STRING "KAME-BSD 1.1"
81163953Srrs/* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */
82163953Srrs#define SCTP_AUDIT_SIZE 256
83163953Srrs
84167598Srrs
85167598Srrs#define SCTP_KTRHEAD_NAME "sctp_iterator"
86199866Stuexen#define SCTP_KTHREAD_PAGES 0
87167598Srrs
88218211Srrs#define SCTP_MCORE_NAME "sctp_core_worker"
89167598Srrs
90218211Srrs
91167598Srrs/* If you support Multi-VRF how big to
92167598Srrs * make the initial array of VRF's to.
93167598Srrs */
94167598Srrs#define SCTP_DEFAULT_VRF_SIZE 4
95167598Srrs
96171477Srrs/* constants for rto calc */
97171477Srrs#define sctp_align_safe_nocopy 0
98171477Srrs#define sctp_align_unsafe_makecopy 1
99171477Srrs
100171440Srrs/* JRS - Values defined for the HTCP algorithm */
101171440Srrs#define ALPHA_BASE	(1<<7)	/* 1.0 with shift << 7 */
102171440Srrs#define BETA_MIN	(1<<6)	/* 0.5 with shift << 7 */
103171440Srrs#define BETA_MAX	102	/* 0.8 with shift << 7 */
104171440Srrs
105163953Srrs/* Places that CWND log can happen from */
106163953Srrs#define SCTP_CWND_LOG_FROM_FR	1
107163953Srrs#define SCTP_CWND_LOG_FROM_RTX	2
108163953Srrs#define SCTP_CWND_LOG_FROM_BRST	3
109163953Srrs#define SCTP_CWND_LOG_FROM_SS	4
110163953Srrs#define SCTP_CWND_LOG_FROM_CA	5
111163953Srrs#define SCTP_CWND_LOG_FROM_SAT	6
112163953Srrs#define SCTP_BLOCK_LOG_INTO_BLK 7
113163953Srrs#define SCTP_BLOCK_LOG_OUTOF_BLK 8
114163953Srrs#define SCTP_BLOCK_LOG_CHECK     9
115163953Srrs#define SCTP_STR_LOG_FROM_INTO_STRD 10
116163953Srrs#define SCTP_STR_LOG_FROM_IMMED_DEL 11
117163953Srrs#define SCTP_STR_LOG_FROM_INSERT_HD 12
118163953Srrs#define SCTP_STR_LOG_FROM_INSERT_MD 13
119163953Srrs#define SCTP_STR_LOG_FROM_INSERT_TL 14
120163953Srrs#define SCTP_STR_LOG_FROM_MARK_TSN  15
121163953Srrs#define SCTP_STR_LOG_FROM_EXPRS_DEL 16
122163953Srrs#define SCTP_FR_LOG_BIGGEST_TSNS    17
123163953Srrs#define SCTP_FR_LOG_STRIKE_TEST     18
124163953Srrs#define SCTP_FR_LOG_STRIKE_CHUNK    19
125163953Srrs#define SCTP_FR_T3_TIMEOUT          20
126163953Srrs#define SCTP_MAP_PREPARE_SLIDE      21
127163953Srrs#define SCTP_MAP_SLIDE_FROM         22
128163953Srrs#define SCTP_MAP_SLIDE_RESULT       23
129163953Srrs#define SCTP_MAP_SLIDE_CLEARED	    24
130163953Srrs#define SCTP_MAP_SLIDE_NONE         25
131163953Srrs#define SCTP_FR_T3_MARK_TIME        26
132163953Srrs#define SCTP_FR_T3_MARKED           27
133163953Srrs#define SCTP_FR_T3_STOPPED          28
134163953Srrs#define SCTP_FR_MARKED              30
135163953Srrs#define SCTP_CWND_LOG_NOADV_SS      31
136163953Srrs#define SCTP_CWND_LOG_NOADV_CA      32
137163953Srrs#define SCTP_MAX_BURST_APPLIED      33
138163953Srrs#define SCTP_MAX_IFP_APPLIED        34
139163953Srrs#define SCTP_MAX_BURST_ERROR_STOP   35
140163953Srrs#define SCTP_INCREASE_PEER_RWND     36
141163953Srrs#define SCTP_DECREASE_PEER_RWND     37
142163953Srrs#define SCTP_SET_PEER_RWND_VIA_SACK 38
143163953Srrs#define SCTP_LOG_MBCNT_INCREASE     39
144163953Srrs#define SCTP_LOG_MBCNT_DECREASE     40
145163953Srrs#define SCTP_LOG_MBCNT_CHKSET       41
146163953Srrs#define SCTP_LOG_NEW_SACK           42
147163953Srrs#define SCTP_LOG_TSN_ACKED          43
148163953Srrs#define SCTP_LOG_TSN_REVOKED        44
149163953Srrs#define SCTP_LOG_LOCK_TCB           45
150163953Srrs#define SCTP_LOG_LOCK_INP           46
151163953Srrs#define SCTP_LOG_LOCK_SOCK          47
152163953Srrs#define SCTP_LOG_LOCK_SOCKBUF_R     48
153163953Srrs#define SCTP_LOG_LOCK_SOCKBUF_S     49
154163953Srrs#define SCTP_LOG_LOCK_CREATE        50
155163953Srrs#define SCTP_LOG_INITIAL_RTT        51
156163953Srrs#define SCTP_LOG_RTTVAR             52
157163953Srrs#define SCTP_LOG_SBALLOC            53
158163953Srrs#define SCTP_LOG_SBFREE             54
159163953Srrs#define SCTP_LOG_SBRESULT           55
160163953Srrs#define SCTP_FR_DUPED               56
161163953Srrs#define SCTP_FR_MARKED_EARLY        57
162163953Srrs#define SCTP_FR_CWND_REPORT         58
163163953Srrs#define SCTP_FR_CWND_REPORT_START   59
164163953Srrs#define SCTP_FR_CWND_REPORT_STOP    60
165163953Srrs#define SCTP_CWND_LOG_FROM_SEND     61
166163953Srrs#define SCTP_CWND_INITIALIZATION    62
167163953Srrs#define SCTP_CWND_LOG_FROM_T3       63
168163953Srrs#define SCTP_CWND_LOG_FROM_SACK     64
169163953Srrs#define SCTP_CWND_LOG_NO_CUMACK     65
170163953Srrs#define SCTP_CWND_LOG_FROM_RESEND   66
171163953Srrs#define SCTP_FR_LOG_CHECK_STRIKE    67
172163953Srrs#define SCTP_SEND_NOW_COMPLETES     68
173163953Srrs#define SCTP_CWND_LOG_FILL_OUTQ_CALLED 69
174163953Srrs#define SCTP_CWND_LOG_FILL_OUTQ_FILLS  70
175163953Srrs#define SCTP_LOG_FREE_SENT             71
176163953Srrs#define SCTP_NAGLE_APPLIED          72
177163953Srrs#define SCTP_NAGLE_SKIPPED          73
178163953Srrs#define SCTP_WAKESND_FROM_SACK      74
179163953Srrs#define SCTP_WAKESND_FROM_FWDTSN    75
180163953Srrs#define SCTP_NOWAKE_FROM_SACK       76
181163953Srrs#define SCTP_CWNDLOG_PRESEND        77
182163953Srrs#define SCTP_CWNDLOG_ENDSEND        78
183163953Srrs#define SCTP_AT_END_OF_SACK         79
184163953Srrs#define SCTP_REASON_FOR_SC          80
185163953Srrs#define SCTP_BLOCK_LOG_INTO_BLKA    81
186163953Srrs#define SCTP_ENTER_USER_RECV        82
187163953Srrs#define SCTP_USER_RECV_SACKS        83
188163953Srrs#define SCTP_SORECV_BLOCKSA         84
189163953Srrs#define SCTP_SORECV_BLOCKSB         85
190163953Srrs#define SCTP_SORECV_DONE            86
191163953Srrs#define SCTP_SACK_RWND_UPDATE       87
192163953Srrs#define SCTP_SORECV_ENTER           88
193163953Srrs#define SCTP_SORECV_ENTERPL         89
194163953Srrs#define SCTP_MBUF_INPUT             90
195163953Srrs#define SCTP_MBUF_IALLOC            91
196163953Srrs#define SCTP_MBUF_IFREE             92
197163953Srrs#define SCTP_MBUF_ICOPY             93
198178197Srrs#define SCTP_MBUF_SPLIT             94
199178197Srrs#define SCTP_SORCV_FREECTL          95
200178197Srrs#define SCTP_SORCV_DOESCPY          96
201178197Srrs#define SCTP_SORCV_DOESLCK          97
202178197Srrs#define SCTP_SORCV_DOESADJ          98
203178197Srrs#define SCTP_SORCV_BOTWHILE         99
204178197Srrs#define SCTP_SORCV_PASSBF          100
205178197Srrs#define SCTP_SORCV_ADJD            101
206178197Srrs#define SCTP_UNKNOWN_MAX           102
207178197Srrs#define SCTP_RANDY_STUFF           103
208178197Srrs#define SCTP_RANDY_STUFF1          104
209178197Srrs#define SCTP_STRMOUT_LOG_ASSIGN	   105
210178197Srrs#define SCTP_STRMOUT_LOG_SEND	   106
211178197Srrs#define SCTP_FLIGHT_LOG_DOWN_CA    107
212178197Srrs#define SCTP_FLIGHT_LOG_UP         108
213178197Srrs#define SCTP_FLIGHT_LOG_DOWN_GAP   109
214178197Srrs#define SCTP_FLIGHT_LOG_DOWN_RSND  110
215178197Srrs#define SCTP_FLIGHT_LOG_UP_RSND    111
216178197Srrs#define SCTP_FLIGHT_LOG_DOWN_RSND_TO    112
217178197Srrs#define SCTP_FLIGHT_LOG_DOWN_WP    113
218178197Srrs#define SCTP_FLIGHT_LOG_UP_REVOKE  114
219178197Srrs#define SCTP_FLIGHT_LOG_DOWN_PDRP  115
220178197Srrs#define SCTP_FLIGHT_LOG_DOWN_PMTU  116
221178197Srrs#define SCTP_SACK_LOG_NORMAL	   117
222178197Srrs#define SCTP_SACK_LOG_EXPRESS	   118
223178197Srrs#define SCTP_MAP_TSN_ENTERS        119
224178197Srrs#define SCTP_THRESHOLD_CLEAR       120
225178197Srrs#define SCTP_THRESHOLD_INCR        121
226189371Srrs#define SCTP_FLIGHT_LOG_DWN_WP_FWD 122
227189790Srrs#define SCTP_FWD_TSN_CHECK         123
228189790Srrs#define SCTP_LOG_MAX_TYPES 124
229163953Srrs/*
230170744Srrs * To turn on various logging, you must first enable 'options KTR' and
231170744Srrs * you might want to bump the entires 'options KTR_ENTRIES=80000'.
232170744Srrs * To get something to log you define one of the logging defines.
233170744Srrs * (see LINT).
234163953Srrs *
235170744Srrs * This gets the compile in place, but you still need to turn the
236170744Srrs * logging flag on too in the sysctl (see in sctp.h).
237163953Srrs */
238171943Srrs
239163953Srrs#define SCTP_LOG_EVENT_UNKNOWN 0
240163953Srrs#define SCTP_LOG_EVENT_CWND  1
241163953Srrs#define SCTP_LOG_EVENT_BLOCK 2
242163953Srrs#define SCTP_LOG_EVENT_STRM  3
243163953Srrs#define SCTP_LOG_EVENT_FR    4
244163953Srrs#define SCTP_LOG_EVENT_MAP   5
245163953Srrs#define SCTP_LOG_EVENT_MAXBURST 6
246163953Srrs#define SCTP_LOG_EVENT_RWND  7
247163953Srrs#define SCTP_LOG_EVENT_MBCNT 8
248163953Srrs#define SCTP_LOG_EVENT_SACK  9
249163953Srrs#define SCTP_LOG_LOCK_EVENT 10
250163953Srrs#define SCTP_LOG_EVENT_RTT  11
251163953Srrs#define SCTP_LOG_EVENT_SB   12
252163953Srrs#define SCTP_LOG_EVENT_NAGLE 13
253163953Srrs#define SCTP_LOG_EVENT_WAKE 14
254163953Srrs#define SCTP_LOG_MISC_EVENT 15
255163953Srrs#define SCTP_LOG_EVENT_CLOSE 16
256163953Srrs#define SCTP_LOG_EVENT_MBUF 17
257170744Srrs#define SCTP_LOG_CHUNK_PROC 18
258170744Srrs#define SCTP_LOG_ERROR_RET  19
259163953Srrs
260170744Srrs#define SCTP_LOG_MAX_EVENT 20
261163953Srrs
262163953Srrs#define SCTP_LOCK_UNKNOWN 2
263163953Srrs
264163953Srrs
265163953Srrs/* number of associations by default for zone allocation */
266163953Srrs#define SCTP_MAX_NUM_OF_ASOC	40000
267163953Srrs/* how many addresses per assoc remote and local */
268163953Srrs#define SCTP_SCALE_FOR_ADDR	2
269163953Srrs
270163953Srrs/* default AUTO_ASCONF mode enable(1)/disable(0) value (sysctl) */
271167598Srrs#define SCTP_DEFAULT_AUTO_ASCONF	1
272163953Srrs
273179157Srrs/* default MULTIPLE_ASCONF mode enable(1)/disable(0) value (sysctl) */
274179157Srrs#define SCTP_DEFAULT_MULTIPLE_ASCONFS	0
275179157Srrs
276171990Srrs/* default MOBILITY_BASE mode enable(1)/disable(0) value (sysctl) */
277171990Srrs#define SCTP_DEFAULT_MOBILITY_BASE	0
278171990Srrs
279171990Srrs/* default MOBILITY_FASTHANDOFF mode enable(1)/disable(0) value (sysctl) */
280171990Srrs#define SCTP_DEFAULT_MOBILITY_FASTHANDOFF	0
281171990Srrs
282163953Srrs/*
283163953Srrs * Theshold for rwnd updates, we have to read (sb_hiwat >>
284163953Srrs * SCTP_RWND_HIWAT_SHIFT) before we will look to see if we need to send a
285163953Srrs * window update sack. When we look, we compare the last rwnd we sent vs the
286163953Srrs * current rwnd. It too must be greater than this value. Using 3 divdes the
287163953Srrs * hiwat by 8, so for 200k rwnd we need to read 24k. For a 64k rwnd we need
288163953Srrs * to read 8k. This seems about right.. I hope :-D.. we do set a
289163953Srrs * min of a MTU on it so if the rwnd is real small we will insist
290163953Srrs * on a full MTU of 1500 bytes.
291163953Srrs */
292163953Srrs#define SCTP_RWND_HIWAT_SHIFT 3
293163953Srrs
294163953Srrs/* How much of the rwnd must the
295163953Srrs * message be taking up to start partial delivery.
296163953Srrs * We calculate this by shifing the hi_water (recv_win)
297163953Srrs * left the following .. set to 1, when a message holds
298163953Srrs * 1/2 the rwnd. If we set it to 2 when a message holds
299163953Srrs * 1/4 the rwnd...etc..
300163953Srrs */
301163953Srrs
302163953Srrs#define SCTP_PARTIAL_DELIVERY_SHIFT 1
303163953Srrs
304163953Srrs/*
305163953Srrs * default HMAC for cookies, etc... use one of the AUTH HMAC id's
306163953Srrs * SCTP_HMAC is the HMAC_ID to use
307163953Srrs * SCTP_SIGNATURE_SIZE is the digest length
308163953Srrs */
309163953Srrs#define SCTP_HMAC		SCTP_AUTH_HMAC_ID_SHA1
310163953Srrs#define SCTP_SIGNATURE_SIZE	SCTP_AUTH_DIGEST_LEN_SHA1
311163953Srrs#define SCTP_SIGNATURE_ALOC_SIZE SCTP_SIGNATURE_SIZE
312163953Srrs
313163953Srrs/*
314163953Srrs * the SCTP protocol signature this includes the version number encoded in
315163953Srrs * the last 4 bits of the signature.
316163953Srrs */
317163953Srrs#define PROTO_SIGNATURE_A	0x30000000
318163953Srrs#define SCTP_VERSION_NUMBER	0x3
319163953Srrs
320163953Srrs#define MAX_TSN	0xffffffff
321163953Srrs
322163953Srrs/* how many executions every N tick's */
323163953Srrs#define SCTP_ITERATOR_MAX_AT_ONCE 20
324163953Srrs
325163953Srrs/* number of clock ticks between iterator executions */
326163953Srrs#define SCTP_ITERATOR_TICKS 1
327163953Srrs
328163953Srrs/*
329163953Srrs * option: If you comment out the following you will receive the old behavior
330163953Srrs * of obeying cwnd for the fast retransmit algorithm. With this defined a FR
331163953Srrs * happens right away with-out waiting for the flightsize to drop below the
332163953Srrs * cwnd value (which is reduced by the FR to 1/2 the inflight packets).
333163953Srrs */
334163953Srrs#define SCTP_IGNORE_CWND_ON_FR 1
335163953Srrs
336163953Srrs/*
337163953Srrs * Adds implementors guide behavior to only use newest highest update in SACK
338163953Srrs * gap ack's to figure out if you need to stroke a chunk for FR.
339163953Srrs */
340163953Srrs#define SCTP_NO_FR_UNLESS_SEGMENT_SMALLER 1
341163953Srrs
342217913Stuexen/* default max I can burst out after a fast retransmit, 0 disables it */
343237893Stuexen#define SCTP_DEF_MAX_BURST 4
344218186Srrs#define SCTP_DEF_HBMAX_BURST 4
345218186Srrs#define SCTP_DEF_FRMAX_BURST 4
346218186Srrs
347218186Srrs/* RTO calculation flag to say if it
348218186Srrs * is safe to determine local lan or not.
349218186Srrs */
350219397Srrs#define SCTP_RTT_FROM_NON_DATA 0
351219397Srrs#define SCTP_RTT_FROM_DATA     1
352218186Srrs
353218186Srrs
354163953Srrs/* IP hdr (20/40) + 12+2+2 (enet) + sctp common 12 */
355163953Srrs#define SCTP_FIRST_MBUF_RESV 68
356163953Srrs/* Packet transmit states in the sent field */
357163953Srrs#define SCTP_DATAGRAM_UNSENT		0
358163953Srrs#define SCTP_DATAGRAM_SENT		1
359163953Srrs#define SCTP_DATAGRAM_RESEND1		2	/* not used (in code, but may
360163953Srrs						 * hit this value) */
361163953Srrs#define SCTP_DATAGRAM_RESEND2		3	/* not used (in code, but may
362163953Srrs						 * hit this value) */
363163953Srrs#define SCTP_DATAGRAM_RESEND		4
364163953Srrs#define SCTP_DATAGRAM_ACKED		10010
365163953Srrs#define SCTP_DATAGRAM_MARKED		20010
366163953Srrs#define SCTP_FORWARD_TSN_SKIP		30010
367252943Stuexen#define SCTP_DATAGRAM_NR_ACKED		40010
368163953Srrs
369163953Srrs/* chunk output send from locations */
370163953Srrs#define SCTP_OUTPUT_FROM_USR_SEND       0
371163953Srrs#define SCTP_OUTPUT_FROM_T3       	1
372163953Srrs#define SCTP_OUTPUT_FROM_INPUT_ERROR    2
373163953Srrs#define SCTP_OUTPUT_FROM_CONTROL_PROC   3
374163953Srrs#define SCTP_OUTPUT_FROM_SACK_TMR       4
375163953Srrs#define SCTP_OUTPUT_FROM_SHUT_TMR       5
376163953Srrs#define SCTP_OUTPUT_FROM_HB_TMR         6
377163953Srrs#define SCTP_OUTPUT_FROM_SHUT_ACK_TMR   7
378163953Srrs#define SCTP_OUTPUT_FROM_ASCONF_TMR     8
379163953Srrs#define SCTP_OUTPUT_FROM_STRRST_TMR     9
380163953Srrs#define SCTP_OUTPUT_FROM_AUTOCLOSE_TMR  10
381163953Srrs#define SCTP_OUTPUT_FROM_EARLY_FR_TMR   11
382163953Srrs#define SCTP_OUTPUT_FROM_STRRST_REQ     12
383163953Srrs#define SCTP_OUTPUT_FROM_USR_RCVD       13
384164205Srrs#define SCTP_OUTPUT_FROM_COOKIE_ACK     14
385167598Srrs#define SCTP_OUTPUT_FROM_DRAIN          15
386171990Srrs#define SCTP_OUTPUT_FROM_CLOSING        16
387231029Stuexen#define SCTP_OUTPUT_FROM_SOCKOPT        17
388231029Stuexen
389163953Srrs/* SCTP chunk types are moved sctp.h for application (NAT, FW) use */
390163953Srrs
391163953Srrs/* align to 32-bit sizes */
392231039Stuexen#define SCTP_SIZE32(x)	((((x) + 3) >> 2) << 2)
393163953Srrs
394163953Srrs#define IS_SCTP_CONTROL(a) ((a)->chunk_type != SCTP_DATA)
395163953Srrs#define IS_SCTP_DATA(a) ((a)->chunk_type == SCTP_DATA)
396163953Srrs
397163953Srrs
398163953Srrs/* SCTP parameter types */
399163953Srrs/*************0x0000 series*************/
400163953Srrs#define SCTP_HEARTBEAT_INFO		0x0001
401163953Srrs#define SCTP_IPV4_ADDRESS		0x0005
402163953Srrs#define SCTP_IPV6_ADDRESS		0x0006
403163953Srrs#define SCTP_STATE_COOKIE		0x0007
404163953Srrs#define SCTP_UNRECOG_PARAM		0x0008
405163953Srrs#define SCTP_COOKIE_PRESERVE		0x0009
406163953Srrs#define SCTP_HOSTNAME_ADDRESS		0x000b
407163953Srrs#define SCTP_SUPPORTED_ADDRTYPE		0x000c
408163953Srrs
409188854Srrs/* draft-ietf-stewart-tsvwg-strreset-xxx */
410163953Srrs#define SCTP_STR_RESET_OUT_REQUEST	0x000d
411163953Srrs#define SCTP_STR_RESET_IN_REQUEST	0x000e
412163953Srrs#define SCTP_STR_RESET_TSN_REQUEST	0x000f
413163953Srrs#define SCTP_STR_RESET_RESPONSE		0x0010
414234790Stuexen#define SCTP_STR_RESET_ADD_OUT_STREAMS	0x0011
415234790Stuexen#define SCTP_STR_RESET_ADD_IN_STREAMS   0x0012
416163953Srrs
417163953Srrs#define SCTP_MAX_RESET_PARAMS 2
418163953Srrs#define SCTP_STREAM_RESET_TSN_DELTA    0x1000
419163953Srrs
420163953Srrs/*************0x4000 series*************/
421163953Srrs
422163953Srrs/*************0x8000 series*************/
423163953Srrs#define SCTP_ECN_CAPABLE		0x8000
424218129Srrs
425163953Srrs/* draft-ietf-tsvwg-auth-xxx */
426163953Srrs#define SCTP_RANDOM			0x8002
427163953Srrs#define SCTP_CHUNK_LIST			0x8003
428163953Srrs#define SCTP_HMAC_LIST			0x8004
429163953Srrs/*
430163953Srrs * draft-ietf-tsvwg-addip-sctp-xx param=0x8008  len=0xNNNN Byte | Byte | Byte
431163953Srrs * | Byte Byte | Byte ...
432163953Srrs *
433163953Srrs * Where each byte is a chunk type extension supported. For example, to support
434163953Srrs * all chunks one would have (in hex):
435163953Srrs *
436163953Srrs * 80 01 00 09 C0 C1 80 81 82 00 00 00
437163953Srrs *
438163953Srrs * Has the parameter. C0 = PR-SCTP    (RFC3758) C1, 80 = ASCONF (addip draft) 81
439163953Srrs * = Packet Drop 82 = Stream Reset 83 = Authentication
440163953Srrs */
441163953Srrs#define SCTP_SUPPORTED_CHUNK_EXT    0x8008
442163953Srrs
443163953Srrs/*************0xC000 series*************/
444163953Srrs#define SCTP_PRSCTP_SUPPORTED		0xc000
445163953Srrs/* draft-ietf-tsvwg-addip-sctp */
446163953Srrs#define SCTP_ADD_IP_ADDRESS		0xc001
447163953Srrs#define SCTP_DEL_IP_ADDRESS		0xc002
448163953Srrs#define SCTP_ERROR_CAUSE_IND		0xc003
449163953Srrs#define SCTP_SET_PRIM_ADDR		0xc004
450163953Srrs#define SCTP_SUCCESS_REPORT		0xc005
451163953Srrs#define SCTP_ULP_ADAPTATION		0xc006
452185694Srrs/* behave-nat-draft */
453185694Srrs#define SCTP_HAS_NAT_SUPPORT            0xc007
454185694Srrs#define SCTP_NAT_VTAGS                  0xc008
455163953Srrs
456163953Srrs/* bits for TOS field */
457163953Srrs#define SCTP_ECT0_BIT		0x02
458163953Srrs#define SCTP_ECT1_BIT		0x01
459163953Srrs#define SCTP_CE_BITS		0x03
460163953Srrs
461163953Srrs/* below turns off above */
462163953Srrs#define SCTP_FLEXIBLE_ADDRESS	0x20
463163953Srrs#define SCTP_NO_HEARTBEAT	0x40
464163953Srrs
465163953Srrs/* mask to get sticky */
466163953Srrs#define SCTP_STICKY_OPTIONS_MASK	0x0c
467163953Srrs
468163953Srrs
469163953Srrs/*
470163953Srrs * SCTP states for internal state machine XXX (should match "user" values)
471163953Srrs */
472163953Srrs#define SCTP_STATE_EMPTY		0x0000
473163953Srrs#define SCTP_STATE_INUSE		0x0001
474163953Srrs#define SCTP_STATE_COOKIE_WAIT		0x0002
475163953Srrs#define SCTP_STATE_COOKIE_ECHOED	0x0004
476163953Srrs#define SCTP_STATE_OPEN			0x0008
477163953Srrs#define SCTP_STATE_SHUTDOWN_SENT	0x0010
478163953Srrs#define SCTP_STATE_SHUTDOWN_RECEIVED	0x0020
479163953Srrs#define SCTP_STATE_SHUTDOWN_ACK_SENT	0x0040
480163953Srrs#define SCTP_STATE_SHUTDOWN_PENDING	0x0080
481163953Srrs#define SCTP_STATE_CLOSED_SOCKET	0x0100
482163953Srrs#define SCTP_STATE_ABOUT_TO_BE_FREED    0x0200
483163953Srrs#define SCTP_STATE_PARTIAL_MSG_LEFT     0x0400
484171745Srrs#define SCTP_STATE_WAS_ABORTED          0x0800
485207924Srrs#define SCTP_STATE_IN_ACCEPT_QUEUE      0x1000
486163953Srrs#define SCTP_STATE_MASK			0x007f
487163953Srrs
488163953Srrs#define SCTP_GET_STATE(asoc)	((asoc)->state & SCTP_STATE_MASK)
489171943Srrs#define SCTP_SET_STATE(asoc, newstate)  ((asoc)->state = ((asoc)->state & ~SCTP_STATE_MASK) |  newstate)
490172703Srrs#define SCTP_CLEAR_SUBSTATE(asoc, substate) ((asoc)->state &= ~substate)
491172703Srrs#define SCTP_ADD_SUBSTATE(asoc, substate) ((asoc)->state |= substate)
492163953Srrs
493163953Srrs/* SCTP reachability state for each address */
494163953Srrs#define SCTP_ADDR_REACHABLE		0x001
495225635Stuexen#define SCTP_ADDR_NO_PMTUD              0x002
496163953Srrs#define SCTP_ADDR_NOHB			0x004
497163953Srrs#define SCTP_ADDR_BEING_DELETED		0x008
498163953Srrs#define SCTP_ADDR_NOT_IN_ASSOC		0x010
499163953Srrs#define SCTP_ADDR_OUT_OF_SCOPE		0x080
500163953Srrs#define SCTP_ADDR_UNCONFIRMED		0x200
501167598Srrs#define SCTP_ADDR_REQ_PRIMARY           0x400
502171440Srrs/* JRS 5/13/07 - Added potentially failed state for CMT PF */
503217635Srrs#define SCTP_ADDR_PF                    0x800
504163953Srrs
505163953Srrs/* bound address types (e.g. valid address types to allow) */
506163953Srrs#define SCTP_BOUND_V6		0x01
507163953Srrs#define SCTP_BOUND_V4		0x02
508163953Srrs
509163953Srrs/*
510163953Srrs * what is the default number of mbufs in a chain I allow before switching to
511163953Srrs * a cluster
512163953Srrs */
513163953Srrs#define SCTP_DEFAULT_MBUFS_IN_CHAIN 5
514163953Srrs
515169655Srrs/* How long a cookie lives in milli-seconds */
516169655Srrs#define SCTP_DEFAULT_COOKIE_LIFE	60000
517163953Srrs
518163953Srrs/* Maximum the mapping array will  grow to (TSN mapping array) */
519163953Srrs#define SCTP_MAPPING_ARRAY	512
520163953Srrs
521163953Srrs/* size of the inital malloc on the mapping array */
522163953Srrs#define SCTP_INITIAL_MAPPING_ARRAY  16
523163953Srrs/* how much we grow the mapping array each call */
524163953Srrs#define SCTP_MAPPING_ARRAY_INCR     32
525206137Stuexen
526163953Srrs/*
527163953Srrs * Here we define the timer types used by the implementation as arguments in
528163953Srrs * the set/get timer type calls.
529163953Srrs */
530163953Srrs#define SCTP_TIMER_INIT 	0
531163953Srrs#define SCTP_TIMER_RECV 	1
532163953Srrs#define SCTP_TIMER_SEND 	2
533163953Srrs#define SCTP_TIMER_HEARTBEAT	3
534163953Srrs#define SCTP_TIMER_PMTU		4
535163953Srrs#define SCTP_TIMER_MAXSHUTDOWN	5
536163953Srrs#define SCTP_TIMER_SIGNATURE	6
537163953Srrs/*
538163953Srrs * number of timer types in the base SCTP structure used in the set/get and
539163953Srrs * has the base default.
540163953Srrs */
541163953Srrs#define SCTP_NUM_TMRS	7
542163953Srrs
543163953Srrs/* timer types */
544163953Srrs#define SCTP_TIMER_TYPE_NONE		0
545163953Srrs#define SCTP_TIMER_TYPE_SEND		1
546163953Srrs#define SCTP_TIMER_TYPE_INIT		2
547163953Srrs#define SCTP_TIMER_TYPE_RECV		3
548163953Srrs#define SCTP_TIMER_TYPE_SHUTDOWN	4
549163953Srrs#define SCTP_TIMER_TYPE_HEARTBEAT	5
550163953Srrs#define SCTP_TIMER_TYPE_COOKIE		6
551163953Srrs#define SCTP_TIMER_TYPE_NEWCOOKIE	7
552163953Srrs#define SCTP_TIMER_TYPE_PATHMTURAISE	8
553163953Srrs#define SCTP_TIMER_TYPE_SHUTDOWNACK	9
554163953Srrs#define SCTP_TIMER_TYPE_ASCONF		10
555163953Srrs#define SCTP_TIMER_TYPE_SHUTDOWNGUARD	11
556163953Srrs#define SCTP_TIMER_TYPE_AUTOCLOSE	12
557163953Srrs#define SCTP_TIMER_TYPE_EVENTWAKE	13
558163953Srrs#define SCTP_TIMER_TYPE_STRRESET        14
559163953Srrs#define SCTP_TIMER_TYPE_INPKILL         15
560224641Stuexen#define SCTP_TIMER_TYPE_ASOCKILL        16
561224641Stuexen#define SCTP_TIMER_TYPE_ADDR_WQ         17
562224641Stuexen#define SCTP_TIMER_TYPE_ZERO_COPY       18
563224641Stuexen#define SCTP_TIMER_TYPE_ZCOPY_SENDQ     19
564224641Stuexen#define SCTP_TIMER_TYPE_PRIM_DELETED    20
565163953Srrs/* add new timers here - and increment LAST */
566224641Stuexen#define SCTP_TIMER_TYPE_LAST            21
567163953Srrs
568163953Srrs#define SCTP_IS_TIMER_TYPE_VALID(t)	(((t) > SCTP_TIMER_TYPE_NONE) && \
569163953Srrs					 ((t) < SCTP_TIMER_TYPE_LAST))
570163953Srrs
571163953Srrs
572163953Srrs
573163953Srrs/* max number of TSN's dup'd that I will hold */
574163953Srrs#define SCTP_MAX_DUP_TSNS	20
575163953Srrs
576163953Srrs/*
577163953Srrs * Here we define the types used when setting the retry amounts.
578163953Srrs */
579163953Srrs/* How many drop re-attempts we make on  INIT/COOKIE-ECHO */
580163953Srrs#define SCTP_RETRY_DROPPED_THRESH 4
581163953Srrs
582163953Srrs/*
583163953Srrs * Maxmium number of chunks a single association can have on it. Note that
584163953Srrs * this is a squishy number since the count can run over this if the user
585163953Srrs * sends a large message down .. the fragmented chunks don't count until
586163953Srrs * AFTER the message is on queue.. it would be the next send that blocks
587163953Srrs * things. This number will get tuned up at boot in the sctp_init and use the
588163953Srrs * number of clusters as a base. This way high bandwidth environments will
589163953Srrs * not get impacted by the lower bandwidth sending a bunch of 1 byte chunks
590163953Srrs */
591163953Srrs#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512
592163953Srrs
593172091Srrs
594167598Srrs/* The conversion from time to ticks and vice versa is done by rounding
595167598Srrs * upwards. This way we can test in the code the time to be positive and
596167598Srrs * know that this corresponds to a positive number of ticks.
597167598Srrs */
598167598Srrs#define MSEC_TO_TICKS(x) ((hz == 1000) ? x : ((((x) * hz) + 999) / 1000))
599167598Srrs#define TICKS_TO_MSEC(x) ((hz == 1000) ? x : ((((x) * 1000) + (hz - 1)) / hz))
600163953Srrs
601163953Srrs#define SEC_TO_TICKS(x) ((x) * hz)
602167598Srrs#define TICKS_TO_SEC(x) (((x) + (hz - 1)) / hz)
603163953Srrs
604163953Srrs/*
605163953Srrs * Basically the minimum amount of time before I do a early FR. Making this
606163953Srrs * value to low will cause duplicate retransmissions.
607163953Srrs */
608163953Srrs#define SCTP_MINFR_MSEC_TIMER 250
609163953Srrs/* The floor this value is allowed to fall to when starting a timer. */
610163953Srrs#define SCTP_MINFR_MSEC_FLOOR 20
611163953Srrs
612163953Srrs/* init timer def = 1 sec */
613163953Srrs#define SCTP_INIT_SEC	1
614163953Srrs
615163953Srrs/* send timer def = 1 seconds */
616163953Srrs#define SCTP_SEND_SEC	1
617163953Srrs
618163953Srrs/* recv timer def = 200ms  */
619163953Srrs#define SCTP_RECV_MSEC	200
620163953Srrs
621163953Srrs/* 30 seconds + RTO (in ms) */
622163953Srrs#define SCTP_HB_DEFAULT_MSEC	30000
623163953Srrs
624163953Srrs/* Max time I will wait for Shutdown to complete */
625163953Srrs#define SCTP_DEF_MAX_SHUTDOWN_SEC 180
626163953Srrs
627163953Srrs
628163953Srrs/*
629163953Srrs * This is how long a secret lives, NOT how long a cookie lives how many
630163953Srrs * ticks the current secret will live.
631163953Srrs */
632163953Srrs#define SCTP_DEFAULT_SECRET_LIFE_SEC 3600
633163953Srrs
634163953Srrs#define SCTP_RTO_UPPER_BOUND	(60000)	/* 60 sec in ms */
635224641Stuexen#define SCTP_RTO_LOWER_BOUND	(1000)	/* 1 sec is ms */
636163953Srrs#define SCTP_RTO_INITIAL	(3000)	/* 3 sec in ms */
637163953Srrs
638163953Srrs
639163953Srrs#define SCTP_INP_KILL_TIMEOUT 20/* number of ms to retry kill of inpcb */
640163953Srrs#define SCTP_ASOC_KILL_TIMEOUT 10	/* number of ms to retry kill of inpcb */
641163953Srrs
642224641Stuexen#define SCTP_DEF_MAX_INIT		8
643224641Stuexen#define SCTP_DEF_MAX_SEND		10
644224641Stuexen#define SCTP_DEF_MAX_PATH_RTX		5
645224641Stuexen#define SCTP_DEF_PATH_PF_THRESHOLD	SCTP_DEF_MAX_PATH_RTX
646163953Srrs
647163953Srrs#define SCTP_DEF_PMTU_RAISE_SEC	600	/* 10 min between raise attempts */
648163953Srrs
649170056Srrs
650163953Srrs/* How many streams I request initally by default */
651163953Srrs#define SCTP_OSTREAM_INITIAL 10
652252978Stuexen#define SCTP_ISTREAM_INITIAL 2048
653163953Srrs
654163953Srrs/*
655163953Srrs * How many smallest_mtu's need to increase before a window update sack is
656163953Srrs * sent (should be a power of 2).
657163953Srrs */
658163953Srrs/* Send window update (incr * this > hiwat). Should be a power of 2 */
659163953Srrs#define SCTP_MINIMAL_RWND		(4096)	/* minimal rwnd */
660163953Srrs
661224641Stuexen#define SCTP_ADDRMAX		16
662163953Srrs
663163953Srrs/* SCTP DEBUG Switch parameters */
664163953Srrs#define SCTP_DEBUG_TIMER1	0x00000001
665170181Srrs#define SCTP_DEBUG_TIMER2	0x00000002	/* unused */
666170181Srrs#define SCTP_DEBUG_TIMER3	0x00000004	/* unused */
667163953Srrs#define SCTP_DEBUG_TIMER4	0x00000008
668163953Srrs#define SCTP_DEBUG_OUTPUT1	0x00000010
669163953Srrs#define SCTP_DEBUG_OUTPUT2	0x00000020
670163953Srrs#define SCTP_DEBUG_OUTPUT3	0x00000040
671163953Srrs#define SCTP_DEBUG_OUTPUT4	0x00000080
672163953Srrs#define SCTP_DEBUG_UTIL1	0x00000100
673170181Srrs#define SCTP_DEBUG_UTIL2	0x00000200	/* unused */
674163953Srrs#define SCTP_DEBUG_AUTH1	0x00000400
675170181Srrs#define SCTP_DEBUG_AUTH2	0x00000800	/* unused */
676163953Srrs#define SCTP_DEBUG_INPUT1	0x00001000
677163953Srrs#define SCTP_DEBUG_INPUT2	0x00002000
678163953Srrs#define SCTP_DEBUG_INPUT3	0x00004000
679170181Srrs#define SCTP_DEBUG_INPUT4	0x00008000	/* unused */
680163953Srrs#define SCTP_DEBUG_ASCONF1	0x00010000
681163953Srrs#define SCTP_DEBUG_ASCONF2	0x00020000
682170181Srrs#define SCTP_DEBUG_OUTPUT5	0x00040000	/* unused */
683170181Srrs#define SCTP_DEBUG_XXX		0x00080000	/* unused */
684163953Srrs#define SCTP_DEBUG_PCB1		0x00100000
685170181Srrs#define SCTP_DEBUG_PCB2		0x00200000	/* unused */
686163953Srrs#define SCTP_DEBUG_PCB3		0x00400000
687172266Srrs#define SCTP_DEBUG_PCB4		0x00800000
688163953Srrs#define SCTP_DEBUG_INDATA1	0x01000000
689170181Srrs#define SCTP_DEBUG_INDATA2	0x02000000	/* unused */
690170181Srrs#define SCTP_DEBUG_INDATA3	0x04000000	/* unused */
691188067Srrs#define SCTP_DEBUG_CRCOFFLOAD	0x08000000	/* unused */
692170181Srrs#define SCTP_DEBUG_USRREQ1	0x10000000	/* unused */
693170181Srrs#define SCTP_DEBUG_USRREQ2	0x20000000	/* unused */
694163953Srrs#define SCTP_DEBUG_PEEL1	0x40000000
695170181Srrs#define SCTP_DEBUG_XXXXX	0x80000000	/* unused */
696163953Srrs#define SCTP_DEBUG_ALL		0x7ff3ffff
697163953Srrs#define SCTP_DEBUG_NOISY	0x00040000
698163953Srrs
699163953Srrs/* What sender needs to see to avoid SWS or we consider peers rwnd 0 */
700163953Srrs#define SCTP_SWS_SENDER_DEF	1420
701163953Srrs
702163953Srrs/*
703163953Srrs * SWS is scaled to the sb_hiwat of the socket. A value of 2 is hiwat/4, 1
704163953Srrs * would be hiwat/2 etc.
705163953Srrs */
706163953Srrs/* What receiver needs to see in sockbuf or we tell peer its 1 */
707163953Srrs#define SCTP_SWS_RECEIVER_DEF	3000
708163953Srrs
709163953Srrs#define SCTP_INITIAL_CWND 4380
710163953Srrs
711188067Srrs#define SCTP_DEFAULT_MTU 1500	/* emergency default MTU */
712163953Srrs/* amount peer is obligated to have in rwnd or I will abort */
713163953Srrs#define SCTP_MIN_RWND	1500
714163953Srrs
715163953Srrs#define SCTP_DEFAULT_MAXSEGMENT 65535
716163953Srrs
717170642Srrs#define SCTP_CHUNK_BUFFER_SIZE	512
718166675Srrs#define SCTP_PARAM_BUFFER_SIZE	512
719163953Srrs
720171990Srrs/* small chunk store for looking at chunk_list in auth */
721171990Srrs#define SCTP_SMALL_CHUNK_STORE 260
722171990Srrs
723163953Srrs#define SCTP_HOW_MANY_SECRETS	2	/* how many secrets I keep */
724163953Srrs
725163953Srrs#define SCTP_NUMBER_OF_SECRETS	8	/* or 8 * 4 = 32 octets */
726163953Srrs#define SCTP_SECRET_SIZE	32	/* number of octets in a 256 bits */
727163953Srrs
728163953Srrs
729163953Srrs/*
730163953Srrs * SCTP upper layer notifications
731163953Srrs */
732185694Srrs#define SCTP_NOTIFY_ASSOC_UP                     1
733185694Srrs#define SCTP_NOTIFY_ASSOC_DOWN                   2
734185694Srrs#define SCTP_NOTIFY_INTERFACE_DOWN               3
735185694Srrs#define SCTP_NOTIFY_INTERFACE_UP                 4
736237889Stuexen#define SCTP_NOTIFY_SENT_DG_FAIL                 5
737237889Stuexen#define SCTP_NOTIFY_UNSENT_DG_FAIL               6
738237889Stuexen#define SCTP_NOTIFY_SPECIAL_SP_FAIL              7
739237889Stuexen#define SCTP_NOTIFY_ASSOC_LOC_ABORTED            8
740237889Stuexen#define SCTP_NOTIFY_ASSOC_REM_ABORTED            9
741237889Stuexen#define SCTP_NOTIFY_ASSOC_RESTART               10
742237889Stuexen#define SCTP_NOTIFY_PEER_SHUTDOWN               11
743237889Stuexen#define SCTP_NOTIFY_ASCONF_ADD_IP               12
744237889Stuexen#define SCTP_NOTIFY_ASCONF_DELETE_IP            13
745237889Stuexen#define SCTP_NOTIFY_ASCONF_SET_PRIMARY          14
746237889Stuexen#define SCTP_NOTIFY_PARTIAL_DELVIERY_INDICATION 15
747237889Stuexen#define SCTP_NOTIFY_INTERFACE_CONFIRMED         16
748237889Stuexen#define SCTP_NOTIFY_STR_RESET_RECV              17
749237889Stuexen#define SCTP_NOTIFY_STR_RESET_SEND              18
750237889Stuexen#define SCTP_NOTIFY_STR_RESET_FAILED_OUT        19
751237889Stuexen#define SCTP_NOTIFY_STR_RESET_FAILED_IN         20
752237889Stuexen#define SCTP_NOTIFY_STR_RESET_DENIED_OUT        21
753237889Stuexen#define SCTP_NOTIFY_STR_RESET_DENIED_IN         22
754237889Stuexen#define SCTP_NOTIFY_AUTH_NEW_KEY                23
755237889Stuexen#define SCTP_NOTIFY_AUTH_FREE_KEY               24
756237889Stuexen#define SCTP_NOTIFY_NO_PEER_AUTH                25
757237889Stuexen#define SCTP_NOTIFY_SENDER_DRY                  26
758237890Stuexen#define SCTP_NOTIFY_REMOTE_ERROR                27
759163953Srrs
760163953Srrs/* This is the value for messages that are NOT completely
761163953Srrs * copied down where we will start to split the message.
762163953Srrs * So, with our default, we split only if the piece we
763163953Srrs * want to take will fill up a full MTU (assuming
764163953Srrs * a 1500 byte MTU).
765163953Srrs */
766168124Srrs#define SCTP_DEFAULT_SPLIT_POINT_MIN 2904
767163953Srrs
768266181Stuexen/* Maximum length of diagnostic information in error causes */
769266181Stuexen#define SCTP_DIAG_INFO_LEN 64
770266181Stuexen
771165220Srrs/* ABORT CODES and other tell-tale location
772165220Srrs * codes are generated by adding the below
773165220Srrs * to the instance id.
774165220Srrs */
775165220Srrs
776165220Srrs/* File defines */
777165220Srrs#define SCTP_FROM_SCTP_INPUT   0x10000000
778165220Srrs#define SCTP_FROM_SCTP_PCB     0x20000000
779165220Srrs#define SCTP_FROM_SCTP_INDATA  0x30000000
780165220Srrs#define SCTP_FROM_SCTP_TIMER   0x40000000
781165220Srrs#define SCTP_FROM_SCTP_USRREQ  0x50000000
782165220Srrs#define SCTP_FROM_SCTPUTIL     0x60000000
783165220Srrs#define SCTP_FROM_SCTP6_USRREQ 0x70000000
784165220Srrs#define SCTP_FROM_SCTP_ASCONF  0x80000000
785165220Srrs#define SCTP_FROM_SCTP_OUTPUT  0x90000000
786165220Srrs#define SCTP_FROM_SCTP_PEELOFF 0xa0000000
787170056Srrs#define SCTP_FROM_SCTP_PANDA   0xb0000000
788171943Srrs#define SCTP_FROM_SCTP_SYSCTL  0xc0000000
789165220Srrs
790165220Srrs/* Location ID's */
791165220Srrs#define SCTP_LOC_1  0x00000001
792165220Srrs#define SCTP_LOC_2  0x00000002
793165220Srrs#define SCTP_LOC_3  0x00000003
794165220Srrs#define SCTP_LOC_4  0x00000004
795165220Srrs#define SCTP_LOC_5  0x00000005
796165220Srrs#define SCTP_LOC_6  0x00000006
797165220Srrs#define SCTP_LOC_7  0x00000007
798165220Srrs#define SCTP_LOC_8  0x00000008
799165220Srrs#define SCTP_LOC_9  0x00000009
800165220Srrs#define SCTP_LOC_10 0x0000000a
801165220Srrs#define SCTP_LOC_11 0x0000000b
802165220Srrs#define SCTP_LOC_12 0x0000000c
803165220Srrs#define SCTP_LOC_13 0x0000000d
804165220Srrs#define SCTP_LOC_14 0x0000000e
805165220Srrs#define SCTP_LOC_15 0x0000000f
806165220Srrs#define SCTP_LOC_16 0x00000010
807165220Srrs#define SCTP_LOC_17 0x00000011
808165220Srrs#define SCTP_LOC_18 0x00000012
809165220Srrs#define SCTP_LOC_19 0x00000013
810165220Srrs#define SCTP_LOC_20 0x00000014
811165220Srrs#define SCTP_LOC_21 0x00000015
812165220Srrs#define SCTP_LOC_22 0x00000016
813165220Srrs#define SCTP_LOC_23 0x00000017
814165220Srrs#define SCTP_LOC_24 0x00000018
815165220Srrs#define SCTP_LOC_25 0x00000019
816165220Srrs#define SCTP_LOC_26 0x0000001a
817165220Srrs#define SCTP_LOC_27 0x0000001b
818165220Srrs#define SCTP_LOC_28 0x0000001c
819165220Srrs#define SCTP_LOC_29 0x0000001d
820165220Srrs#define SCTP_LOC_30 0x0000001e
821165220Srrs#define SCTP_LOC_31 0x0000001f
822165220Srrs#define SCTP_LOC_32 0x00000020
823169352Srrs#define SCTP_LOC_33 0x00000021
824165220Srrs
825165220Srrs
826165220Srrs/* Free assoc codes */
827165220Srrs#define SCTP_NORMAL_PROC      0
828165220Srrs#define SCTP_PCBFREE_NOFORCE  1
829165220Srrs#define SCTP_PCBFREE_FORCE    2
830165220Srrs
831165220Srrs/* From codes for adding addresses */
832165220Srrs#define SCTP_ADDR_IS_CONFIRMED 8
833165220Srrs#define SCTP_ADDR_DYNAMIC_ADDED 6
834165220Srrs#define SCTP_IN_COOKIE_PROC 100
835165220Srrs#define SCTP_ALLOC_ASOC  1
836165220Srrs#define SCTP_LOAD_ADDR_2 2
837165220Srrs#define SCTP_LOAD_ADDR_3 3
838165220Srrs#define SCTP_LOAD_ADDR_4 4
839165220Srrs#define SCTP_LOAD_ADDR_5 5
840165220Srrs
841165220Srrs#define SCTP_DONOT_SETSCOPE 0
842165220Srrs#define SCTP_DO_SETSCOPE 1
843165220Srrs
844165220Srrs
845163953Srrs/* This value determines the default for when
846163953Srrs * we try to add more on the send queue., if
847163953Srrs * there is room. This prevents us from cycling
848163953Srrs * into the copy_resume routine to often if
849163953Srrs * we have not got enough space to add a decent
850163953Srrs * enough size message. Note that if we have enough
851163953Srrs * space to complete the message copy we will always
852163953Srrs * add to the message, no matter what the size. Its
853163953Srrs * only when we reach the point that we have some left
854163953Srrs * to add, there is only room for part of it that we
855163953Srrs * will use this threshold. Its also a sysctl.
856163953Srrs */
857163953Srrs#define SCTP_DEFAULT_ADD_MORE 1452
858163953Srrs
859163953Srrs#ifndef SCTP_PCBHASHSIZE
860163953Srrs/* default number of association hash buckets in each endpoint */
861163953Srrs#define SCTP_PCBHASHSIZE 256
862163953Srrs#endif
863163953Srrs#ifndef SCTP_TCBHASHSIZE
864163953Srrs#define SCTP_TCBHASHSIZE 1024
865163953Srrs#endif
866163953Srrs
867163953Srrs#ifndef SCTP_CHUNKQUEUE_SCALE
868163953Srrs#define SCTP_CHUNKQUEUE_SCALE 10
869163953Srrs#endif
870163953Srrs
871163953Srrs/* clock variance is 1 ms */
872163953Srrs#define SCTP_CLOCK_GRANULARITY	1
873163953Srrs#define IP_HDR_SIZE 40		/* we use the size of a IP6 header here this
874163953Srrs				 * detracts a small amount for ipv4 but it
875163953Srrs				 * simplifies the ipv6 addition */
876163953Srrs
877169380Srrs/* Argument magic number for sctp_inpcb_free() */
878169380Srrs
879169380Srrs/* third argument */
880169380Srrs#define SCTP_CALLED_DIRECTLY_NOCMPSET     0
881169380Srrs#define SCTP_CALLED_AFTER_CMPSET_OFCLOSE  1
882208879Srrs#define SCTP_CALLED_FROM_INPKILL_TIMER    2
883169380Srrs/* second argument */
884169380Srrs#define SCTP_FREE_SHOULD_USE_ABORT          1
885169380Srrs#define SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE 0
886169380Srrs
887163953Srrs#ifndef IPPROTO_SCTP
888163953Srrs#define IPPROTO_SCTP 132	/* the Official IANA number :-) */
889163953Srrs#endif				/* !IPPROTO_SCTP */
890163953Srrs
891163953Srrs#define SCTP_MAX_DATA_BUNDLING		256
892163953Srrs
893163953Srrs/* modular comparison */
894216825Stuexen/* See RFC 1982 for details. */
895218232Srrs#define SCTP_SSN_GT(a, b) (((a < b) && ((uint16_t)(b - a) > (1U<<15))) || \
896218232Srrs                           ((a > b) && ((uint16_t)(a - b) < (1U<<15))))
897216825Stuexen#define SCTP_SSN_GE(a, b) (SCTP_SSN_GT(a, b) || (a == b))
898218232Srrs#define SCTP_TSN_GT(a, b) (((a < b) && ((uint32_t)(b - a) > (1U<<31))) || \
899218232Srrs                           ((a > b) && ((uint32_t)(a - b) < (1U<<31))))
900216825Stuexen#define SCTP_TSN_GE(a, b) (SCTP_TSN_GT(a, b) || (a == b))
901163953Srrs
902163953Srrs/* Mapping array manipulation routines */
903163953Srrs#define SCTP_IS_TSN_PRESENT(arry, gap) ((arry[(gap >> 3)] >> (gap & 0x07)) & 0x01)
904163953Srrs#define SCTP_SET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] |= (0x01 << ((gap & 0x07))))
905163953Srrs#define SCTP_UNSET_TSN_PRESENT(arry, gap) (arry[(gap >> 3)] &= ((~(0x01 << ((gap & 0x07)))) & 0xff))
906206137Stuexen#define SCTP_CALC_TSN_TO_GAP(gap, tsn, mapping_tsn) do { \
907206137Stuexen	                if (tsn >= mapping_tsn) { \
908206137Stuexen						gap = tsn - mapping_tsn; \
909206137Stuexen					} else { \
910206137Stuexen						gap = (MAX_TSN - mapping_tsn) + tsn + 1; \
911206137Stuexen					} \
912231039Stuexen                  } while (0)
913163953Srrs
914163953Srrs
915168124Srrs#define SCTP_RETRAN_DONE -1
916168124Srrs#define SCTP_RETRAN_EXIT -2
917168124Srrs
918163953Srrs/*
919163953Srrs * This value defines the number of vtag block time wait entry's per list
920163953Srrs * element.  Each entry will take 2 4 byte ints (and of course the overhead
921163953Srrs * of the next pointer as well). Using 15 as an example will yield * ((8 *
922163953Srrs * 15) + 8) or 128 bytes of overhead for each timewait block that gets
923163953Srrs * initialized. Increasing it to 31 would yeild 256 bytes per block.
924163953Srrs */
925163953Srrs#define SCTP_NUMBER_IN_VTAG_BLOCK 15
926163953Srrs/*
927163953Srrs * If we use the STACK option, we have an array of this size head pointers.
928163953Srrs * This array is mod'd the with the size to find which bucket and then all
929163953Srrs * entries must be searched to see if the tag is in timed wait. If so we
930163953Srrs * reject it.
931163953Srrs */
932184883Srrs#define SCTP_STACK_VTAG_HASH_SIZE   32
933163953Srrs
934163953Srrs/*
935173179Srrs * Number of seconds of time wait for a vtag.
936163953Srrs */
937173179Srrs#define SCTP_TIME_WAIT 60
938163953Srrs
939218186Srrs/* How many micro seconds is the cutoff from
940218186Srrs * local lan type rtt's
941218186Srrs */
942218186Srrs /*
943219120Srrs  * We allow 900us for the rtt.
944218186Srrs  */
945219120Srrs#define SCTP_LOCAL_LAN_RTT 900
946218186Srrs#define SCTP_LAN_UNKNOWN  0
947218186Srrs#define SCTP_LAN_LOCAL    1
948218186Srrs#define SCTP_LAN_INTERNET 2
949218186Srrs
950212799Stuexen#define SCTP_SEND_BUFFER_SPLITTING 0x00000001
951212799Stuexen#define SCTP_RECV_BUFFER_SPLITTING 0x00000002
952212799Stuexen
953163953Srrs/* The system retains a cache of free chunks such to
954163953Srrs * cut down on calls the memory allocation system. There
955163953Srrs * is a per association limit of free items and a overall
956163953Srrs * system limit. If either one gets hit then the resource
957163953Srrs * stops being cached.
958163953Srrs */
959163953Srrs
960163953Srrs#define SCTP_DEF_ASOC_RESC_LIMIT 10
961163953Srrs#define SCTP_DEF_SYSTEM_RESC_LIMIT 1000
962163953Srrs
963172090Srrs/*-
964172090Srrs * defines for socket lock states.
965172090Srrs * Used by __APPLE__ and SCTP_SO_LOCK_TESTING
966172090Srrs */
967172090Srrs#define SCTP_SO_LOCKED		1
968172090Srrs#define SCTP_SO_NOT_LOCKED	0
969163953Srrs
970172090Srrs
971172396Srrs#define SCTP_HOLDS_LOCK 1
972172396Srrs#define SCTP_NOT_LOCKED 0
973172396Srrs
974172091Srrs/*-
975172091Srrs * For address locks, do we hold the lock?
976172091Srrs */
977172091Srrs#define SCTP_ADDR_LOCKED 1
978172091Srrs#define SCTP_ADDR_NOT_LOCKED 0
979172091Srrs
980163953Srrs#define IN4_ISPRIVATE_ADDRESS(a) \
981166675Srrs   ((((uint8_t *)&(a)->s_addr)[0] == 10) || \
982166675Srrs    ((((uint8_t *)&(a)->s_addr)[0] == 172) && \
983166675Srrs     (((uint8_t *)&(a)->s_addr)[1] >= 16) && \
984166675Srrs     (((uint8_t *)&(a)->s_addr)[1] <= 32)) || \
985166675Srrs    ((((uint8_t *)&(a)->s_addr)[0] == 192) && \
986166675Srrs     (((uint8_t *)&(a)->s_addr)[1] == 168)))
987163953Srrs
988163953Srrs#define IN4_ISLOOPBACK_ADDRESS(a) \
989166675Srrs    ((((uint8_t *)&(a)->s_addr)[0] == 127) && \
990166675Srrs     (((uint8_t *)&(a)->s_addr)[1] == 0) && \
991166675Srrs     (((uint8_t *)&(a)->s_addr)[2] == 0) && \
992166675Srrs     (((uint8_t *)&(a)->s_addr)[3] == 1))
993163953Srrs
994252969Stuexen#define IN4_ISLINKLOCAL_ADDRESS(a) \
995252969Stuexen    ((((uint8_t *)&(a)->s_addr)[0] == 169) && \
996252969Stuexen     (((uint8_t *)&(a)->s_addr)[1] == 254))
997163953Srrs
998252969Stuexen
999163953Srrs#if defined(_KERNEL)
1000231038Stuexen#define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x))
1001231038Stuexen#define SCTP_GETPTIME_TIMEVAL(x) (microuptime(x))
1002180387Srrs#endif
1003163953Srrs
1004180387Srrs#if defined(_KERNEL) || defined(__Userspace__)
1005163953Srrs#define sctp_sowwakeup(inp, so) \
1006163953Srrsdo { \
1007163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1008163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
1009163953Srrs	} else { \
1010163953Srrs		sowwakeup(so); \
1011163953Srrs	} \
1012163953Srrs} while (0)
1013163953Srrs
1014163953Srrs#define sctp_sowwakeup_locked(inp, so) \
1015163953Srrsdo { \
1016163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1017163953Srrs                SOCKBUF_UNLOCK(&((so)->so_snd)); \
1018163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
1019163953Srrs	} else { \
1020163953Srrs		sowwakeup_locked(so); \
1021163953Srrs	} \
1022163953Srrs} while (0)
1023163953Srrs
1024163953Srrs#define sctp_sorwakeup(inp, so) \
1025163953Srrsdo { \
1026163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1027163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
1028163953Srrs	} else { \
1029163953Srrs		sorwakeup(so); \
1030163953Srrs	} \
1031163953Srrs} while (0)
1032163953Srrs
1033163953Srrs#define sctp_sorwakeup_locked(inp, so) \
1034163953Srrsdo { \
1035163953Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
1036163953Srrs		inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
1037163953Srrs                SOCKBUF_UNLOCK(&((so)->so_rcv)); \
1038163953Srrs	} else { \
1039163953Srrs		sorwakeup_locked(so); \
1040163953Srrs	} \
1041163953Srrs} while (0)
1042163953Srrs
1043180387Srrs#endif				/* _KERNEL || __Userspace__ */
1044163953Srrs#endif
1045