34 #include <sys/cdefs.h> 35 __FBSDID(
"$FreeBSD: head/sys/netinet/sctp_var.h 301114 2016-06-01 10:14:04Z bz $");
38 #ifndef _NETINET_SCTP_VAR_H_ 39 #define _NETINET_SCTP_VAR_H_ 43 #if defined(_KERNEL) || defined(__Userspace__) 45 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) 46 extern struct pr_usrreqs sctp_usrreqs;
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) 55 #define sctp_stcb_feature_on(inp, stcb, feature) {\ 57 stcb->asoc.sctp_features |= feature; \ 59 inp->sctp_features |= feature; \ 62 #define sctp_stcb_feature_off(inp, stcb, feature) {\ 64 stcb->asoc.sctp_features &= ~feature; \ 66 inp->sctp_features &= ~feature; \ 69 #define sctp_stcb_is_feature_on(inp, stcb, feature) \ 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) \ 76 ((stcb->asoc.sctp_features & feature) == 0)) || \ 77 ((stcb == NULL) && (inp != NULL) && \ 78 ((inp->sctp_features & feature) == 0)) || \ 79 ((stcb == NULL) && (inp == NULL))) 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) 87 #define sctp_maxspace(sb) (max((sb)->sb_hiwat,SCTP_MINIMAL_RWND)) 89 #define sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_cc) ? (sctp_maxspace(sb) - (asoc)->sb_cc) : 0)) 91 #define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_cc) ? (sctp_maxspace(sb) - (sb)->sb_cc) : 0)) 93 #define sctp_sbspace_sub(a,b) (((a) > (b)) ? ((a) - (b)) : 0) 105 #define sctp_free_a_readq(_stcb, _readq) { \ 106 if ((_readq)->on_strm_q) \ 107 panic("On strm q stcb:%p readq:%p", (_stcb), (_readq)); \ 108 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \ 109 SCTP_DECR_READQ_COUNT(); \ 112 #define sctp_free_a_readq(_stcb, _readq) { \ 113 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \ 114 SCTP_DECR_READQ_COUNT(); \ 118 #define sctp_alloc_a_readq(_stcb, _readq) { \ 119 (_readq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_readq), struct sctp_queued_to_read); \ 121 SCTP_INCR_READQ_COUNT(); \ 125 #define sctp_free_a_strmoq(_stcb, _strmoq, _so_locked) { \ 126 if ((_strmoq)->holds_key_ref) { \ 127 sctp_auth_key_release(stcb, sp->auth_keyid, _so_locked); \ 128 (_strmoq)->holds_key_ref = 0; \ 130 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_strmoq), (_strmoq)); \ 131 SCTP_DECR_STRMOQ_COUNT(); \ 134 #define sctp_alloc_a_strmoq(_stcb, _strmoq) { \ 135 (_strmoq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_strmoq), struct sctp_stream_queue_pending); \ 137 memset(_strmoq, 0, sizeof(struct sctp_stream_queue_pending)); \ 138 SCTP_INCR_STRMOQ_COUNT(); \ 139 (_strmoq)->holds_key_ref = 0; \ 143 #define sctp_free_a_chunk(_stcb, _chk, _so_locked) { \ 144 if ((_chk)->holds_key_ref) {\ 145 sctp_auth_key_release((_stcb), (_chk)->auth_keyid, _so_locked); \ 146 (_chk)->holds_key_ref = 0; \ 149 SCTP_TCB_LOCK_ASSERT((_stcb)); \ 150 if ((_chk)->whoTo) { \ 151 sctp_free_remote_addr((_chk)->whoTo); \ 152 (_chk)->whoTo = NULL; \ 154 if (((_stcb)->asoc.free_chunk_cnt > SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit)) || \ 155 (SCTP_BASE_INFO(ipi_free_chunks) > SCTP_BASE_SYSCTL(sctp_system_free_resc_limit))) { \ 156 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \ 157 SCTP_DECR_CHK_COUNT(); \ 159 TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \ 160 (_stcb)->asoc.free_chunk_cnt++; \ 161 atomic_add_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \ 164 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \ 165 SCTP_DECR_CHK_COUNT(); \ 169 #define sctp_alloc_a_chunk(_stcb, _chk) { \ 170 if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ 171 (_chk) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_chunk), struct sctp_tmit_chunk); \ 173 SCTP_INCR_CHK_COUNT(); \ 174 (_chk)->whoTo = NULL; \ 175 (_chk)->holds_key_ref = 0; \ 178 (_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \ 179 TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \ 180 atomic_subtract_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \ 181 (_chk)->holds_key_ref = 0; \ 182 SCTP_STAT_INCR(sctps_cached_chk); \ 183 (_stcb)->asoc.free_chunk_cnt--; \ 187 #if defined(__FreeBSD__) && __FreeBSD_version > 500000 189 #define sctp_free_remote_addr(__net) { \ 191 if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \ 192 (void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \ 193 (void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \ 194 (void)SCTP_OS_TIMER_STOP(&(__net)->hb_timer.timer); \ 195 if ((__net)->ro.ro_rt) { \ 196 RTFREE((__net)->ro.ro_rt); \ 197 (__net)->ro.ro_rt = NULL; \ 199 if ((__net)->src_addr_selected) { \ 200 sctp_free_ifa((__net)->ro._s_addr); \ 201 (__net)->ro._s_addr = NULL; \ 203 (__net)->src_addr_selected = 0; \ 204 (__net)->dest_state &= ~SCTP_ADDR_REACHABLE; \ 205 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \ 206 SCTP_DECR_RADDR_COUNT(); \ 211 #define sctp_sbfree(ctl, stcb, sb, m) { \ 212 SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ 213 SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \ 214 if (((ctl)->do_not_ref_stcb == 0) && stcb) {\ 215 SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ 216 SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \ 218 if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ 219 SCTP_BUF_TYPE(m) != MT_OOBDATA) \ 220 atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ 223 #define sctp_sballoc(stcb, sb, m) { \ 224 atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \ 225 atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ 227 atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ 228 atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \ 230 if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ 231 SCTP_BUF_TYPE(m) != MT_OOBDATA) \ 232 atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ 237 #define sctp_free_remote_addr(__net) { \ 239 if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \ 240 (void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \ 241 (void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \ 242 (void)SCTP_OS_TIMER_STOP(&(__net)->hb_timer.timer); \ 243 if ((__net)->ro.ro_rt) { \ 244 RTFREE((__net)->ro.ro_rt); \ 245 (__net)->ro.ro_rt = NULL; \ 247 if ((__net)->src_addr_selected) { \ 248 sctp_free_ifa((__net)->ro._s_addr); \ 249 (__net)->ro._s_addr = NULL; \ 251 (__net)->src_addr_selected = 0; \ 252 (__net)->dest_state &=~SCTP_ADDR_REACHABLE; \ 253 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \ 254 SCTP_DECR_RADDR_COUNT(); \ 259 #if defined(__Panda__) 260 #define sctp_sbfree(ctl, stcb, sb, m) { \ 261 if ((sb)->sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \ 262 atomic_subtract_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ 266 if (((ctl)->do_not_ref_stcb == 0) && stcb) { \ 267 if ((stcb)->asoc.sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \ 268 atomic_subtract_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ 270 (stcb)->asoc.sb_cc = 0; \ 275 #define sctp_sballoc(stcb, sb, m) { \ 276 atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ 278 atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ 284 #define sctp_sbfree(ctl, stcb, sb, m) { \ 285 SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ 286 SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \ 287 if (((ctl)->do_not_ref_stcb == 0) && stcb) { \ 288 SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ 289 SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \ 293 #define sctp_sballoc(stcb, sb, m) { \ 294 atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ 295 atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ 297 atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ 298 atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \ 304 #define sctp_ucount_incr(val) { \ 308 #define sctp_ucount_decr(val) { \ 316 #define sctp_mbuf_crush(data) do { \ 319 while (_m && (SCTP_BUF_LEN(_m) == 0)) { \ 320 (data) = SCTP_BUF_NEXT(_m); \ 321 SCTP_BUF_NEXT(_m) = NULL; \ 327 #define sctp_flight_size_decrease(tp1) do { \ 328 if (tp1->whoTo->flight_size >= tp1->book_size) \ 329 tp1->whoTo->flight_size -= tp1->book_size; \ 331 tp1->whoTo->flight_size = 0; \ 334 #define sctp_flight_size_increase(tp1) do { \ 335 (tp1)->whoTo->flight_size += (tp1)->book_size; \ 338 #ifdef SCTP_FS_SPEC_LOG 339 #define sctp_total_flight_decrease(stcb, tp1) do { \ 340 if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \ 341 stcb->asoc.fs_index = 0;\ 342 stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \ 343 stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \ 344 stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \ 345 stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \ 346 stcb->asoc.fslog[stcb->asoc.fs_index].incr = 0; \ 347 stcb->asoc.fslog[stcb->asoc.fs_index].decr = 1; \ 348 stcb->asoc.fs_index++; \ 349 tp1->window_probe = 0; \ 350 if (stcb->asoc.total_flight >= tp1->book_size) { \ 351 stcb->asoc.total_flight -= tp1->book_size; \ 352 if (stcb->asoc.total_flight_count > 0) \ 353 stcb->asoc.total_flight_count--; \ 355 stcb->asoc.total_flight = 0; \ 356 stcb->asoc.total_flight_count = 0; \ 360 #define sctp_total_flight_increase(stcb, tp1) do { \ 361 if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \ 362 stcb->asoc.fs_index = 0;\ 363 stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \ 364 stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \ 365 stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \ 366 stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \ 367 stcb->asoc.fslog[stcb->asoc.fs_index].incr = 1; \ 368 stcb->asoc.fslog[stcb->asoc.fs_index].decr = 0; \ 369 stcb->asoc.fs_index++; \ 370 (stcb)->asoc.total_flight_count++; \ 371 (stcb)->asoc.total_flight += (tp1)->book_size; \ 376 #define sctp_total_flight_decrease(stcb, tp1) do { \ 377 tp1->window_probe = 0; \ 378 if (stcb->asoc.total_flight >= tp1->book_size) { \ 379 stcb->asoc.total_flight -= tp1->book_size; \ 380 if (stcb->asoc.total_flight_count > 0) \ 381 stcb->asoc.total_flight_count--; \ 383 stcb->asoc.total_flight = 0; \ 384 stcb->asoc.total_flight_count = 0; \ 388 #define sctp_total_flight_increase(stcb, tp1) do { \ 389 (stcb)->asoc.total_flight_count++; \ 390 (stcb)->asoc.total_flight += (tp1)->book_size; \ 395 #define SCTP_PF_ENABLED(_net) (_net->pf_threshold < _net->failure_threshold) 396 #define SCTP_NET_IS_PF(_net) (_net->pf_threshold < _net->error_count) 404 #if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) || defined(__Userspace__) 405 void sctp_close(
struct socket *so);
410 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) 411 #if defined(__FreeBSD__) && __FreeBSD_version < 902000 412 void sctp_ctlinput __P((
int,
struct sockaddr *,
void *));
413 int sctp_ctloutput __P((
struct socket *,
struct sockopt *));
415 void sctp_input_with_port __P((
struct mbuf *,
int,
uint16_t));
416 void sctp_input __P((
struct mbuf *,
int));
420 void sctp_ctlinput(
int,
struct sockaddr *,
void *);
421 int sctp_ctloutput(
struct socket *,
struct sockopt *);
423 void sctp_input_with_port(
struct mbuf *,
int,
uint16_t);
424 #if defined(__FreeBSD__) && __FreeBSD_version >= 1100020 425 int sctp_input(
struct mbuf **,
int *,
int);
427 void sctp_input(
struct mbuf *,
int);
433 #if defined(__Panda__) 434 void sctp_input(pakhandle_type i_pak);
435 #elif defined(__Userspace__) 438 void sctp_input(
struct mbuf *,...);
440 void *sctp_ctlinput(
int,
struct sockaddr *,
void *);
441 int sctp_ctloutput(
int,
struct socket *,
int,
int,
struct mbuf **);
443 #if defined(__FreeBSD__) && __FreeBSD_version < 902000 448 #if defined(__Userspace__) 451 void (*)(
const char *, ...));
452 #elif defined(__FreeBSD__) && __FreeBSD_version < 902000 454 #elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)) 461 #if !defined(__FreeBSD__) 464 #if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) 465 int sctp_flush(
struct socket *,
int);
467 #if defined(__FreeBSD__) && __FreeBSD_version < 902000 473 int,
int,
struct proc *);
476 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) 477 int sctp_ingetaddr(
struct socket *,
struct sockaddr **);
478 #elif defined(__Panda__) 479 int sctp_ingetaddr(
struct socket *,
struct sockaddr *);
481 int sctp_ingetaddr(
struct socket *,
struct mbuf *);
483 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) 484 int sctp_peeraddr(
struct socket *,
struct sockaddr **);
485 #elif defined(__Panda__) 486 int sctp_peeraddr(
struct socket *,
struct sockaddr *);
488 int sctp_peeraddr(
struct socket *,
struct mbuf *);
490 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 491 #if __FreeBSD_version >= 700000 496 #elif defined(__Windows__) 498 #elif defined(__Userspace__) 503 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__) 505 #elif defined(__Panda__) Definition: DiagnosticsBase.cpp:11
thread
Definition: __init__.py:35
void sctp_init(void)
Definition: sctp_usrreq.c:82
Definition: sctp_structs.h:305
DOMString dp
Definition: WebCryptoAPI.idl:118
int sctp_bindx(int, struct sockaddr *, int, int)
Definition: sctp_pcb.h:444
int sctp_detach(struct socket *so)
Definition: sctp_usrreq.c:901
Definition: user_socketvar.h:125
Definition: user_socketvar.h:74
__BEGIN_DECLS int sctp_peeloff(int, sctp_assoc_t)
void sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint16_t nxtsz)
Definition: sctp_usrreq.c:249
int sctp_accept(struct socket *so, struct mbuf *nam)
Definition: sctp_usrreq.c:8335
unsigned char uint8_t
Definition: ptypes.h:89
unsigned short uint16_t
Definition: ptypes.h:97
void sctp_drain()
Definition: sctp_pcb.c:8039
const gchar * domain
Definition: WebKitCookieManager.h:123
Definition: sctp_pcb.h:614
Definition: user_mbuf.h:231
int sctp_listen(struct socket *so, struct proc *p)
Definition: sctp_usrreq.c:8118
Definition: sctp_header.h:189
int sctp_shutdown(struct socket *so)
Definition: sctp_usrreq.c:1296
void sctp_finish(void)
Definition: sctp_usrreq.c:178
int sctp_disconnect(struct socket *so)
Definition: sctp_usrreq.c:1080
EGLContext EGLenum EGLClientBuffer buffer
Definition: eglext.h:192
GLuint GLsizei GLsizei * length
Definition: gl2.h:435