1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
5  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6  * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * a) Redistributions of source code must retain the above copyright notice,
12  *    this list of conditions and the following disclaimer.
13  *
14  * b) Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the distribution.
17  *
18  * c) Neither the name of Cisco Systems, Inc. nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifdef __FreeBSD__
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 360292 2020-04-25 09:06:11Z melifaro $");
38 #endif
39 
40 #ifndef _NETINET_SCTP_VAR_H_
41 #define _NETINET_SCTP_VAR_H_
42 
43 #include <netinet/sctp_uio.h>
44 
45 #if defined(_KERNEL) || defined(__Userspace__)
46 
47 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
48 extern struct pr_usrreqs sctp_usrreqs;
49 #endif
50 
51 
52 #define sctp_feature_on(inp, feature)  (inp->sctp_features |= feature)
53 #define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature)
54 #define sctp_is_feature_on(inp, feature) ((inp->sctp_features & feature) == feature)
55 #define sctp_is_feature_off(inp, feature) ((inp->sctp_features & feature) == 0)
56 
57 #define sctp_stcb_feature_on(inp, stcb, feature) {\
58 	if (stcb) { \
59 		stcb->asoc.sctp_features |= feature; \
60 	} else if (inp) { \
61 		inp->sctp_features |= feature; \
62 	} \
63 }
64 #define sctp_stcb_feature_off(inp, stcb, feature) {\
65 	if (stcb) { \
66 		stcb->asoc.sctp_features &= ~feature; \
67 	} else if (inp) { \
68 		inp->sctp_features &= ~feature; \
69 	} \
70 }
71 #define sctp_stcb_is_feature_on(inp, stcb, feature) \
72 	(((stcb != NULL) && \
73 	  ((stcb->asoc.sctp_features & feature) == feature)) || \
74 	 ((stcb == NULL) && (inp != NULL) && \
75 	  ((inp->sctp_features & feature) == feature)))
76 #define sctp_stcb_is_feature_off(inp, stcb, feature) \
77 	(((stcb != NULL) && \
78 	  ((stcb->asoc.sctp_features & feature) == 0)) || \
79 	 ((stcb == NULL) && (inp != NULL) && \
80 	  ((inp->sctp_features & feature) == 0)) || \
81 	 ((stcb == NULL) && (inp == NULL)))
82 
83 /* managing mobility_feature in inpcb (by micchie) */
84 #define sctp_mobility_feature_on(inp, feature)  (inp->sctp_mobility_features |= feature)
85 #define sctp_mobility_feature_off(inp, feature) (inp->sctp_mobility_features &= ~feature)
86 #define sctp_is_mobility_feature_on(inp, feature) (inp->sctp_mobility_features & feature)
87 #define sctp_is_mobility_feature_off(inp, feature) ((inp->sctp_mobility_features & feature) == 0)
88 
89 #define sctp_maxspace(sb) (max((sb)->sb_hiwat,SCTP_MINIMAL_RWND))
90 
91 #define	sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_cc) ? (sctp_maxspace(sb) - (asoc)->sb_cc) : 0))
92 
93 #define	sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_cc) ? (sctp_maxspace(sb) - (sb)->sb_cc) : 0))
94 
95 #define sctp_sbspace_sub(a,b) (((a) > (b)) ? ((a) - (b)) : 0)
96 
97 /*
98  * I tried to cache the readq entries at one point. But the reality
99  * is that it did not add any performance since this meant we had to
100  * lock the STCB on read. And at that point once you have to do an
101  * extra lock, it really does not matter if the lock is in the ZONE
102  * stuff or in our code. Note that this same problem would occur with
103  * an mbuf cache as well so it is not really worth doing, at least
104  * right now :-D
105  */
106 #ifdef INVARIANTS
107 #define sctp_free_a_readq(_stcb, _readq) { \
108 	if ((_readq)->on_strm_q) \
109 		panic("On strm q stcb:%p readq:%p", (_stcb), (_readq)); \
110 	SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
111 	SCTP_DECR_READQ_COUNT(); \
112 }
113 #else
114 #define sctp_free_a_readq(_stcb, _readq) { \
115 	SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
116 	SCTP_DECR_READQ_COUNT(); \
117 }
118 #endif
119 
120 #define sctp_alloc_a_readq(_stcb, _readq) { \
121 	(_readq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_readq), struct sctp_queued_to_read); \
122 	if ((_readq)) { \
123 	     SCTP_INCR_READQ_COUNT(); \
124 	} \
125 }
126 
127 #define sctp_free_a_strmoq(_stcb, _strmoq, _so_locked) { \
128 	if ((_strmoq)->holds_key_ref) { \
129 		sctp_auth_key_release(stcb, sp->auth_keyid, _so_locked); \
130 		(_strmoq)->holds_key_ref = 0; \
131 	} \
132 	SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_strmoq), (_strmoq)); \
133 	SCTP_DECR_STRMOQ_COUNT(); \
134 }
135 
136 #define sctp_alloc_a_strmoq(_stcb, _strmoq) { \
137 	(_strmoq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_strmoq), struct sctp_stream_queue_pending); \
138 	if ((_strmoq)) { \
139 		memset(_strmoq, 0, sizeof(struct sctp_stream_queue_pending)); \
140 		SCTP_INCR_STRMOQ_COUNT(); \
141 		(_strmoq)->holds_key_ref = 0; \
142 	} \
143 }
144 
145 #define sctp_free_a_chunk(_stcb, _chk, _so_locked) { \
146 	if ((_chk)->holds_key_ref) {\
147 		sctp_auth_key_release((_stcb), (_chk)->auth_keyid, _so_locked); \
148 		(_chk)->holds_key_ref = 0; \
149 	} \
150 	if (_stcb) { \
151 		SCTP_TCB_LOCK_ASSERT((_stcb)); \
152 		if ((_chk)->whoTo) { \
153 			sctp_free_remote_addr((_chk)->whoTo); \
154 			(_chk)->whoTo = NULL; \
155 		} \
156 		if (((_stcb)->asoc.free_chunk_cnt > SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit)) || \
157 		    (SCTP_BASE_INFO(ipi_free_chunks) > SCTP_BASE_SYSCTL(sctp_system_free_resc_limit))) { \
158 			SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \
159 			SCTP_DECR_CHK_COUNT(); \
160 		} else { \
161 			TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
162 			(_stcb)->asoc.free_chunk_cnt++; \
163 			atomic_add_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \
164 		} \
165 	} else { \
166 		SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \
167 		SCTP_DECR_CHK_COUNT(); \
168 	} \
169 }
170 
171 #define sctp_alloc_a_chunk(_stcb, _chk) { \
172 	if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \
173 		(_chk) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_chunk), struct sctp_tmit_chunk); \
174 		if ((_chk)) { \
175 			SCTP_INCR_CHK_COUNT(); \
176 			(_chk)->whoTo = NULL; \
177 			(_chk)->holds_key_ref = 0; \
178 		} \
179 	} else { \
180 		(_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \
181 		TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
182 		atomic_subtract_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \
183 		(_chk)->holds_key_ref = 0; \
184 		SCTP_STAT_INCR(sctps_cached_chk); \
185 		(_stcb)->asoc.free_chunk_cnt--; \
186 	} \
187 }
188 
189 #if defined(__FreeBSD__)
190 
191 #define sctp_free_remote_addr(__net) { \
192 	if ((__net)) {  \
193 		if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
194 			(void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \
195 			RO_NHFREE(&(__net)->ro); \
196 			if ((__net)->src_addr_selected) { \
197 				sctp_free_ifa((__net)->ro._s_addr); \
198 				(__net)->ro._s_addr = NULL; \
199 			} \
200 			(__net)->src_addr_selected = 0; \
201 			(__net)->dest_state &= ~SCTP_ADDR_REACHABLE; \
202 			SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \
203 			SCTP_DECR_RADDR_COUNT(); \
204 		} \
205 	} \
206 }
207 
208 #define sctp_sbfree(ctl, stcb, sb, m) { \
209 	SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
210 	SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
211 	if (((ctl)->do_not_ref_stcb == 0) && stcb) {\
212 		SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
213 		SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
214 	} \
215 	if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
216 	    SCTP_BUF_TYPE(m) != MT_OOBDATA) \
217 		atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
218 }
219 
220 #define sctp_sballoc(stcb, sb, m) { \
221 	atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \
222 	atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
223 	if (stcb) { \
224 		atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
225 		atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
226 	} \
227 	if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
228 	    SCTP_BUF_TYPE(m) != MT_OOBDATA) \
229 		atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
230 }
231 
232 #else				/* FreeBSD Version <= 500000 or non-FreeBSD */
233 
234 #define sctp_free_remote_addr(__net) { \
235 	if ((__net)) { \
236 		if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
237 			(void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \
238 			if ((__net)->ro.ro_rt) { \
239 				RTFREE((__net)->ro.ro_rt); \
240 				(__net)->ro.ro_rt = NULL; \
241 			} \
242 			if ((__net)->src_addr_selected) { \
243 				sctp_free_ifa((__net)->ro._s_addr); \
244 				(__net)->ro._s_addr = NULL; \
245 			} \
246 			(__net)->src_addr_selected = 0; \
247 			(__net)->dest_state &=~SCTP_ADDR_REACHABLE; \
248 			SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \
249 			SCTP_DECR_RADDR_COUNT(); \
250 		} \
251 	} \
252 }
253 
254 #if defined(__Panda__)
255 #define sctp_sbfree(ctl, stcb, sb, m) { \
256 	if ((sb)->sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \
257 		atomic_subtract_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
258 	} else { \
259 		(sb)->sb_cc = 0; \
260 	} \
261 	if (((ctl)->do_not_ref_stcb == 0) && stcb) { \
262 		if ((stcb)->asoc.sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \
263 			atomic_subtract_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
264 		} else { \
265 			(stcb)->asoc.sb_cc = 0; \
266 		} \
267 	} \
268 }
269 
270 #define sctp_sballoc(stcb, sb, m) { \
271 	atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
272 	if (stcb) { \
273 		atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
274 	} \
275 }
276 
277 #else
278 
279 #define sctp_sbfree(ctl, stcb, sb, m) { \
280 	SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
281 	SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
282 	if (((ctl)->do_not_ref_stcb == 0) && stcb) { \
283 		SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
284 		SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
285 	} \
286 }
287 
288 #define sctp_sballoc(stcb, sb, m) { \
289 	atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
290 	atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
291 	if (stcb) { \
292 		atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
293 		atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
294 	} \
295 }
296 #endif
297 #endif
298 
299 #define sctp_ucount_incr(val) { \
300 	val++; \
301 }
302 
303 #define sctp_ucount_decr(val) { \
304 	if (val > 0) { \
305 		val--; \
306 	} else { \
307 		val = 0; \
308 	} \
309 }
310 
311 #define sctp_mbuf_crush(data) do { \
312 	struct mbuf *_m; \
313 	_m = (data); \
314 	while (_m && (SCTP_BUF_LEN(_m) == 0)) { \
315 		(data)  = SCTP_BUF_NEXT(_m); \
316 		SCTP_BUF_NEXT(_m) = NULL; \
317 		sctp_m_free(_m); \
318 		_m = (data); \
319 	} \
320 } while (0)
321 
322 #define sctp_flight_size_decrease(tp1) do { \
323 	if (tp1->whoTo->flight_size >= tp1->book_size) \
324 		tp1->whoTo->flight_size -= tp1->book_size; \
325 	else \
326 		tp1->whoTo->flight_size = 0; \
327 } while (0)
328 
329 #define sctp_flight_size_increase(tp1) do { \
330 	(tp1)->whoTo->flight_size += (tp1)->book_size; \
331 } while (0)
332 
333 #ifdef SCTP_FS_SPEC_LOG
334 #define sctp_total_flight_decrease(stcb, tp1) do { \
335 	if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
336 		stcb->asoc.fs_index = 0;\
337 	stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
338 	stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
339 	stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
340 	stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
341 	stcb->asoc.fslog[stcb->asoc.fs_index].incr = 0; \
342 	stcb->asoc.fslog[stcb->asoc.fs_index].decr = 1; \
343 	stcb->asoc.fs_index++; \
344 	tp1->window_probe = 0; \
345 	if (stcb->asoc.total_flight >= tp1->book_size) { \
346 		stcb->asoc.total_flight -= tp1->book_size; \
347 		if (stcb->asoc.total_flight_count > 0) \
348 			stcb->asoc.total_flight_count--; \
349 	} else { \
350 		stcb->asoc.total_flight = 0; \
351 		stcb->asoc.total_flight_count = 0; \
352 	} \
353 } while (0)
354 
355 #define sctp_total_flight_increase(stcb, tp1) do { \
356 	if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
357 		stcb->asoc.fs_index = 0;\
358 	stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
359 	stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
360 	stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
361 	stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
362 	stcb->asoc.fslog[stcb->asoc.fs_index].incr = 1; \
363 	stcb->asoc.fslog[stcb->asoc.fs_index].decr = 0; \
364 	stcb->asoc.fs_index++; \
365 	(stcb)->asoc.total_flight_count++; \
366 	(stcb)->asoc.total_flight += (tp1)->book_size; \
367 } while (0)
368 
369 #else
370 
371 #define sctp_total_flight_decrease(stcb, tp1) do { \
372 	tp1->window_probe = 0; \
373 	if (stcb->asoc.total_flight >= tp1->book_size) { \
374 		stcb->asoc.total_flight -= tp1->book_size; \
375 		if (stcb->asoc.total_flight_count > 0) \
376 			stcb->asoc.total_flight_count--; \
377 	} else { \
378 		stcb->asoc.total_flight = 0; \
379 		stcb->asoc.total_flight_count = 0; \
380 	} \
381 } while (0)
382 
383 #define sctp_total_flight_increase(stcb, tp1) do { \
384 	(stcb)->asoc.total_flight_count++; \
385 	(stcb)->asoc.total_flight += (tp1)->book_size; \
386 } while (0)
387 
388 #endif
389 
390 #define SCTP_PF_ENABLED(_net) (_net->pf_threshold < _net->failure_threshold)
391 #define SCTP_NET_IS_PF(_net) (_net->pf_threshold < _net->error_count)
392 
393 struct sctp_nets;
394 struct sctp_inpcb;
395 struct sctp_tcb;
396 struct sctphdr;
397 
398 
399 #if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) || defined(__Userspace__)
400 void sctp_close(struct socket *so);
401 #else
402 int sctp_detach(struct socket *so);
403 #endif
404 int sctp_disconnect(struct socket *so);
405 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
406 #if defined(__FreeBSD__) && __FreeBSD_version < 902000
407 void sctp_ctlinput __P((int, struct sockaddr *, void *));
408 int sctp_ctloutput __P((struct socket *, struct sockopt *));
409 #ifdef INET
410 void sctp_input_with_port __P((struct mbuf *, int, uint16_t));
411 void sctp_input __P((struct mbuf *, int));
412 #endif
413 void sctp_pathmtu_adjustment __P((struct sctp_tcb *, uint16_t));
414 #else
415 #if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
416 void sctp_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED);
417 #else
418 void sctp_ctlinput(int, struct sockaddr *, void *);
419 #endif
420 int sctp_ctloutput(struct socket *, struct sockopt *);
421 #ifdef INET
422 void sctp_input_with_port(struct mbuf *, int, uint16_t);
423 #if defined(__FreeBSD__) && __FreeBSD_version >= 1100020
424 int sctp_input(struct mbuf **, int *, int);
425 #else
426 void sctp_input(struct mbuf *, int);
427 #endif
428 #endif
429 void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
430 #endif
431 #else
432 #if defined(__Panda__)
433 void sctp_input(pakhandle_type i_pak);
434 #elif defined(__Userspace__)
435 void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
436 #else
437 void sctp_input(struct mbuf *,...);
438 #endif
439 void *sctp_ctlinput(int, struct sockaddr *, void *);
440 int sctp_ctloutput(int, struct socket *, int, int, struct mbuf **);
441 #endif
442 #if defined(__FreeBSD__) && __FreeBSD_version < 902000
443 void sctp_drain __P((void));
444 #else
445 void sctp_drain(void);
446 #endif
447 #if defined(__Userspace__)
448 void sctp_init(uint16_t,
449                int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
450                void (*)(const char *, ...), int start_threads);
451 #elif defined(__FreeBSD__) && __FreeBSD_version < 902000
452 void sctp_init __P((void));
453 #elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
454 void sctp_init(struct protosw *pp, struct domain *dp);
455 #else
456 void sctp_init(void);
457 void sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
458     uint8_t, uint8_t, uint16_t, uint32_t);
459 #endif
460 #if !defined(__FreeBSD__)
461 void sctp_finish(void);
462 #endif
463 #if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
464 int sctp_flush(struct socket *, int);
465 #endif
466 #if defined(__FreeBSD__) && __FreeBSD_version < 902000
467 int sctp_shutdown __P((struct socket *));
468 #else
469 int sctp_shutdown(struct socket *);
470 #endif
471 int sctp_bindx(struct socket *, int, struct sockaddr_storage *,
472 	int, int, struct proc *);
473 /* can't use sctp_assoc_t here */
474 int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
475 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
476 int sctp_ingetaddr(struct socket *, struct sockaddr **);
477 #elif defined(__Panda__)
478 int sctp_ingetaddr(struct socket *, struct sockaddr *);
479 #else
480 int sctp_ingetaddr(struct socket *, struct mbuf *);
481 #endif
482 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
483 int sctp_peeraddr(struct socket *, struct sockaddr **);
484 #elif defined(__Panda__)
485 int sctp_peeraddr(struct socket *, struct sockaddr *);
486 #else
487 int sctp_peeraddr(struct socket *, struct mbuf *);
488 #endif
489 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
490 #if __FreeBSD_version >= 700000
491 int sctp_listen(struct socket *, int, struct thread *);
492 #else
493 int sctp_listen(struct socket *, struct thread *);
494 #endif
495 #elif defined(__Windows__)
496 int sctp_listen(struct socket *, int, PKTHREAD);
497 #elif defined(__Userspace__)
498 int sctp_listen(struct socket *, int, struct proc *);
499 #else
500 int sctp_listen(struct socket *, struct proc *);
501 #endif
502 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
503 int sctp_accept(struct socket *, struct sockaddr **);
504 #elif defined(__Panda__)
505 int sctp_accept(struct socket *, struct sockaddr *, int *, void *, int *);
506 #else
507 int sctp_accept(struct socket *, struct mbuf *);
508 #endif
509 
510 #endif /* _KERNEL */
511 
512 #endif /* !_NETINET_SCTP_VAR_H_ */
513