Lines Matching refs:stcb

65 sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr)
69 sctp_clog.x.sb.stcb = stcb;
71 if (stcb)
72 sctp_clog.x.sb.stcb_sbcc = stcb->asoc.sb_cc;
86 sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc)
92 if (stcb) {
93 sctp_clog.x.close.stcb = (void *)stcb;
94 sctp_clog.x.close.state = (uint16_t) stcb->asoc.state;
96 sctp_clog.x.close.stcb = 0;
127 sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t tsn, uint16_t sseq, uint16_t stream, int from)
131 sctp_clog.x.strlog.stcb = stcb;
147 sctp_log_nagle_event(struct sctp_tcb *stcb, int action)
151 sctp_clog.x.nagle.stcb = (void *)stcb;
152 sctp_clog.x.nagle.total_flight = stcb->asoc.total_flight;
153 sctp_clog.x.nagle.total_in_queue = stcb->asoc.total_output_queue_size;
154 sctp_clog.x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue;
155 sctp_clog.x.nagle.count_in_flight = stcb->asoc.total_flight_count;
254 sctp_clog.x.strlog.stcb = control->stcb;
275 sctp_log_cwnd(struct sctp_tcb *stcb, struct sctp_nets *net, int augment, uint8_t from)
280 if (stcb->asoc.send_queue_cnt > 255)
283 sctp_clog.x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt;
284 if (stcb->asoc.stream_queue_cnt > 255)
287 sctp_clog.x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt;
297 sctp_clog.x.cwnd.meets_pseudo_cumack = stcb->asoc.peers_rwnd;
310 sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from)
322 if (stcb) {
323 sctp_clog.x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx);
354 sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *net, int error, int burst, uint8_t from)
363 if (stcb->asoc.send_queue_cnt > 255)
366 sctp_clog.x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt;
367 if (stcb->asoc.stream_queue_cnt > 255)
370 sctp_clog.x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt;
444 sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t wake_cnt, int from)
448 sctp_clog.x.wake.stcb = (void *)stcb;
450 sctp_clog.x.wake.flight = stcb->asoc.total_flight_count;
451 sctp_clog.x.wake.send_q = stcb->asoc.send_queue_cnt;
452 sctp_clog.x.wake.sent_q = stcb->asoc.sent_queue_cnt;
454 if (stcb->asoc.stream_queue_cnt < 0xff)
455 sctp_clog.x.wake.stream_qcnt = (uint8_t) stcb->asoc.stream_queue_cnt;
459 if (stcb->asoc.chunks_on_out_queue < 0xff)
460 sctp_clog.x.wake.chunks_on_oque = (uint8_t) stcb->asoc.chunks_on_out_queue;
466 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE)
468 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_WAKEOUTPUT)
470 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_WAKEINPUT)
473 if (stcb->sctp_socket) {
474 struct socket *so = stcb->sctp_socket;
571 sctp_auditing(int from, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
593 if (stcb == NULL) {
604 (0x000000ff & stcb->asoc.sent_queue_retran_cnt);
612 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) {
620 if (resend_cnt != stcb->asoc.sent_queue_retran_cnt) {
628 resend_cnt, stcb->asoc.sent_queue_retran_cnt);
630 stcb->asoc.sent_queue_retran_cnt = resend_cnt;
633 (0x000000ff & stcb->asoc.sent_queue_retran_cnt);
639 if (tot_out != stcb->asoc.total_flight) {
648 (int)stcb->asoc.total_flight);
649 stcb->asoc.total_flight = tot_out;
651 if (tot_book_cnt != stcb->asoc.total_flight_count) {
661 stcb->asoc.total_flight_count = tot_book_cnt;
664 TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) {
667 if (tot_out != stcb->asoc.total_flight) {
676 stcb->asoc.total_flight, tot_out);
678 TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) {
681 TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) {
720 sctp_stop_timers_for_shutdown(struct sctp_tcb *stcb)
725 asoc = &stcb->asoc;
881 sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
904 asoc = &stcb->asoc;
906 SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_INUSE);
940 asoc->my_vtag = sctp_select_a_tag(inp, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
943 asoc->my_vtag_nonce = sctp_select_a_tag(inp, stcb->sctp_ep->sctp_lport, stcb->rport, 0);
944 asoc->peer_vtag_nonce = sctp_select_a_tag(inp, stcb->sctp_ep->sctp_lport, stcb->rport, 0);
1032 stcb->asoc.congestion_control_module = inp->sctp_ep.sctp_default_cc_module;
1033 stcb->asoc.cc_functions = sctp_cc_functions[inp->sctp_ep.sctp_default_cc_module];
1035 stcb->asoc.stream_scheduling_module = inp->sctp_ep.sctp_default_ss_module;
1036 stcb->asoc.ss_functions = sctp_ss_functions[inp->sctp_ep.sctp_default_ss_module];
1049 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOMEM);
1077 asoc->ss_functions.sctp_ss_init(stcb, asoc, 0);
1085 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOMEM);
1094 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOMEM);
1262 if (it->stcb == NULL) {
1264 it->stcb = LIST_FIRST(&it->inp->sctp_asoc_list);
1266 if ((inp_skip) || it->stcb == NULL) {
1275 while (it->stcb) {
1276 SCTP_TCB_LOCK(it->stcb);
1277 if (it->asoc_state && ((it->stcb->asoc.state & it->asoc_state) != it->asoc_state)) {
1279 SCTP_TCB_UNLOCK(it->stcb);
1286 atomic_add_int(&it->stcb->asoc.refcnt, 1);
1287 SCTP_TCB_UNLOCK(it->stcb);
1297 atomic_add_int(&it->stcb->asoc.refcnt, -1);
1315 SCTP_TCB_LOCK(it->stcb);
1316 atomic_add_int(&it->stcb->asoc.refcnt, -1);
1320 (*it->function_assoc) (it->inp, it->stcb, it->pointer, it->val);
1327 sctp_chunk_output(it->inp, it->stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED);
1329 SCTP_TCB_UNLOCK(it->stcb);
1331 it->stcb = LIST_NEXT(it->stcb, sctp_tcblist);
1332 if (it->stcb == NULL) {
1427 struct sctp_tcb *stcb;
1439 stcb = (struct sctp_tcb *)tmr->tcb;
1446 sctp_auditing(3, inp, stcb, net);
1494 if (stcb) {
1495 atomic_add_int(&stcb->asoc.refcnt, 1);
1496 if (stcb->asoc.state == 0) {
1497 atomic_add_int(&stcb->asoc.refcnt, -1);
1511 if (stcb) {
1512 atomic_add_int(&stcb->asoc.refcnt, -1);
1519 if (stcb) {
1520 SCTP_TCB_LOCK(stcb);
1521 atomic_add_int(&stcb->asoc.refcnt, -1);
1523 ((stcb->asoc.state == 0) ||
1524 (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED))) {
1525 SCTP_TCB_UNLOCK(stcb);
1573 if ((stcb == NULL) || (inp == NULL)) {
1577 stcb->asoc.timodata++;
1578 stcb->asoc.num_send_timers_up--;
1579 if (stcb->asoc.num_send_timers_up < 0) {
1580 stcb->asoc.num_send_timers_up = 0;
1582 SCTP_TCB_LOCK_ASSERT(stcb);
1583 if (sctp_t3rxt_timer(inp, stcb, net)) {
1588 SCTP_TCB_LOCK_ASSERT(stcb);
1590 sctp_auditing(4, inp, stcb, net);
1592 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED);
1593 if ((stcb->asoc.num_send_timers_up == 0) &&
1594 (stcb->asoc.sent_queue_cnt > 0)) {
1603 chk = TAILQ_FIRST(&stcb->asoc.sent_queue);
1604 sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb,
1609 if ((stcb == NULL) || (inp == NULL)) {
1613 stcb->asoc.timoinit++;
1614 if (sctp_t1init_timer(inp, stcb, net)) {
1622 if ((stcb == NULL) || (inp == NULL)) {
1626 stcb->asoc.timosack++;
1627 sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED);
1629 sctp_auditing(4, inp, stcb, net);
1631 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SACK_TMR, SCTP_SO_NOT_LOCKED);
1634 if ((stcb == NULL) || (inp == NULL)) {
1637 if (sctp_shutdown_timer(inp, stcb, net)) {
1642 stcb->asoc.timoshutdown++;
1644 sctp_auditing(4, inp, stcb, net);
1646 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_TMR, SCTP_SO_NOT_LOCKED);
1649 if ((stcb == NULL) || (inp == NULL) || (net == NULL)) {
1653 stcb->asoc.timoheartbeat++;
1654 if (sctp_heartbeat_timer(inp, stcb, net)) {
1659 sctp_auditing(4, inp, stcb, net);
1662 sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net);
1663 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_HB_TMR, SCTP_SO_NOT_LOCKED);
1667 if ((stcb == NULL) || (inp == NULL)) {
1670 if (sctp_cookie_timer(inp, stcb, net)) {
1675 stcb->asoc.timocookie++;
1677 sctp_auditing(4, inp, stcb, net);
1683 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED);
1710 sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, stcb, net);
1715 if ((stcb == NULL) || (inp == NULL)) {
1719 sctp_pathmtu_timer(inp, stcb, net);
1723 if ((stcb == NULL) || (inp == NULL)) {
1726 if (sctp_shutdownack_timer(inp, stcb, net)) {
1731 stcb->asoc.timoshutdownack++;
1733 sctp_auditing(4, inp, stcb, net);
1735 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_ACK_TMR, SCTP_SO_NOT_LOCKED);
1738 if ((stcb == NULL) || (inp == NULL)) {
1742 sctp_abort_an_association(inp, stcb, NULL, SCTP_SO_NOT_LOCKED);
1747 if ((stcb == NULL) || (inp == NULL)) {
1750 if (sctp_strreset_timer(inp, stcb, net)) {
1755 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_TMR, SCTP_SO_NOT_LOCKED);
1758 if ((stcb == NULL) || (inp == NULL)) {
1761 if (sctp_asconf_timer(inp, stcb, net)) {
1767 sctp_auditing(4, inp, stcb, net);
1769 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_ASCONF_TMR, SCTP_SO_NOT_LOCKED);
1772 if ((stcb == NULL) || (inp == NULL)) {
1775 sctp_delete_prim_timer(inp, stcb, net);
1780 if ((stcb == NULL) || (inp == NULL)) {
1784 sctp_autoclose_timer(inp, stcb, net);
1785 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_AUTOCLOSE_TMR, SCTP_SO_NOT_LOCKED);
1789 if ((stcb == NULL) || (inp == NULL)) {
1795 sctp_timer_stop(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL, SCTP_FROM_SCTPUTIL + SCTP_LOC_1);
1798 atomic_add_int(&stcb->asoc.refcnt, 1);
1799 SCTP_TCB_UNLOCK(stcb);
1801 SCTP_TCB_LOCK(stcb);
1802 atomic_subtract_int(&stcb->asoc.refcnt, 1);
1804 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_2);
1812 stcb = NULL;
1837 sctp_auditing(5, inp, stcb, net);
1839 if ((did_output) && stcb) {
1847 sctp_fix_ecn_echo(&stcb->asoc);
1850 if (stcb) {
1851 SCTP_TCB_UNLOCK(stcb);
1864 sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
1874 if (stcb) {
1875 SCTP_TCB_LOCK_ASSERT(stcb);
1896 if ((stcb == NULL) || (net == NULL)) {
1901 rto_val = stcb->asoc.initial_rto;
1913 if ((stcb == NULL) || (net == NULL)) {
1918 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
1928 if (stcb == NULL) {
1931 tmr = &stcb->asoc.dack_timer;
1932 to_ticks = MSEC_TO_TICKS(stcb->asoc.delayed_ack);
1936 if ((stcb == NULL) || (net == NULL)) {
1940 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
1952 if ((inp == NULL) || (stcb == NULL) || (net == NULL)) {
1963 to_ticks = stcb->asoc.initial_rto;
1992 if ((stcb == NULL) || (net == NULL)) {
1996 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
2014 if (stcb == NULL) {
2017 tmr = &stcb->asoc.strreset_timer;
2037 if ((stcb == NULL) || (inp == NULL)) {
2051 if ((stcb == NULL) || (net == NULL)) {
2055 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
2066 if ((inp == NULL) || (stcb == NULL)) {
2070 tmr = &stcb->asoc.shut_guard_timer;
2074 * Here the timer comes from the stcb but its value is from
2077 if ((stcb == NULL) || (net == NULL)) {
2081 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
2085 tmr = &stcb->asoc.strreset_timer;
2089 * Here the timer comes from the stcb but its value is from
2092 if ((stcb == NULL) || (net == NULL)) {
2096 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
2100 tmr = &stcb->asoc.asconf_timer;
2103 if ((stcb == NULL) || (net != NULL)) {
2106 to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
2107 tmr = &stcb->asoc.delete_prim_timer;
2110 if (stcb == NULL) {
2113 if (stcb->asoc.sctp_autoclose_ticks == 0) {
2115 * Really an error since stcb is NOT set to
2120 to_ticks = stcb->asoc.sctp_autoclose_ticks;
2121 tmr = &stcb->asoc.autoclose_timer;
2143 stcb->asoc.num_send_timers_up++;
2148 tmr->tcb = (void *)stcb;
2158 sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
2168 if (stcb) {
2169 SCTP_TCB_LOCK_ASSERT(stcb);
2182 if ((stcb == NULL) || (net == NULL)) {
2188 if ((stcb == NULL) || (net == NULL)) {
2194 if (stcb == NULL) {
2197 tmr = &stcb->asoc.dack_timer;
2200 if ((stcb == NULL) || (net == NULL)) {
2206 if ((stcb == NULL) || (net == NULL)) {
2212 if ((stcb == NULL) || (net == NULL)) {
2229 if (stcb == NULL) {
2232 tmr = &stcb->asoc.strreset_timer;
2244 if ((stcb == NULL) || (net == NULL)) {
2250 if ((stcb == NULL) || (net == NULL)) {
2256 if (stcb == NULL) {
2259 tmr = &stcb->asoc.shut_guard_timer;
2262 if (stcb == NULL) {
2265 tmr = &stcb->asoc.strreset_timer;
2268 if (stcb == NULL) {
2271 tmr = &stcb->asoc.asconf_timer;
2274 if (stcb == NULL) {
2277 tmr = &stcb->asoc.delete_prim_timer;
2280 if (stcb == NULL) {
2283 tmr = &stcb->asoc.autoclose_timer;
2302 if ((t_type == SCTP_TIMER_TYPE_SEND) && (stcb != NULL)) {
2303 stcb->asoc.num_send_timers_up--;
2304 if (stcb->asoc.num_send_timers_up < 0) {
2305 stcb->asoc.num_send_timers_up = 0;
2366 sctp_calculate_rto(struct sctp_tcb *stcb,
2396 if (stcb->asoc.use_precise_time) {
2413 (*asoc->cc_functions.sctp_rtt_calculated) (stcb, net, &now);
2464 (stcb->asoc.sat_network_lockout == 0)) {
2465 stcb->asoc.sat_network = 1;
2466 } else if ((!first_measure) && stcb->asoc.sat_network) {
2467 stcb->asoc.sat_network = 0;
2468 stcb->asoc.sat_network_lockout = 1;
2471 if (new_rto < stcb->asoc.minrto) {
2472 new_rto = stcb->asoc.minrto;
2474 if (new_rto > stcb->asoc.maxrto) {
2475 new_rto = stcb->asoc.maxrto;
2591 sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb,
2609 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVASSOCEVNT)) {
2639 sac->sac_outbound_streams = stcb->asoc.streamoutcnt;
2640 sac->sac_inbound_streams = stcb->asoc.streamincnt;
2641 sac->sac_assoc_id = sctp_get_associd(stcb);
2645 if (stcb->asoc.prsctp_supported == 1) {
2648 if (stcb->asoc.auth_supported == 1) {
2651 if (stcb->asoc.asconf_supported == 1) {
2655 if (stcb->asoc.reconfig_supported == 1) {
2665 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
2666 0, 0, stcb->asoc.context, 0, 0, 0,
2673 sctp_add_to_readq(stcb->sctp_ep, stcb,
2675 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD,
2686 if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
2687 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) &&
2689 SOCK_LOCK(stcb->sctp_socket);
2691 if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) {
2692 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNREFUSED);
2693 stcb->sctp_socket->so_error = ECONNREFUSED;
2695 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNRESET);
2696 stcb->sctp_socket->so_error = ECONNRESET;
2699 if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) ||
2700 (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED)) {
2701 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ETIMEDOUT);
2702 stcb->sctp_socket->so_error = ETIMEDOUT;
2704 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNABORTED);
2705 stcb->sctp_socket->so_error = ECONNABORTED;
2711 so = SCTP_INP_SO(stcb->sctp_ep);
2713 atomic_add_int(&stcb->asoc.refcnt, 1);
2714 SCTP_TCB_UNLOCK(stcb);
2716 SCTP_TCB_LOCK(stcb);
2717 atomic_subtract_int(&stcb->asoc.refcnt, 1);
2718 if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) {
2724 if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
2725 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) &&
2727 socantrcvmore_locked(stcb->sctp_socket);
2729 sorwakeup(stcb->sctp_socket);
2730 sowwakeup(stcb->sctp_socket);
2739 sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state,
2746 if ((stcb == NULL) ||
2747 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVPADDREVNT)) {
2792 spc->spc_assoc_id = sctp_get_associd(stcb);
2798 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
2799 0, 0, stcb->asoc.context, 0, 0, 0,
2810 sctp_add_to_readq(stcb->sctp_ep, stcb,
2812 &stcb->sctp_socket->so_rcv, 1,
2819 sctp_notify_send_failed(struct sctp_tcb *stcb, uint8_t sent, uint32_t error,
2832 if ((stcb == NULL) ||
2833 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) &&
2834 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT))) {
2838 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2848 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2866 ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb);
2867 ssfe->ssfe_assoc_id = sctp_get_associd(stcb);
2889 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
2890 ssf->ssf_assoc_id = sctp_get_associd(stcb);
2911 if (sctp_sbspace_failedmsgs(&stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {
2916 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
2917 0, 0, stcb->asoc.context, 0, 0, 0,
2925 sctp_add_to_readq(stcb->sctp_ep, stcb,
2927 &stcb->sctp_socket->so_rcv, 1,
2934 sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error,
2947 if ((stcb == NULL) ||
2948 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) &&
2949 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT))) {
2953 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2964 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2981 ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb);
2982 ssfe->ssfe_assoc_id = sctp_get_associd(stcb);
3002 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
3003 ssf->ssf_assoc_id = sctp_get_associd(stcb);
3015 if (sctp_sbspace_failedmsgs(&stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {
3020 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3021 0, 0, stcb->asoc.context, 0, 0, 0,
3029 sctp_add_to_readq(stcb->sctp_ep, stcb,
3031 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked);
3037 sctp_notify_adaptation_layer(struct sctp_tcb *stcb)
3043 if ((stcb == NULL) ||
3044 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_ADAPTATIONEVNT)) {
3058 sai->sai_adaptation_ind = stcb->asoc.peers_adaptation;
3059 sai->sai_assoc_id = sctp_get_associd(stcb);
3065 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3066 0, 0, stcb->asoc.context, 0, 0, 0,
3077 sctp_add_to_readq(stcb->sctp_ep, stcb,
3079 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
3084 sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb, uint32_t error,
3096 if ((stcb == NULL) ||
3097 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_PDAPIEVNT)) {
3101 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ) {
3117 pdapi->pdapi_assoc_id = sctp_get_associd(stcb);
3121 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3122 0, 0, stcb->asoc.context, 0, 0, 0,
3135 sb = &stcb->sctp_socket->so_rcv;
3137 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m_notify));
3139 sctp_sballoc(stcb, sb, m_notify);
3141 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
3145 if (stcb->asoc.control_pdapi)
3146 TAILQ_INSERT_AFTER(&stcb->sctp_ep->read_queue, stcb->asoc.control_pdapi, control, next);
3149 TAILQ_INSERT_TAIL(&stcb->sctp_ep->read_queue, control, next);
3151 if (stcb->sctp_ep && stcb->sctp_socket) {
3156 so = SCTP_INP_SO(stcb->sctp_ep);
3158 atomic_add_int(&stcb->asoc.refcnt, 1);
3159 SCTP_TCB_UNLOCK(stcb);
3161 SCTP_TCB_LOCK(stcb);
3162 atomic_subtract_int(&stcb->asoc.refcnt, 1);
3163 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
3169 sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket);
3179 sctp_notify_shutdown_event(struct sctp_tcb *stcb)
3189 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
3190 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
3195 so = SCTP_INP_SO(stcb->sctp_ep);
3196 atomic_add_int(&stcb->asoc.refcnt, 1);
3197 SCTP_TCB_UNLOCK(stcb);
3199 SCTP_TCB_LOCK(stcb);
3200 atomic_subtract_int(&stcb->asoc.refcnt, 1);
3201 if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) {
3206 socantsendmore(stcb->sctp_socket);
3211 if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT)) {
3224 sse->sse_assoc_id = sctp_get_associd(stcb);
3230 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3231 0, 0, stcb->asoc.context, 0, 0, 0,
3242 sctp_add_to_readq(stcb->sctp_ep, stcb,
3244 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
3248 sctp_notify_sender_dry_event(struct sctp_tcb *stcb,
3259 if ((stcb == NULL) ||
3260 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_DRYEVNT)) {
3275 event->sender_dry_assoc_id = sctp_get_associd(stcb);
3281 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3282 0, 0, stcb->asoc.context, 0, 0, 0,
3293 sctp_add_to_readq(stcb->sctp_ep, stcb, control,
3294 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked);
3299 sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, uint16_t numberout, int flag)
3305 if ((stcb == NULL) ||
3306 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_CHANGEEVNT))) {
3310 if ((stcb->asoc.peer_req_out) && flag) {
3312 stcb->asoc.peer_req_out = 0;
3315 stcb->asoc.peer_req_out = 0;
3326 stradd->strchange_assoc_id = sctp_get_associd(stcb);
3331 if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {
3337 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3338 0, 0, stcb->asoc.context, 0, 0, 0,
3349 sctp_add_to_readq(stcb->sctp_ep, stcb,
3351 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
3355 sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32_t recv_tsn, int flag)
3361 if ((stcb == NULL) ||
3362 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_ASSOC_RESETEVNT))) {
3376 strasoc->assocreset_assoc_id = sctp_get_associd(stcb);
3381 if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {
3387 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3388 0, 0, stcb->asoc.context, 0, 0, 0,
3399 sctp_add_to_readq(stcb->sctp_ep, stcb,
3401 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
3407 sctp_notify_stream_reset(struct sctp_tcb *stcb,
3415 if ((stcb == NULL) ||
3416 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT))) {
3436 strreset->strreset_assoc_id = sctp_get_associd(stcb);
3446 if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {
3452 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3453 0, 0, stcb->asoc.context, 0, 0, 0,
3464 sctp_add_to_readq(stcb->sctp_ep, stcb,
3466 &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
3471 sctp_notify_remote_error(struct sctp_tcb *stcb, uint16_t error, struct sctp_error_chunk *chunk)
3478 if ((stcb == NULL) ||
3479 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVPEERERR)) {
3504 sre->sre_assoc_id = sctp_get_associd(stcb);
3510 control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
3511 0, 0, stcb->asoc.context, 0, 0, 0,
3518 sctp_add_to_readq(stcb->sctp_ep, stcb,
3520 &stcb->sctp_socket->so_rcv, 1,
3529 sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
3536 if ((stcb == NULL) ||
3537 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
3538 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
3539 (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) {
3543 if (stcb->sctp_socket->so_rcv.sb_state & SBS_CANTRCVMORE) {
3546 if ((stcb->asoc.state & SCTP_STATE_COOKIE_WAIT) ||
3547 (stcb->asoc.state & SCTP_STATE_COOKIE_ECHOED)) {
3557 if (stcb->asoc.assoc_up_sent == 0) {
3558 sctp_notify_assoc_change(SCTP_COMM_UP, stcb, error, NULL, 0, so_locked);
3559 stcb->asoc.assoc_up_sent = 1;
3561 if (stcb->asoc.adaptation_needed && (stcb->asoc.adaptation_sent == 0)) {
3562 sctp_notify_adaptation_layer(stcb);
3564 if (stcb->asoc.auth_supported == 0) {
3565 sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0,
3570 sctp_notify_assoc_change(SCTP_SHUTDOWN_COMP, stcb, error, NULL, 0, so_locked);
3577 sctp_notify_peer_addr_change(stcb, SCTP_ADDR_UNREACHABLE,
3586 sctp_notify_peer_addr_change(stcb, SCTP_ADDR_AVAILABLE,
3595 sctp_notify_peer_addr_change(stcb, SCTP_ADDR_CONFIRMED,
3600 sctp_notify_send_failed2(stcb, error,
3604 sctp_notify_send_failed(stcb, 1, error,
3608 sctp_notify_send_failed(stcb, 0, error,
3617 sctp_notify_partial_delivery_indication(stcb, error, val, so_locked);
3621 if (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) ||
3622 ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED)) {
3623 sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 0, so_locked);
3625 sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 0, so_locked);
3629 if (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) ||
3630 ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED)) {
3631 sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 1, so_locked);
3633 sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 1, so_locked);
3637 sctp_notify_assoc_change(SCTP_RESTART, stcb, error, NULL, 0, so_locked);
3638 if (stcb->asoc.auth_supported == 0) {
3639 sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0,
3644 sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_OUTGOING_SSN);
3647 sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_INCOMING);
3650 sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
3654 sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
3658 sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
3662 sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
3666 sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data,
3670 sctp_notify_peer_addr_change(stcb, SCTP_ADDR_REMOVED, data,
3674 sctp_notify_peer_addr_change(stcb, SCTP_ADDR_MADE_PRIM, data,
3678 sctp_notify_shutdown_event(stcb);
3681 sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, error,
3686 sctp_notify_authentication(stcb, SCTP_AUTH_FREE_KEY, error,
3691 sctp_notify_authentication(stcb, SCTP_AUTH_NO_AUTH, error,
3696 sctp_notify_sender_dry_event(stcb, so_locked);
3699 sctp_notify_remote_error(stcb, error, data);
3709 sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock, int so_locked
3721 if (stcb == NULL) {
3724 asoc = &stcb->asoc;
3729 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
3730 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
3736 SCTP_TCB_SEND_LOCK(stcb);
3752 sctp_free_bufspace(stcb, asoc, chk, 1);
3753 sctp_ulp_notify(SCTP_NOTIFY_SENT_DG_FAIL, stcb,
3760 sctp_free_a_chunk(stcb, chk, so_locked);
3775 sctp_free_bufspace(stcb, asoc, chk, 1);
3776 sctp_ulp_notify(SCTP_NOTIFY_UNSENT_DG_FAIL, stcb,
3783 sctp_free_a_chunk(stcb, chk, so_locked);
3794 sctp_free_spbufspace(stcb, asoc, sp);
3796 sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL, stcb,
3810 sctp_free_a_strmoq(stcb, sp, so_locked);
3816 SCTP_TCB_SEND_UNLOCK(stcb);
3821 sctp_abort_notification(struct sctp_tcb *stcb, uint8_t from_peer, uint16_t error,
3828 if (stcb == NULL) {
3831 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
3832 ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) &&
3833 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_CONNECTED))) {
3834 stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_WAS_ABORTED;
3836 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
3837 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
3838 (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) {
3842 sctp_report_all_outbound(stcb, error, 1, so_locked);
3844 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_REM_ABORTED, stcb, error, abort, so_locked);
3846 sctp_ulp_notify(SCTP_NOTIFY_ASSOC_LOC_ABORTED, stcb, error, abort, so_locked);
3851 sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
3866 if (stcb != NULL) {
3868 vtag = stcb->asoc.peer_vtag;
3869 sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED);
3871 vrf_id = stcb->asoc.vrf_id;
3872 stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
3877 if (stcb != NULL) {
3881 atomic_add_int(&stcb->asoc.refcnt, 1);
3882 SCTP_TCB_UNLOCK(stcb);
3884 SCTP_TCB_LOCK(stcb);
3885 atomic_subtract_int(&stcb->asoc.refcnt, 1);
3888 if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
3889 (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
3892 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_4);
3901 sctp_print_out_track_log(struct sctp_tcb *stcb)
3906 SCTP_PRINTF("Last ep reason:%x\n", stcb->sctp_ep->last_abort_code);
3908 if ((stcb->asoc.tsn_in_at == 0) && (stcb->asoc.tsn_in_wrapped == 0)) {
3912 if (stcb->asoc.tsn_in_wrapped) {
3913 for (i = stcb->asoc.tsn_in_at; i < SCTP_TSN_LOG_SIZE; i++) {
3915 stcb->asoc.in_tsnlog[i].tsn,
3916 stcb->asoc.in_tsnlog[i].strm,
3917 stcb->asoc.in_tsnlog[i].seq,
3918 stcb->asoc.in_tsnlog[i].flgs,
3919 stcb->asoc.in_tsnlog[i].sz);
3922 if (stcb->asoc.tsn_in_at) {
3923 for (i = 0; i < stcb->asoc.tsn_in_at; i++) {
3925 stcb->asoc.in_tsnlog[i].tsn,
3926 stcb->asoc.in_tsnlog[i].strm,
3927 stcb->asoc.in_tsnlog[i].seq,
3928 stcb->asoc.in_tsnlog[i].flgs,
3929 stcb->asoc.in_tsnlog[i].sz);
3934 if ((stcb->asoc.tsn_out_at == 0) &&
3935 (stcb->asoc.tsn_out_wrapped == 0)) {
3938 if (stcb->asoc.tsn_out_wrapped) {
3939 for (i = stcb->asoc.tsn_out_at; i < SCTP_TSN_LOG_SIZE; i++) {
3941 stcb->asoc.out_tsnlog[i].tsn,
3942 stcb->asoc.out_tsnlog[i].strm,
3943 stcb->asoc.out_tsnlog[i].seq,
3944 stcb->asoc.out_tsnlog[i].flgs,
3945 stcb->asoc.out_tsnlog[i].sz);
3948 if (stcb->asoc.tsn_out_at) {
3949 for (i = 0; i < stcb->asoc.tsn_out_at; i++) {
3951 stcb->asoc.out_tsnlog[i].tsn,
3952 stcb->asoc.out_tsnlog[i].strm,
3953 stcb->asoc.out_tsnlog[i].seq,
3954 stcb->asoc.out_tsnlog[i].flgs,
3955 stcb->asoc.out_tsnlog[i].sz);
3964 sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
3980 if (stcb == NULL) {
3990 stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
3994 sctp_abort_notification(stcb, 0, 0, NULL, so_locked);
3997 sctp_send_abort_tcb(stcb, op_err, so_locked);
3999 if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
4000 (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
4005 sctp_print_out_track_log(stcb);
4009 atomic_add_int(&stcb->asoc.refcnt, 1);
4010 SCTP_TCB_UNLOCK(stcb);
4012 SCTP_TCB_LOCK(stcb);
4013 atomic_subtract_int(&stcb->asoc.refcnt, 1);
4016 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTPUTIL + SCTP_LOC_5);
4278 struct sctp_tcb *stcb,
4283 * belong to stcb and move then to the new inp.
4310 /* Pull off all for out target stcb */
4311 if (control->stcb == stcb) {
4318 sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
4320 sctp_sbfree(control, stcb, &old_so->so_rcv, m);
4322 sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
4339 sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m));
4341 sctp_sballoc(stcb, &new_so->so_rcv, m);
4343 sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
4353 struct sctp_tcb *stcb,
4394 atomic_add_int(&stcb->total_recvs, 1);
4418 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m));
4420 sctp_sballoc(stcb, sb, m);
4422 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
4452 if (stcb) {
4453 atomic_add_int(&stcb->asoc.refcnt, 1);
4454 SCTP_TCB_UNLOCK(stcb);
4457 if (stcb) {
4458 SCTP_TCB_LOCK(stcb);
4459 atomic_subtract_int(&stcb->asoc.refcnt, 1);
4480 struct sctp_tcb *stcb,
4538 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(mm));
4540 sctp_sballoc(stcb, sb, mm);
4542 sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
4578 if (stcb && (control == stcb->asoc.control_pdapi)) {
4579 stcb->asoc.control_pdapi = NULL;
4584 if (stcb == NULL) {
4605 if (stcb) {
4606 atomic_add_int(&stcb->asoc.refcnt, 1);
4607 SCTP_TCB_UNLOCK(stcb);
4610 if (stcb) {
4611 SCTP_TCB_LOCK(stcb);
4612 atomic_subtract_int(&stcb->asoc.refcnt, 1);
4682 sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc,
4702 if (stcb->sctp_socket && (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) ||
4703 ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)))) {
4704 if (stcb->sctp_socket->so_snd.sb_cc >= tp1->book_size) {
4705 stcb->sctp_socket->so_snd.sb_cc -= tp1->book_size;
4707 stcb->sctp_socket->so_snd.sb_cc = 0;
4716 sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
4735 stcb->asoc.abandoned_sent[0]++;
4736 stcb->asoc.abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++;
4737 stcb->asoc.strmout[stream].abandoned_sent[0]++;
4739 stcb->asoc.strmout[stream].abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++;
4742 stcb->asoc.abandoned_unsent[0]++;
4743 stcb->asoc.abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++;
4744 stcb->asoc.strmout[stream].abandoned_unsent[0]++;
4746 stcb->asoc.strmout[stream].abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++;
4754 sctp_total_flight_decrease(stcb, tp1);
4756 sctp_free_bufspace(stcb, &stcb->asoc, tp1, 1);
4757 stcb->asoc.peers_rwnd += tp1->send_size;
4758 stcb->asoc.peers_rwnd += SCTP_BASE_SYSCTL(sctp_peer_chunk_oh);
4760 sctp_ulp_notify(SCTP_NOTIFY_SENT_DG_FAIL, stcb, 0, tp1, so_locked);
4762 sctp_ulp_notify(SCTP_NOTIFY_UNSENT_DG_FAIL, stcb, 0, tp1, so_locked);
4770 stcb->asoc.sent_queue_cnt_removeable--;
4797 TAILQ_FOREACH_SAFE(tp1, &stcb->asoc.send_queue, sctp_next, tp2) {
4809 sctp_free_bufspace(stcb, &stcb->asoc, tp1, 1);
4811 sctp_ulp_notify(SCTP_NOTIFY_SENT_DG_FAIL, stcb, 0, tp1, so_locked);
4813 sctp_ulp_notify(SCTP_NOTIFY_UNSENT_DG_FAIL, stcb, 0, tp1, so_locked);
4826 TAILQ_REMOVE(&stcb->asoc.send_queue, tp1, sctp_next);
4831 TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, tp1,
4833 stcb->asoc.send_queue_cnt--;
4834 stcb->asoc.sent_queue_cnt++;
4842 SCTP_TCB_SEND_LOCK(stcb);
4843 strq = &stcb->asoc.strmout[stream];
4854 sctp_alloc_a_chunk(stcb, chk);
4867 chk->asoc = &stcb->asoc;
4876 chk->whoTo = stcb->asoc.primary_destination;
4878 chk->rec.data.TSN_seq = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1);
4879 stcb->asoc.pr_sctp_cnt++;
4880 TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, chk, sctp_next);
4881 stcb->asoc.sent_queue_cnt++;
4882 stcb->asoc.pr_sctp_cnt++;
4894 sctp_free_spbufspace(stcb, &stcb->asoc, sp);
4904 SCTP_TCB_SEND_UNLOCK(stcb);
4910 so = SCTP_INP_SO(stcb->sctp_ep);
4912 atomic_add_int(&stcb->asoc.refcnt, 1);
4913 SCTP_TCB_UNLOCK(stcb);
4915 SCTP_TCB_LOCK(stcb);
4916 atomic_subtract_int(&stcb->asoc.refcnt, 1);
4917 if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) {
4924 sctp_sowwakeup(stcb->sctp_ep, stcb->sctp_socket);
5096 sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t * freed_so_far, int hold_rlock,
5104 if (stcb == NULL)
5107 atomic_add_int(&stcb->asoc.refcnt, 1);
5109 if (stcb->asoc.state & (SCTP_STATE_ABOUT_TO_BE_FREED |
5115 SCTP_INP_INCR_REF(stcb->sctp_ep);
5116 if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) ||
5117 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
5120 so = stcb->sctp_socket;
5124 atomic_add_int(&stcb->freed_by_sorcv_sincelast, *freed_so_far);
5130 rwnd = sctp_calc_rwnd(stcb, &stcb->asoc);
5131 if (rwnd >= stcb->asoc.my_last_reported_rwnd) {
5132 dif = rwnd - stcb->asoc.my_last_reported_rwnd;
5138 SCTP_INP_READ_UNLOCK(stcb->sctp_ep);
5141 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
5149 SCTP_TCB_LOCK(stcb);
5150 if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
5152 SCTP_TCB_UNLOCK(stcb);
5156 sctp_send_sack(stcb, SCTP_SO_LOCKED);
5158 sctp_chunk_output(stcb->sctp_ep, stcb,
5161 sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, SCTP_FROM_SCTPUTIL + SCTP_LOC_6);
5162 SCTP_TCB_UNLOCK(stcb);
5165 stcb->freed_by_sorcv_sincelast = dif;
5169 SCTP_INP_READ_LOCK(stcb->sctp_ep);
5171 SCTP_INP_DECR_REF(stcb->sctp_ep);
5173 atomic_add_int(&stcb->asoc.refcnt, -1);
5200 struct sctp_tcb *stcb = NULL;
5431 sctp_free_a_readq(stcb, control);
5464 sctp_free_a_readq(stcb, control);
5477 if ((ctl->stcb != control->stcb) && (ctl->length) &&
5481 (ctl->stcb->asoc.strmin[ctl->sinfo_stream].delivery_started == 0)))
5497 (ctl->stcb->asoc.strmin[ctl->sinfo_stream].delivery_started == 0)))) {
5530 * Note that stcb COULD be NULL.
5537 stcb = control->stcb;
5538 if (stcb) {
5540 (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED)) {
5542 stcb = NULL;
5559 atomic_add_int(&stcb->asoc.refcnt, 1);
5571 freed_so_far = stcb->freed_by_sorcv_sincelast;
5572 stcb->freed_by_sorcv_sincelast = 0;
5575 if (stcb &&
5578 stcb->asoc.strmin[control->sinfo_stream].delivery_started = 1;
5623 * update off the real current cum-ack, if we have an stcb.
5625 if ((control->do_not_ref_stcb == 0) && stcb)
5626 sinfo->sinfo_cumtsn = stcb->asoc.cumulative_tsn;
5725 if ((control->do_not_ref_stcb == 0) && stcb &&
5726 stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
5747 (control->stcb != NULL) &&
5749 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0;
5763 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
5765 sctp_sbfree(control, stcb, &so->so_rcv, m);
5768 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
5813 sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, cp_len);
5817 stcb) {
5818 atomic_subtract_int(&stcb->asoc.sb_cc, cp_len);
5824 sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb,
5835 if (((stcb) && (in_flags & MSG_PEEK) == 0) &&
5838 sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req);
5887 sctp_free_a_readq(stcb, control);
5891 sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req);
5938 if (((stcb) && (in_flags & MSG_PEEK) == 0) &&
5942 sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req);
5981 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0;
5986 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0;
6036 (control->stcb != NULL) &&
6038 control->stcb->asoc.strmin[control->sinfo_stream].delivery_started = 0;
6049 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
6051 sctp_sbfree(control, stcb, &so->so_rcv, m);
6056 control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
6084 if ((stcb) && (in_flags & MSG_PEEK) == 0) {
6088 sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req);
6120 if (stcb == NULL) {
6122 panic("stcb for refcnt has gone NULL?");
6128 atomic_add_int(&stcb->asoc.refcnt, -1);
6130 stcb->freed_by_sorcv_sincelast = freed_so_far;
6133 if (stcb) {
6137 stcb->asoc.my_rwnd,
6290 sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr,
6309 inp = stcb->sctp_ep;
6320 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, EINVAL);
6321 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_7);
6325 if (sctp_add_remote_addr(stcb, sa, NULL, SCTP_DONOT_SETSCOPE, SCTP_ADDR_IS_CONFIRMED)) {
6327 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOBUFS);
6328 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_7);
6341 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, EINVAL);
6342 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_8);
6346 if (sctp_add_remote_addr(stcb, sa, NULL, SCTP_DONOT_SETSCOPE, SCTP_ADDR_IS_CONFIRMED)) {
6348 SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOBUFS);
6349 (void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_USRREQ + SCTP_LOC_8);
6371 struct sctp_tcb *stcb = NULL;
6426 stcb = sctp_findassociation_ep_addr(&inp, sa, NULL, NULL, NULL);
6427 if (stcb != NULL) {
6429 return (stcb);
6660 sctp_local_addr_count(struct sctp_tcb *stcb)
6678 loopback_scope = stcb->asoc.scope.loopback_scope;
6680 ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
6681 ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
6684 local_scope = stcb->asoc.scope.local_scope;
6685 site_scope = stcb->asoc.scope.site_scope;
6686 ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
6689 vrf = sctp_find_vrf(stcb->asoc.vrf_id);
6695 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
6705 if (sctp_is_addr_restricted(stcb, sctp_ifa))
6721 if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred,
6745 if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred,
6792 LIST_FOREACH(laddr, &stcb->sctp_ep->sctp_addr_list,
6794 if (sctp_is_addr_restricted(stcb, laddr->ifa)) {