1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40#ifndef __sctp_constants_h__
41#define __sctp_constants_h__
42
43#include <linux/sctp.h>
44#include <linux/ipv6.h>
45#include <net/tcp_states.h>
46
47
48enum { SCTP_MAX_STREAM = 0xffff };
49enum { SCTP_DEFAULT_OUTSTREAMS = 10 };
50enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM };
51
52
53
54
55#define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE
56
57#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1)
58
59#define SCTP_NUM_ADDIP_CHUNK_TYPES 2
60
61#define SCTP_NUM_PRSCTP_CHUNK_TYPES 1
62
63#define SCTP_NUM_RECONF_CHUNK_TYPES 1
64
65#define SCTP_NUM_AUTH_CHUNK_TYPES 1
66
67#define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNK_TYPES + \
68 SCTP_NUM_ADDIP_CHUNK_TYPES +\
69 SCTP_NUM_PRSCTP_CHUNK_TYPES +\
70 SCTP_NUM_RECONF_CHUNK_TYPES +\
71 SCTP_NUM_AUTH_CHUNK_TYPES)
72
73
74enum sctp_event_type {
75 SCTP_EVENT_T_CHUNK = 1,
76 SCTP_EVENT_T_TIMEOUT,
77 SCTP_EVENT_T_OTHER,
78 SCTP_EVENT_T_PRIMITIVE
79};
80
81
82
83
84
85enum sctp_event_timeout {
86 SCTP_EVENT_TIMEOUT_NONE = 0,
87 SCTP_EVENT_TIMEOUT_T1_COOKIE,
88 SCTP_EVENT_TIMEOUT_T1_INIT,
89 SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
90 SCTP_EVENT_TIMEOUT_T3_RTX,
91 SCTP_EVENT_TIMEOUT_T4_RTO,
92 SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
93 SCTP_EVENT_TIMEOUT_HEARTBEAT,
94 SCTP_EVENT_TIMEOUT_RECONF,
95 SCTP_EVENT_TIMEOUT_SACK,
96 SCTP_EVENT_TIMEOUT_AUTOCLOSE,
97};
98
99#define SCTP_EVENT_TIMEOUT_MAX SCTP_EVENT_TIMEOUT_AUTOCLOSE
100#define SCTP_NUM_TIMEOUT_TYPES (SCTP_EVENT_TIMEOUT_MAX + 1)
101
102enum sctp_event_other {
103 SCTP_EVENT_NO_PENDING_TSN = 0,
104 SCTP_EVENT_ICMP_PROTO_UNREACH,
105};
106
107#define SCTP_EVENT_OTHER_MAX SCTP_EVENT_ICMP_PROTO_UNREACH
108#define SCTP_NUM_OTHER_TYPES (SCTP_EVENT_OTHER_MAX + 1)
109
110
111enum sctp_event_primitive {
112 SCTP_PRIMITIVE_ASSOCIATE = 0,
113 SCTP_PRIMITIVE_SHUTDOWN,
114 SCTP_PRIMITIVE_ABORT,
115 SCTP_PRIMITIVE_SEND,
116 SCTP_PRIMITIVE_REQUESTHEARTBEAT,
117 SCTP_PRIMITIVE_ASCONF,
118 SCTP_PRIMITIVE_RECONF,
119};
120
121#define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_RECONF
122#define SCTP_NUM_PRIMITIVE_TYPES (SCTP_EVENT_PRIMITIVE_MAX + 1)
123
124
125
126
127
128
129
130union sctp_subtype {
131 enum sctp_cid chunk;
132 enum sctp_event_timeout timeout;
133 enum sctp_event_other other;
134 enum sctp_event_primitive primitive;
135};
136
137#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
138static inline union sctp_subtype \
139SCTP_ST_## _name (_type _arg) \
140{ union sctp_subtype _retval; _retval._elt = _arg; return _retval; }
141
142SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, enum sctp_cid, chunk)
143SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, enum sctp_event_timeout, timeout)
144SCTP_SUBTYPE_CONSTRUCTOR(OTHER, enum sctp_event_other, other)
145SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, enum sctp_event_primitive, primitive)
146
147
148#define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA || \
149 a->chunk_hdr->type == SCTP_CID_I_DATA)
150
151
152enum sctp_ierror {
153 SCTP_IERROR_NO_ERROR = 0,
154 SCTP_IERROR_BASE = 1000,
155 SCTP_IERROR_NO_COOKIE,
156 SCTP_IERROR_BAD_SIG,
157 SCTP_IERROR_STALE_COOKIE,
158 SCTP_IERROR_NOMEM,
159 SCTP_IERROR_MALFORMED,
160 SCTP_IERROR_BAD_TAG,
161 SCTP_IERROR_BIG_GAP,
162 SCTP_IERROR_DUP_TSN,
163 SCTP_IERROR_HIGH_TSN,
164 SCTP_IERROR_IGNORE_TSN,
165 SCTP_IERROR_NO_DATA,
166 SCTP_IERROR_BAD_STREAM,
167 SCTP_IERROR_BAD_PORTS,
168 SCTP_IERROR_AUTH_BAD_HMAC,
169 SCTP_IERROR_AUTH_BAD_KEYID,
170 SCTP_IERROR_PROTO_VIOLATION,
171 SCTP_IERROR_ERROR,
172 SCTP_IERROR_ABORT,
173};
174
175
176
177
178enum sctp_state {
179
180 SCTP_STATE_CLOSED = 0,
181 SCTP_STATE_COOKIE_WAIT = 1,
182 SCTP_STATE_COOKIE_ECHOED = 2,
183 SCTP_STATE_ESTABLISHED = 3,
184 SCTP_STATE_SHUTDOWN_PENDING = 4,
185 SCTP_STATE_SHUTDOWN_SENT = 5,
186 SCTP_STATE_SHUTDOWN_RECEIVED = 6,
187 SCTP_STATE_SHUTDOWN_ACK_SENT = 7,
188
189};
190
191#define SCTP_STATE_MAX SCTP_STATE_SHUTDOWN_ACK_SENT
192#define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1)
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210enum sctp_sock_state {
211 SCTP_SS_CLOSED = TCP_CLOSE,
212 SCTP_SS_LISTENING = TCP_LISTEN,
213 SCTP_SS_ESTABLISHING = TCP_SYN_SENT,
214 SCTP_SS_ESTABLISHED = TCP_ESTABLISHED,
215 SCTP_SS_CLOSING = TCP_CLOSE_WAIT,
216};
217
218
219const char *sctp_cname(const union sctp_subtype id);
220const char *sctp_oname(const union sctp_subtype id);
221const char *sctp_tname(const union sctp_subtype id);
222const char *sctp_pname(const union sctp_subtype id);
223
224
225extern const char *const sctp_state_tbl[];
226extern const char *const sctp_evttype_tbl[];
227extern const char *const sctp_status_tbl[];
228
229
230enum { SCTP_MAX_CHUNK_LEN = ((1<<16) - sizeof(__u32)) };
231
232
233
234
235enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 };
236
237
238
239
240
241
242
243
244
245
246
247#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG
248#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL
249#define SCTP_TSN_MAP_SIZE 4096
250
251
252
253
254
255
256enum { SCTP_MAX_DUP_TSNS = 16 };
257enum { SCTP_MAX_GABS = 16 };
258
259
260#define SCTP_DEFAULT_TIMEOUT_HEARTBEAT (30*1000)
261
262
263#define SCTP_DEFAULT_TIMEOUT_SACK (200)
264
265
266
267
268
269
270
271#define SCTP_RTO_INITIAL (3 * 1000)
272#define SCTP_RTO_MIN (1 * 1000)
273#define SCTP_RTO_MAX (60 * 1000)
274
275#define SCTP_RTO_ALPHA 3
276#define SCTP_RTO_BETA 2
277
278
279#define SCTP_DEFAULT_MAX_BURST 4
280
281#define SCTP_CLOCK_GRANULARITY 1
282
283#define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000)
284
285#define SCTP_DEFAULT_MINWINDOW 1500
286#define SCTP_DEFAULT_MAXWINDOW 65535
287#define SCTP_DEFAULT_RWND_SHIFT 4
288
289
290
291#define SCTP_DEFAULT_MAXSEGMENT 1500
292
293
294#define SCTP_DEFAULT_MINSEGMENT 512
295
296#define SCTP_SECRET_SIZE 32
297
298#define SCTP_SIGNATURE_SIZE 20
299
300#define SCTP_COOKIE_MULTIPLE 32
301
302
303
304
305
306
307enum sctp_xmit {
308 SCTP_XMIT_OK,
309 SCTP_XMIT_PMTU_FULL,
310 SCTP_XMIT_RWND_FULL,
311 SCTP_XMIT_DELAY,
312};
313
314
315enum sctp_transport_cmd {
316 SCTP_TRANSPORT_UP,
317 SCTP_TRANSPORT_DOWN,
318 SCTP_TRANSPORT_PF,
319};
320
321
322
323
324
325
326
327
328enum sctp_scope {
329 SCTP_SCOPE_GLOBAL,
330 SCTP_SCOPE_PRIVATE,
331 SCTP_SCOPE_LINK,
332 SCTP_SCOPE_LOOPBACK,
333 SCTP_SCOPE_UNUSABLE,
334};
335
336enum {
337 SCTP_SCOPE_POLICY_DISABLE,
338 SCTP_SCOPE_POLICY_ENABLE,
339 SCTP_SCOPE_POLICY_PRIVATE,
340 SCTP_SCOPE_POLICY_LINK,
341};
342
343#define SCTP_SCOPE_POLICY_MAX SCTP_SCOPE_POLICY_LINK
344
345
346
347
348
349
350
351#define IS_IPV4_UNUSABLE_ADDRESS(a) \
352 ((htonl(INADDR_BROADCAST) == a) || \
353 ipv4_is_multicast(a) || \
354 ipv4_is_zeronet(a) || \
355 ipv4_is_test_198(a) || \
356 ipv4_is_anycast_6to4(a))
357
358
359#define SCTP_ADDR6_ALLOWED 0x00000001
360
361#define SCTP_ADDR4_PEERSUPP 0x00000002
362
363#define SCTP_ADDR6_PEERSUPP 0x00000004
364
365
366
367enum sctp_retransmit_reason {
368 SCTP_RTXR_T3_RTX,
369 SCTP_RTXR_FAST_RTX,
370 SCTP_RTXR_PMTUD,
371 SCTP_RTXR_T1_RTX,
372};
373
374
375enum sctp_lower_cwnd {
376 SCTP_LOWER_CWND_T3_RTX,
377 SCTP_LOWER_CWND_FAST_RTX,
378 SCTP_LOWER_CWND_ECNE,
379 SCTP_LOWER_CWND_INACTIVE,
380};
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399enum {
400 SCTP_AUTH_HMAC_ID_RESERVED_0,
401 SCTP_AUTH_HMAC_ID_SHA1,
402 SCTP_AUTH_HMAC_ID_RESERVED_2,
403#if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE)
404 SCTP_AUTH_HMAC_ID_SHA256,
405#endif
406 __SCTP_AUTH_HMAC_MAX
407};
408
409#define SCTP_AUTH_HMAC_ID_MAX __SCTP_AUTH_HMAC_MAX - 1
410#define SCTP_AUTH_NUM_HMACS __SCTP_AUTH_HMAC_MAX
411#define SCTP_SHA1_SIG_SIZE 20
412#define SCTP_SHA256_SIG_SIZE 32
413
414
415
416
417
418#define SCTP_NUM_NOAUTH_CHUNKS 4
419#define SCTP_AUTH_MAX_CHUNKS (SCTP_NUM_CHUNK_TYPES - SCTP_NUM_NOAUTH_CHUNKS)
420
421
422
423
424#define SCTP_AUTH_RANDOM_LENGTH 32
425
426#endif
427