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