Lines Matching +full:wakeup +full:- +full:rtt +full:- +full:timer
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
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.
1868 if ((scope->loopback_scope == 0) && in sctp_is_address_in_scope()
1869 (ifa->ifn_p) && SCTP_IFN_IS_IFT_LOOP(ifa->ifn_p)) { in sctp_is_address_in_scope()
1875 switch (ifa->address.sa.sa_family) { in sctp_is_address_in_scope()
1878 if (scope->ipv4_addr_legal) { in sctp_is_address_in_scope()
1881 sin = &ifa->address.sin; in sctp_is_address_in_scope()
1882 if (sin->sin_addr.s_addr == 0) { in sctp_is_address_in_scope()
1886 if ((scope->ipv4_local_scope == 0) && in sctp_is_address_in_scope()
1887 (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) { in sctp_is_address_in_scope()
1898 if (scope->ipv6_addr_legal) { in sctp_is_address_in_scope()
1903 * IFA locks must now be applied HERE <-> in sctp_is_address_in_scope()
1908 if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { in sctp_is_address_in_scope()
1912 sin6 = &ifa->address.sin6; in sctp_is_address_in_scope()
1913 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { in sctp_is_address_in_scope()
1918 (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))) { in sctp_is_address_in_scope()
1921 if ((scope->site_scope == 0) && in sctp_is_address_in_scope()
1922 (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { in sctp_is_address_in_scope()
1945 switch (ifa->address.sa.sa_family) { in sctp_add_addr_to_mbuf()
1979 switch (ifa->address.sa.sa_family) { in sctp_add_addr_to_mbuf()
1986 sin = &ifa->address.sin; in sctp_add_addr_to_mbuf()
1988 paramh->param_type = htons(SCTP_IPV4_ADDRESS); in sctp_add_addr_to_mbuf()
1989 paramh->param_length = htons(plen); in sctp_add_addr_to_mbuf()
1990 ipv4p->addr = sin->sin_addr.s_addr; in sctp_add_addr_to_mbuf()
2001 sin6 = &ifa->address.sin6; in sctp_add_addr_to_mbuf()
2003 paramh->param_type = htons(SCTP_IPV6_ADDRESS); in sctp_add_addr_to_mbuf()
2004 paramh->param_length = htons(plen); in sctp_add_addr_to_mbuf()
2005 memcpy(ipv6p->addr, &sin6->sin6_addr, in sctp_add_addr_to_mbuf()
2006 sizeof(ipv6p->addr)); in sctp_add_addr_to_mbuf()
2008 in6_clearscope((struct in6_addr *)ipv6p->addr); in sctp_add_addr_to_mbuf()
2033 vrf_id = inp->def_vrf_id; in sctp_add_addresses_to_i_ia()
2040 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { in sctp_add_addresses_to_i_ia()
2045 if (vrf->total_ifa_count > SCTP_COUNT_LIMIT) { in sctp_add_addresses_to_i_ia()
2050 LIST_FOREACH(sctp_ifnp, &vrf->ifnlist, next_ifn) { in sctp_add_addresses_to_i_ia()
2051 if ((scope->loopback_scope == 0) && in sctp_add_addresses_to_i_ia()
2059 LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) { in sctp_add_addresses_to_i_ia()
2061 if ((sctp_ifap->address.sa.sa_family == AF_INET) && in sctp_add_addresses_to_i_ia()
2062 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_add_addresses_to_i_ia()
2063 &sctp_ifap->address.sin.sin_addr) != 0)) { in sctp_add_addresses_to_i_ia()
2068 if ((sctp_ifap->address.sa.sa_family == AF_INET6) && in sctp_add_addresses_to_i_ia()
2069 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_add_addresses_to_i_ia()
2070 &sctp_ifap->address.sin6.sin6_addr) != 0)) { in sctp_add_addresses_to_i_ia()
2092 LIST_FOREACH(sctp_ifnp, &vrf->ifnlist, next_ifn) { in sctp_add_addresses_to_i_ia()
2094 if ((scope->loopback_scope == 0) && in sctp_add_addresses_to_i_ia()
2102 LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) { in sctp_add_addresses_to_i_ia()
2104 if ((sctp_ifap->address.sa.sa_family == AF_INET) && in sctp_add_addresses_to_i_ia()
2105 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_add_addresses_to_i_ia()
2106 &sctp_ifap->address.sin.sin_addr) != 0)) { in sctp_add_addresses_to_i_ia()
2111 if ((sctp_ifap->address.sa.sa_family == AF_INET6) && in sctp_add_addresses_to_i_ia()
2112 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_add_addresses_to_i_ia()
2113 &sctp_ifap->address.sin6.sin6_addr) != 0)) { in sctp_add_addresses_to_i_ia()
2156 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { in sctp_add_addresses_to_i_ia()
2157 if (laddr->ifa == NULL) { in sctp_add_addresses_to_i_ia()
2160 if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) in sctp_add_addresses_to_i_ia()
2166 if (laddr->action == SCTP_DEL_IP_ADDRESS) { in sctp_add_addresses_to_i_ia()
2173 if (sctp_is_address_in_scope(laddr->ifa, in sctp_add_addresses_to_i_ia()
2186 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { in sctp_add_addresses_to_i_ia()
2187 if (laddr->ifa == NULL) { in sctp_add_addresses_to_i_ia()
2190 if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) { in sctp_add_addresses_to_i_ia()
2193 if (sctp_is_address_in_scope(laddr->ifa, in sctp_add_addresses_to_i_ia()
2205 m_at = sctp_add_addr_to_mbuf(m_at, laddr->ifa, chunk_len); in sctp_add_addresses_to_i_ia()
2232 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2234 * ---------------------------------------- in sctp_is_ifa_addr_preferred()
2236 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2237 * P | L | yes-v4 no-v6 in sctp_is_ifa_addr_preferred()
2238 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2239 * G | L | yes-v4 no-v6 in sctp_is_ifa_addr_preferred()
2240 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2242 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2244 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2246 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2248 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2250 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2252 * ----------------------------------------- in sctp_is_ifa_addr_preferred()
2255 if (ifa->address.sa.sa_family != fam) { in sctp_is_ifa_addr_preferred()
2256 /* forget mis-matched family */ in sctp_is_ifa_addr_preferred()
2263 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &ifa->address.sa); in sctp_is_ifa_addr_preferred()
2268 if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { in sctp_is_ifa_addr_preferred()
2272 if (ifa->src_is_priv && !ifa->src_is_loop) { in sctp_is_ifa_addr_preferred()
2278 if (ifa->src_is_glob) { in sctp_is_ifa_addr_preferred()
2289 * straightforward and easier to validate :-) in sctp_is_ifa_addr_preferred()
2292 ifa->src_is_loop, ifa->src_is_priv, ifa->src_is_glob); in sctp_is_ifa_addr_preferred()
2296 if ((ifa->src_is_loop) && (dest_is_priv)) { in sctp_is_ifa_addr_preferred()
2300 if ((ifa->src_is_glob) && (dest_is_priv)) { in sctp_is_ifa_addr_preferred()
2304 if ((ifa->src_is_loop) && (dest_is_global)) { in sctp_is_ifa_addr_preferred()
2308 if ((ifa->src_is_priv) && (dest_is_global)) { in sctp_is_ifa_addr_preferred()
2332 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2334 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2336 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2337 * P | L | yes-v4 no-v6 in sctp_is_ifa_addr_acceptable()
2338 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2340 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2342 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2344 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2345 * G | P | yes - May not work in sctp_is_ifa_addr_acceptable()
2346 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2348 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2349 * P | G | yes - May not work in sctp_is_ifa_addr_acceptable()
2350 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2352 * ----------------------------------------- in sctp_is_ifa_addr_acceptable()
2355 if (ifa->address.sa.sa_family != fam) { in sctp_is_ifa_addr_acceptable()
2358 ifa->address.sa.sa_family, fam); in sctp_is_ifa_addr_acceptable()
2362 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT3, &ifa->address.sa); in sctp_is_ifa_addr_acceptable()
2371 if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) { in sctp_is_ifa_addr_acceptable()
2374 if (ifa->src_is_priv) { in sctp_is_ifa_addr_acceptable()
2384 * straightforward and easier to validate :-) in sctp_is_ifa_addr_acceptable()
2386 SCTPDBG(SCTP_DEBUG_OUTPUT3, "ifa->src_is_loop:%d dest_is_priv:%d\n", in sctp_is_ifa_addr_acceptable()
2387 ifa->src_is_loop, in sctp_is_ifa_addr_acceptable()
2389 if ((ifa->src_is_loop == 1) && (dest_is_priv)) { in sctp_is_ifa_addr_acceptable()
2392 SCTPDBG(SCTP_DEBUG_OUTPUT3, "ifa->src_is_loop:%d dest_is_glob:%d\n", in sctp_is_ifa_addr_acceptable()
2393 ifa->src_is_loop, in sctp_is_ifa_addr_acceptable()
2395 if ((ifa->src_is_loop == 1) && (dest_is_global)) { in sctp_is_ifa_addr_acceptable()
2409 /* There are no restrictions, no TCB :-) */ in sctp_is_addr_restricted()
2412 LIST_FOREACH(laddr, &stcb->asoc.sctp_restricted_addrs, sctp_nxt_addr) { in sctp_is_addr_restricted()
2413 if (laddr->ifa == NULL) { in sctp_is_addr_restricted()
2418 if (laddr->ifa == ifa) { in sctp_is_addr_restricted()
2433 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { in sctp_is_addr_in_ep()
2434 if (laddr->ifa == NULL) { in sctp_is_addr_in_ep()
2439 if ((laddr->ifa == ifa) && laddr->action == 0) in sctp_is_addr_in_ep()
2477 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { in sctp_choose_boundspecific_inp()
2479 if ((sctp_ifa->address.sa.sa_family == AF_INET) && in sctp_choose_boundspecific_inp()
2480 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_choose_boundspecific_inp()
2481 &sctp_ifa->address.sin.sin_addr) != 0)) { in sctp_choose_boundspecific_inp()
2486 if ((sctp_ifa->address.sa.sa_family == AF_INET6) && in sctp_choose_boundspecific_inp()
2487 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_choose_boundspecific_inp()
2488 &sctp_ifa->address.sin6.sin6_addr) != 0)) { in sctp_choose_boundspecific_inp()
2492 if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && in sctp_choose_boundspecific_inp()
2501 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_inp()
2512 starting_point = inp->next_addr_touse; in sctp_choose_boundspecific_inp()
2514 if (inp->next_addr_touse == NULL) { in sctp_choose_boundspecific_inp()
2515 inp->next_addr_touse = LIST_FIRST(&inp->sctp_addr_list); in sctp_choose_boundspecific_inp()
2518 for (laddr = inp->next_addr_touse; laddr; in sctp_choose_boundspecific_inp()
2520 if (laddr->ifa == NULL) { in sctp_choose_boundspecific_inp()
2524 if (laddr->action == SCTP_DEL_IP_ADDRESS) { in sctp_choose_boundspecific_inp()
2528 sifa = sctp_is_ifa_addr_preferred(laddr->ifa, dest_is_loop, in sctp_choose_boundspecific_inp()
2532 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_inp()
2536 inp->next_addr_touse = NULL; in sctp_choose_boundspecific_inp()
2540 inp->next_addr_touse = starting_point; in sctp_choose_boundspecific_inp()
2543 if (inp->next_addr_touse == NULL) { in sctp_choose_boundspecific_inp()
2544 inp->next_addr_touse = LIST_FIRST(&inp->sctp_addr_list); in sctp_choose_boundspecific_inp()
2549 for (laddr = inp->next_addr_touse; laddr; in sctp_choose_boundspecific_inp()
2551 if (laddr->ifa == NULL) { in sctp_choose_boundspecific_inp()
2555 if (laddr->action == SCTP_DEL_IP_ADDRESS) { in sctp_choose_boundspecific_inp()
2559 sifa = sctp_is_ifa_addr_acceptable(laddr->ifa, dest_is_loop, in sctp_choose_boundspecific_inp()
2563 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_inp()
2567 inp->next_addr_touse = NULL; in sctp_choose_boundspecific_inp()
2615 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { in sctp_choose_boundspecific_stcb()
2617 if ((sctp_ifa->address.sa.sa_family == AF_INET) && in sctp_choose_boundspecific_stcb()
2618 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_choose_boundspecific_stcb()
2619 &sctp_ifa->address.sin.sin_addr) != 0)) { in sctp_choose_boundspecific_stcb()
2624 if ((sctp_ifa->address.sa.sa_family == AF_INET6) && in sctp_choose_boundspecific_stcb()
2625 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_choose_boundspecific_stcb()
2626 &sctp_ifa->address.sin6.sin6_addr) != 0)) { in sctp_choose_boundspecific_stcb()
2630 if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && (non_asoc_addr_ok == 0)) in sctp_choose_boundspecific_stcb()
2641 /* on the no-no list */ in sctp_choose_boundspecific_stcb()
2644 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_stcb()
2649 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { in sctp_choose_boundspecific_stcb()
2651 if ((sctp_ifa->address.sa.sa_family == AF_INET) && in sctp_choose_boundspecific_stcb()
2652 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_choose_boundspecific_stcb()
2653 &sctp_ifa->address.sin.sin_addr) != 0)) { in sctp_choose_boundspecific_stcb()
2658 if ((sctp_ifa->address.sa.sa_family == AF_INET6) && in sctp_choose_boundspecific_stcb()
2659 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_choose_boundspecific_stcb()
2660 &sctp_ifa->address.sin6.sin6_addr) != 0)) { in sctp_choose_boundspecific_stcb()
2664 if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && (non_asoc_addr_ok == 0)) in sctp_choose_boundspecific_stcb()
2675 /* on the no-no list */ in sctp_choose_boundspecific_stcb()
2678 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_stcb()
2687 starting_point = stcb->asoc.last_used_address; in sctp_choose_boundspecific_stcb()
2689 if (stcb->asoc.last_used_address == NULL) { in sctp_choose_boundspecific_stcb()
2691 stcb->asoc.last_used_address = LIST_FIRST(&inp->sctp_addr_list); in sctp_choose_boundspecific_stcb()
2694 for (laddr = stcb->asoc.last_used_address; laddr; in sctp_choose_boundspecific_stcb()
2696 if (laddr->ifa == NULL) { in sctp_choose_boundspecific_stcb()
2700 if (laddr->action == SCTP_DEL_IP_ADDRESS) { in sctp_choose_boundspecific_stcb()
2704 sifa = sctp_is_ifa_addr_preferred(laddr->ifa, dest_is_loop, dest_is_priv, fam); in sctp_choose_boundspecific_stcb()
2712 /* on the no-no list */ in sctp_choose_boundspecific_stcb()
2715 stcb->asoc.last_used_address = laddr; in sctp_choose_boundspecific_stcb()
2716 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_stcb()
2720 stcb->asoc.last_used_address = NULL; in sctp_choose_boundspecific_stcb()
2724 stcb->asoc.last_used_address = starting_point; in sctp_choose_boundspecific_stcb()
2727 if (stcb->asoc.last_used_address == NULL) { in sctp_choose_boundspecific_stcb()
2729 stcb->asoc.last_used_address = LIST_FIRST(&inp->sctp_addr_list); in sctp_choose_boundspecific_stcb()
2732 for (laddr = stcb->asoc.last_used_address; laddr; in sctp_choose_boundspecific_stcb()
2734 if (laddr->ifa == NULL) { in sctp_choose_boundspecific_stcb()
2738 if (laddr->action == SCTP_DEL_IP_ADDRESS) { in sctp_choose_boundspecific_stcb()
2742 sifa = sctp_is_ifa_addr_acceptable(laddr->ifa, dest_is_loop, in sctp_choose_boundspecific_stcb()
2751 /* on the no-no list */ in sctp_choose_boundspecific_stcb()
2754 stcb->asoc.last_used_address = laddr; in sctp_choose_boundspecific_stcb()
2755 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundspecific_stcb()
2759 stcb->asoc.last_used_address = NULL; in sctp_choose_boundspecific_stcb()
2782 memcpy(&sin6, &ro->ro_dst, sizeof(struct sockaddr_in6)); in sctp_select_nth_preferred_addr_from_ifn_boundall()
2786 LIST_FOREACH(ifa, &ifn->ifalist, next_ifa) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2788 if ((ifa->address.sa.sa_family == AF_INET) && in sctp_select_nth_preferred_addr_from_ifn_boundall()
2789 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_select_nth_preferred_addr_from_ifn_boundall()
2790 &ifa->address.sin.sin_addr) != 0)) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2795 if ((ifa->address.sa.sa_family == AF_INET6) && in sctp_select_nth_preferred_addr_from_ifn_boundall()
2796 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_select_nth_preferred_addr_from_ifn_boundall()
2797 &ifa->address.sin6.sin6_addr) != 0)) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2801 if ((ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && in sctp_select_nth_preferred_addr_from_ifn_boundall()
2811 sifa->src_is_loop && sifa->src_is_priv) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2820 IN6_IS_ADDR_LINKLOCAL(&sifa->address.sin6.sin6_addr) && in sctp_select_nth_preferred_addr_from_ifn_boundall()
2823 * link-local <-> link-local must belong to the same in sctp_select_nth_preferred_addr_from_ifn_boundall()
2826 memcpy(&lsa6, &sifa->address.sin6, sizeof(struct sockaddr_in6)); in sctp_select_nth_preferred_addr_from_ifn_boundall()
2835 * Check if the IPv6 address matches to next-hop. In the in sctp_select_nth_preferred_addr_from_ifn_boundall()
2839 * next-hop. (by micchie) in sctp_select_nth_preferred_addr_from_ifn_boundall()
2843 sctp_is_mobility_feature_on(stcb->sctp_ep, SCTP_MOBILITY_BASE)) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2844 if (sctp_v6src_match_nexthop(&sifa->address.sin6, ro) == 0) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2852 sctp_is_mobility_feature_on(stcb->sctp_ep, SCTP_MOBILITY_BASE)) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2859 if (sctp_is_address_in_scope(ifa, &stcb->asoc.scope, 0) == 0) { in sctp_select_nth_preferred_addr_from_ifn_boundall()
2894 LIST_FOREACH(ifa, &ifn->ifalist, next_ifa) { in sctp_count_num_preferred_boundall()
2896 if ((ifa->address.sa.sa_family == AF_INET) && in sctp_count_num_preferred_boundall()
2897 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_count_num_preferred_boundall()
2898 &ifa->address.sin.sin_addr) != 0)) { in sctp_count_num_preferred_boundall()
2903 if ((ifa->address.sa.sa_family == AF_INET6) && in sctp_count_num_preferred_boundall()
2905 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_count_num_preferred_boundall()
2906 &ifa->address.sin6.sin6_addr) != 0)) { in sctp_count_num_preferred_boundall()
2910 if ((ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && in sctp_count_num_preferred_boundall()
2920 if (sctp_is_address_in_scope(ifa, &stcb->asoc.scope, 0) == 0) { in sctp_count_num_preferred_boundall()
2961 /*- in sctp_choose_boundall()
2973 * abort :-<. in sctp_choose_boundall()
2989 ifn_index, sctp_ifn->ifn_name); in sctp_choose_boundall()
2992 cur_addr_num = net->indx_of_eligible_next_to_use; in sctp_choose_boundall()
3000 num_preferred, sctp_ifn->ifn_name); in sctp_choose_boundall()
3027 atomic_add_int(&sctp_ifa->refcount, 1); in sctp_choose_boundall()
3030 net->indx_of_eligible_next_to_use = cur_addr_num + 1; in sctp_choose_boundall()
3040 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { in sctp_choose_boundall()
3042 sctp_ifn->ifn_name); in sctp_choose_boundall()
3060 SCTPDBG(SCTP_DEBUG_OUTPUT2, "No preferred -- skipping to next\n"); in sctp_choose_boundall()
3080 net->indx_of_eligible_next_to_use = cur_addr_num + 1; in sctp_choose_boundall()
3084 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &sifa->address.sa); in sctp_choose_boundall()
3086 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &net->ro._l_addr.sa); in sctp_choose_boundall()
3088 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundall()
3098 SCTPDBG(SCTP_DEBUG_OUTPUT2, "Jump to Plan D - no emit_ifn\n"); in sctp_choose_boundall()
3101 LIST_FOREACH(sctp_ifa, &emit_ifn->ifalist, next_ifa) { in sctp_choose_boundall()
3104 if ((sctp_ifa->address.sa.sa_family == AF_INET) && in sctp_choose_boundall()
3105 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_choose_boundall()
3106 &sctp_ifa->address.sin.sin_addr) != 0)) { in sctp_choose_boundall()
3112 if ((sctp_ifa->address.sa.sa_family == AF_INET6) && in sctp_choose_boundall()
3113 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_choose_boundall()
3114 &sctp_ifa->address.sin6.sin6_addr) != 0)) { in sctp_choose_boundall()
3119 if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && in sctp_choose_boundall()
3131 if (sctp_is_address_in_scope(sifa, &stcb->asoc.scope, 0) == 0) { in sctp_choose_boundall()
3150 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundall()
3161 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { in sctp_choose_boundall()
3166 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { in sctp_choose_boundall()
3168 if ((sctp_ifa->address.sa.sa_family == AF_INET) && in sctp_choose_boundall()
3169 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_choose_boundall()
3170 &sctp_ifa->address.sin.sin_addr) != 0)) { in sctp_choose_boundall()
3175 if ((sctp_ifa->address.sa.sa_family == AF_INET6) && in sctp_choose_boundall()
3176 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_choose_boundall()
3177 &sctp_ifa->address.sin6.sin6_addr) != 0)) { in sctp_choose_boundall()
3181 if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && in sctp_choose_boundall()
3190 if (sctp_is_address_in_scope(sifa, &stcb->asoc.scope, 0) == 0) { in sctp_choose_boundall()
3212 if ((retried == 0) && (stcb->asoc.scope.ipv4_local_scope == 0)) { in sctp_choose_boundall()
3213 stcb->asoc.scope.ipv4_local_scope = 1; in sctp_choose_boundall()
3217 stcb->asoc.scope.ipv4_local_scope = 0; in sctp_choose_boundall()
3225 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { in sctp_choose_boundall()
3230 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { in sctp_choose_boundall()
3234 if ((sctp_ifa->address.sa.sa_family == AF_INET) && in sctp_choose_boundall()
3235 (prison_check_ip4(inp->ip_inp.inp.inp_cred, in sctp_choose_boundall()
3236 &sctp_ifa->address.sin.sin_addr) != 0)) { in sctp_choose_boundall()
3241 if ((sctp_ifa->address.sa.sa_family == AF_INET6) && in sctp_choose_boundall()
3242 (prison_check_ip6(inp->ip_inp.inp.inp_cred, in sctp_choose_boundall()
3243 &sctp_ifa->address.sin6.sin6_addr) != 0)) { in sctp_choose_boundall()
3247 if ((sctp_ifa->localifa_flags & SCTP_ADDR_DEFER_USE) && in sctp_choose_boundall()
3261 &stcb->asoc.scope, 0) == 0) { in sctp_choose_boundall()
3278 if ((tmp_sifa->address.sin.sin_family == AF_INET) && in sctp_choose_boundall()
3279 (IN4_ISPRIVATE_ADDRESS(&(tmp_sifa->address.sin.sin_addr)))) { in sctp_choose_boundall()
3285 atomic_add_int(&sifa->refcount, 1); in sctp_choose_boundall()
3303 struct sockaddr_in *to = (struct sockaddr_in *)&ro->ro_dst; in sctp_source_address_selection()
3306 struct sockaddr_in6 *to6 = (struct sockaddr_in6 *)&ro->ro_dst; in sctp_source_address_selection()
3311 * - Find the route if needed, cache if I can. in sctp_source_address_selection()
3312 * - Look at interface address in route, Is it in the bound list. If so we in sctp_source_address_selection()
3314 * - If not we must rotate amongst the addresses. in sctp_source_address_selection()
3323 * ------------------------------------------ in sctp_source_address_selection()
3325 * ----------------------------------------- in sctp_source_address_selection()
3327 * ----------------------------------------- in sctp_source_address_selection()
3329 * ----------------------------------------- in sctp_source_address_selection()
3331 * ----------------------------------------- in sctp_source_address_selection()
3333 *------------------------------------------ in sctp_source_address_selection()
3336 *------------------------------------------ in sctp_source_address_selection()
3338 * ----------------------------------------- in sctp_source_address_selection()
3340 * ----------------------------------------- in sctp_source_address_selection()
3342 * ----------------------------------------- in sctp_source_address_selection()
3344 * ----------------------------------------- in sctp_source_address_selection()
3346 *------------------------------------------ in sctp_source_address_selection()
3354 * one is best? And what about NAT's sending P->G may get you a NAT in sctp_source_address_selection()
3360 * - count the number of addresses on the interface. in sctp_source_address_selection()
3361 * - if it is one, no problem except case <c>. in sctp_source_address_selection()
3363 * - if there are more than one, then we need to worry about scope P in sctp_source_address_selection()
3364 * or G. We should prefer G -> G and P -> P if possible. in sctp_source_address_selection()
3365 * Then as a secondary fall back to mixed types G->P being a last in sctp_source_address_selection()
3367 * - The above all works for bound all, but bound specific we need to in sctp_source_address_selection()
3372 if (ro->ro_nh == NULL) { in sctp_source_address_selection()
3376 SCTP_RTALLOC(ro, vrf_id, inp->fibnum); in sctp_source_address_selection()
3378 if (ro->ro_nh == NULL) { in sctp_source_address_selection()
3381 fam = ro->ro_dst.sa_family; in sctp_source_address_selection()
3388 if (IN4_ISLOOPBACK_ADDRESS(&to->sin_addr)) { in sctp_source_address_selection()
3392 net->addr_is_local = 1; in sctp_source_address_selection()
3394 } else if ((IN4_ISPRIVATE_ADDRESS(&to->sin_addr))) { in sctp_source_address_selection()
3402 if (IN6_IS_ADDR_LOOPBACK(&to6->sin6_addr) || in sctp_source_address_selection()
3413 net->addr_is_local = 1; in sctp_source_address_selection()
3415 } else if (IN6_IS_ADDR_LINKLOCAL(&to6->sin6_addr)) { in sctp_source_address_selection()
3422 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, (struct sockaddr *)&ro->ro_dst); in sctp_source_address_selection()
3424 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { in sctp_source_address_selection()
3469 rem_len = tot_len - off; in sctp_find_cmsg()
3483 cmsg_data_len = (int)cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh)); in sctp_find_cmsg()
3517 sndrcvinfo->sinfo_stream = sndinfo.snd_sid; in sctp_find_cmsg()
3518 sndrcvinfo->sinfo_flags = sndinfo.snd_flags; in sctp_find_cmsg()
3519 sndrcvinfo->sinfo_ppid = sndinfo.snd_ppid; in sctp_find_cmsg()
3520 sndrcvinfo->sinfo_context = sndinfo.snd_context; in sctp_find_cmsg()
3521 sndrcvinfo->sinfo_assoc_id = sndinfo.snd_assoc_id; in sctp_find_cmsg()
3529 sndrcvinfo->sinfo_timetolive = prinfo.pr_value; in sctp_find_cmsg()
3531 sndrcvinfo->sinfo_timetolive = 0; in sctp_find_cmsg()
3533 sndrcvinfo->sinfo_flags |= prinfo.pr_policy; in sctp_find_cmsg()
3540 sndrcvinfo->sinfo_keynumber_valid = 1; in sctp_find_cmsg()
3541 sndrcvinfo->sinfo_keynumber = authinfo.auth_keynumber; in sctp_find_cmsg()
3568 rem_len = tot_len - off; in sctp_process_cmsgs_for_init()
3585 cmsg_data_len = (int)cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh)); in sctp_process_cmsgs_for_init()
3596 stcb->asoc.max_init_times = initmsg.sinit_max_attempts; in sctp_process_cmsgs_for_init()
3598 stcb->asoc.pre_open_streams = initmsg.sinit_num_ostreams; in sctp_process_cmsgs_for_init()
3600 stcb->asoc.max_inbound_streams = initmsg.sinit_max_instreams; in sctp_process_cmsgs_for_init()
3602 stcb->asoc.initial_init_rto_max = initmsg.sinit_max_init_timeo; in sctp_process_cmsgs_for_init()
3603 if (stcb->asoc.streamoutcnt < stcb->asoc.pre_open_streams) { in sctp_process_cmsgs_for_init()
3612 stcb->asoc.streamoutcnt, stcb->asoc.pre_open_streams); in sctp_process_cmsgs_for_init()
3616 (stcb->asoc.pre_open_streams * sizeof(struct sctp_stream_out)), in sctp_process_cmsgs_for_init()
3620 SCTP_FREE(stcb->asoc.strmout, SCTP_M_STRMO); in sctp_process_cmsgs_for_init()
3621 stcb->asoc.strmout = tmp_str; in sctp_process_cmsgs_for_init()
3622 stcb->asoc.strm_realoutsize = stcb->asoc.streamoutcnt = stcb->asoc.pre_open_streams; in sctp_process_cmsgs_for_init()
3624 stcb->asoc.pre_open_streams = stcb->asoc.streamoutcnt; in sctp_process_cmsgs_for_init()
3626 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { in sctp_process_cmsgs_for_init()
3627 TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); in sctp_process_cmsgs_for_init()
3628 stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], NULL); in sctp_process_cmsgs_for_init()
3629 stcb->asoc.strmout[i].chunks_on_queues = 0; in sctp_process_cmsgs_for_init()
3632 stcb->asoc.strmout[i].abandoned_sent[j] = 0; in sctp_process_cmsgs_for_init()
3633 stcb->asoc.strmout[i].abandoned_unsent[j] = 0; in sctp_process_cmsgs_for_init()
3636 stcb->asoc.strmout[i].abandoned_sent[0] = 0; in sctp_process_cmsgs_for_init()
3637 stcb->asoc.strmout[i].abandoned_unsent[0] = 0; in sctp_process_cmsgs_for_init()
3639 stcb->asoc.strmout[i].next_mid_ordered = 0; in sctp_process_cmsgs_for_init()
3640 stcb->asoc.strmout[i].next_mid_unordered = 0; in sctp_process_cmsgs_for_init()
3641 stcb->asoc.strmout[i].sid = i; in sctp_process_cmsgs_for_init()
3642 stcb->asoc.strmout[i].last_msg_incomplete = 0; in sctp_process_cmsgs_for_init()
3643 stcb->asoc.strmout[i].state = SCTP_STREAM_OPENING; in sctp_process_cmsgs_for_init()
3656 sin.sin_port = stcb->rport; in sctp_process_cmsgs_for_init()
3664 if (sctp_add_remote_addr(stcb, (struct sockaddr *)&sin, NULL, stcb->asoc.port, in sctp_process_cmsgs_for_init()
3680 sin6.sin6_port = stcb->rport; in sctp_process_cmsgs_for_init()
3696 if (sctp_add_remote_addr(stcb, (struct sockaddr *)&sin, NULL, stcb->asoc.port, in sctp_process_cmsgs_for_init()
3703 if (sctp_add_remote_addr(stcb, (struct sockaddr *)&sin6, NULL, stcb->asoc.port, in sctp_process_cmsgs_for_init()
3739 rem_len = tot_len - off; in sctp_findassociation_cmsgs()
3756 cmsg_data_len = (int)cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh)); in sctp_findassociation_cmsgs()
3853 ph->param_type = htons(SCTP_STATE_COOKIE); in sctp_add_cookie()
3854 ph->param_length = 0; /* fill in at the end */ in sctp_add_cookie()
3858 /* tack the INIT and then the INIT-ACK onto the chain */ in sctp_add_cookie()
3889 ph->param_length = htons(cookie_sz); in sctp_add_cookie()
3898 if ((stcb != NULL) && (stcb->asoc.ecn_supported == 1)) { in sctp_get_ect()
3911 SCTPDBG(SCTP_DEBUG_OUTPUT1, "dropped packet - no valid source addr\n"); in sctp_handle_no_route()
3915 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT1, &net->ro._l_addr.sa); in sctp_handle_no_route()
3916 if (net->dest_state & SCTP_ADDR_CONFIRMED) { in sctp_handle_no_route()
3917 if ((net->dest_state & SCTP_ADDR_REACHABLE) && stcb) { in sctp_handle_no_route()
3923 net->dest_state &= ~SCTP_ADDR_REACHABLE; in sctp_handle_no_route()
3924 net->dest_state &= ~SCTP_ADDR_PF; in sctp_handle_no_route()
3928 if (net == stcb->asoc.primary_destination) { in sctp_handle_no_route()
3934 if (stcb->asoc.alternate) { in sctp_handle_no_route()
3935 sctp_free_remote_addr(stcb->asoc.alternate); in sctp_handle_no_route()
3937 stcb->asoc.alternate = alt; in sctp_handle_no_route()
3938 atomic_add_int(&stcb->asoc.alternate->ref_count, 1); in sctp_handle_no_route()
3939 if (net->ro._s_addr) { in sctp_handle_no_route()
3940 sctp_free_ifa(net->ro._s_addr); in sctp_handle_no_route()
3941 net->ro._s_addr = NULL; in sctp_handle_no_route()
3943 net->src_addr_selected = 0; in sctp_handle_no_route()
3976 * - fill in the HMAC digest of any AUTH chunk in the packet. in sctp_lowlevel_chunk_output()
3977 * - calculate and fill in the SCTP checksum. in sctp_lowlevel_chunk_output()
3978 * - prepend an IP address header. in sctp_lowlevel_chunk_output()
3979 * - if boundall use INADDR_ANY. in sctp_lowlevel_chunk_output()
3980 * - if boundspecific do source address selection. in sctp_lowlevel_chunk_output()
3981 * - set fragmentation option for ipV4. in sctp_lowlevel_chunk_output()
3982 * - On return from IP output, check/adjust mtu size of output in sctp_lowlevel_chunk_output()
4000 if ((net) && (net->dest_state & SCTP_ADDR_OUT_OF_SCOPE)) { in sctp_lowlevel_chunk_output()
4007 vrf_id = stcb->asoc.vrf_id; in sctp_lowlevel_chunk_output()
4009 vrf_id = inp->def_vrf_id; in sctp_lowlevel_chunk_output()
4018 tos_value = net->dscp; in sctp_lowlevel_chunk_output()
4020 tos_value = stcb->asoc.default_dscp; in sctp_lowlevel_chunk_output()
4022 tos_value = inp->sctp_ep.default_dscp; in sctp_lowlevel_chunk_output()
4025 switch (to->sa_family) { in sctp_lowlevel_chunk_output()
4048 m->m_pkthdr.flowid = net->flowid; in sctp_lowlevel_chunk_output()
4049 M_HASHTYPE_SET(m, net->flowtype); in sctp_lowlevel_chunk_output()
4051 m->m_pkthdr.flowid = mflowid; in sctp_lowlevel_chunk_output()
4056 ip->ip_v = IPVERSION; in sctp_lowlevel_chunk_output()
4057 ip->ip_hl = (sizeof(struct ip) >> 2); in sctp_lowlevel_chunk_output()
4064 tos_value = inp->ip_inp.inp.inp_ip_tos; in sctp_lowlevel_chunk_output()
4071 ip->ip_off = htons(IP_DF); in sctp_lowlevel_chunk_output()
4073 ip->ip_off = htons(0); in sctp_lowlevel_chunk_output()
4078 ip->ip_ttl = inp->ip_inp.inp.inp_ip_ttl; in sctp_lowlevel_chunk_output()
4079 ip->ip_len = htons(packet_length); in sctp_lowlevel_chunk_output()
4080 ip->ip_tos = tos_value; in sctp_lowlevel_chunk_output()
4082 ip->ip_p = IPPROTO_UDP; in sctp_lowlevel_chunk_output()
4084 ip->ip_p = IPPROTO_SCTP; in sctp_lowlevel_chunk_output()
4086 ip->ip_sum = 0; in sctp_lowlevel_chunk_output()
4090 memcpy(&ro->ro_dst, to, to->sa_len); in sctp_lowlevel_chunk_output()
4092 ro = (sctp_route_t *)&net->ro; in sctp_lowlevel_chunk_output()
4095 ip->ip_dst.s_addr = ((struct sockaddr_in *)to)->sin_addr.s_addr; in sctp_lowlevel_chunk_output()
4099 …if (net->ro._s_addr && (net->ro._s_addr->localifa_flags & (SCTP_BEING_DELETED | SCTP_ADDR_IFA_UNUS… in sctp_lowlevel_chunk_output()
4100 sctp_free_ifa(net->ro._s_addr); in sctp_lowlevel_chunk_output()
4101 net->ro._s_addr = NULL; in sctp_lowlevel_chunk_output()
4102 net->src_addr_selected = 0; in sctp_lowlevel_chunk_output()
4105 if (net->src_addr_selected == 0) { in sctp_lowlevel_chunk_output()
4107 net->ro._s_addr = sctp_source_address_selection(inp, stcb, in sctp_lowlevel_chunk_output()
4110 net->src_addr_selected = 1; in sctp_lowlevel_chunk_output()
4112 if (net->ro._s_addr == NULL) { in sctp_lowlevel_chunk_output()
4114 net->src_addr_selected = 0; in sctp_lowlevel_chunk_output()
4120 ip->ip_src = net->ro._s_addr->address.sin.sin_addr; in sctp_lowlevel_chunk_output()
4135 ip->ip_src = _lsrc->address.sin.sin_addr; in sctp_lowlevel_chunk_output()
4138 ip->ip_src = over_addr->sin.sin_addr; in sctp_lowlevel_chunk_output()
4139 SCTP_RTALLOC(ro, vrf_id, inp->fibnum); in sctp_lowlevel_chunk_output()
4150 udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); in sctp_lowlevel_chunk_output()
4151 udp->uh_dport = port; in sctp_lowlevel_chunk_output()
4152 udp->uh_ulen = htons((uint16_t)(packet_length - sizeof(struct ip))); in sctp_lowlevel_chunk_output()
4154 … udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); in sctp_lowlevel_chunk_output()
4156 udp->uh_sum = 0; in sctp_lowlevel_chunk_output()
4163 sctphdr->src_port = src_port; in sctp_lowlevel_chunk_output()
4164 sctphdr->dest_port = dest_port; in sctp_lowlevel_chunk_output()
4165 sctphdr->v_tag = v_tag; in sctp_lowlevel_chunk_output()
4166 sctphdr->checksum = 0; in sctp_lowlevel_chunk_output()
4175 if (ro->ro_nh == NULL) { in sctp_lowlevel_chunk_output()
4190 (uint32_t)(ntohl(ip->ip_src.s_addr))); in sctp_lowlevel_chunk_output()
4192 (uint32_t)(ntohl(ip->ip_dst.s_addr))); in sctp_lowlevel_chunk_output()
4194 (void *)ro->ro_nh); in sctp_lowlevel_chunk_output()
4207 sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr)); in sctp_lowlevel_chunk_output()
4217 m->m_pkthdr.csum_flags = CSUM_SCTP; in sctp_lowlevel_chunk_output()
4218 m->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); in sctp_lowlevel_chunk_output()
4242 if ((ro->ro_nh != NULL) && (net->ro._s_addr) && in sctp_lowlevel_chunk_output()
4243 ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0)) { in sctp_lowlevel_chunk_output()
4246 mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_nh); in sctp_lowlevel_chunk_output()
4248 if (net->port) { in sctp_lowlevel_chunk_output()
4249 mtu -= sizeof(struct udphdr); in sctp_lowlevel_chunk_output()
4251 if (mtu < net->mtu) { in sctp_lowlevel_chunk_output()
4252 net->mtu = mtu; in sctp_lowlevel_chunk_output()
4253 if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) { in sctp_lowlevel_chunk_output()
4258 } else if (ro->ro_nh == NULL) { in sctp_lowlevel_chunk_output()
4260 if (net->ro._s_addr && in sctp_lowlevel_chunk_output()
4261 net->src_addr_selected) { in sctp_lowlevel_chunk_output()
4262 sctp_free_ifa(net->ro._s_addr); in sctp_lowlevel_chunk_output()
4263 net->ro._s_addr = NULL; in sctp_lowlevel_chunk_output()
4265 net->src_addr_selected = 0; in sctp_lowlevel_chunk_output()
4286 flowlabel = net->flowlabel; in sctp_lowlevel_chunk_output()
4288 flowlabel = stcb->asoc.default_flowlabel; in sctp_lowlevel_chunk_output()
4290 flowlabel = inp->sctp_ep.default_flowlabel; in sctp_lowlevel_chunk_output()
4298 flowlabel = ntohl(((struct inpcb *)inp)->inp_flow); in sctp_lowlevel_chunk_output()
4316 m->m_pkthdr.flowid = net->flowid; in sctp_lowlevel_chunk_output()
4317 M_HASHTYPE_SET(m, net->flowtype); in sctp_lowlevel_chunk_output()
4319 m->m_pkthdr.flowid = mflowid; in sctp_lowlevel_chunk_output()
4339 memcpy(&ro->ro_dst, sin6, sin6->sin6_len); in sctp_lowlevel_chunk_output()
4341 ro = (sctp_route_t *)&net->ro; in sctp_lowlevel_chunk_output()
4353 tos_value = (ntohl(((struct inpcb *)inp)->inp_flow) >> 20) & 0xff; in sctp_lowlevel_chunk_output()
4364 ip6h->ip6_flow = htonl(flowinfo); in sctp_lowlevel_chunk_output()
4366 ip6h->ip6_nxt = IPPROTO_UDP; in sctp_lowlevel_chunk_output()
4368 ip6h->ip6_nxt = IPPROTO_SCTP; in sctp_lowlevel_chunk_output()
4370 ip6h->ip6_plen = htons((uint16_t)(packet_length - sizeof(struct ip6_hdr))); in sctp_lowlevel_chunk_output()
4371 ip6h->ip6_dst = sin6->sin6_addr; in sctp_lowlevel_chunk_output()
4375 * to a limited degree the kame src-addr-sel, since in sctp_lowlevel_chunk_output()
4384 …if (net->ro._s_addr && (net->ro._s_addr->localifa_flags & (SCTP_BEING_DELETED | SCTP_ADDR_IFA_UNUS… in sctp_lowlevel_chunk_output()
4385 sctp_free_ifa(net->ro._s_addr); in sctp_lowlevel_chunk_output()
4386 net->ro._s_addr = NULL; in sctp_lowlevel_chunk_output()
4387 net->src_addr_selected = 0; in sctp_lowlevel_chunk_output()
4390 if (net->src_addr_selected == 0) { in sctp_lowlevel_chunk_output()
4391 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; in sctp_lowlevel_chunk_output()
4399 net->ro._s_addr = sctp_source_address_selection(inp, in sctp_lowlevel_chunk_output()
4406 net->src_addr_selected = 1; in sctp_lowlevel_chunk_output()
4408 if (net->ro._s_addr == NULL) { in sctp_lowlevel_chunk_output()
4410 net->src_addr_selected = 0; in sctp_lowlevel_chunk_output()
4416 lsa6->sin6_addr = net->ro._s_addr->address.sin6.sin6_addr; in sctp_lowlevel_chunk_output()
4418 sin6 = (struct sockaddr_in6 *)&ro->ro_dst; in sctp_lowlevel_chunk_output()
4438 lsa6->sin6_addr = _lsrc->address.sin6.sin6_addr; in sctp_lowlevel_chunk_output()
4441 lsa6->sin6_addr = over_addr->sin6.sin6_addr; in sctp_lowlevel_chunk_output()
4442 SCTP_RTALLOC(ro, vrf_id, inp->fibnum); in sctp_lowlevel_chunk_output()
4446 lsa6->sin6_port = inp->sctp_lport; in sctp_lowlevel_chunk_output()
4448 if (ro->ro_nh == NULL) { in sctp_lowlevel_chunk_output()
4461 * the non-SCOPEDROUTING case. in sctp_lowlevel_chunk_output()
4466 lsa6_storage.sin6_addr = lsa6->sin6_addr; in sctp_lowlevel_chunk_output()
4473 lsa6_storage.sin6_addr = lsa6->sin6_addr; in sctp_lowlevel_chunk_output()
4474 lsa6_storage.sin6_port = inp->sctp_lport; in sctp_lowlevel_chunk_output()
4476 ip6h->ip6_src = lsa6->sin6_addr; in sctp_lowlevel_chunk_output()
4486 udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); in sctp_lowlevel_chunk_output()
4487 udp->uh_dport = port; in sctp_lowlevel_chunk_output()
4488 udp->uh_ulen = htons((uint16_t)(packet_length - sizeof(struct ip6_hdr))); in sctp_lowlevel_chunk_output()
4489 udp->uh_sum = 0; in sctp_lowlevel_chunk_output()
4495 sctphdr->src_port = src_port; in sctp_lowlevel_chunk_output()
4496 sctphdr->dest_port = dest_port; in sctp_lowlevel_chunk_output()
4497 sctphdr->v_tag = v_tag; in sctp_lowlevel_chunk_output()
4498 sctphdr->checksum = 0; in sctp_lowlevel_chunk_output()
4504 ip6h->ip6_hlim = SCTP_GET_HLIM(inp, ro); in sctp_lowlevel_chunk_output()
4509 sin6->sin6_addr = ip6h->ip6_dst; in sctp_lowlevel_chunk_output()
4510 lsa6->sin6_addr = ip6h->ip6_src; in sctp_lowlevel_chunk_output()
4519 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; in sctp_lowlevel_chunk_output()
4524 prev_scope = sin6->sin6_scope_id; in sctp_lowlevel_chunk_output()
4525 prev_port = sin6->sin6_port; in sctp_lowlevel_chunk_output()
4536 sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); in sctp_lowlevel_chunk_output()
4538 …if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), packet_length - sizeof(st… in sctp_lowlevel_chunk_output()
4539 udp->uh_sum = 0xffff; in sctp_lowlevel_chunk_output()
4542 m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; in sctp_lowlevel_chunk_output()
4543 m->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); in sctp_lowlevel_chunk_output()
4555 sin6->sin6_scope_id = prev_scope; in sctp_lowlevel_chunk_output()
4556 sin6->sin6_port = prev_port; in sctp_lowlevel_chunk_output()
4575 if (ro->ro_nh == NULL) { in sctp_lowlevel_chunk_output()
4577 if (net->ro._s_addr && in sctp_lowlevel_chunk_output()
4578 net->src_addr_selected) { in sctp_lowlevel_chunk_output()
4579 sctp_free_ifa(net->ro._s_addr); in sctp_lowlevel_chunk_output()
4580 net->ro._s_addr = NULL; in sctp_lowlevel_chunk_output()
4582 net->src_addr_selected = 0; in sctp_lowlevel_chunk_output()
4584 if ((ro->ro_nh != NULL) && (net->ro._s_addr) && in sctp_lowlevel_chunk_output()
4585 ((net->dest_state & SCTP_ADDR_NO_PMTUD) == 0)) { in sctp_lowlevel_chunk_output()
4588 mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, ro->ro_nh); in sctp_lowlevel_chunk_output()
4590 if (net->port) { in sctp_lowlevel_chunk_output()
4591 mtu -= sizeof(struct udphdr); in sctp_lowlevel_chunk_output()
4593 if (mtu < net->mtu) { in sctp_lowlevel_chunk_output()
4594 net->mtu = mtu; in sctp_lowlevel_chunk_output()
4595 if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) { in sctp_lowlevel_chunk_output()
4601 if ((ND_IFINFO(ifp)->linkmtu > 0) && in sctp_lowlevel_chunk_output()
4602 (stcb->asoc.smallest_mtu > ND_IFINFO(ifp)->linkmtu)) { in sctp_lowlevel_chunk_output()
4603 sctp_pathmtu_adjustment(stcb, ND_IFINFO(ifp)->linkmtu, false); in sctp_lowlevel_chunk_output()
4612 ((struct sockaddr *)to)->sa_family); in sctp_lowlevel_chunk_output()
4635 net = stcb->asoc.primary_destination; in sctp_send_initiate()
4637 net = TAILQ_FIRST(&stcb->asoc.nets); in sctp_send_initiate()
4643 net->dest_state &= ~SCTP_ADDR_UNCONFIRMED; in sctp_send_initiate()
4647 net->dest_state &= ~SCTP_ADDR_UNCONFIRMED; in sctp_send_initiate()
4651 if (net->ro._l_addr.sa.sa_family == AF_INET6) { in sctp_send_initiate()
4656 if (IN6_IS_ADDR_LINKLOCAL(&net->ro._l_addr.sin6.sin6_addr)) in sctp_send_initiate()
4660 if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { in sctp_send_initiate()
4662 SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - failed timer?\n"); in sctp_send_initiate()
4665 /* start the INIT timer */ in sctp_send_initiate()
4670 /* No memory, INIT timer will re-attempt. */ in sctp_send_initiate()
4671 SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - mbuf?\n"); in sctp_send_initiate()
4679 init->ch.chunk_type = SCTP_INITIATION; in sctp_send_initiate()
4680 init->ch.chunk_flags = 0; in sctp_send_initiate()
4682 init->ch.chunk_length = 0; in sctp_send_initiate()
4684 init->init.initiate_tag = htonl(stcb->asoc.my_vtag); in sctp_send_initiate()
4686 init->init.a_rwnd = htonl(max(inp->sctp_socket ? SCTP_SB_LIMIT_RCV(inp->sctp_socket) : 0, in sctp_send_initiate()
4688 init->init.num_outbound_streams = htons(stcb->asoc.pre_open_streams); in sctp_send_initiate()
4689 init->init.num_inbound_streams = htons(stcb->asoc.max_inbound_streams); in sctp_send_initiate()
4690 init->init.initial_tsn = htonl(stcb->asoc.init_seq_number); in sctp_send_initiate()
4693 if (inp->sctp_ep.adaptation_layer_indicator_provided) { in sctp_send_initiate()
4696 ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); in sctp_send_initiate()
4697 ali->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4698 ali->indication = htonl(inp->sctp_ep.adaptation_layer_indicator); in sctp_send_initiate()
4703 if (stcb->asoc.ecn_supported == 1) { in sctp_send_initiate()
4706 ph->param_type = htons(SCTP_ECN_CAPABLE); in sctp_send_initiate()
4707 ph->param_length = htons(parameter_len); in sctp_send_initiate()
4711 /* PR-SCTP supported parameter */ in sctp_send_initiate()
4712 if (stcb->asoc.prsctp_supported == 1) { in sctp_send_initiate()
4715 ph->param_type = htons(SCTP_PRSCTP_SUPPORTED); in sctp_send_initiate()
4716 ph->param_length = htons(parameter_len); in sctp_send_initiate()
4721 if (stcb->asoc.rcv_edmid != SCTP_EDMID_NONE) { in sctp_send_initiate()
4724 zero_chksum->ph.param_type = htons(SCTP_ZERO_CHECKSUM_ACCEPTABLE); in sctp_send_initiate()
4725 zero_chksum->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4726 zero_chksum->edmid = htonl(stcb->asoc.rcv_edmid); in sctp_send_initiate()
4734 ph->param_type = htons(SCTP_HAS_NAT_SUPPORT); in sctp_send_initiate()
4735 ph->param_length = htons(parameter_len); in sctp_send_initiate()
4742 if (stcb->asoc.prsctp_supported == 1) { in sctp_send_initiate()
4743 pr_supported->chunk_types[num_ext++] = SCTP_FORWARD_CUM_TSN; in sctp_send_initiate()
4744 if (stcb->asoc.idata_supported) { in sctp_send_initiate()
4745 pr_supported->chunk_types[num_ext++] = SCTP_IFORWARD_CUM_TSN; in sctp_send_initiate()
4748 if (stcb->asoc.auth_supported == 1) { in sctp_send_initiate()
4749 pr_supported->chunk_types[num_ext++] = SCTP_AUTHENTICATION; in sctp_send_initiate()
4751 if (stcb->asoc.asconf_supported == 1) { in sctp_send_initiate()
4752 pr_supported->chunk_types[num_ext++] = SCTP_ASCONF; in sctp_send_initiate()
4753 pr_supported->chunk_types[num_ext++] = SCTP_ASCONF_ACK; in sctp_send_initiate()
4755 if (stcb->asoc.reconfig_supported == 1) { in sctp_send_initiate()
4756 pr_supported->chunk_types[num_ext++] = SCTP_STREAM_RESET; in sctp_send_initiate()
4758 if (stcb->asoc.idata_supported) { in sctp_send_initiate()
4759 pr_supported->chunk_types[num_ext++] = SCTP_IDATA; in sctp_send_initiate()
4761 if (stcb->asoc.nrsack_supported == 1) { in sctp_send_initiate()
4762 pr_supported->chunk_types[num_ext++] = SCTP_NR_SELECTIVE_ACK; in sctp_send_initiate()
4764 if (stcb->asoc.pktdrop_supported == 1) { in sctp_send_initiate()
4765 pr_supported->chunk_types[num_ext++] = SCTP_PACKET_DROPPED; in sctp_send_initiate()
4769 pr_supported->ph.param_type = htons(SCTP_SUPPORTED_CHUNK_EXT); in sctp_send_initiate()
4770 pr_supported->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4771 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate()
4775 if (stcb->asoc.auth_supported) { in sctp_send_initiate()
4777 if (stcb->asoc.authinfo.random != NULL) { in sctp_send_initiate()
4786 parameter_len = (uint16_t)sizeof(struct sctp_auth_random) + stcb->asoc.authinfo.random_len; in sctp_send_initiate()
4788 memcpy(randp, stcb->asoc.authinfo.random->key, parameter_len); in sctp_send_initiate()
4789 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate()
4793 if (stcb->asoc.local_hmacs != NULL) { in sctp_send_initiate()
4803 stcb->asoc.local_hmacs->num_algo * sizeof(uint16_t)); in sctp_send_initiate()
4804 hmacs->ph.param_type = htons(SCTP_HMAC_LIST); in sctp_send_initiate()
4805 hmacs->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4806 sctp_serialize_hmaclist(stcb->asoc.local_hmacs, (uint8_t *)hmacs->hmac_ids); in sctp_send_initiate()
4807 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate()
4811 if (stcb->asoc.local_auth_chunks != NULL) { in sctp_send_initiate()
4821 sctp_auth_get_chklist_size(stcb->asoc.local_auth_chunks)); in sctp_send_initiate()
4822 chunks->ph.param_type = htons(SCTP_CHUNK_LIST); in sctp_send_initiate()
4823 chunks->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4824 sctp_serialize_auth_chunks(stcb->asoc.local_auth_chunks, chunks->chunk_types); in sctp_send_initiate()
4825 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate()
4831 if (stcb->asoc.cookie_preserve_req > 0) { in sctp_send_initiate()
4841 cookie_preserve->ph.param_type = htons(SCTP_COOKIE_PRESERVE); in sctp_send_initiate()
4842 cookie_preserve->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4843 cookie_preserve->time = htonl(stcb->asoc.cookie_preserve_req); in sctp_send_initiate()
4844 stcb->asoc.cookie_preserve_req = 0; in sctp_send_initiate()
4848 if (stcb->asoc.scope.ipv4_addr_legal || stcb->asoc.scope.ipv6_addr_legal) { in sctp_send_initiate()
4857 if (stcb->asoc.scope.ipv4_addr_legal) { in sctp_send_initiate()
4860 if (stcb->asoc.scope.ipv6_addr_legal) { in sctp_send_initiate()
4864 sup_addr->ph.param_type = htons(SCTP_SUPPORTED_ADDRTYPE); in sctp_send_initiate()
4865 sup_addr->ph.param_length = htons(parameter_len); in sctp_send_initiate()
4867 if (stcb->asoc.scope.ipv4_addr_legal) { in sctp_send_initiate()
4868 sup_addr->addr_type[i++] = htons(SCTP_IPV4_ADDRESS); in sctp_send_initiate()
4870 if (stcb->asoc.scope.ipv6_addr_legal) { in sctp_send_initiate()
4871 sup_addr->addr_type[i++] = htons(SCTP_IPV6_ADDRESS); in sctp_send_initiate()
4873 padding_len = 4 - 2 * i; in sctp_send_initiate()
4885 m_last = sctp_add_addresses_to_i_ia(inp, stcb, &stcb->asoc.scope, in sctp_send_initiate()
4889 init->ch.chunk_length = htons(chunk_len); in sctp_send_initiate()
4896 SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n"); in sctp_send_initiate()
4898 (struct sockaddr *)&net->ro._l_addr, in sctp_send_initiate()
4900 inp->sctp_lport, stcb->rport, htonl(0), in sctp_send_initiate()
4901 net->port, NULL, in sctp_send_initiate()
4906 stcb->asoc.ifp_had_enobuf = 1; in sctp_send_initiate()
4910 stcb->asoc.ifp_had_enobuf = 0; in sctp_send_initiate()
4913 (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time); in sctp_send_initiate()
4925 * Given a mbuf containing an INIT or INIT-ACK with the param_offset in sctp_arethere_unrecognized_parameters()
4934 * By having param_offset be pre-set to where parameters begin it is in sctp_arethere_unrecognized_parameters()
4952 limit = ntohs(cp->chunk_length) - sizeof(struct sctp_init_chunk); in sctp_arethere_unrecognized_parameters()
4960 ptype = ntohs(phdr->param_type); in sctp_arethere_unrecognized_parameters()
4961 plen = ntohs(phdr->param_length); in sctp_arethere_unrecognized_parameters()
4964 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error %d\n", plen); in sctp_arethere_unrecognized_parameters()
4967 limit -= SCTP_SIZE32(plen); in sctp_arethere_unrecognized_parameters()
4968 /*- in sctp_arethere_unrecognized_parameters()
4973 * an operr.. to either incorporate (init-ack) or send. in sctp_arethere_unrecognized_parameters()
4994 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error chklist %d\n", plen); in sctp_arethere_unrecognized_parameters()
5001 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error supaddrtype %d\n", plen); in sctp_arethere_unrecognized_parameters()
5008 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error checksum acceptable %d\n", plen); in sctp_arethere_unrecognized_parameters()
5017 *edmid = ntohl(zero_chksum_p->edmid); in sctp_arethere_unrecognized_parameters()
5024 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error random %d\n", plen); in sctp_arethere_unrecognized_parameters()
5034 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error setprim %d\n", plen); in sctp_arethere_unrecognized_parameters()
5042 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error ipv4 addr %d\n", plen); in sctp_arethere_unrecognized_parameters()
5049 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error ipv6 addr %d\n", plen); in sctp_arethere_unrecognized_parameters()
5056 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error cookie-preserve %d\n", plen); in sctp_arethere_unrecognized_parameters()
5063 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error nat support %d\n", plen); in sctp_arethere_unrecognized_parameters()
5071 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error prsctp %d\n", plen); in sctp_arethere_unrecognized_parameters()
5078 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error ecn %d\n", plen); in sctp_arethere_unrecognized_parameters()
5085 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error adapatation %d\n", plen); in sctp_arethere_unrecognized_parameters()
5092 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error success %d\n", plen); in sctp_arethere_unrecognized_parameters()
5118 * Pre-reserve space for IP, SCTP, in sctp_arethere_unrecognized_parameters()
5130 cause->code = htons(SCTP_CAUSE_UNRESOLVABLE_ADDR); in sctp_arethere_unrecognized_parameters()
5131 cause->length = htons((uint16_t)(sizeof(struct sctp_gen_error_cause) + plen)); in sctp_arethere_unrecognized_parameters()
5201 param->param_type = htons(SCTP_UNRECOG_PARAM); in sctp_arethere_unrecognized_parameters()
5202 param->param_length = htons((uint16_t)sizeof(struct sctp_paramhdr) + plen); in sctp_arethere_unrecognized_parameters()
5216 pad_needed = 4 - (plen % 4); in sctp_arethere_unrecognized_parameters()
5264 param->param_type = htons(SCTP_CAUSE_PROTOCOL_VIOLATION); in sctp_arethere_unrecognized_parameters()
5265 param->param_length = htons(2 * sizeof(struct sctp_paramhdr)); in sctp_arethere_unrecognized_parameters()
5267 param->param_type = htons(ptype); in sctp_arethere_unrecognized_parameters()
5268 param->param_length = htons(plen); in sctp_arethere_unrecognized_parameters()
5313 switch (src->sa_family) { in sctp_are_there_new_addresses()
5316 if (asoc->scope.ipv4_addr_legal) { in sctp_are_there_new_addresses()
5323 if (asoc->scope.ipv6_addr_legal) { in sctp_are_there_new_addresses()
5334 TAILQ_FOREACH(net, &asoc->nets, sctp_next) { in sctp_are_there_new_addresses()
5335 sa = (struct sockaddr *)&net->ro._l_addr; in sctp_are_there_new_addresses()
5336 if (sa->sa_family == src->sa_family) { in sctp_are_there_new_addresses()
5338 if (sa->sa_family == AF_INET) { in sctp_are_there_new_addresses()
5343 if (sa4->sin_addr.s_addr == src4->sin_addr.s_addr) { in sctp_are_there_new_addresses()
5350 if (sa->sa_family == AF_INET6) { in sctp_are_there_new_addresses()
5379 ptype = ntohs(phdr->param_type); in sctp_are_there_new_addresses()
5380 plen = ntohs(phdr->param_length); in sctp_are_there_new_addresses()
5405 if (asoc->scope.ipv4_addr_legal) { in sctp_are_there_new_addresses()
5407 sin4.sin_addr.s_addr = p4->addr; in sctp_are_there_new_addresses()
5428 if (asoc->scope.ipv6_addr_legal) { in sctp_are_there_new_addresses()
5430 memcpy((caddr_t)&sin6.sin6_addr, p6->addr, in sctp_are_there_new_addresses()
5431 sizeof(p6->addr)); in sctp_are_there_new_addresses()
5444 TAILQ_FOREACH(net, &asoc->nets, sctp_next) { in sctp_are_there_new_addresses()
5445 sa = (struct sockaddr *)&net->ro._l_addr; in sctp_are_there_new_addresses()
5446 if (sa->sa_family != sa_touse->sa_family) { in sctp_are_there_new_addresses()
5450 if (sa->sa_family == AF_INET) { in sctp_are_there_new_addresses()
5452 if (sa4->sin_addr.s_addr == in sctp_are_there_new_addresses()
5460 if (sa->sa_family == AF_INET6) { in sctp_are_there_new_addresses()
5493 * INIT-ACK with COOKIE and send back. We assume that the in_initpkt has done
5541 asoc = &stcb->asoc; in sctp_send_initiate_ack()
5547 …if (sctp_are_there_new_addresses(asoc, init_pkt, offset, offset + ntohs(init_chk->ch.chunk_length)… in sctp_send_initiate_ack()
5549 * new addresses, out of here in non-cookie-wait in sctp_send_initiate_ack()
5553 mflowtype, mflowid, inp->fibnum, in sctp_send_initiate_ack()
5557 if (src_net != NULL && (src_net->port != port)) { in sctp_send_initiate_ack()
5560 * in non-cookie-wait states in sctp_send_initiate_ack()
5569 mflowtype, mflowid, inp->fibnum, in sctp_send_initiate_ack()
5590 init_chk->init.initiate_tag, op_err, in sctp_send_initiate_ack()
5591 mflowtype, mflowid, inp->fibnum, in sctp_send_initiate_ack()
5597 /* No memory, INIT timer will re-attempt. */ in sctp_send_initiate_ack()
5620 stc.tie_tag_my_vtag = asoc->my_vtag_nonce; in sctp_send_initiate_ack()
5621 stc.tie_tag_peer_vtag = asoc->peer_vtag_nonce; in sctp_send_initiate_ack()
5622 stc.cookie_life = asoc->cookie_life; in sctp_send_initiate_ack()
5623 net = asoc->primary_destination; in sctp_send_initiate_ack()
5628 stc.cookie_life = inp->sctp_ep.def_cookie_life; in sctp_send_initiate_ack()
5632 stc.myport = sh->dest_port; in sctp_send_initiate_ack()
5633 stc.peerport = sh->src_port; in sctp_send_initiate_ack()
5640 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { in sctp_send_initiate_ack()
5654 switch (dst->sa_family) { in sctp_send_initiate_ack()
5659 stc.address[0] = src4->sin_addr.s_addr; in sctp_send_initiate_ack()
5665 stc.laddress[0] = dst4->sin_addr.s_addr; in sctp_send_initiate_ack()
5672 if ((IN4_ISPRIVATE_ADDRESS(&src4->sin_addr)) || in sctp_send_initiate_ack()
5673 (IN4_ISPRIVATE_ADDRESS(&dst4->sin_addr))) { in sctp_send_initiate_ack()
5690 memcpy(&stc.address, &src6->sin6_addr, sizeof(struct in6_addr)); in sctp_send_initiate_ack()
5691 stc.scope_id = ntohs(in6_getscope(&src6->sin6_addr)); in sctp_send_initiate_ack()
5697 } else if (IN6_IS_ADDR_LINKLOCAL(&src6->sin6_addr) || in sctp_send_initiate_ack()
5698 IN6_IS_ADDR_LINKLOCAL(&dst6->sin6_addr)) { in sctp_send_initiate_ack()
5724 } else if (IN6_IS_ADDR_SITELOCAL(&src6->sin6_addr) || in sctp_send_initiate_ack()
5725 IN6_IS_ADDR_SITELOCAL(&dst6->sin6_addr)) { in sctp_send_initiate_ack()
5733 memcpy(&stc.laddress, &dst6->sin6_addr, sizeof(struct in6_addr)); in sctp_send_initiate_ack()
5750 stc.loopback_scope = asoc->scope.loopback_scope; in sctp_send_initiate_ack()
5751 stc.ipv4_scope = asoc->scope.ipv4_local_scope; in sctp_send_initiate_ack()
5752 stc.site_scope = asoc->scope.site_scope; in sctp_send_initiate_ack()
5753 stc.local_scope = asoc->scope.local_scope; in sctp_send_initiate_ack()
5756 TAILQ_FOREACH(lnet, &asoc->nets, sctp_next) { in sctp_send_initiate_ack()
5757 if (lnet->ro._l_addr.sin6.sin6_family == AF_INET6) { in sctp_send_initiate_ack()
5758 if (IN6_IS_ADDR_LINKLOCAL(&lnet->ro._l_addr.sin6.sin6_addr)) { in sctp_send_initiate_ack()
5769 to = (struct sockaddr *)&net->ro._l_addr; in sctp_send_initiate_ack()
5770 switch (to->sa_family) { in sctp_send_initiate_ack()
5774 stc.address[0] = sin->sin_addr.s_addr; in sctp_send_initiate_ack()
5779 if (net->src_addr_selected == 0) { in sctp_send_initiate_ack()
5784 net->ro._s_addr = sctp_source_address_selection(inp, in sctp_send_initiate_ack()
5785 stcb, (sctp_route_t *)&net->ro, in sctp_send_initiate_ack()
5787 if (net->ro._s_addr == NULL) { in sctp_send_initiate_ack()
5793 net->src_addr_selected = 1; in sctp_send_initiate_ack()
5795 stc.laddress[0] = net->ro._s_addr->address.sin.sin_addr.s_addr; in sctp_send_initiate_ack()
5807 memcpy(&stc.address, &sin6->sin6_addr, in sctp_send_initiate_ack()
5810 stc.scope_id = sin6->sin6_scope_id; in sctp_send_initiate_ack()
5811 if (net->src_addr_selected == 0) { in sctp_send_initiate_ack()
5816 net->ro._s_addr = sctp_source_address_selection(inp, in sctp_send_initiate_ack()
5817 stcb, (sctp_route_t *)&net->ro, in sctp_send_initiate_ack()
5819 if (net->ro._s_addr == NULL) { in sctp_send_initiate_ack()
5825 net->src_addr_selected = 1; in sctp_send_initiate_ack()
5827 memcpy(&stc.laddress, &net->ro._s_addr->address.sin6.sin6_addr, in sctp_send_initiate_ack()
5835 stc.rcv_edmid = asoc->rcv_edmid; in sctp_send_initiate_ack()
5837 stc.rcv_edmid = inp->rcv_edmid; in sctp_send_initiate_ack()
5842 stc.peers_vtag = ntohl(init_chk->init.initiate_tag); in sctp_send_initiate_ack()
5848 initack->ch.chunk_type = SCTP_INITIATION_ACK; in sctp_send_initiate_ack()
5849 initack->ch.chunk_flags = 0; in sctp_send_initiate_ack()
5851 initack->ch.chunk_length = 0; in sctp_send_initiate_ack()
5857 /* re-use the v-tags and init-seq here */ in sctp_send_initiate_ack()
5858 initack->init.initiate_tag = htonl(asoc->my_vtag); in sctp_send_initiate_ack()
5859 initack->init.initial_tsn = htonl(asoc->init_seq_number); in sctp_send_initiate_ack()
5864 atomic_add_int(&asoc->refcnt, 1); in sctp_send_initiate_ack()
5868 vtag = sctp_select_a_tag(inp, inp->sctp_lport, sh->src_port, 1); in sctp_send_initiate_ack()
5870 if ((asoc->peer_supports_nat) && (vtag == asoc->my_vtag)) { in sctp_send_initiate_ack()
5877 initack->init.initiate_tag = htonl(vtag); in sctp_send_initiate_ack()
5879 itsn = sctp_select_initial_TSN(&inp->sctp_ep); in sctp_send_initiate_ack()
5880 initack->init.initial_tsn = htonl(itsn); in sctp_send_initiate_ack()
5882 atomic_subtract_int(&asoc->refcnt, 1); in sctp_send_initiate_ack()
5887 vtag = sctp_select_a_tag(inp, inp->sctp_lport, sh->src_port, 1); in sctp_send_initiate_ack()
5889 initack->init.initiate_tag = htonl(vtag); in sctp_send_initiate_ack()
5891 initack->init.initial_tsn = htonl(sctp_select_initial_TSN(&inp->sctp_ep)); in sctp_send_initiate_ack()
5897 stc.my_vtag = initack->init.initiate_tag; in sctp_send_initiate_ack()
5900 so = inp->sctp_socket; in sctp_send_initiate_ack()
5907 initack->init.a_rwnd = htonl(max(SCTP_SB_LIMIT_RCV(so), SCTP_MINIMAL_RWND)); in sctp_send_initiate_ack()
5910 his_limit = ntohs(init_chk->init.num_inbound_streams); in sctp_send_initiate_ack()
5913 if (asoc->streamoutcnt > asoc->pre_open_streams) { in sctp_send_initiate_ack()
5914 i_want = asoc->streamoutcnt; in sctp_send_initiate_ack()
5916 i_want = asoc->pre_open_streams; in sctp_send_initiate_ack()
5919 i_want = inp->sctp_ep.pre_open_stream_count; in sctp_send_initiate_ack()
5923 initack->init.num_outbound_streams = init_chk->init.num_inbound_streams; in sctp_send_initiate_ack()
5926 initack->init.num_outbound_streams = htons(i_want); in sctp_send_initiate_ack()
5929 initack->init.num_inbound_streams = in sctp_send_initiate_ack()
5930 htons(inp->sctp_ep.max_open_streams_intome); in sctp_send_initiate_ack()
5933 if (inp->sctp_ep.adaptation_layer_indicator_provided) { in sctp_send_initiate_ack()
5936 ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); in sctp_send_initiate_ack()
5937 ali->ph.param_length = htons(parameter_len); in sctp_send_initiate_ack()
5938 ali->indication = htonl(inp->sctp_ep.adaptation_layer_indicator); in sctp_send_initiate_ack()
5943 if (((asoc != NULL) && (asoc->ecn_supported == 1)) || in sctp_send_initiate_ack()
5944 ((asoc == NULL) && (inp->ecn_supported == 1))) { in sctp_send_initiate_ack()
5947 ph->param_type = htons(SCTP_ECN_CAPABLE); in sctp_send_initiate_ack()
5948 ph->param_length = htons(parameter_len); in sctp_send_initiate_ack()
5952 /* PR-SCTP supported parameter */ in sctp_send_initiate_ack()
5953 if (((asoc != NULL) && (asoc->prsctp_supported == 1)) || in sctp_send_initiate_ack()
5954 ((asoc == NULL) && (inp->prsctp_supported == 1))) { in sctp_send_initiate_ack()
5957 ph->param_type = htons(SCTP_PRSCTP_SUPPORTED); in sctp_send_initiate_ack()
5958 ph->param_length = htons(parameter_len); in sctp_send_initiate_ack()
5963 if (((asoc != NULL) && (asoc->rcv_edmid != SCTP_EDMID_NONE)) || in sctp_send_initiate_ack()
5964 ((asoc == NULL) && (inp->rcv_edmid != SCTP_EDMID_NONE))) { in sctp_send_initiate_ack()
5967 zero_chksum->ph.param_type = htons(SCTP_ZERO_CHECKSUM_ACCEPTABLE); in sctp_send_initiate_ack()
5968 zero_chksum->ph.param_length = htons(parameter_len); in sctp_send_initiate_ack()
5970 zero_chksum->edmid = htonl(asoc->rcv_edmid); in sctp_send_initiate_ack()
5972 zero_chksum->edmid = htonl(inp->rcv_edmid); in sctp_send_initiate_ack()
5981 ph->param_type = htons(SCTP_HAS_NAT_SUPPORT); in sctp_send_initiate_ack()
5982 ph->param_length = htons(parameter_len); in sctp_send_initiate_ack()
5989 if (((asoc != NULL) && (asoc->prsctp_supported == 1)) || in sctp_send_initiate_ack()
5990 ((asoc == NULL) && (inp->prsctp_supported == 1))) { in sctp_send_initiate_ack()
5991 pr_supported->chunk_types[num_ext++] = SCTP_FORWARD_CUM_TSN; in sctp_send_initiate_ack()
5992 if (((asoc != NULL) && (asoc->idata_supported == 1)) || in sctp_send_initiate_ack()
5993 ((asoc == NULL) && (inp->idata_supported == 1))) { in sctp_send_initiate_ack()
5994 pr_supported->chunk_types[num_ext++] = SCTP_IFORWARD_CUM_TSN; in sctp_send_initiate_ack()
5997 if (((asoc != NULL) && (asoc->auth_supported == 1)) || in sctp_send_initiate_ack()
5998 ((asoc == NULL) && (inp->auth_supported == 1))) { in sctp_send_initiate_ack()
5999 pr_supported->chunk_types[num_ext++] = SCTP_AUTHENTICATION; in sctp_send_initiate_ack()
6001 if (((asoc != NULL) && (asoc->asconf_supported == 1)) || in sctp_send_initiate_ack()
6002 ((asoc == NULL) && (inp->asconf_supported == 1))) { in sctp_send_initiate_ack()
6003 pr_supported->chunk_types[num_ext++] = SCTP_ASCONF; in sctp_send_initiate_ack()
6004 pr_supported->chunk_types[num_ext++] = SCTP_ASCONF_ACK; in sctp_send_initiate_ack()
6006 if (((asoc != NULL) && (asoc->reconfig_supported == 1)) || in sctp_send_initiate_ack()
6007 ((asoc == NULL) && (inp->reconfig_supported == 1))) { in sctp_send_initiate_ack()
6008 pr_supported->chunk_types[num_ext++] = SCTP_STREAM_RESET; in sctp_send_initiate_ack()
6010 if (((asoc != NULL) && (asoc->idata_supported == 1)) || in sctp_send_initiate_ack()
6011 ((asoc == NULL) && (inp->idata_supported == 1))) { in sctp_send_initiate_ack()
6012 pr_supported->chunk_types[num_ext++] = SCTP_IDATA; in sctp_send_initiate_ack()
6014 if (((asoc != NULL) && (asoc->nrsack_supported == 1)) || in sctp_send_initiate_ack()
6015 ((asoc == NULL) && (inp->nrsack_supported == 1))) { in sctp_send_initiate_ack()
6016 pr_supported->chunk_types[num_ext++] = SCTP_NR_SELECTIVE_ACK; in sctp_send_initiate_ack()
6018 if (((asoc != NULL) && (asoc->pktdrop_supported == 1)) || in sctp_send_initiate_ack()
6019 ((asoc == NULL) && (inp->pktdrop_supported == 1))) { in sctp_send_initiate_ack()
6020 pr_supported->chunk_types[num_ext++] = SCTP_PACKET_DROPPED; in sctp_send_initiate_ack()
6024 pr_supported->ph.param_type = htons(SCTP_SUPPORTED_CHUNK_EXT); in sctp_send_initiate_ack()
6025 pr_supported->ph.param_length = htons(parameter_len); in sctp_send_initiate_ack()
6026 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate_ack()
6031 if (((asoc != NULL) && (asoc->auth_supported == 1)) || in sctp_send_initiate_ack()
6032 ((asoc == NULL) && (inp->auth_supported == 1))) { in sctp_send_initiate_ack()
6046 randp->ph.param_type = htons(SCTP_RANDOM); in sctp_send_initiate_ack()
6047 randp->ph.param_length = htons(parameter_len); in sctp_send_initiate_ack()
6048 SCTP_READ_RANDOM(randp->random_data, SCTP_AUTH_RANDOM_SIZE_DEFAULT); in sctp_send_initiate_ack()
6049 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate_ack()
6060 sctp_serialize_hmaclist(inp->sctp_ep.local_hmacs, in sctp_send_initiate_ack()
6061 (uint8_t *)hmacs->hmac_ids); in sctp_send_initiate_ack()
6062 hmacs->ph.param_type = htons(SCTP_HMAC_LIST); in sctp_send_initiate_ack()
6063 hmacs->ph.param_length = htons(parameter_len); in sctp_send_initiate_ack()
6064 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate_ack()
6075 sctp_serialize_auth_chunks(inp->sctp_ep.local_auth_chunks, in sctp_send_initiate_ack()
6076 chunks->chunk_types); in sctp_send_initiate_ack()
6077 chunks->ph.param_type = htons(SCTP_CHUNK_LIST); in sctp_send_initiate_ack()
6078 chunks->ph.param_length = htons(parameter_len); in sctp_send_initiate_ack()
6079 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate_ack()
6114 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate_ack()
6147 padding_len = SCTP_SIZE32(parameter_len) - parameter_len; in sctp_send_initiate_ack()
6152 * the INIT-ACK. in sctp_send_initiate_ack()
6154 initack->ch.chunk_length = htons(chunk_len); in sctp_send_initiate_ack()
6161 (uint8_t *)inp->sctp_ep.secret_key[(int)(inp->sctp_ep.current_secret_number)], in sctp_send_initiate_ack()
6166 * here since the timer will drive a retranmission. in sctp_send_initiate_ack()
6181 use_zero_crc = (asoc->rcv_edmid != SCTP_EDMID_NONE) && (asoc->rcv_edmid == edmid); in sctp_send_initiate_ack()
6183 use_zero_crc = (inp->rcv_edmid != SCTP_EDMID_NONE) && (inp->rcv_edmid == edmid); in sctp_send_initiate_ack()
6188 inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag, in sctp_send_initiate_ack()
6196 asoc->ifp_had_enobuf = 1; in sctp_send_initiate_ack()
6202 asoc->ifp_had_enobuf = 0; in sctp_send_initiate_ack()
6218 if ((asoc->prsctp_supported) && in sctp_prune_prsctp()
6219 (asoc->sent_queue_cnt_removeable > 0)) { in sctp_prune_prsctp()
6220 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { in sctp_prune_prsctp()
6227 if (PR_SCTP_BUF_ENABLED(chk->flags)) { in sctp_prune_prsctp()
6229 * This one is PR-SCTP AND buffer space in sctp_prune_prsctp()
6232 if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) { in sctp_prune_prsctp()
6240 if (chk->data) { in sctp_prune_prsctp()
6248 if (chk->sent > SCTP_DATAGRAM_UNSENT) in sctp_prune_prsctp()
6264 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) { in sctp_prune_prsctp()
6266 if (PR_SCTP_BUF_ENABLED(chk->flags)) { in sctp_prune_prsctp()
6267 if (chk->rec.data.timetodrop.tv_sec > (long)srcv->sinfo_timetolive) { in sctp_prune_prsctp()
6268 if (chk->data) { in sctp_prune_prsctp()
6282 } /* end if chk->data */ in sctp_prune_prsctp()
6284 } /* end if chk pr-sctp */ in sctp_prune_prsctp()
6295 asoc = &stcb->asoc; in sctp_get_frag_point()
6297 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { in sctp_get_frag_point()
6303 if (asoc->idata_supported) { in sctp_get_frag_point()
6305 if (sctp_auth_is_required_chunk(SCTP_IDATA, asoc->peer_auth_chunks)) { in sctp_get_frag_point()
6306 overhead += sctp_get_auth_chunk_len(asoc->peer_hmac_id); in sctp_get_frag_point()
6310 if (sctp_auth_is_required_chunk(SCTP_DATA, asoc->peer_auth_chunks)) { in sctp_get_frag_point()
6311 overhead += sctp_get_auth_chunk_len(asoc->peer_hmac_id); in sctp_get_frag_point()
6317 if (asoc->smallest_mtu % 4 > 0) { in sctp_get_frag_point()
6318 overhead += (asoc->smallest_mtu % 4); in sctp_get_frag_point()
6320 KASSERT(asoc->smallest_mtu > overhead, in sctp_get_frag_point()
6322 asoc->smallest_mtu, overhead)); in sctp_get_frag_point()
6323 frag_point = asoc->smallest_mtu - overhead; in sctp_get_frag_point()
6327 if ((asoc->sctp_frag_point > 0) && in sctp_get_frag_point()
6328 (asoc->sctp_frag_point < frag_point)) { in sctp_get_frag_point()
6329 frag_point = asoc->sctp_frag_point; in sctp_get_frag_point()
6341 if (PR_SCTP_ENABLED(sp->sinfo_flags)) { in sctp_set_prsctp_policy()
6342 sp->act_flags |= PR_SCTP_POLICY(sp->sinfo_flags); in sctp_set_prsctp_policy()
6343 } else if (sp->timetolive > 0) { in sctp_set_prsctp_policy()
6344 sp->sinfo_flags |= SCTP_PR_SCTP_TTL; in sctp_set_prsctp_policy()
6345 sp->act_flags |= PR_SCTP_POLICY(sp->sinfo_flags); in sctp_set_prsctp_policy()
6349 switch (PR_SCTP_POLICY(sp->sinfo_flags)) { in sctp_set_prsctp_policy()
6355 sp->ts.tv_sec = sp->timetolive; in sctp_set_prsctp_policy()
6356 sp->ts.tv_usec = 0; in sctp_set_prsctp_policy()
6362 (void)SCTP_GETTIME_TIMEVAL(&sp->ts); in sctp_set_prsctp_policy()
6363 tv.tv_sec = sp->timetolive / 1000; in sctp_set_prsctp_policy()
6364 tv.tv_usec = (sp->timetolive * 1000) % 1000000; in sctp_set_prsctp_policy()
6369 timevaladd(&sp->ts, &tv); in sctp_set_prsctp_policy()
6377 sp->ts.tv_sec = sp->timetolive; in sctp_set_prsctp_policy()
6378 sp->ts.tv_usec = 0; in sctp_set_prsctp_policy()
6383 PR_SCTP_POLICY(sp->sinfo_flags)); in sctp_set_prsctp_policy()
6405 if (srcv->sinfo_stream >= stcb->asoc.streamoutcnt) { in sctp_msg_append()
6411 if ((stcb->asoc.stream_locked) && in sctp_msg_append()
6412 (stcb->asoc.stream_locked_on != srcv->sinfo_stream)) { in sctp_msg_append()
6417 if ((stcb->asoc.strmout[srcv->sinfo_stream].state != SCTP_STREAM_OPEN) && in sctp_msg_append()
6418 (stcb->asoc.strmout[srcv->sinfo_stream].state != SCTP_STREAM_OPENING)) { in sctp_msg_append()
6422 if (stcb->asoc.strmout[srcv->sinfo_stream].state > SCTP_STREAM_OPEN) { in sctp_msg_append()
6433 (stcb->asoc.state & SCTP_STATE_SHUTDOWN_PENDING)) { in sctp_msg_append()
6445 sp->sinfo_flags = srcv->sinfo_flags; in sctp_msg_append()
6446 sp->timetolive = srcv->sinfo_timetolive; in sctp_msg_append()
6447 sp->ppid = srcv->sinfo_ppid; in sctp_msg_append()
6448 sp->context = srcv->sinfo_context; in sctp_msg_append()
6449 sp->fsn = 0; in sctp_msg_append()
6450 if (sp->sinfo_flags & SCTP_ADDR_OVER) { in sctp_msg_append()
6451 sp->net = net; in sctp_msg_append()
6452 atomic_add_int(&sp->net->ref_count, 1); in sctp_msg_append()
6454 sp->net = NULL; in sctp_msg_append()
6456 (void)SCTP_GETTIME_TIMEVAL(&sp->ts); in sctp_msg_append()
6457 sp->sid = srcv->sinfo_stream; in sctp_msg_append()
6458 sp->msg_is_complete = 1; in sctp_msg_append()
6459 sp->sender_all_done = 1; in sctp_msg_append()
6460 sp->some_taken = 0; in sctp_msg_append()
6461 sp->data = m; in sctp_msg_append()
6462 sp->tail_mbuf = NULL; in sctp_msg_append()
6469 sp->length = 0; in sctp_msg_append()
6472 sp->tail_mbuf = at; in sctp_msg_append()
6473 sp->length += SCTP_BUF_LEN(at); in sctp_msg_append()
6475 if (srcv->sinfo_keynumber_valid) { in sctp_msg_append()
6476 sp->auth_keyid = srcv->sinfo_keynumber; in sctp_msg_append()
6478 sp->auth_keyid = stcb->asoc.authinfo.active_keyid; in sctp_msg_append()
6480 if (sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.peer_auth_chunks)) { in sctp_msg_append()
6481 sctp_auth_key_acquire(stcb, sp->auth_keyid); in sctp_msg_append()
6482 sp->holds_key_ref = 1; in sctp_msg_append()
6484 strm = &stcb->asoc.strmout[srcv->sinfo_stream]; in sctp_msg_append()
6485 sctp_snd_sb_alloc(stcb, sp->length); in sctp_msg_append()
6486 atomic_add_int(&stcb->asoc.stream_queue_cnt, 1); in sctp_msg_append()
6487 TAILQ_INSERT_TAIL(&strm->outqueue, sp, next); in sctp_msg_append()
6488 stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc, strm, sp); in sctp_msg_append()
6521 (sizeofcpy <= (int)((((SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + MHLEN)))) { in sctp_copy_mbufchain()
6580 sizeofcpy -= len; in sctp_copy_mbufchain()
6625 * save off the end and update the end-chain position in sctp_copy_mbufchain()
6637 /* save off the end and update the end-chain position */ in sctp_copy_mbufchain()
6673 if (ca->m == NULL) { in sctp_sendall_iterator()
6676 if (ca->inp != inp) { in sctp_sendall_iterator()
6680 if (ca->sndlen > 0) { in sctp_sendall_iterator()
6681 m = SCTP_M_COPYM(ca->m, 0, M_COPYALL, M_NOWAIT); in sctp_sendall_iterator()
6684 ca->cnt_failed++; in sctp_sendall_iterator()
6696 if (stcb->asoc.alternate) { in sctp_sendall_iterator()
6697 net = stcb->asoc.alternate; in sctp_sendall_iterator()
6699 net = stcb->asoc.primary_destination; in sctp_sendall_iterator()
6701 if (ca->sndrcv.sinfo_flags & SCTP_ABORT) { in sctp_sendall_iterator()
6716 ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); in sctp_sendall_iterator()
6717 ph->param_length = htons((uint16_t)(sizeof(struct sctp_paramhdr) + ca->sndlen)); in sctp_sendall_iterator()
6720 * We add one here to keep the assoc from dis-appearing on in sctp_sendall_iterator()
6723 atomic_add_int(&stcb->asoc.refcnt, 1); in sctp_sendall_iterator()
6732 * stcb will return to us un-locked.. since free_asoc in sctp_sendall_iterator()
6734 * relock.. to unlock in the iterator timer :-0 in sctp_sendall_iterator()
6737 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_sendall_iterator()
6741 ret = sctp_msg_append(stcb, net, m, &ca->sndrcv); in sctp_sendall_iterator()
6743 asoc = &stcb->asoc; in sctp_sendall_iterator()
6744 if (ca->sndrcv.sinfo_flags & SCTP_EOF) { in sctp_sendall_iterator()
6746 if (TAILQ_EMPTY(&asoc->send_queue) && in sctp_sendall_iterator()
6747 TAILQ_EMPTY(&asoc->sent_queue) && in sctp_sendall_iterator()
6749 if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc)) { in sctp_sendall_iterator()
6769 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, in sctp_sendall_iterator()
6771 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, in sctp_sendall_iterator()
6785 * and move to SHUTDOWN-PENDING in sctp_sendall_iterator()
6790 if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc)) { in sctp_sendall_iterator()
6794 if (TAILQ_EMPTY(&asoc->send_queue) && in sctp_sendall_iterator()
6795 TAILQ_EMPTY(&asoc->sent_queue) && in sctp_sendall_iterator()
6796 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) { in sctp_sendall_iterator()
6805 atomic_add_int(&stcb->asoc.refcnt, 1); in sctp_sendall_iterator()
6806 sctp_abort_an_association(stcb->sctp_ep, stcb, in sctp_sendall_iterator()
6808 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_sendall_iterator()
6815 un_sent = ((stcb->asoc.total_output_queue_size - stcb->asoc.total_flight) + in sctp_sendall_iterator()
6816 (stcb->asoc.stream_queue_cnt * SCTP_DATA_CHUNK_OVERHEAD(stcb))); in sctp_sendall_iterator()
6819 (stcb->asoc.total_flight > 0) && in sctp_sendall_iterator()
6820 (un_sent < (int)(stcb->asoc.smallest_mtu - SCTP_MIN_OVERHEAD))) { in sctp_sendall_iterator()
6829 (void)sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, in sctp_sendall_iterator()
6836 ca->cnt_failed++; in sctp_sendall_iterator()
6838 ca->cnt_sent++; in sctp_sendall_iterator()
6854 * user you can't send the data :-> in sctp_sendall_completes()
6858 if (ca->inp) { in sctp_sendall_completes()
6860 SCTP_INP_WLOCK(ca->inp); in sctp_sendall_completes()
6861 ca->inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP; in sctp_sendall_completes()
6862 SCTP_INP_WUNLOCK(ca->inp); in sctp_sendall_completes()
6864 sctp_m_freem(ca->m); in sctp_sendall_completes()
6895 left -= willcpy; in sctp_copy_out_all()
6920 sndlen = uio->uio_resid; in sctp_sendall()
6939 ca->inp = inp; in sctp_sendall()
6941 memcpy(&ca->sndrcv, srcv, sizeof(struct sctp_nonpad_sndrcvinfo)); in sctp_sendall()
6945 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SND_ITERATOR_UP) != 0) { in sctp_sendall()
6951 inp->sctp_flags |= SCTP_PCB_FLAGS_SND_ITERATOR_UP; in sctp_sendall()
6955 * this :-0 in sctp_sendall()
6957 ca->sndrcv.sinfo_flags &= ~SCTP_SENDALL; in sctp_sendall()
6959 ca->sndlen = sndlen; in sctp_sendall()
6961 ca->m = sctp_copy_out_all(uio, ca->sndlen); in sctp_sendall()
6962 if (ca->m == NULL) { in sctp_sendall()
6966 inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP; in sctp_sendall()
6972 ca->m = m; in sctp_sendall()
6981 inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP; in sctp_sendall()
6995 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) { in sctp_toss_old_cookies()
6996 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) { in sctp_toss_old_cookies()
6997 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next); in sctp_toss_old_cookies()
6998 asoc->ctrl_queue_cnt--; in sctp_toss_old_cookies()
6999 if (chk->data) { in sctp_toss_old_cookies()
7000 sctp_m_freem(chk->data); in sctp_toss_old_cookies()
7001 chk->data = NULL; in sctp_toss_old_cookies()
7015 asoc = &stcb->asoc; in sctp_toss_old_asconf()
7016 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) { in sctp_toss_old_asconf()
7018 if (chk->rec.chunk_id.id == SCTP_ASCONF) { in sctp_toss_old_asconf()
7019 if (chk->data) { in sctp_toss_old_asconf()
7020 acp = mtod(chk->data, struct sctp_asconf_chunk *); in sctp_toss_old_asconf()
7021 if (SCTP_TSN_GT(ntohl(acp->serial_number), asoc->asconf_seq_out_acked)) { in sctp_toss_old_asconf()
7026 TAILQ_REMOVE(&asoc->asconf_send_queue, chk, sctp_next); in sctp_toss_old_asconf()
7027 asoc->ctrl_queue_cnt--; in sctp_toss_old_asconf()
7028 if (chk->data) { in sctp_toss_old_asconf()
7029 sctp_m_freem(chk->data); in sctp_toss_old_asconf()
7030 chk->data = NULL; in sctp_toss_old_asconf()
7049 TAILQ_REMOVE(&asoc->send_queue, data_list[i], sctp_next); in sctp_clean_up_datalist()
7050 asoc->send_queue_cnt--; in sctp_clean_up_datalist()
7057 data_list[i]->do_rtt = 0; in sctp_clean_up_datalist()
7060 data_list[i]->sent_rcv_time = net->last_sent_time; in sctp_clean_up_datalist()
7061 data_list[i]->rec.data.cwnd_at_send = net->cwnd; in sctp_clean_up_datalist()
7062 data_list[i]->rec.data.fast_retran_tsn = data_list[i]->rec.data.tsn; in sctp_clean_up_datalist()
7063 if (data_list[i]->whoTo == NULL) { in sctp_clean_up_datalist()
7064 data_list[i]->whoTo = net; in sctp_clean_up_datalist()
7065 atomic_add_int(&net->ref_count, 1); in sctp_clean_up_datalist()
7068 tp1 = TAILQ_LAST(&asoc->sent_queue, sctpchunk_listhead); in sctp_clean_up_datalist()
7069 if ((tp1) && SCTP_TSN_GT(tp1->rec.data.tsn, data_list[i]->rec.data.tsn)) { in sctp_clean_up_datalist()
7080 if (SCTP_TSN_GT(tp1->rec.data.tsn, data_list[i]->rec.data.tsn)) { in sctp_clean_up_datalist()
7083 TAILQ_INSERT_AFTER(&asoc->sent_queue, tp1, data_list[i], sctp_next); in sctp_clean_up_datalist()
7085 TAILQ_INSERT_TAIL(&asoc->sent_queue, in sctp_clean_up_datalist()
7090 /* This does not lower until the cum-ack passes it */ in sctp_clean_up_datalist()
7091 asoc->sent_queue_cnt++; in sctp_clean_up_datalist()
7092 if ((asoc->peers_rwnd <= 0) && in sctp_clean_up_datalist()
7093 (asoc->total_flight == 0) && in sctp_clean_up_datalist()
7101 data_list[i]->sent = SCTP_DATAGRAM_SENT; in sctp_clean_up_datalist()
7102 data_list[i]->snd_count = 1; in sctp_clean_up_datalist()
7103 data_list[i]->rec.data.chunk_was_revoked = 0; in sctp_clean_up_datalist()
7106 data_list[i]->whoTo->flight_size, in sctp_clean_up_datalist()
7107 data_list[i]->book_size, in sctp_clean_up_datalist()
7108 (uint32_t)(uintptr_t)data_list[i]->whoTo, in sctp_clean_up_datalist()
7109 data_list[i]->rec.data.tsn); in sctp_clean_up_datalist()
7115 asoc->peers_rwnd, data_list[i]->send_size, SCTP_BASE_SYSCTL(sctp_peer_chunk_oh)); in sctp_clean_up_datalist()
7117 asoc->peers_rwnd = sctp_sbspace_sub(asoc->peers_rwnd, in sctp_clean_up_datalist()
7118 (uint32_t)(data_list[i]->send_size + SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))); in sctp_clean_up_datalist()
7119 if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) { in sctp_clean_up_datalist()
7121 asoc->peers_rwnd = 0; in sctp_clean_up_datalist()
7124 if (asoc->cc_functions.sctp_cwnd_update_packet_transmitted) { in sctp_clean_up_datalist()
7125 (*asoc->cc_functions.sctp_cwnd_update_packet_transmitted) (stcb, net); in sctp_clean_up_datalist()
7134 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) { in sctp_clean_up_ctl()
7135 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) || in sctp_clean_up_ctl()
7136 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */ in sctp_clean_up_ctl()
7137 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) || in sctp_clean_up_ctl()
7138 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) || in sctp_clean_up_ctl()
7139 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) || in sctp_clean_up_ctl()
7140 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) || in sctp_clean_up_ctl()
7141 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) || in sctp_clean_up_ctl()
7142 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) || in sctp_clean_up_ctl()
7143 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) || in sctp_clean_up_ctl()
7144 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) || in sctp_clean_up_ctl()
7145 (chk->rec.chunk_id.id == SCTP_ECN_CWR) || in sctp_clean_up_ctl()
7146 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) { in sctp_clean_up_ctl()
7149 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next); in sctp_clean_up_ctl()
7150 asoc->ctrl_queue_cnt--; in sctp_clean_up_ctl()
7151 if (chk->data) { in sctp_clean_up_ctl()
7152 sctp_m_freem(chk->data); in sctp_clean_up_ctl()
7153 chk->data = NULL; in sctp_clean_up_ctl()
7155 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) { in sctp_clean_up_ctl()
7156 asoc->fwd_tsn_cnt--; in sctp_clean_up_ctl()
7159 } else if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) { in sctp_clean_up_ctl()
7161 if (chk != asoc->str_reset) { in sctp_clean_up_ctl()
7183 /*- in sctp_can_we_split_this()
7186 * arrives to transmit - wait for more data in sctp_can_we_split_this()
7188 if (stcb->asoc.total_flight == 0) { in sctp_can_we_split_this()
7202 /*- in sctp_can_we_split_this()
7207 if (SCTP_SB_LIMIT_SND(stcb->sctp_socket) < frag_point) { in sctp_can_we_split_this()
7211 ((length - space_left) < SCTP_BASE_SYSCTL(sctp_min_residual))) { in sctp_can_we_split_this()
7212 /* Sub-optimal residual don't split in non-eeor mode. */ in sctp_can_we_split_this()
7250 asoc = &stcb->asoc; in sctp_move_to_outqueue()
7253 sp = TAILQ_FIRST(&strq->outqueue); in sctp_move_to_outqueue()
7255 sp = TAILQ_FIRST(&strq->outqueue); in sctp_move_to_outqueue()
7259 if ((sctp_is_feature_on(stcb->sctp_ep, SCTP_PCB_FLAGS_EXPLICIT_EOR) == 0) && in sctp_move_to_outqueue()
7260 (stcb->asoc.idata_supported == 0) && in sctp_move_to_outqueue()
7261 (strq->last_msg_incomplete)) { in sctp_move_to_outqueue()
7263 strq->sid, in sctp_move_to_outqueue()
7264 strq->last_msg_incomplete); in sctp_move_to_outqueue()
7265 strq->last_msg_incomplete = 0; in sctp_move_to_outqueue()
7270 if ((sp->msg_is_complete) && (sp->length == 0)) { in sctp_move_to_outqueue()
7271 if (sp->sender_all_done) { in sctp_move_to_outqueue()
7277 if ((sp->put_last_out == 0) && (sp->discard_rest == 0)) { in sctp_move_to_outqueue()
7278 SCTP_PRINTF("Gak, put out entire msg with NO end!-1\n"); in sctp_move_to_outqueue()
7280 sp->sender_all_done, in sctp_move_to_outqueue()
7281 sp->length, in sctp_move_to_outqueue()
7282 sp->msg_is_complete, in sctp_move_to_outqueue()
7283 sp->put_last_out); in sctp_move_to_outqueue()
7285 atomic_subtract_int(&asoc->stream_queue_cnt, 1); in sctp_move_to_outqueue()
7286 TAILQ_REMOVE(&strq->outqueue, sp, next); in sctp_move_to_outqueue()
7287 stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp); in sctp_move_to_outqueue()
7288 if ((strq->state == SCTP_STREAM_RESET_PENDING) && in sctp_move_to_outqueue()
7289 (strq->chunks_on_queues == 0) && in sctp_move_to_outqueue()
7290 TAILQ_EMPTY(&strq->outqueue)) { in sctp_move_to_outqueue()
7291 stcb->asoc.trigger_reset = 1; in sctp_move_to_outqueue()
7293 if (sp->net) { in sctp_move_to_outqueue()
7294 sctp_free_remote_addr(sp->net); in sctp_move_to_outqueue()
7295 sp->net = NULL; in sctp_move_to_outqueue()
7297 if (sp->data) { in sctp_move_to_outqueue()
7298 sctp_m_freem(sp->data); in sctp_move_to_outqueue()
7299 sp->data = NULL; in sctp_move_to_outqueue()
7315 if (sp->length == 0) { in sctp_move_to_outqueue()
7320 } else if (sp->discard_rest) { in sctp_move_to_outqueue()
7322 atomic_subtract_int(&stcb->asoc.total_output_queue_size, sp->length); in sctp_move_to_outqueue()
7323 if ((stcb->sctp_socket != NULL) && in sctp_move_to_outqueue()
7324 ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || in sctp_move_to_outqueue()
7325 (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { in sctp_move_to_outqueue()
7326 SCTP_SB_DECR(&stcb->sctp_socket->so_snd, sp->length); in sctp_move_to_outqueue()
7328 if (sp->data) { in sctp_move_to_outqueue()
7329 sctp_m_freem(sp->data); in sctp_move_to_outqueue()
7330 sp->data = NULL; in sctp_move_to_outqueue()
7331 sp->tail_mbuf = NULL; in sctp_move_to_outqueue()
7333 sp->length = 0; in sctp_move_to_outqueue()
7334 sp->some_taken = 1; in sctp_move_to_outqueue()
7340 some_taken = sp->some_taken; in sctp_move_to_outqueue()
7341 length = sp->length; in sctp_move_to_outqueue()
7342 if (sp->msg_is_complete) { in sctp_move_to_outqueue()
7347 if (sp->some_taken) { in sctp_move_to_outqueue()
7352 sp->put_last_out = 1; in sctp_move_to_outqueue()
7353 if (sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) { in sctp_move_to_outqueue()
7358 if (sp->some_taken == 0) { in sctp_move_to_outqueue()
7361 sp->some_taken = 1; in sctp_move_to_outqueue()
7369 if (sp->some_taken == 0) { in sctp_move_to_outqueue()
7371 sp->some_taken = 1; in sctp_move_to_outqueue()
7393 if (sp->sinfo_flags & SCTP_UNORDERED) { in sctp_move_to_outqueue()
7397 (sp->sinfo_flags & SCTP_EOF) == SCTP_EOF) { in sctp_move_to_outqueue()
7402 chk->rec.data.rcv_flags = rcv_flags; in sctp_move_to_outqueue()
7406 if (to_move < sp->length) { in sctp_move_to_outqueue()
7410 chk->data = sp->data; in sctp_move_to_outqueue()
7411 chk->last_mbuf = sp->tail_mbuf; in sctp_move_to_outqueue()
7413 sp->data = sp->tail_mbuf = NULL; in sctp_move_to_outqueue()
7418 chk->data = SCTP_M_COPYM(sp->data, 0, to_move, M_NOWAIT); in sctp_move_to_outqueue()
7419 chk->last_mbuf = NULL; in sctp_move_to_outqueue()
7420 if (chk->data == NULL) { in sctp_move_to_outqueue()
7421 sp->some_taken = some_taken; in sctp_move_to_outqueue()
7429 sctp_log_mbc(chk->data, SCTP_MBUF_ICOPY); in sctp_move_to_outqueue()
7433 m_adj(sp->data, to_move); in sctp_move_to_outqueue()
7435 m = sp->data; in sctp_move_to_outqueue()
7437 sp->data = SCTP_BUF_NEXT(m); in sctp_move_to_outqueue()
7439 if (sp->tail_mbuf == m) { in sctp_move_to_outqueue()
7440 /*- in sctp_move_to_outqueue()
7443 * than the sp->length. in sctp_move_to_outqueue()
7446 panic("Huh, freeing tail? - TSNH"); in sctp_move_to_outqueue()
7448 SCTP_PRINTF("Huh, freeing tail? - TSNH\n"); in sctp_move_to_outqueue()
7449 sp->tail_mbuf = sp->data = NULL; in sctp_move_to_outqueue()
7450 sp->length = 0; in sctp_move_to_outqueue()
7454 m = sp->data; in sctp_move_to_outqueue()
7457 if (SCTP_BUF_IS_EXTENDED(chk->data)) { in sctp_move_to_outqueue()
7458 chk->copy_by_ref = 1; in sctp_move_to_outqueue()
7460 chk->copy_by_ref = 0; in sctp_move_to_outqueue()
7466 if (chk->last_mbuf == NULL) { in sctp_move_to_outqueue()
7467 chk->last_mbuf = chk->data; in sctp_move_to_outqueue()
7468 while (SCTP_BUF_NEXT(chk->last_mbuf) != NULL) { in sctp_move_to_outqueue()
7469 chk->last_mbuf = SCTP_BUF_NEXT(chk->last_mbuf); in sctp_move_to_outqueue()
7474 /*- This should not happen either in sctp_move_to_outqueue()
7476 * of sp->length if its larger. in sctp_move_to_outqueue()
7482 sp->length = 0; in sctp_move_to_outqueue()
7485 atomic_subtract_int(&sp->length, to_move); in sctp_move_to_outqueue()
7488 if (M_LEADINGSPACE(chk->data) < leading) { in sctp_move_to_outqueue()
7499 if (sp->data == NULL) { in sctp_move_to_outqueue()
7501 sp->data = chk->data; in sctp_move_to_outqueue()
7502 sp->tail_mbuf = chk->last_mbuf; in sctp_move_to_outqueue()
7507 m_tmp = sp->data; in sctp_move_to_outqueue()
7508 sp->data = chk->data; in sctp_move_to_outqueue()
7509 SCTP_BUF_NEXT(chk->last_mbuf) = m_tmp; in sctp_move_to_outqueue()
7511 sp->some_taken = some_taken; in sctp_move_to_outqueue()
7512 atomic_add_int(&sp->length, to_move); in sctp_move_to_outqueue()
7513 chk->data = NULL; in sctp_move_to_outqueue()
7520 SCTP_BUF_NEXT(m) = chk->data; in sctp_move_to_outqueue()
7521 chk->data = m; in sctp_move_to_outqueue()
7522 M_ALIGN(chk->data, 4); in sctp_move_to_outqueue()
7525 SCTP_BUF_PREPEND(chk->data, SCTP_DATA_CHUNK_OVERHEAD(stcb), M_NOWAIT); in sctp_move_to_outqueue()
7526 if (chk->data == NULL) { in sctp_move_to_outqueue()
7539 chk->book_size = chk->send_size = (uint16_t)(to_move + SCTP_DATA_CHUNK_OVERHEAD(stcb)); in sctp_move_to_outqueue()
7540 chk->book_size_scale = 0; in sctp_move_to_outqueue()
7541 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_move_to_outqueue()
7543 chk->flags = 0; in sctp_move_to_outqueue()
7544 chk->asoc = &stcb->asoc; in sctp_move_to_outqueue()
7545 chk->pad_inplace = 0; in sctp_move_to_outqueue()
7546 chk->no_fr_allowed = 0; in sctp_move_to_outqueue()
7547 if (stcb->asoc.idata_supported == 0) { in sctp_move_to_outqueue()
7550 chk->rec.data.mid = 0; in sctp_move_to_outqueue()
7552 chk->rec.data.mid = strq->next_mid_ordered; in sctp_move_to_outqueue()
7554 strq->next_mid_ordered++; in sctp_move_to_outqueue()
7559 chk->rec.data.mid = strq->next_mid_unordered; in sctp_move_to_outqueue()
7561 strq->next_mid_unordered++; in sctp_move_to_outqueue()
7564 chk->rec.data.mid = strq->next_mid_ordered; in sctp_move_to_outqueue()
7566 strq->next_mid_ordered++; in sctp_move_to_outqueue()
7570 chk->rec.data.sid = sp->sid; in sctp_move_to_outqueue()
7571 chk->rec.data.ppid = sp->ppid; in sctp_move_to_outqueue()
7572 chk->rec.data.context = sp->context; in sctp_move_to_outqueue()
7573 chk->rec.data.doing_fast_retransmit = 0; in sctp_move_to_outqueue()
7575 chk->rec.data.timetodrop = sp->ts; in sctp_move_to_outqueue()
7576 chk->flags = sp->act_flags; in sctp_move_to_outqueue()
7578 if (sp->net) { in sctp_move_to_outqueue()
7579 chk->whoTo = sp->net; in sctp_move_to_outqueue()
7580 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_move_to_outqueue()
7582 chk->whoTo = NULL; in sctp_move_to_outqueue()
7584 if (sp->holds_key_ref) { in sctp_move_to_outqueue()
7585 chk->auth_keyid = sp->auth_keyid; in sctp_move_to_outqueue()
7586 sctp_auth_key_acquire(stcb, chk->auth_keyid); in sctp_move_to_outqueue()
7587 chk->holds_key_ref = 1; in sctp_move_to_outqueue()
7589 stcb->asoc.ss_functions.sctp_ss_scheduled(stcb, net, asoc, strq, to_move); in sctp_move_to_outqueue()
7590 chk->rec.data.tsn = atomic_fetchadd_int(&asoc->sending_seq, 1); in sctp_move_to_outqueue()
7593 (uint32_t)(uintptr_t)stcb, sp->length, in sctp_move_to_outqueue()
7594 (uint32_t)((chk->rec.data.sid << 16) | (0x0000ffff & chk->rec.data.mid)), in sctp_move_to_outqueue()
7595 chk->rec.data.tsn); in sctp_move_to_outqueue()
7597 if (stcb->asoc.idata_supported == 0) { in sctp_move_to_outqueue()
7598 dchkh = mtod(chk->data, struct sctp_data_chunk *); in sctp_move_to_outqueue()
7600 ndchkh = mtod(chk->data, struct sctp_idata_chunk *); in sctp_move_to_outqueue()
7609 if (asoc->tsn_out_at >= SCTP_TSN_LOG_SIZE) { in sctp_move_to_outqueue()
7610 asoc->tsn_out_at = 0; in sctp_move_to_outqueue()
7611 asoc->tsn_out_wrapped = 1; in sctp_move_to_outqueue()
7613 asoc->out_tsnlog[asoc->tsn_out_at].tsn = chk->rec.data.tsn; in sctp_move_to_outqueue()
7614 asoc->out_tsnlog[asoc->tsn_out_at].strm = chk->rec.data.sid; in sctp_move_to_outqueue()
7615 asoc->out_tsnlog[asoc->tsn_out_at].seq = chk->rec.data.mid; in sctp_move_to_outqueue()
7616 asoc->out_tsnlog[asoc->tsn_out_at].sz = chk->send_size; in sctp_move_to_outqueue()
7617 asoc->out_tsnlog[asoc->tsn_out_at].flgs = chk->rec.data.rcv_flags; in sctp_move_to_outqueue()
7618 asoc->out_tsnlog[asoc->tsn_out_at].stcb = (void *)stcb; in sctp_move_to_outqueue()
7619 asoc->out_tsnlog[asoc->tsn_out_at].in_pos = asoc->tsn_out_at; in sctp_move_to_outqueue()
7620 asoc->out_tsnlog[asoc->tsn_out_at].in_out = 2; in sctp_move_to_outqueue()
7621 asoc->tsn_out_at++; in sctp_move_to_outqueue()
7623 if (stcb->asoc.idata_supported == 0) { in sctp_move_to_outqueue()
7624 dchkh->ch.chunk_type = SCTP_DATA; in sctp_move_to_outqueue()
7625 dchkh->ch.chunk_flags = chk->rec.data.rcv_flags; in sctp_move_to_outqueue()
7626 dchkh->dp.tsn = htonl(chk->rec.data.tsn); in sctp_move_to_outqueue()
7627 dchkh->dp.sid = htons(strq->sid); in sctp_move_to_outqueue()
7628 dchkh->dp.ssn = htons((uint16_t)chk->rec.data.mid); in sctp_move_to_outqueue()
7629 dchkh->dp.ppid = chk->rec.data.ppid; in sctp_move_to_outqueue()
7630 dchkh->ch.chunk_length = htons(chk->send_size); in sctp_move_to_outqueue()
7632 ndchkh->ch.chunk_type = SCTP_IDATA; in sctp_move_to_outqueue()
7633 ndchkh->ch.chunk_flags = chk->rec.data.rcv_flags; in sctp_move_to_outqueue()
7634 ndchkh->dp.tsn = htonl(chk->rec.data.tsn); in sctp_move_to_outqueue()
7635 ndchkh->dp.sid = htons(strq->sid); in sctp_move_to_outqueue()
7636 ndchkh->dp.reserved = htons(0); in sctp_move_to_outqueue()
7637 ndchkh->dp.mid = htonl(chk->rec.data.mid); in sctp_move_to_outqueue()
7638 if (sp->fsn == 0) in sctp_move_to_outqueue()
7639 ndchkh->dp.ppid_fsn.ppid = chk->rec.data.ppid; in sctp_move_to_outqueue()
7641 ndchkh->dp.ppid_fsn.fsn = htonl(sp->fsn); in sctp_move_to_outqueue()
7642 sp->fsn++; in sctp_move_to_outqueue()
7643 ndchkh->ch.chunk_length = htons(chk->send_size); in sctp_move_to_outqueue()
7645 /* Now advance the chk->send_size by the actual pad needed. */ in sctp_move_to_outqueue()
7646 if (chk->send_size < SCTP_SIZE32(chk->book_size)) { in sctp_move_to_outqueue()
7651 pads = SCTP_SIZE32(chk->book_size) - chk->send_size; in sctp_move_to_outqueue()
7652 lm = sctp_pad_lastmbuf(chk->data, pads, chk->last_mbuf); in sctp_move_to_outqueue()
7654 chk->last_mbuf = lm; in sctp_move_to_outqueue()
7655 chk->pad_inplace = 1; in sctp_move_to_outqueue()
7657 chk->send_size += pads; in sctp_move_to_outqueue()
7659 if (PR_SCTP_ENABLED(chk->flags)) { in sctp_move_to_outqueue()
7660 asoc->pr_sctp_cnt++; in sctp_move_to_outqueue()
7662 if (sp->msg_is_complete && (sp->length == 0) && (sp->sender_all_done)) { in sctp_move_to_outqueue()
7664 if (sp->put_last_out == 0) { in sctp_move_to_outqueue()
7665 SCTP_PRINTF("Gak, put out entire msg with NO end!-2\n"); in sctp_move_to_outqueue()
7667 sp->sender_all_done, in sctp_move_to_outqueue()
7668 sp->length, in sctp_move_to_outqueue()
7669 sp->msg_is_complete, in sctp_move_to_outqueue()
7670 sp->put_last_out); in sctp_move_to_outqueue()
7672 atomic_subtract_int(&asoc->stream_queue_cnt, 1); in sctp_move_to_outqueue()
7673 TAILQ_REMOVE(&strq->outqueue, sp, next); in sctp_move_to_outqueue()
7674 stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp); in sctp_move_to_outqueue()
7675 if ((strq->state == SCTP_STREAM_RESET_PENDING) && in sctp_move_to_outqueue()
7676 (strq->chunks_on_queues == 0) && in sctp_move_to_outqueue()
7677 TAILQ_EMPTY(&strq->outqueue)) { in sctp_move_to_outqueue()
7678 stcb->asoc.trigger_reset = 1; in sctp_move_to_outqueue()
7680 if (sp->net) { in sctp_move_to_outqueue()
7681 sctp_free_remote_addr(sp->net); in sctp_move_to_outqueue()
7682 sp->net = NULL; in sctp_move_to_outqueue()
7684 if (sp->data) { in sctp_move_to_outqueue()
7685 sctp_m_freem(sp->data); in sctp_move_to_outqueue()
7686 sp->data = NULL; in sctp_move_to_outqueue()
7690 asoc->chunks_on_out_queue++; in sctp_move_to_outqueue()
7691 strq->chunks_on_queues++; in sctp_move_to_outqueue()
7692 TAILQ_INSERT_TAIL(&asoc->send_queue, chk, sctp_next); in sctp_move_to_outqueue()
7693 asoc->send_queue_cnt++; in sctp_move_to_outqueue()
7709 asoc = &stcb->asoc; in sctp_fill_outqueue()
7711 switch (net->ro._l_addr.sa.sa_family) { in sctp_fill_outqueue()
7714 space_left = net->mtu - SCTP_MIN_V4_OVERHEAD; in sctp_fill_outqueue()
7719 space_left = net->mtu - SCTP_MIN_OVERHEAD; in sctp_fill_outqueue()
7724 space_left = net->mtu; in sctp_fill_outqueue()
7728 space_left -= SCTP_DATA_CHUNK_OVERHEAD(stcb); in sctp_fill_outqueue()
7732 strq = stcb->asoc.ss_functions.sctp_ss_select_stream(stcb, net, asoc); in sctp_fill_outqueue()
7742 strq = stcb->asoc.ss_functions.sctp_ss_select_stream(stcb, net, asoc); in sctp_fill_outqueue()
7745 space_left -= moved; in sctp_fill_outqueue()
7750 space_left -= SCTP_DATA_CHUNK_OVERHEAD(stcb); in sctp_fill_outqueue()
7759 stcb->asoc.ss_functions.sctp_ss_packet_done(stcb, net, asoc); in sctp_fill_outqueue()
7762 if ((stcb->asoc.sctp_cmt_on_off == 0) && in sctp_fill_outqueue()
7763 (net == stcb->asoc.primary_destination)) { in sctp_fill_outqueue()
7766 } else if (stcb->asoc.sctp_cmt_on_off > 0) { in sctp_fill_outqueue()
7778 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_fix_ecn_echo()
7779 if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) { in sctp_fix_ecn_echo()
7780 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_fix_ecn_echo()
7796 asoc = &stcb->asoc; in sctp_move_chunks_from_net()
7797 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { in sctp_move_chunks_from_net()
7798 TAILQ_FOREACH(sp, &stcb->asoc.strmout[i].outqueue, next) { in sctp_move_chunks_from_net()
7799 if (sp->net == net) { in sctp_move_chunks_from_net()
7800 sctp_free_remote_addr(sp->net); in sctp_move_chunks_from_net()
7801 sp->net = NULL; in sctp_move_chunks_from_net()
7805 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) { in sctp_move_chunks_from_net()
7806 if (chk->whoTo == net) { in sctp_move_chunks_from_net()
7807 sctp_free_remote_addr(chk->whoTo); in sctp_move_chunks_from_net()
7808 chk->whoTo = NULL; in sctp_move_chunks_from_net()
7826 * - Service the stream queue that is next, moving any in sctp_med_chunk_output()
7830 * chunks its ok to not send the entire message ;-) in sctp_med_chunk_output()
7831 * - Check to see if the cwnd/rwnd allows any output, if so we go ahead and in sctp_med_chunk_output()
7856 * JRS 5/14/07 - Add flag for whether a heartbeat is sent to the in sctp_med_chunk_output()
7864 auth_keyid = stcb->asoc.authinfo.active_keyid; in sctp_med_chunk_output()
7865 if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) || in sctp_med_chunk_output()
7889 if ((TAILQ_EMPTY(&asoc->control_send_queue) || in sctp_med_chunk_output()
7890 (asoc->ctrl_queue_cnt == stcb->asoc.ecn_echo_cnt_onq)) && in sctp_med_chunk_output()
7891 TAILQ_EMPTY(&asoc->asconf_send_queue) && in sctp_med_chunk_output()
7892 TAILQ_EMPTY(&asoc->send_queue) && in sctp_med_chunk_output()
7898 if (asoc->peers_rwnd == 0) { in sctp_med_chunk_output()
7901 if (asoc->total_flight > 0) { in sctp_med_chunk_output()
7906 if (stcb->asoc.ecn_echo_cnt_onq) { in sctp_med_chunk_output()
7909 (asoc->ctrl_queue_cnt == stcb->asoc.ecn_echo_cnt_onq)) { in sctp_med_chunk_output()
7910 /* Nothing but ECNe to send - we don't do that */ in sctp_med_chunk_output()
7913 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_med_chunk_output()
7914 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) || in sctp_med_chunk_output()
7915 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) { in sctp_med_chunk_output()
7916 sack_goes_to = chk->whoTo; in sctp_med_chunk_output()
7921 max_rwnd_per_dest = ((asoc->peers_rwnd + asoc->total_flight) / asoc->numnets); in sctp_med_chunk_output()
7922 if (stcb->sctp_socket) in sctp_med_chunk_output()
7923 max_send_per_dest = SCTP_SB_LIMIT_SND(stcb->sctp_socket) / asoc->numnets; in sctp_med_chunk_output()
7927 /* How many non-directed chunks are there? */ in sctp_med_chunk_output()
7928 TAILQ_FOREACH(chk, &asoc->send_queue, sctp_next) { in sctp_med_chunk_output()
7929 if (chk->whoTo == NULL) { in sctp_med_chunk_output()
7931 * We already have non-directed chunks on in sctp_med_chunk_output()
7932 * the queue, no need to do a fill-up. in sctp_med_chunk_output()
7941 (!stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, asoc))) { in sctp_med_chunk_output()
7942 TAILQ_FOREACH(net, &asoc->nets, sctp_next) { in sctp_med_chunk_output()
7954 net->window_probe = 0; in sctp_med_chunk_output()
7955 if ((net != stcb->asoc.alternate) && in sctp_med_chunk_output()
7956 ((net->dest_state & SCTP_ADDR_PF) || in sctp_med_chunk_output()
7957 ((net->dest_state & SCTP_ADDR_REACHABLE) == 0) || in sctp_med_chunk_output()
7958 (net->dest_state & SCTP_ADDR_UNCONFIRMED))) { in sctp_med_chunk_output()
7965 if ((stcb->asoc.cc_functions.sctp_cwnd_new_transmission_begins) && in sctp_med_chunk_output()
7966 (net->flight_size == 0)) { in sctp_med_chunk_output()
7967 (*stcb->asoc.cc_functions.sctp_cwnd_new_transmission_begins) (stcb, net); in sctp_med_chunk_output()
7969 if (net->flight_size >= net->cwnd) { in sctp_med_chunk_output()
7970 /* skip this network, no room - can't fill */ in sctp_med_chunk_output()
7990 if (TAILQ_EMPTY(&asoc->control_send_queue) && in sctp_med_chunk_output()
7991 TAILQ_EMPTY(&asoc->asconf_send_queue) && in sctp_med_chunk_output()
7992 TAILQ_EMPTY(&asoc->send_queue)) { in sctp_med_chunk_output()
7997 if (asoc->sctp_cmt_on_off > 0) { in sctp_med_chunk_output()
7999 start_at = asoc->last_net_cmt_send_started; in sctp_med_chunk_output()
8002 start_at = TAILQ_FIRST(&asoc->nets); in sctp_med_chunk_output()
8004 start_at = TAILQ_NEXT(asoc->last_net_cmt_send_started, sctp_next); in sctp_med_chunk_output()
8006 start_at = TAILQ_FIRST(&asoc->nets); in sctp_med_chunk_output()
8009 asoc->last_net_cmt_send_started = start_at; in sctp_med_chunk_output()
8011 start_at = TAILQ_FIRST(&asoc->nets); in sctp_med_chunk_output()
8013 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_med_chunk_output()
8014 if (chk->whoTo == NULL) { in sctp_med_chunk_output()
8015 if (asoc->alternate) { in sctp_med_chunk_output()
8016 chk->whoTo = asoc->alternate; in sctp_med_chunk_output()
8018 chk->whoTo = asoc->primary_destination; in sctp_med_chunk_output()
8020 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_med_chunk_output()
8033 if (TAILQ_EMPTY(&asoc->control_send_queue) && in sctp_med_chunk_output()
8034 TAILQ_EMPTY(&asoc->asconf_send_queue) && in sctp_med_chunk_output()
8035 (net->flight_size >= net->cwnd)) { in sctp_med_chunk_output()
8048 if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { in sctp_med_chunk_output()
8053 switch (((struct sockaddr *)&net->ro._l_addr)->sa_family) { in sctp_med_chunk_output()
8056 mtu = net->mtu - SCTP_MIN_V4_OVERHEAD; in sctp_med_chunk_output()
8061 mtu = net->mtu - SCTP_MIN_OVERHEAD; in sctp_med_chunk_output()
8066 mtu = net->mtu; in sctp_med_chunk_output()
8071 if (mtu > asoc->peers_rwnd) { in sctp_med_chunk_output()
8072 if (asoc->total_flight > 0) { in sctp_med_chunk_output()
8074 r_mtu = asoc->peers_rwnd; in sctp_med_chunk_output()
8088 TAILQ_FOREACH_SAFE(chk, &asoc->asconf_send_queue, sctp_next, nchk) { in sctp_med_chunk_output()
8089 if (chk->rec.chunk_id.id != SCTP_ASCONF) { in sctp_med_chunk_output()
8092 if (chk->whoTo == NULL) { in sctp_med_chunk_output()
8093 if (asoc->alternate == NULL) { in sctp_med_chunk_output()
8094 if (asoc->primary_destination != net) { in sctp_med_chunk_output()
8098 if (asoc->alternate != net) { in sctp_med_chunk_output()
8103 if (chk->whoTo != net) { in sctp_med_chunk_output()
8107 if (chk->data == NULL) { in sctp_med_chunk_output()
8110 if (chk->sent != SCTP_DATAGRAM_UNSENT && in sctp_med_chunk_output()
8111 chk->sent != SCTP_DATAGRAM_RESEND) { in sctp_med_chunk_output()
8123 sctp_auth_is_required_chunk(chk->rec.chunk_id.id, in sctp_med_chunk_output()
8124 stcb->asoc.peer_auth_chunks)) { in sctp_med_chunk_output()
8125 omtu = sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); in sctp_med_chunk_output()
8129 if ((chk->send_size < (int)(mtu - omtu)) || in sctp_med_chunk_output()
8130 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) { in sctp_med_chunk_output()
8133 * from the chk->data for control but the in sctp_med_chunk_output()
8146 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id, in sctp_med_chunk_output()
8147 stcb->asoc.peer_auth_chunks))) { in sctp_med_chunk_output()
8153 chk->rec.chunk_id.id); in sctp_med_chunk_output()
8156 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain, in sctp_med_chunk_output()
8157 (int)chk->rec.chunk_id.can_take_data, in sctp_med_chunk_output()
8158 chk->send_size, chk->copy_by_ref); in sctp_med_chunk_output()
8166 if (mtu > (chk->send_size + omtu)) in sctp_med_chunk_output()
8167 mtu -= (chk->send_size + omtu); in sctp_med_chunk_output()
8170 to_out += (chk->send_size + omtu); in sctp_med_chunk_output()
8172 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) { in sctp_med_chunk_output()
8175 if (chk->rec.chunk_id.can_take_data) in sctp_med_chunk_output()
8176 chk->data = NULL; in sctp_med_chunk_output()
8188 chk->sent = SCTP_DATAGRAM_SENT; in sctp_med_chunk_output()
8189 if (chk->whoTo == NULL) { in sctp_med_chunk_output()
8190 chk->whoTo = net; in sctp_med_chunk_output()
8191 atomic_add_int(&net->ref_count, 1); in sctp_med_chunk_output()
8193 chk->snd_count++; in sctp_med_chunk_output()
8211 net->last_sent_time = *now; in sctp_med_chunk_output()
8214 (struct sockaddr *)&net->ro._l_addr, in sctp_med_chunk_output()
8216 stcb->asoc.authinfo.active_keyid, in sctp_med_chunk_output()
8218 inp->sctp_lport, stcb->rport, in sctp_med_chunk_output()
8219 htonl(stcb->asoc.peer_vtag), in sctp_med_chunk_output()
8220 net->port, NULL, in sctp_med_chunk_output()
8232 asoc->ifp_had_enobuf = 1; in sctp_med_chunk_output()
8248 asoc->ifp_had_enobuf = 0; in sctp_med_chunk_output()
8262 switch (net->ro._l_addr.sa.sa_family) { in sctp_med_chunk_output()
8265 mtu = net->mtu - SCTP_MIN_V4_OVERHEAD; in sctp_med_chunk_output()
8270 mtu = net->mtu - SCTP_MIN_OVERHEAD; in sctp_med_chunk_output()
8275 mtu = net->mtu; in sctp_med_chunk_output()
8291 TAILQ_FOREACH_SAFE(chk, &asoc->control_send_queue, sctp_next, nchk) { in sctp_med_chunk_output()
8293 (chk->rec.chunk_id.id == SCTP_ECN_ECHO) && in sctp_med_chunk_output()
8294 (chk->whoTo != sack_goes_to)) { in sctp_med_chunk_output()
8300 if (chk->whoTo == net) { in sctp_med_chunk_output()
8314 if (chk->whoTo == NULL) { in sctp_med_chunk_output()
8315 if (asoc->alternate == NULL) { in sctp_med_chunk_output()
8316 if (asoc->primary_destination != net) { in sctp_med_chunk_output()
8320 if (asoc->alternate != net) { in sctp_med_chunk_output()
8325 if (chk->whoTo != net) { in sctp_med_chunk_output()
8330 if (chk->data == NULL) { in sctp_med_chunk_output()
8333 if (chk->sent != SCTP_DATAGRAM_UNSENT) { in sctp_med_chunk_output()
8350 sctp_auth_is_required_chunk(chk->rec.chunk_id.id, in sctp_med_chunk_output()
8351 stcb->asoc.peer_auth_chunks)) { in sctp_med_chunk_output()
8352 omtu = sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); in sctp_med_chunk_output()
8356 if ((chk->send_size <= (int)(mtu - omtu)) || in sctp_med_chunk_output()
8357 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) { in sctp_med_chunk_output()
8360 * from the chk->data for control but the in sctp_med_chunk_output()
8373 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id, in sctp_med_chunk_output()
8374 stcb->asoc.peer_auth_chunks))) { in sctp_med_chunk_output()
8380 chk->rec.chunk_id.id); in sctp_med_chunk_output()
8383 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain, in sctp_med_chunk_output()
8384 (int)chk->rec.chunk_id.can_take_data, in sctp_med_chunk_output()
8385 chk->send_size, chk->copy_by_ref); in sctp_med_chunk_output()
8393 if (mtu > (chk->send_size + omtu)) in sctp_med_chunk_output()
8394 mtu -= (chk->send_size + omtu); in sctp_med_chunk_output()
8397 to_out += (chk->send_size + omtu); in sctp_med_chunk_output()
8399 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) { in sctp_med_chunk_output()
8402 if (chk->rec.chunk_id.can_take_data) in sctp_med_chunk_output()
8403 chk->data = NULL; in sctp_med_chunk_output()
8405 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) || in sctp_med_chunk_output()
8406 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK) || /* EY */ in sctp_med_chunk_output()
8407 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) || in sctp_med_chunk_output()
8408 (chk->rec.chunk_id.id == SCTP_HEARTBEAT_ACK) || in sctp_med_chunk_output()
8409 (chk->rec.chunk_id.id == SCTP_SHUTDOWN) || in sctp_med_chunk_output()
8410 (chk->rec.chunk_id.id == SCTP_SHUTDOWN_ACK) || in sctp_med_chunk_output()
8411 (chk->rec.chunk_id.id == SCTP_OPERATION_ERROR) || in sctp_med_chunk_output()
8412 (chk->rec.chunk_id.id == SCTP_COOKIE_ACK) || in sctp_med_chunk_output()
8413 (chk->rec.chunk_id.id == SCTP_ECN_CWR) || in sctp_med_chunk_output()
8414 (chk->rec.chunk_id.id == SCTP_PACKET_DROPPED) || in sctp_med_chunk_output()
8415 (chk->rec.chunk_id.id == SCTP_ASCONF_ACK)) { in sctp_med_chunk_output()
8416 if (chk->rec.chunk_id.id == SCTP_HEARTBEAT_REQUEST) { in sctp_med_chunk_output()
8420 if ((chk->rec.chunk_id.id == SCTP_SELECTIVE_ACK) || in sctp_med_chunk_output()
8421 (chk->rec.chunk_id.id == SCTP_NR_SELECTIVE_ACK)) { in sctp_med_chunk_output()
8422 /* turn off the timer */ in sctp_med_chunk_output()
8423 if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { in sctp_med_chunk_output()
8438 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) { in sctp_med_chunk_output()
8441 } else if (chk->rec.chunk_id.id == SCTP_ECN_ECHO) { in sctp_med_chunk_output()
8445 * over-zealous in our in sctp_med_chunk_output()
8456 chk->sent = SCTP_DATAGRAM_SENT; in sctp_med_chunk_output()
8457 if (chk->whoTo == NULL) { in sctp_med_chunk_output()
8458 chk->whoTo = net; in sctp_med_chunk_output()
8459 atomic_add_int(&net->ref_count, 1); in sctp_med_chunk_output()
8461 chk->snd_count++; in sctp_med_chunk_output()
8470 switch (asoc->snd_edmid) { in sctp_med_chunk_output()
8499 net->last_sent_time = *now; in sctp_med_chunk_output()
8503 (struct sockaddr *)&net->ro._l_addr, in sctp_med_chunk_output()
8506 stcb->asoc.authinfo.active_keyid, in sctp_med_chunk_output()
8508 inp->sctp_lport, stcb->rport, in sctp_med_chunk_output()
8509 htonl(stcb->asoc.peer_vtag), in sctp_med_chunk_output()
8510 net->port, NULL, in sctp_med_chunk_output()
8522 asoc->ifp_had_enobuf = 1; in sctp_med_chunk_output()
8537 asoc->ifp_had_enobuf = 0; in sctp_med_chunk_output()
8551 switch (net->ro._l_addr.sa.sa_family) { in sctp_med_chunk_output()
8554 mtu = net->mtu - SCTP_MIN_V4_OVERHEAD; in sctp_med_chunk_output()
8559 mtu = net->mtu - SCTP_MIN_OVERHEAD; in sctp_med_chunk_output()
8564 mtu = net->mtu; in sctp_med_chunk_output()
8577 if ((asoc->sctp_cmt_on_off > 0) && in sctp_med_chunk_output()
8578 (net != stcb->asoc.alternate) && in sctp_med_chunk_output()
8579 (net->dest_state & SCTP_ADDR_PF)) { in sctp_med_chunk_output()
8582 if (net->flight_size >= net->cwnd) { in sctp_med_chunk_output()
8585 if ((asoc->sctp_cmt_on_off > 0) && in sctp_med_chunk_output()
8587 (net->flight_size > max_rwnd_per_dest)) { in sctp_med_chunk_output()
8596 if ((asoc->sctp_cmt_on_off > 0) && in sctp_med_chunk_output()
8599 (net->flight_size > max_send_per_dest)) { in sctp_med_chunk_output()
8612 stcb->asoc.peer_auth_chunks); in sctp_med_chunk_output()
8614 mtu -= sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); in sctp_med_chunk_output()
8617 switch (((struct sockaddr *)&net->ro._l_addr)->sa_family) { in sctp_med_chunk_output()
8620 if (net->mtu > SCTP_MIN_V4_OVERHEAD) in sctp_med_chunk_output()
8621 omtu = net->mtu - SCTP_MIN_V4_OVERHEAD; in sctp_med_chunk_output()
8628 if (net->mtu > SCTP_MIN_OVERHEAD) in sctp_med_chunk_output()
8629 omtu = net->mtu - SCTP_MIN_OVERHEAD; in sctp_med_chunk_output()
8643 TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) { in sctp_med_chunk_output()
8649 if (net->flight_size >= net->cwnd) { in sctp_med_chunk_output()
8654 if ((chk->whoTo != NULL) && in sctp_med_chunk_output()
8655 (chk->whoTo != net)) { in sctp_med_chunk_output()
8660 if (asoc->sctp_cmt_on_off == 0) { in sctp_med_chunk_output()
8661 if ((asoc->alternate) && in sctp_med_chunk_output()
8662 (asoc->alternate != net) && in sctp_med_chunk_output()
8663 (chk->whoTo == NULL)) { in sctp_med_chunk_output()
8665 } else if ((net != asoc->primary_destination) && in sctp_med_chunk_output()
8666 (asoc->alternate == NULL) && in sctp_med_chunk_output()
8667 (chk->whoTo == NULL)) { in sctp_med_chunk_output()
8671 if ((chk->send_size > omtu) && ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) == 0)) { in sctp_med_chunk_output()
8672 /*- in sctp_med_chunk_output()
8685 chk->send_size, mtu); in sctp_med_chunk_output()
8686 chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; in sctp_med_chunk_output()
8689 (asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) { in sctp_med_chunk_output()
8692 dchkh = mtod(chk->data, struct sctp_data_chunk *); in sctp_med_chunk_output()
8693 dchkh->ch.chunk_flags |= SCTP_DATA_SACK_IMMEDIATELY; in sctp_med_chunk_output()
8695 if (((chk->send_size <= mtu) && (chk->send_size <= r_mtu)) || in sctp_med_chunk_output()
8696 ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) && (chk->send_size <= asoc->peers_rwnd))) { in sctp_med_chunk_output()
8712 auth_keyid = chk->auth_keyid; in sctp_med_chunk_output()
8720 auth_keyid = chk->auth_keyid; in sctp_med_chunk_output()
8722 } else if (auth_keyid != chk->auth_keyid) { in sctp_med_chunk_output()
8730 outchain = sctp_copy_mbufchain(chk->data, outchain, &endoutchain, 0, in sctp_med_chunk_output()
8731 chk->send_size, chk->copy_by_ref); in sctp_med_chunk_output()
8734 if (!SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { in sctp_med_chunk_output()
8743 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) { in sctp_med_chunk_output()
8747 if (mtu > chk->send_size) in sctp_med_chunk_output()
8748 mtu -= chk->send_size; in sctp_med_chunk_output()
8752 if (r_mtu > chk->send_size) in sctp_med_chunk_output()
8753 r_mtu -= chk->send_size; in sctp_med_chunk_output()
8757 to_out += chk->send_size; in sctp_med_chunk_output()
8766 chk->window_probe = 0; in sctp_med_chunk_output()
8771 if (chk->sent == SCTP_DATAGRAM_UNSENT) { in sctp_med_chunk_output()
8772 if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) == 0) { in sctp_med_chunk_output()
8777 if (((chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) && in sctp_med_chunk_output()
8778 ((chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) == 0)) in sctp_med_chunk_output()
8791 if ((one_chunk) && (stcb->asoc.total_flight == 0)) { in sctp_med_chunk_output()
8792 data_list[0]->window_probe = 1; in sctp_med_chunk_output()
8793 net->window_probe = 1; in sctp_med_chunk_output()
8809 switch (asoc->snd_edmid) { in sctp_med_chunk_output()
8817 /* We may need to start a control timer or two */ in sctp_med_chunk_output()
8833 /* must start a send timer if data is being sent */ in sctp_med_chunk_output()
8834 if (bundle_at && (!SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer))) { in sctp_med_chunk_output()
8836 * no timer running on this destination in sctp_med_chunk_output()
8847 net->last_sent_time = *now; in sctp_med_chunk_output()
8853 (struct sockaddr *)&net->ro._l_addr, in sctp_med_chunk_output()
8861 inp->sctp_lport, stcb->rport, in sctp_med_chunk_output()
8862 htonl(stcb->asoc.peer_vtag), in sctp_med_chunk_output()
8863 net->port, NULL, in sctp_med_chunk_output()
8873 asoc->ifp_had_enobuf = 1; in sctp_med_chunk_output()
8885 /*- in sctp_med_chunk_output()
8895 asoc->ifp_had_enobuf = 0; in sctp_med_chunk_output()
8906 tsns_sent = data_list[0]->rec.data.tsn; in sctp_med_chunk_output()
8909 (void)SCTP_GETTIME_TIMEVAL(&asoc->time_last_sent); in sctp_med_chunk_output()
8911 *now = asoc->time_last_sent; in sctp_med_chunk_output()
8913 asoc->time_last_sent = *now; in sctp_med_chunk_output()
8915 if (net->rto_needed) { in sctp_med_chunk_output()
8916 data_list[0]->do_rtt = 1; in sctp_med_chunk_output()
8917 net->rto_needed = 0; in sctp_med_chunk_output()
8932 start_at = TAILQ_FIRST(&asoc->nets); in sctp_med_chunk_output()
8956 /*- in sctp_queue_op_err()
8985 padding_length = 4 - padding_length; in sctp_queue_op_err()
8999 chk->copy_by_ref = 0; in sctp_queue_op_err()
9000 chk->rec.chunk_id.id = SCTP_OPERATION_ERROR; in sctp_queue_op_err()
9001 chk->rec.chunk_id.can_take_data = 0; in sctp_queue_op_err()
9002 chk->flags = 0; in sctp_queue_op_err()
9003 chk->send_size = (uint16_t)chunk_length; in sctp_queue_op_err()
9004 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_queue_op_err()
9005 chk->snd_count = 0; in sctp_queue_op_err()
9006 chk->asoc = &stcb->asoc; in sctp_queue_op_err()
9007 chk->data = op_err; in sctp_queue_op_err()
9008 chk->whoTo = NULL; in sctp_queue_op_err()
9010 hdr->chunk_type = SCTP_OPERATION_ERROR; in sctp_queue_op_err()
9011 hdr->chunk_flags = 0; in sctp_queue_op_err()
9012 hdr->chunk_length = htons(chk->send_size); in sctp_queue_op_err()
9013 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_queue_op_err()
9014 chk->asoc->ctrl_queue_cnt++; in sctp_queue_op_err()
9023 /*- in sctp_send_cookie_echo()
9041 return (-3); in sctp_send_cookie_echo()
9043 ptype = ntohs(phdr->param_type); in sctp_send_cookie_echo()
9044 plen = ntohs(phdr->param_length); in sctp_send_cookie_echo()
9046 return (-6); in sctp_send_cookie_echo()
9053 return (-7); in sctp_send_cookie_echo()
9058 return (-2); in sctp_send_cookie_echo()
9061 pad = 4 - pad; in sctp_send_cookie_echo()
9065 return (-8); in sctp_send_cookie_echo()
9080 hdr->chunk_type = SCTP_COOKIE_ECHO; in sctp_send_cookie_echo()
9081 hdr->chunk_flags = 0; in sctp_send_cookie_echo()
9087 return (-5); in sctp_send_cookie_echo()
9089 chk->copy_by_ref = 0; in sctp_send_cookie_echo()
9090 chk->rec.chunk_id.id = SCTP_COOKIE_ECHO; in sctp_send_cookie_echo()
9091 chk->rec.chunk_id.can_take_data = 0; in sctp_send_cookie_echo()
9092 chk->flags = CHUNK_FLAGS_FRAGMENT_OK; in sctp_send_cookie_echo()
9093 chk->send_size = SCTP_SIZE32(plen); in sctp_send_cookie_echo()
9094 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_cookie_echo()
9095 chk->snd_count = 0; in sctp_send_cookie_echo()
9096 chk->asoc = &stcb->asoc; in sctp_send_cookie_echo()
9097 chk->data = cookie; in sctp_send_cookie_echo()
9098 chk->whoTo = net; in sctp_send_cookie_echo()
9099 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_cookie_echo()
9100 TAILQ_INSERT_HEAD(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_send_cookie_echo()
9101 chk->asoc->ctrl_queue_cnt++; in sctp_send_cookie_echo()
9134 chdr->chunk_type = SCTP_HEARTBEAT_ACK; in sctp_send_heartbeat_ack()
9135 chdr->chunk_flags = 0; in sctp_send_heartbeat_ack()
9137 sctp_pad_lastmbuf(outchain, 4 - (chk_length % 4), NULL); in sctp_send_heartbeat_ack()
9145 chk->copy_by_ref = 0; in sctp_send_heartbeat_ack()
9146 chk->rec.chunk_id.id = SCTP_HEARTBEAT_ACK; in sctp_send_heartbeat_ack()
9147 chk->rec.chunk_id.can_take_data = 1; in sctp_send_heartbeat_ack()
9148 chk->flags = 0; in sctp_send_heartbeat_ack()
9149 chk->send_size = chk_length; in sctp_send_heartbeat_ack()
9150 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_heartbeat_ack()
9151 chk->snd_count = 0; in sctp_send_heartbeat_ack()
9152 chk->asoc = &stcb->asoc; in sctp_send_heartbeat_ack()
9153 chk->data = outchain; in sctp_send_heartbeat_ack()
9154 chk->whoTo = net; in sctp_send_heartbeat_ack()
9155 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_heartbeat_ack()
9156 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_send_heartbeat_ack()
9157 chk->asoc->ctrl_queue_cnt++; in sctp_send_heartbeat_ack()
9163 /* formulate and queue a cookie-ack back to sender */ in sctp_send_cookie_ack()
9182 chk->copy_by_ref = 0; in sctp_send_cookie_ack()
9183 chk->rec.chunk_id.id = SCTP_COOKIE_ACK; in sctp_send_cookie_ack()
9184 chk->rec.chunk_id.can_take_data = 1; in sctp_send_cookie_ack()
9185 chk->flags = 0; in sctp_send_cookie_ack()
9186 chk->send_size = sizeof(struct sctp_chunkhdr); in sctp_send_cookie_ack()
9187 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_cookie_ack()
9188 chk->snd_count = 0; in sctp_send_cookie_ack()
9189 chk->asoc = &stcb->asoc; in sctp_send_cookie_ack()
9190 chk->data = cookie_ack; in sctp_send_cookie_ack()
9191 if (chk->asoc->last_control_chunk_from != NULL) { in sctp_send_cookie_ack()
9192 chk->whoTo = chk->asoc->last_control_chunk_from; in sctp_send_cookie_ack()
9193 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_cookie_ack()
9195 chk->whoTo = NULL; in sctp_send_cookie_ack()
9198 hdr->chunk_type = SCTP_COOKIE_ACK; in sctp_send_cookie_ack()
9199 hdr->chunk_flags = 0; in sctp_send_cookie_ack()
9200 hdr->chunk_length = htons(chk->send_size); in sctp_send_cookie_ack()
9201 SCTP_BUF_LEN(cookie_ack) = chk->send_size; in sctp_send_cookie_ack()
9202 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_send_cookie_ack()
9203 chk->asoc->ctrl_queue_cnt++; in sctp_send_cookie_ack()
9210 /* formulate and queue a SHUTDOWN-ACK back to the sender */ in sctp_send_shutdown_ack()
9227 chk->copy_by_ref = 0; in sctp_send_shutdown_ack()
9228 chk->rec.chunk_id.id = SCTP_SHUTDOWN_ACK; in sctp_send_shutdown_ack()
9229 chk->rec.chunk_id.can_take_data = 1; in sctp_send_shutdown_ack()
9230 chk->flags = 0; in sctp_send_shutdown_ack()
9231 chk->send_size = sizeof(struct sctp_chunkhdr); in sctp_send_shutdown_ack()
9232 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_shutdown_ack()
9233 chk->snd_count = 0; in sctp_send_shutdown_ack()
9234 chk->asoc = &stcb->asoc; in sctp_send_shutdown_ack()
9235 chk->data = m_shutdown_ack; in sctp_send_shutdown_ack()
9236 chk->whoTo = net; in sctp_send_shutdown_ack()
9237 if (chk->whoTo) { in sctp_send_shutdown_ack()
9238 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_shutdown_ack()
9241 ack_cp->ch.chunk_type = SCTP_SHUTDOWN_ACK; in sctp_send_shutdown_ack()
9242 ack_cp->ch.chunk_flags = 0; in sctp_send_shutdown_ack()
9243 ack_cp->ch.chunk_length = htons(chk->send_size); in sctp_send_shutdown_ack()
9244 SCTP_BUF_LEN(m_shutdown_ack) = chk->send_size; in sctp_send_shutdown_ack()
9245 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_send_shutdown_ack()
9246 chk->asoc->ctrl_queue_cnt++; in sctp_send_shutdown_ack()
9258 TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) { in sctp_send_shutdown()
9259 if (chk->rec.chunk_id.id == SCTP_SHUTDOWN) { in sctp_send_shutdown()
9261 if (chk->whoTo) { in sctp_send_shutdown()
9262 sctp_free_remote_addr(chk->whoTo); in sctp_send_shutdown()
9263 chk->whoTo = NULL; in sctp_send_shutdown()
9281 chk->copy_by_ref = 0; in sctp_send_shutdown()
9282 chk->rec.chunk_id.id = SCTP_SHUTDOWN; in sctp_send_shutdown()
9283 chk->rec.chunk_id.can_take_data = 1; in sctp_send_shutdown()
9284 chk->flags = 0; in sctp_send_shutdown()
9285 chk->send_size = sizeof(struct sctp_shutdown_chunk); in sctp_send_shutdown()
9286 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_shutdown()
9287 chk->snd_count = 0; in sctp_send_shutdown()
9288 chk->asoc = &stcb->asoc; in sctp_send_shutdown()
9289 chk->data = m_shutdown; in sctp_send_shutdown()
9290 chk->whoTo = net; in sctp_send_shutdown()
9291 if (chk->whoTo) { in sctp_send_shutdown()
9292 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_shutdown()
9295 shutdown_cp->ch.chunk_type = SCTP_SHUTDOWN; in sctp_send_shutdown()
9296 shutdown_cp->ch.chunk_flags = 0; in sctp_send_shutdown()
9297 shutdown_cp->ch.chunk_length = htons(chk->send_size); in sctp_send_shutdown()
9298 shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn); in sctp_send_shutdown()
9299 SCTP_BUF_LEN(m_shutdown) = chk->send_size; in sctp_send_shutdown()
9300 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_send_shutdown()
9301 chk->asoc->ctrl_queue_cnt++; in sctp_send_shutdown()
9303 TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, sctp_next); in sctp_send_shutdown()
9304 chk->whoTo = net; in sctp_send_shutdown()
9305 if (chk->whoTo) { in sctp_send_shutdown()
9306 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_shutdown()
9308 shutdown_cp = mtod(chk->data, struct sctp_shutdown_chunk *); in sctp_send_shutdown()
9309 shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn); in sctp_send_shutdown()
9310 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next); in sctp_send_shutdown()
9328 if ((!TAILQ_EMPTY(&stcb->asoc.asconf_send_queue)) && in sctp_send_asconf()
9329 (!sctp_is_feature_on(stcb->sctp_ep, SCTP_PCB_FLAGS_MULTIPLE_ASCONFS))) { in sctp_send_asconf()
9347 chk->copy_by_ref = 0; in sctp_send_asconf()
9348 chk->rec.chunk_id.id = SCTP_ASCONF; in sctp_send_asconf()
9349 chk->rec.chunk_id.can_take_data = 0; in sctp_send_asconf()
9350 chk->flags = CHUNK_FLAGS_FRAGMENT_OK; in sctp_send_asconf()
9351 chk->data = m_asconf; in sctp_send_asconf()
9352 chk->send_size = len; in sctp_send_asconf()
9353 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_asconf()
9354 chk->snd_count = 0; in sctp_send_asconf()
9355 chk->asoc = &stcb->asoc; in sctp_send_asconf()
9356 chk->whoTo = net; in sctp_send_asconf()
9357 if (chk->whoTo) { in sctp_send_asconf()
9358 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_asconf()
9360 TAILQ_INSERT_TAIL(&chk->asoc->asconf_send_queue, chk, sctp_next); in sctp_send_asconf()
9361 chk->asoc->ctrl_queue_cnt++; in sctp_send_asconf()
9369 * formulate and queue a asconf-ack back to sender. the asconf-ack in sctp_send_asconf_ack()
9378 /* Get the latest ASCONF-ACK */ in sctp_send_asconf_ack()
9379 latest_ack = TAILQ_LAST(&stcb->asoc.asconf_ack_sent, sctp_asconf_ackhead); in sctp_send_asconf_ack()
9383 if (latest_ack->last_sent_to != NULL && in sctp_send_asconf_ack()
9384 latest_ack->last_sent_to == stcb->asoc.last_control_chunk_from) { in sctp_send_asconf_ack()
9386 net = sctp_find_alternate_net(stcb, stcb->asoc.last_control_chunk_from, 0); in sctp_send_asconf_ack()
9389 if (stcb->asoc.last_control_chunk_from == NULL) { in sctp_send_asconf_ack()
9390 if (stcb->asoc.alternate) { in sctp_send_asconf_ack()
9391 net = stcb->asoc.alternate; in sctp_send_asconf_ack()
9393 net = stcb->asoc.primary_destination; in sctp_send_asconf_ack()
9396 net = stcb->asoc.last_control_chunk_from; in sctp_send_asconf_ack()
9401 if (stcb->asoc.last_control_chunk_from == NULL) { in sctp_send_asconf_ack()
9402 if (stcb->asoc.alternate) { in sctp_send_asconf_ack()
9403 net = stcb->asoc.alternate; in sctp_send_asconf_ack()
9405 net = stcb->asoc.primary_destination; in sctp_send_asconf_ack()
9408 net = stcb->asoc.last_control_chunk_from; in sctp_send_asconf_ack()
9411 latest_ack->last_sent_to = net; in sctp_send_asconf_ack()
9413 TAILQ_FOREACH(ack, &stcb->asoc.asconf_ack_sent, next) { in sctp_send_asconf_ack()
9414 if (ack->data == NULL) { in sctp_send_asconf_ack()
9419 m_ack = SCTP_M_COPYM(ack->data, 0, M_COPYALL, M_NOWAIT); in sctp_send_asconf_ack()
9437 chk->copy_by_ref = 0; in sctp_send_asconf_ack()
9438 chk->rec.chunk_id.id = SCTP_ASCONF_ACK; in sctp_send_asconf_ack()
9439 chk->rec.chunk_id.can_take_data = 1; in sctp_send_asconf_ack()
9440 chk->flags = CHUNK_FLAGS_FRAGMENT_OK; in sctp_send_asconf_ack()
9441 chk->whoTo = net; in sctp_send_asconf_ack()
9442 if (chk->whoTo) { in sctp_send_asconf_ack()
9443 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_asconf_ack()
9445 chk->data = m_ack; in sctp_send_asconf_ack()
9446 chk->send_size = ack->len; in sctp_send_asconf_ack()
9447 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_asconf_ack()
9448 chk->snd_count = 0; in sctp_send_asconf_ack()
9449 chk->asoc = &stcb->asoc; in sctp_send_asconf_ack()
9451 TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); in sctp_send_asconf_ack()
9452 chk->asoc->ctrl_queue_cnt++; in sctp_send_asconf_ack()
9463 /*- in sctp_chunk_retransmission()
9473 * or t3-timeout routines). in sctp_chunk_retransmission()
9498 auth_keyid = stcb->asoc.authinfo.active_keyid; in sctp_chunk_retransmission()
9502 if ((TAILQ_EMPTY(&asoc->sent_queue)) && in sctp_chunk_retransmission()
9503 (TAILQ_EMPTY(&asoc->control_send_queue))) { in sctp_chunk_retransmission()
9505 asoc->sent_queue_retran_cnt); in sctp_chunk_retransmission()
9506 asoc->sent_queue_cnt = 0; in sctp_chunk_retransmission()
9507 asoc->sent_queue_cnt_removeable = 0; in sctp_chunk_retransmission()
9512 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_chunk_retransmission()
9513 if ((chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) || in sctp_chunk_retransmission()
9514 (chk->rec.chunk_id.id == SCTP_STREAM_RESET) || in sctp_chunk_retransmission()
9515 (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN)) { in sctp_chunk_retransmission()
9516 if (chk->sent != SCTP_DATAGRAM_RESEND) { in sctp_chunk_retransmission()
9519 if (chk->rec.chunk_id.id == SCTP_STREAM_RESET) { in sctp_chunk_retransmission()
9520 if (chk != asoc->str_reset) { in sctp_chunk_retransmission()
9529 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) { in sctp_chunk_retransmission()
9537 (sctp_auth_is_required_chunk(chk->rec.chunk_id.id, in sctp_chunk_retransmission()
9538 stcb->asoc.peer_auth_chunks))) { in sctp_chunk_retransmission()
9542 chk->rec.chunk_id.id); in sctp_chunk_retransmission()
9545 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref); in sctp_chunk_retransmission()
9552 /* Start a timer no matter if we succeed or fail */ in sctp_chunk_retransmission()
9553 switch (asoc->snd_edmid) { in sctp_chunk_retransmission()
9561 if (chk->rec.chunk_id.id == SCTP_COOKIE_ECHO) { in sctp_chunk_retransmission()
9562 sctp_timer_start(SCTP_TIMER_TYPE_COOKIE, inp, stcb, chk->whoTo); in sctp_chunk_retransmission()
9564 } else if (chk->rec.chunk_id.id == SCTP_ASCONF) { in sctp_chunk_retransmission()
9566 sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp, stcb, chk->whoTo); in sctp_chunk_retransmission()
9569 chk->snd_count++; /* update our count */ in sctp_chunk_retransmission()
9570 if ((error = sctp_lowlevel_chunk_output(inp, stcb, chk->whoTo, in sctp_chunk_retransmission()
9571 (struct sockaddr *)&chk->whoTo->ro._l_addr, m, in sctp_chunk_retransmission()
9572 auth_offset, auth, stcb->asoc.authinfo.active_keyid, in sctp_chunk_retransmission()
9574 inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), in sctp_chunk_retransmission()
9575 chk->whoTo->port, NULL, in sctp_chunk_retransmission()
9581 asoc->ifp_had_enobuf = 1; in sctp_chunk_retransmission()
9586 asoc->ifp_had_enobuf = 0; in sctp_chunk_retransmission()
9592 * We don't want to mark the net->sent time here since this in sctp_chunk_retransmission()
9593 * we use this for HB and retrans cannot measure RTT in sctp_chunk_retransmission()
9595 /* (void)SCTP_GETTIME_TIMEVAL(&chk->whoTo->last_sent_time); */ in sctp_chunk_retransmission()
9597 chk->sent = SCTP_DATAGRAM_SENT; in sctp_chunk_retransmission()
9598 sctp_ucount_decr(stcb->asoc.sent_queue_retran_cnt); in sctp_chunk_retransmission()
9602 /* Clean up the fwd-tsn list */ in sctp_chunk_retransmission()
9609 * fwd-tsn with it all. in sctp_chunk_retransmission()
9611 if (TAILQ_EMPTY(&asoc->sent_queue)) { in sctp_chunk_retransmission()
9622 data_auth_reqd = sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.peer_auth_chunks); in sctp_chunk_retransmission()
9623 TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { in sctp_chunk_retransmission()
9624 if (chk->sent != SCTP_DATAGRAM_RESEND) { in sctp_chunk_retransmission()
9628 if (chk->data == NULL) { in sctp_chunk_retransmission()
9629 SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n", in sctp_chunk_retransmission()
9630 chk->rec.data.tsn, chk->snd_count, chk->sent); in sctp_chunk_retransmission()
9634 (chk->snd_count >= SCTP_BASE_SYSCTL(sctp_max_retran_chunk))) { in sctp_chunk_retransmission()
9639 chk->rec.data.tsn, chk->snd_count); in sctp_chunk_retransmission()
9642 atomic_add_int(&stcb->asoc.refcnt, 1); in sctp_chunk_retransmission()
9643 sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, in sctp_chunk_retransmission()
9646 atomic_subtract_int(&stcb->asoc.refcnt, 1); in sctp_chunk_retransmission()
9650 net = chk->whoTo; in sctp_chunk_retransmission()
9651 switch (net->ro._l_addr.sa.sa_family) { in sctp_chunk_retransmission()
9654 mtu = net->mtu - SCTP_MIN_V4_OVERHEAD; in sctp_chunk_retransmission()
9659 mtu = net->mtu - SCTP_MIN_OVERHEAD; in sctp_chunk_retransmission()
9664 mtu = net->mtu; in sctp_chunk_retransmission()
9668 if ((asoc->peers_rwnd < mtu) && (asoc->total_flight > 0)) { in sctp_chunk_retransmission()
9672 tsn = asoc->last_acked_seq + 1; in sctp_chunk_retransmission()
9673 if (tsn == chk->rec.data.tsn) { in sctp_chunk_retransmission()
9685 if (asoc->peers_rwnd < mtu) { in sctp_chunk_retransmission()
9687 if ((asoc->peers_rwnd == 0) && in sctp_chunk_retransmission()
9688 (asoc->total_flight == 0)) { in sctp_chunk_retransmission()
9689 chk->window_probe = 1; in sctp_chunk_retransmission()
9690 chk->whoTo->window_probe = 1; in sctp_chunk_retransmission()
9698 net->fast_retran_ip = 0; in sctp_chunk_retransmission()
9699 if (chk->rec.data.doing_fast_retransmit == 0) { in sctp_chunk_retransmission()
9704 if (net->flight_size >= net->cwnd) { in sctp_chunk_retransmission()
9713 net->fast_retran_ip = 1; in sctp_chunk_retransmission()
9723 dmtu = sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); in sctp_chunk_retransmission()
9727 if ((chk->send_size <= (mtu - dmtu)) || in sctp_chunk_retransmission()
9728 (chk->flags & CHUNK_FLAGS_FRAGMENT_OK)) { in sctp_chunk_retransmission()
9738 auth_keyid = chk->auth_keyid; in sctp_chunk_retransmission()
9742 auth_keyid = chk->auth_keyid; in sctp_chunk_retransmission()
9744 } else if (chk->auth_keyid != auth_keyid) { in sctp_chunk_retransmission()
9749 m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref); in sctp_chunk_retransmission()
9755 if (chk->flags & CHUNK_FLAGS_FRAGMENT_OK) { in sctp_chunk_retransmission()
9759 if (mtu > (chk->send_size + dmtu)) in sctp_chunk_retransmission()
9760 mtu -= (chk->send_size + dmtu); in sctp_chunk_retransmission()
9764 if (one_chunk && (asoc->total_flight <= 0)) { in sctp_chunk_retransmission()
9774 if (fwd->sent != SCTP_DATAGRAM_RESEND) { in sctp_chunk_retransmission()
9778 if (fwd->whoTo != net) { in sctp_chunk_retransmission()
9783 dmtu = sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id); in sctp_chunk_retransmission()
9786 if (fwd->send_size <= (mtu - dmtu)) { in sctp_chunk_retransmission()
9795 auth_keyid = fwd->auth_keyid; in sctp_chunk_retransmission()
9799 auth_keyid = fwd->auth_keyid; in sctp_chunk_retransmission()
9801 } else if (fwd->auth_keyid != auth_keyid) { in sctp_chunk_retransmission()
9809 m = sctp_copy_mbufchain(fwd->data, m, &endofchain, 0, fwd->send_size, fwd->copy_by_ref); in sctp_chunk_retransmission()
9815 if (fwd->flags & CHUNK_FLAGS_FRAGMENT_OK) { in sctp_chunk_retransmission()
9819 if (mtu > (fwd->send_size + dmtu)) in sctp_chunk_retransmission()
9820 mtu -= (fwd->send_size + dmtu); in sctp_chunk_retransmission()
9837 * timer. A failure is like a lost IP packet :-) in sctp_chunk_retransmission()
9839 if (!SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { in sctp_chunk_retransmission()
9841 * no timer running on this destination in sctp_chunk_retransmission()
9847 switch (asoc->snd_edmid) { in sctp_chunk_retransmission()
9857 (struct sockaddr *)&net->ro._l_addr, m, in sctp_chunk_retransmission()
9860 inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), in sctp_chunk_retransmission()
9861 net->port, NULL, in sctp_chunk_retransmission()
9868 asoc->ifp_had_enobuf = 1; in sctp_chunk_retransmission()
9873 asoc->ifp_had_enobuf = 0; in sctp_chunk_retransmission()
9880 * We don't want to mark the net->sent time here in sctp_chunk_retransmission()
9882 * measure RTT in sctp_chunk_retransmission()
9884 /* (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time); */ in sctp_chunk_retransmission()
9886 /* For auto-close */ in sctp_chunk_retransmission()
9888 (void)SCTP_GETTIME_TIMEVAL(&asoc->time_last_sent); in sctp_chunk_retransmission()
9889 *now = asoc->time_last_sent; in sctp_chunk_retransmission()
9892 asoc->time_last_sent = *now; in sctp_chunk_retransmission()
9899 tsns_sent = data_list[0]->rec.data.tsn; in sctp_chunk_retransmission()
9903 data_list[i]->sent = SCTP_DATAGRAM_SENT; in sctp_chunk_retransmission()
9910 if (data_list[i]->rec.data.chunk_was_revoked) { in sctp_chunk_retransmission()
9912 data_list[i]->whoTo->cwnd -= data_list[i]->book_size; in sctp_chunk_retransmission()
9913 data_list[i]->rec.data.chunk_was_revoked = 0; in sctp_chunk_retransmission()
9915 data_list[i]->snd_count++; in sctp_chunk_retransmission()
9916 sctp_ucount_decr(asoc->sent_queue_retran_cnt); in sctp_chunk_retransmission()
9918 data_list[i]->sent_rcv_time = asoc->time_last_sent; in sctp_chunk_retransmission()
9919 if (data_list[i]->book_size_scale) { in sctp_chunk_retransmission()
9924 data_list[i]->book_size_scale = 0; in sctp_chunk_retransmission()
9931 atomic_add_int(&((asoc)->total_output_queue_size), data_list[i]->book_size); in sctp_chunk_retransmission()
9932 data_list[i]->book_size *= 2; in sctp_chunk_retransmission()
9936 asoc->peers_rwnd, data_list[i]->send_size, SCTP_BASE_SYSCTL(sctp_peer_chunk_oh)); in sctp_chunk_retransmission()
9938 asoc->peers_rwnd = sctp_sbspace_sub(asoc->peers_rwnd, in sctp_chunk_retransmission()
9939 (uint32_t)(data_list[i]->send_size + in sctp_chunk_retransmission()
9944 data_list[i]->whoTo->flight_size, in sctp_chunk_retransmission()
9945 data_list[i]->book_size, in sctp_chunk_retransmission()
9946 (uint32_t)(uintptr_t)data_list[i]->whoTo, in sctp_chunk_retransmission()
9947 data_list[i]->rec.data.tsn); in sctp_chunk_retransmission()
9951 if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) { in sctp_chunk_retransmission()
9953 asoc->peers_rwnd = 0; in sctp_chunk_retransmission()
9956 (data_list[i]->rec.data.doing_fast_retransmit)) { in sctp_chunk_retransmission()
9958 if ((data_list[i] == TAILQ_FIRST(&asoc->sent_queue)) && in sctp_chunk_retransmission()
9960 /*- in sctp_chunk_retransmission()
9961 * ok we just fast-retrans'd in sctp_chunk_retransmission()
9967 * t3-expiring. in sctp_chunk_retransmission()
9985 if (asoc->sent_queue_retran_cnt <= 0) { in sctp_chunk_retransmission()
9987 asoc->sent_queue_retran_cnt = 0; in sctp_chunk_retransmission()
10007 /* Validate that a timer is running somewhere */ in sctp_timer_validation()
10008 TAILQ_FOREACH(net, &asoc->nets, sctp_next) { in sctp_timer_validation()
10009 if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { in sctp_timer_validation()
10010 /* Here is a timer */ in sctp_timer_validation()
10015 /* Gak, we did not have a timer somewhere */ in sctp_timer_validation()
10016 SCTPDBG(SCTP_DEBUG_OUTPUT3, "Deadlock avoided starting timer on a dest at retran\n"); in sctp_timer_validation()
10017 if (asoc->alternate) { in sctp_timer_validation()
10018 sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb, asoc->alternate); in sctp_timer_validation()
10020 sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb, asoc->primary_destination); in sctp_timer_validation()
10031 /*- in sctp_chunk_output()
10034 * - See if there are retransmits pending, if so we must in sctp_chunk_output()
10036 * - Service the stream queue that is next, moving any in sctp_chunk_output()
10040 * - Check to see if the cwnd/rwnd allows any output, if so we in sctp_chunk_output()
10056 asoc = &stcb->asoc; in sctp_chunk_output()
10070 un_sent = (stcb->asoc.total_output_queue_size - stcb->asoc.total_flight); in sctp_chunk_output()
10073 (TAILQ_EMPTY(&asoc->control_send_queue)) && in sctp_chunk_output()
10074 (TAILQ_EMPTY(&asoc->asconf_send_queue)) && in sctp_chunk_output()
10075 (asoc->sent_queue_retran_cnt == 0) && in sctp_chunk_output()
10076 (asoc->trigger_reset == 0)) { in sctp_chunk_output()
10081 * Do we have something to send, data or control AND a sack timer in sctp_chunk_output()
10082 * running, if so piggy-back the sack. in sctp_chunk_output()
10084 if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { in sctp_chunk_output()
10086 sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, in sctp_chunk_output()
10089 while (asoc->sent_queue_retran_cnt) { in sctp_chunk_output()
10090 /*- in sctp_chunk_output()
10095 /*- in sctp_chunk_output()
10097 * by peer that carried data. Send cookie-ack only in sctp_chunk_output()
10120 /*- in sctp_chunk_output()
10121 * now lets push out control by calling med-level in sctp_chunk_output()
10135 /*- in sctp_chunk_output()
10157 if ((asoc->fr_max_burst > 0) && (tot_frs >= asoc->fr_max_burst)) { in sctp_chunk_output()
10170 TAILQ_FOREACH(net, &asoc->nets, sctp_next) { in sctp_chunk_output()
10171 if ((net->dest_state & SCTP_ADDR_REACHABLE) == 0) { in sctp_chunk_output()
10172 /*- in sctp_chunk_output()
10179 if (net->ref_count > 1) in sctp_chunk_output()
10182 /*- in sctp_chunk_output()
10183 * if ((asoc->sat_network) || (net->addr_is_local)) in sctp_chunk_output()
10184 * { burst_limit = asoc->max_burst * in sctp_chunk_output()
10187 if (asoc->max_burst > 0) { in sctp_chunk_output()
10189 if ((net->flight_size + (asoc->max_burst * net->mtu)) < net->cwnd) { in sctp_chunk_output()
10191 * JRS - Use the congestion in sctp_chunk_output()
10195 asoc->cc_functions.sctp_cwnd_update_after_output(stcb, net, asoc->max_burst); in sctp_chunk_output()
10197 sctp_log_maxburst(stcb, net, 0, asoc->max_burst, SCTP_MAX_BURST_APPLIED); in sctp_chunk_output()
10201 net->fast_retran_ip = 0; in sctp_chunk_output()
10203 if (net->flight_size == 0) { in sctp_chunk_output()
10220 SCTPDBG(SCTP_DEBUG_OUTPUT1, "Error %d was returned from med-c-op\n", error); in sctp_chunk_output()
10222 sctp_log_maxburst(stcb, asoc->primary_destination, error, burst_cnt, SCTP_MAX_BURST_ERROR_STOP); in sctp_chunk_output()
10230 SCTPDBG(SCTP_DEBUG_OUTPUT3, "m-c-o put out %d\n", num_out); in sctp_chunk_output()
10247 un_sent = stcb->asoc.total_output_queue_size - stcb->asoc.total_flight; in sctp_chunk_output()
10248 if ((un_sent < (int)(stcb->asoc.smallest_mtu - SCTP_MIN_OVERHEAD)) && in sctp_chunk_output()
10249 (stcb->asoc.total_flight > 0)) { in sctp_chunk_output()
10254 if (TAILQ_EMPTY(&asoc->control_send_queue) && in sctp_chunk_output()
10255 TAILQ_EMPTY(&asoc->send_queue) && in sctp_chunk_output()
10260 if ((stcb->asoc.total_output_queue_size - stcb->asoc.total_flight) <= 0) { in sctp_chunk_output()
10265 ((asoc->max_burst == 0) || in sctp_chunk_output()
10267 (burst_cnt < asoc->max_burst))); in sctp_chunk_output()
10270 if ((asoc->max_burst > 0) && (burst_cnt >= asoc->max_burst)) { in sctp_chunk_output()
10272 asoc->burst_limit_applied = 1; in sctp_chunk_output()
10274 sctp_log_maxburst(stcb, asoc->primary_destination, 0, burst_cnt, SCTP_MAX_BURST_APPLIED); in sctp_chunk_output()
10277 asoc->burst_limit_applied = 0; in sctp_chunk_output()
10286 /*- in sctp_chunk_output()
10291 if (stcb->asoc.ecn_echo_cnt_onq) in sctp_chunk_output()
10294 if (stcb->asoc.trigger_reset) { in sctp_chunk_output()
10316 if (inp->sctp_socket == NULL) { in sctp_output()
10320 return (sctp_sosend(inp->sctp_socket, in sctp_output()
10343 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in send_forward_tsn()
10344 if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) { in send_forward_tsn()
10346 chk->sent = SCTP_DATAGRAM_UNSENT; in send_forward_tsn()
10347 chk->snd_count = 0; in send_forward_tsn()
10349 if (chk->whoTo) { in send_forward_tsn()
10350 sctp_free_remote_addr(chk->whoTo); in send_forward_tsn()
10351 chk->whoTo = NULL; in send_forward_tsn()
10361 asoc->fwd_tsn_cnt++; in send_forward_tsn()
10362 chk->copy_by_ref = 0; in send_forward_tsn()
10364 * We don't do the old thing here since this is used not for on-wire in send_forward_tsn()
10365 * but to tell if we are sending a fwd-tsn by the stack during in send_forward_tsn()
10366 * output. And if its a IFORWARD or a FORWARD it is a fwd-tsn. in send_forward_tsn()
10368 chk->rec.chunk_id.id = SCTP_FORWARD_CUM_TSN; in send_forward_tsn()
10369 chk->rec.chunk_id.can_take_data = 0; in send_forward_tsn()
10370 chk->flags = 0; in send_forward_tsn()
10371 chk->asoc = asoc; in send_forward_tsn()
10372 chk->whoTo = NULL; in send_forward_tsn()
10373 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); in send_forward_tsn()
10374 if (chk->data == NULL) { in send_forward_tsn()
10378 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in send_forward_tsn()
10379 chk->sent = SCTP_DATAGRAM_UNSENT; in send_forward_tsn()
10380 chk->snd_count = 0; in send_forward_tsn()
10381 TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, sctp_next); in send_forward_tsn()
10382 asoc->ctrl_queue_cnt++; in send_forward_tsn()
10384 /*- in send_forward_tsn()
10388 SCTP_BUF_LEN(chk->data) = 0; in send_forward_tsn()
10389 TAILQ_FOREACH(at, &asoc->sent_queue, sctp_next) { in send_forward_tsn()
10390 if ((at->sent != SCTP_FORWARD_TSN_SKIP) && in send_forward_tsn()
10391 (at->sent != SCTP_DATAGRAM_NR_ACKED)) { in send_forward_tsn()
10395 if (!asoc->idata_supported && (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED)) { in send_forward_tsn()
10401 if (asoc->idata_supported) { in send_forward_tsn()
10408 cnt_of_space = (unsigned int)M_TRAILINGSPACE(chk->data); in send_forward_tsn()
10410 if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { in send_forward_tsn()
10415 if (cnt_of_space > (asoc->smallest_mtu - ovh)) { in send_forward_tsn()
10417 cnt_of_space = asoc->smallest_mtu - ovh; in send_forward_tsn()
10422 asoc->advanced_peer_ack_point); in send_forward_tsn()
10424 advance_peer_ack_point = asoc->advanced_peer_ack_point; in send_forward_tsn()
10426 /*- in send_forward_tsn()
10435 cnt_of_skipped = cnt_of_space - sizeof(struct sctp_forward_tsn_chunk); in send_forward_tsn()
10436 if (asoc->idata_supported) { in send_forward_tsn()
10441 /*- in send_forward_tsn()
10445 at = TAILQ_FIRST(&asoc->sent_queue); in send_forward_tsn()
10457 0xff, cnt_of_skipped, at->rec.data.tsn, in send_forward_tsn()
10458 asoc->advanced_peer_ack_point); in send_forward_tsn()
10461 /*- in send_forward_tsn()
10466 advance_peer_ack_point = last->rec.data.tsn; in send_forward_tsn()
10468 if (asoc->idata_supported) { in send_forward_tsn()
10476 chk->send_size = space_needed; in send_forward_tsn()
10478 fwdtsn = mtod(chk->data, struct sctp_forward_tsn_chunk *); in send_forward_tsn()
10479 fwdtsn->ch.chunk_length = htons(chk->send_size); in send_forward_tsn()
10480 fwdtsn->ch.chunk_flags = 0; in send_forward_tsn()
10481 if (asoc->idata_supported) { in send_forward_tsn()
10482 fwdtsn->ch.chunk_type = SCTP_IFORWARD_CUM_TSN; in send_forward_tsn()
10484 fwdtsn->ch.chunk_type = SCTP_FORWARD_CUM_TSN; in send_forward_tsn()
10486 fwdtsn->new_cumulative_tsn = htonl(advance_peer_ack_point); in send_forward_tsn()
10487 SCTP_BUF_LEN(chk->data) = chk->send_size; in send_forward_tsn()
10489 /*- in send_forward_tsn()
10493 if (asoc->idata_supported) { in send_forward_tsn()
10500 /*- in send_forward_tsn()
10508 * one FWD-TSN. With a bit of work we can later FIX this to in send_forward_tsn()
10513 TAILQ_FOREACH(at, &asoc->sent_queue, sctp_next) { in send_forward_tsn()
10517 if (!asoc->idata_supported && (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED)) { in send_forward_tsn()
10521 if (at->rec.data.tsn == advance_peer_ack_point) { in send_forward_tsn()
10522 at->rec.data.fwd_tsn_cnt = 0; in send_forward_tsn()
10524 if (asoc->idata_supported) { in send_forward_tsn()
10525 strseq_m->sid = htons(at->rec.data.sid); in send_forward_tsn()
10526 if (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED) { in send_forward_tsn()
10527 strseq_m->flags = htons(PR_SCTP_UNORDERED_FLAG); in send_forward_tsn()
10529 strseq_m->flags = 0; in send_forward_tsn()
10531 strseq_m->mid = htonl(at->rec.data.mid); in send_forward_tsn()
10534 strseq->sid = htons(at->rec.data.sid); in send_forward_tsn()
10535 strseq->ssn = htons((uint16_t)at->rec.data.mid); in send_forward_tsn()
10546 /*- in sctp_send_sack()
10547 * Queue up a SACK or NR-SACK in the control queue. in sctp_send_sack()
10548 * We must first check to see if a SACK or NR-SACK is in sctp_send_sack()
10572 if (stcb->asoc.nrsack_supported == 1) { in sctp_send_sack()
10578 asoc = &stcb->asoc; in sctp_send_sack()
10580 if (asoc->last_data_chunk_from == NULL) { in sctp_send_sack()
10586 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_send_sack()
10587 if (chk->rec.chunk_id.id == type) { in sctp_send_sack()
10589 TAILQ_REMOVE(&asoc->control_send_queue, chk, sctp_next); in sctp_send_sack()
10590 asoc->ctrl_queue_cnt--; in sctp_send_sack()
10592 if (a_chk->data) { in sctp_send_sack()
10593 sctp_m_freem(a_chk->data); in sctp_send_sack()
10594 a_chk->data = NULL; in sctp_send_sack()
10596 if (a_chk->whoTo) { in sctp_send_sack()
10597 sctp_free_remote_addr(a_chk->whoTo); in sctp_send_sack()
10598 a_chk->whoTo = NULL; in sctp_send_sack()
10606 /* No memory so we drop the idea, and set a timer */ in sctp_send_sack()
10607 if (stcb->asoc.delayed_ack) { in sctp_send_sack()
10609 stcb->sctp_ep, stcb, NULL, in sctp_send_sack()
10612 stcb->sctp_ep, stcb, NULL); in sctp_send_sack()
10614 stcb->asoc.send_sack = 1; in sctp_send_sack()
10618 a_chk->copy_by_ref = 0; in sctp_send_sack()
10619 a_chk->rec.chunk_id.id = type; in sctp_send_sack()
10620 a_chk->rec.chunk_id.can_take_data = 1; in sctp_send_sack()
10623 asoc->data_pkts_seen = 0; in sctp_send_sack()
10625 a_chk->flags = 0; in sctp_send_sack()
10626 a_chk->asoc = asoc; in sctp_send_sack()
10627 a_chk->snd_count = 0; in sctp_send_sack()
10628 a_chk->send_size = 0; /* fill in later */ in sctp_send_sack()
10629 a_chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_sack()
10630 a_chk->whoTo = NULL; in sctp_send_sack()
10632 if ((asoc->last_data_chunk_from->dest_state & SCTP_ADDR_REACHABLE) == 0) { in sctp_send_sack()
10633 /*- in sctp_send_sack()
10635 * we can select an alternate to asoc->last_data_chunk_from in sctp_send_sack()
10637 a_chk->whoTo = sctp_find_alternate_net(stcb, asoc->last_data_chunk_from, 0); in sctp_send_sack()
10638 if (a_chk->whoTo == NULL) { in sctp_send_sack()
10640 a_chk->whoTo = asoc->last_data_chunk_from; in sctp_send_sack()
10643 a_chk->whoTo = asoc->last_data_chunk_from; in sctp_send_sack()
10645 if (a_chk->whoTo) { in sctp_send_sack()
10646 atomic_add_int(&a_chk->whoTo->ref_count, 1); in sctp_send_sack()
10648 if (SCTP_TSN_GT(asoc->highest_tsn_inside_map, asoc->highest_tsn_inside_nr_map)) { in sctp_send_sack()
10649 highest_tsn = asoc->highest_tsn_inside_map; in sctp_send_sack()
10651 highest_tsn = asoc->highest_tsn_inside_nr_map; in sctp_send_sack()
10653 if (highest_tsn == asoc->cumulative_tsn) { in sctp_send_sack()
10665 a_chk->data = sctp_get_mbuf_for_msg(space_req, 0, M_NOWAIT, 1, MT_DATA); in sctp_send_sack()
10666 if ((a_chk->data == NULL) || in sctp_send_sack()
10667 (a_chk->whoTo == NULL)) { in sctp_send_sack()
10669 if (a_chk->data) { in sctp_send_sack()
10671 sctp_m_freem(a_chk->data); in sctp_send_sack()
10672 a_chk->data = NULL; in sctp_send_sack()
10676 if (stcb->asoc.delayed_ack) { in sctp_send_sack()
10678 stcb->sctp_ep, stcb, NULL, in sctp_send_sack()
10681 stcb->sctp_ep, stcb, NULL); in sctp_send_sack()
10683 stcb->asoc.send_sack = 1; in sctp_send_sack()
10688 SCTP_BUF_RESV_UF(a_chk->data, SCTP_MIN_OVERHEAD); in sctp_send_sack()
10689 space = (unsigned int)M_TRAILINGSPACE(a_chk->data); in sctp_send_sack()
10690 if (space > (a_chk->whoTo->mtu - SCTP_MIN_OVERHEAD)) { in sctp_send_sack()
10691 space = (a_chk->whoTo->mtu - SCTP_MIN_OVERHEAD); in sctp_send_sack()
10693 limit = mtod(a_chk->data, caddr_t); in sctp_send_sack()
10698 if ((asoc->sctp_cmt_on_off > 0) && in sctp_send_sack()
10700 /*- in sctp_send_sack()
10705 flags |= (asoc->cmt_dac_pkts_rcvd << 6); in sctp_send_sack()
10706 asoc->cmt_dac_pkts_rcvd = 0; in sctp_send_sack()
10709 stcb->asoc.cumack_logsnt[stcb->asoc.cumack_log_atsnt] = asoc->cumulative_tsn; in sctp_send_sack()
10710 stcb->asoc.cumack_log_atsnt++; in sctp_send_sack()
10711 if (stcb->asoc.cumack_log_atsnt >= SCTP_TSN_LOG_SIZE) { in sctp_send_sack()
10712 stcb->asoc.cumack_log_atsnt = 0; in sctp_send_sack()
10716 stcb->freed_by_sorcv_sincelast = 0; in sctp_send_sack()
10719 sack = mtod(a_chk->data, struct sctp_sack_chunk *); in sctp_send_sack()
10722 if (highest_tsn > asoc->mapping_array_base_tsn) { in sctp_send_sack()
10723 siz = (((highest_tsn - asoc->mapping_array_base_tsn) + 1) + 7) / 8; in sctp_send_sack()
10725 siz = (((MAX_TSN - asoc->mapping_array_base_tsn) + 1) + highest_tsn + 7) / 8; in sctp_send_sack()
10729 nr_sack = mtod(a_chk->data, struct sctp_nr_sack_chunk *); in sctp_send_sack()
10731 if (asoc->highest_tsn_inside_map > asoc->mapping_array_base_tsn) { in sctp_send_sack()
10732 siz = (((asoc->highest_tsn_inside_map - asoc->mapping_array_base_tsn) + 1) + 7) / 8; in sctp_send_sack()
10734 siz = (((MAX_TSN - asoc->mapping_array_base_tsn) + 1) + asoc->highest_tsn_inside_map + 7) / 8; in sctp_send_sack()
10738 if (SCTP_TSN_GT(asoc->mapping_array_base_tsn, asoc->cumulative_tsn)) { in sctp_send_sack()
10741 offset = asoc->mapping_array_base_tsn - asoc->cumulative_tsn; in sctp_send_sack()
10744 SCTP_TSN_GT(highest_tsn, asoc->cumulative_tsn)) || in sctp_send_sack()
10746 SCTP_TSN_GT(asoc->highest_tsn_inside_map, asoc->cumulative_tsn))) { in sctp_send_sack()
10749 tsn_map = asoc->mapping_array[i]; in sctp_send_sack()
10751 tsn_map |= asoc->nr_mapping_array[i]; in sctp_send_sack()
10758 tsn_map &= (~0U << (1 - offset)); in sctp_send_sack()
10761 if (mergeable && selector->right_edge) { in sctp_send_sack()
10766 num_gap_blocks--; in sctp_send_sack()
10767 gap_descriptor--; in sctp_send_sack()
10769 if (selector->num_entries == 0) in sctp_send_sack()
10772 for (j = 0; j < selector->num_entries; j++) { in sctp_send_sack()
10773 if (mergeable && selector->right_edge) { in sctp_send_sack()
10785 gap_descriptor->start = htons((selector->gaps[j].start + offset)); in sctp_send_sack()
10787 gap_descriptor->end = htons((selector->gaps[j].end + offset)); in sctp_send_sack()
10796 if (selector->left_edge) { in sctp_send_sack()
10811 if (asoc->highest_tsn_inside_nr_map > asoc->mapping_array_base_tsn) { in sctp_send_sack()
10812 siz = (((asoc->highest_tsn_inside_nr_map - asoc->mapping_array_base_tsn) + 1) + 7) / 8; in sctp_send_sack()
10814 siz = (((MAX_TSN - asoc->mapping_array_base_tsn) + 1) + asoc->highest_tsn_inside_nr_map + 7) / 8; in sctp_send_sack()
10817 if (SCTP_TSN_GT(asoc->mapping_array_base_tsn, asoc->cumulative_tsn)) { in sctp_send_sack()
10820 offset = asoc->mapping_array_base_tsn - asoc->cumulative_tsn; in sctp_send_sack()
10822 if (SCTP_TSN_GT(asoc->highest_tsn_inside_nr_map, asoc->cumulative_tsn)) { in sctp_send_sack()
10825 tsn_map = asoc->nr_mapping_array[i]; in sctp_send_sack()
10832 tsn_map &= (~0U << (1 - offset)); in sctp_send_sack()
10835 if (mergeable && selector->right_edge) { in sctp_send_sack()
10840 num_nr_gap_blocks--; in sctp_send_sack()
10841 gap_descriptor--; in sctp_send_sack()
10843 if (selector->num_entries == 0) in sctp_send_sack()
10846 for (j = 0; j < selector->num_entries; j++) { in sctp_send_sack()
10847 if (mergeable && selector->right_edge) { in sctp_send_sack()
10860 gap_descriptor->start = htons((selector->gaps[j].start + offset)); in sctp_send_sack()
10862 gap_descriptor->end = htons((selector->gaps[j].end + offset)); in sctp_send_sack()
10871 if (selector->left_edge) { in sctp_send_sack()
10884 if ((limit_reached == 0) && (asoc->numduptsns)) { in sctp_send_sack()
10886 for (i = 0; i < asoc->numduptsns; i++) { in sctp_send_sack()
10887 *dup = htonl(asoc->dup_tsns[i]); in sctp_send_sack()
10895 asoc->numduptsns = 0; in sctp_send_sack()
10902 a_chk->send_size = (uint16_t)(sizeof(struct sctp_sack_chunk) + in sctp_send_sack()
10905 SCTP_BUF_LEN(a_chk->data) = a_chk->send_size; in sctp_send_sack()
10906 sack->sack.cum_tsn_ack = htonl(asoc->cumulative_tsn); in sctp_send_sack()
10907 sack->sack.a_rwnd = htonl(asoc->my_rwnd); in sctp_send_sack()
10908 sack->sack.num_gap_ack_blks = htons(num_gap_blocks); in sctp_send_sack()
10909 sack->sack.num_dup_tsns = htons(num_dups); in sctp_send_sack()
10910 sack->ch.chunk_type = type; in sctp_send_sack()
10911 sack->ch.chunk_flags = flags; in sctp_send_sack()
10912 sack->ch.chunk_length = htons(a_chk->send_size); in sctp_send_sack()
10914 a_chk->send_size = (uint16_t)(sizeof(struct sctp_nr_sack_chunk) + in sctp_send_sack()
10917 SCTP_BUF_LEN(a_chk->data) = a_chk->send_size; in sctp_send_sack()
10918 nr_sack->nr_sack.cum_tsn_ack = htonl(asoc->cumulative_tsn); in sctp_send_sack()
10919 nr_sack->nr_sack.a_rwnd = htonl(asoc->my_rwnd); in sctp_send_sack()
10920 nr_sack->nr_sack.num_gap_ack_blks = htons(num_gap_blocks); in sctp_send_sack()
10921 nr_sack->nr_sack.num_nr_gap_ack_blks = htons(num_nr_gap_blocks); in sctp_send_sack()
10922 nr_sack->nr_sack.num_dup_tsns = htons(num_dups); in sctp_send_sack()
10923 nr_sack->nr_sack.reserved = 0; in sctp_send_sack()
10924 nr_sack->ch.chunk_type = type; in sctp_send_sack()
10925 nr_sack->ch.chunk_flags = flags; in sctp_send_sack()
10926 nr_sack->ch.chunk_length = htons(a_chk->send_size); in sctp_send_sack()
10928 TAILQ_INSERT_TAIL(&asoc->control_send_queue, a_chk, sctp_next); in sctp_send_sack()
10929 asoc->my_last_reported_rwnd = asoc->my_rwnd; in sctp_send_sack()
10930 asoc->ctrl_queue_cnt++; in sctp_send_sack()
10931 asoc->send_sack = 0; in sctp_send_sack()
10951 /*- in sctp_send_abort_tcb()
10956 stcb->asoc.peer_auth_chunks)) { in sctp_send_abort_tcb()
10963 switch (stcb->asoc.snd_edmid) { in sctp_send_abort_tcb()
10993 padding_len = SCTP_SIZE32(chunk_len) - chunk_len; in sctp_send_abort_tcb()
11002 if (stcb->asoc.alternate) { in sctp_send_abort_tcb()
11003 net = stcb->asoc.alternate; in sctp_send_abort_tcb()
11005 net = stcb->asoc.primary_destination; in sctp_send_abort_tcb()
11009 abort->ch.chunk_type = SCTP_ABORT_ASSOCIATION; in sctp_send_abort_tcb()
11010 if (stcb->asoc.peer_vtag == 0) { in sctp_send_abort_tcb()
11011 /* This happens iff the assoc is in COOKIE-WAIT state. */ in sctp_send_abort_tcb()
11012 vtag = stcb->asoc.my_vtag; in sctp_send_abort_tcb()
11013 abort->ch.chunk_flags = SCTP_HAD_NO_TCB; in sctp_send_abort_tcb()
11015 vtag = stcb->asoc.peer_vtag; in sctp_send_abort_tcb()
11016 abort->ch.chunk_flags = 0; in sctp_send_abort_tcb()
11018 abort->ch.chunk_length = htons(chunk_len); in sctp_send_abort_tcb()
11027 if ((error = sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net, in sctp_send_abort_tcb()
11028 (struct sockaddr *)&net->ro._l_addr, in sctp_send_abort_tcb()
11029 m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0, in sctp_send_abort_tcb()
11030 stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag), in sctp_send_abort_tcb()
11031 stcb->asoc.primary_destination->port, NULL, in sctp_send_abort_tcb()
11037 stcb->asoc.ifp_had_enobuf = 1; in sctp_send_abort_tcb()
11041 stcb->asoc.ifp_had_enobuf = 0; in sctp_send_abort_tcb()
11051 /* formulate and SEND a SHUTDOWN-COMPLETE */ in sctp_send_shutdown_complete()
11066 vtag = stcb->asoc.my_vtag; in sctp_send_shutdown_complete()
11069 vtag = stcb->asoc.peer_vtag; in sctp_send_shutdown_complete()
11071 switch (stcb->asoc.snd_edmid) { in sctp_send_shutdown_complete()
11080 shutdown_complete->ch.chunk_type = SCTP_SHUTDOWN_COMPLETE; in sctp_send_shutdown_complete()
11081 shutdown_complete->ch.chunk_flags = flags; in sctp_send_shutdown_complete()
11082 shutdown_complete->ch.chunk_length = htons(sizeof(struct sctp_shutdown_complete_chunk)); in sctp_send_shutdown_complete()
11084 if ((error = sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net, in sctp_send_shutdown_complete()
11085 (struct sockaddr *)&net->ro._l_addr, in sctp_send_shutdown_complete()
11087 stcb->sctp_ep->sctp_lport, stcb->rport, in sctp_send_shutdown_complete()
11089 net->port, NULL, in sctp_send_shutdown_complete()
11095 stcb->asoc.ifp_had_enobuf = 1; in sctp_send_shutdown_complete()
11099 stcb->asoc.ifp_had_enobuf = 0; in sctp_send_shutdown_complete()
11141 padding_len = 4 - padding_len; in sctp_send_resp_msg()
11154 switch (dst->sa_family) { in sctp_send_resp_msg()
11184 mout->m_pkthdr.flowid = mflowid; in sctp_send_resp_msg()
11192 switch (dst->sa_family) { in sctp_send_resp_msg()
11198 ip->ip_v = IPVERSION; in sctp_send_resp_msg()
11199 ip->ip_hl = (sizeof(struct ip) >> 2); in sctp_send_resp_msg()
11200 ip->ip_tos = 0; in sctp_send_resp_msg()
11201 ip->ip_off = htons(IP_DF); in sctp_send_resp_msg()
11203 ip->ip_ttl = MODULE_GLOBAL(ip_defttl); in sctp_send_resp_msg()
11205 ip->ip_p = IPPROTO_UDP; in sctp_send_resp_msg()
11207 ip->ip_p = IPPROTO_SCTP; in sctp_send_resp_msg()
11209 ip->ip_src.s_addr = dst_sin->sin_addr.s_addr; in sctp_send_resp_msg()
11210 ip->ip_dst.s_addr = src_sin->sin_addr.s_addr; in sctp_send_resp_msg()
11211 ip->ip_sum = 0; in sctp_send_resp_msg()
11221 ip6->ip6_flow = htonl(0x60000000); in sctp_send_resp_msg()
11223 ip6->ip6_flow |= (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); in sctp_send_resp_msg()
11225 ip6->ip6_hlim = MODULE_GLOBAL(ip6_defhlim); in sctp_send_resp_msg()
11227 ip6->ip6_nxt = IPPROTO_UDP; in sctp_send_resp_msg()
11229 ip6->ip6_nxt = IPPROTO_SCTP; in sctp_send_resp_msg()
11231 ip6->ip6_src = dst_sin6->sin6_addr; in sctp_send_resp_msg()
11232 ip6->ip6_dst = src_sin6->sin6_addr; in sctp_send_resp_msg()
11249 udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); in sctp_send_resp_msg()
11250 udp->uh_dport = port; in sctp_send_resp_msg()
11251 udp->uh_sum = 0; in sctp_send_resp_msg()
11252 udp->uh_ulen = htons((uint16_t)(sizeof(struct udphdr) + in sctp_send_resp_msg()
11262 shout->src_port = sh->dest_port; in sctp_send_resp_msg()
11263 shout->dest_port = sh->src_port; in sctp_send_resp_msg()
11264 shout->checksum = 0; in sctp_send_resp_msg()
11266 shout->v_tag = htonl(vtag); in sctp_send_resp_msg()
11268 shout->v_tag = sh->v_tag; in sctp_send_resp_msg()
11272 ch->chunk_type = type; in sctp_send_resp_msg()
11274 ch->chunk_flags = 0; in sctp_send_resp_msg()
11276 ch->chunk_flags = SCTP_HAD_NO_TCB; in sctp_send_resp_msg()
11278 ch->chunk_length = htons((uint16_t)(sizeof(struct sctp_chunkhdr) + cause_len)); in sctp_send_resp_msg()
11287 switch (dst->sa_family) { in sctp_send_resp_msg()
11292 … udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); in sctp_send_resp_msg()
11294 udp->uh_sum = 0; in sctp_send_resp_msg()
11297 ip->ip_len = htons(len); in sctp_send_resp_msg()
11299 shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip) + sizeof(struct udphdr)); in sctp_send_resp_msg()
11305 mout->m_pkthdr.csum_flags = CSUM_SCTP; in sctp_send_resp_msg()
11306 mout->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); in sctp_send_resp_msg()
11320 ip6->ip6_plen = htons((uint16_t)(len - sizeof(struct ip6_hdr))); in sctp_send_resp_msg()
11322 shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); in sctp_send_resp_msg()
11324 …if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_h… in sctp_send_resp_msg()
11325 udp->uh_sum = 0xffff; in sctp_send_resp_msg()
11328 mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; in sctp_send_resp_msg()
11329 mout->m_pkthdr.csum_data = offsetof(struct sctphdr, checksum); in sctp_send_resp_msg()
11343 dst->sa_family); in sctp_send_resp_msg()
11384 switch (net->ro._l_addr.sa.sa_family) { in sctp_send_hb()
11402 chk->copy_by_ref = 0; in sctp_send_hb()
11403 chk->rec.chunk_id.id = SCTP_HEARTBEAT_REQUEST; in sctp_send_hb()
11404 chk->rec.chunk_id.can_take_data = 1; in sctp_send_hb()
11405 chk->flags = 0; in sctp_send_hb()
11406 chk->asoc = &stcb->asoc; in sctp_send_hb()
11407 chk->send_size = sizeof(struct sctp_heartbeat_chunk); in sctp_send_hb()
11409 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER); in sctp_send_hb()
11410 if (chk->data == NULL) { in sctp_send_hb()
11414 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_hb()
11415 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_hb()
11416 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_hb()
11417 chk->snd_count = 0; in sctp_send_hb()
11418 chk->whoTo = net; in sctp_send_hb()
11419 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_hb()
11421 hb = mtod(chk->data, struct sctp_heartbeat_chunk *); in sctp_send_hb()
11424 hb->ch.chunk_type = SCTP_HEARTBEAT_REQUEST; in sctp_send_hb()
11425 hb->ch.chunk_flags = 0; in sctp_send_hb()
11426 hb->ch.chunk_length = htons(chk->send_size); in sctp_send_hb()
11428 hb->heartbeat.hb_info.ph.param_type = htons(SCTP_HEARTBEAT_INFO); in sctp_send_hb()
11429 hb->heartbeat.hb_info.ph.param_length = htons(sizeof(struct sctp_heartbeat_info_param)); in sctp_send_hb()
11430 hb->heartbeat.hb_info.time_value_1 = now.tv_sec; in sctp_send_hb()
11431 hb->heartbeat.hb_info.time_value_2 = now.tv_usec; in sctp_send_hb()
11433 hb->heartbeat.hb_info.addr_family = (uint8_t)net->ro._l_addr.sa.sa_family; in sctp_send_hb()
11434 hb->heartbeat.hb_info.addr_len = net->ro._l_addr.sa.sa_len; in sctp_send_hb()
11435 if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { in sctp_send_hb()
11440 …net->heartbeat_random1 = hb->heartbeat.hb_info.random_value1 = sctp_select_initial_TSN(&stcb->sctp… in sctp_send_hb()
11441 …net->heartbeat_random2 = hb->heartbeat.hb_info.random_value2 = sctp_select_initial_TSN(&stcb->sctp… in sctp_send_hb()
11443 net->heartbeat_random1 = hb->heartbeat.hb_info.random_value1 = 0; in sctp_send_hb()
11444 net->heartbeat_random2 = hb->heartbeat.hb_info.random_value2 = 0; in sctp_send_hb()
11446 switch (net->ro._l_addr.sa.sa_family) { in sctp_send_hb()
11449 memcpy(hb->heartbeat.hb_info.address, in sctp_send_hb()
11450 &net->ro._l_addr.sin.sin_addr, in sctp_send_hb()
11451 sizeof(net->ro._l_addr.sin.sin_addr)); in sctp_send_hb()
11456 memcpy(hb->heartbeat.hb_info.address, in sctp_send_hb()
11457 &net->ro._l_addr.sin6.sin6_addr, in sctp_send_hb()
11458 sizeof(net->ro._l_addr.sin6.sin6_addr)); in sctp_send_hb()
11462 if (chk->data) { in sctp_send_hb()
11463 sctp_m_freem(chk->data); in sctp_send_hb()
11464 chk->data = NULL; in sctp_send_hb()
11470 net->hb_responded = 0; in sctp_send_hb()
11471 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next); in sctp_send_hb()
11472 stcb->asoc.ctrl_queue_cnt++; in sctp_send_hb()
11488 asoc = &stcb->asoc; in sctp_send_ecn_echo()
11490 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_send_ecn_echo()
11491 if ((chk->rec.chunk_id.id == SCTP_ECN_ECHO) && (net == chk->whoTo)) { in sctp_send_ecn_echo()
11495 ecne = mtod(chk->data, struct sctp_ecne_chunk *); in sctp_send_ecn_echo()
11496 ctsn = ntohl(ecne->tsn); in sctp_send_ecn_echo()
11498 ecne->tsn = htonl(high_tsn); in sctp_send_ecn_echo()
11501 cnt = ntohl(ecne->num_pkts_since_cwr); in sctp_send_ecn_echo()
11503 ecne->num_pkts_since_cwr = htonl(cnt); in sctp_send_ecn_echo()
11513 chk->copy_by_ref = 0; in sctp_send_ecn_echo()
11514 chk->rec.chunk_id.id = SCTP_ECN_ECHO; in sctp_send_ecn_echo()
11515 chk->rec.chunk_id.can_take_data = 0; in sctp_send_ecn_echo()
11516 chk->flags = 0; in sctp_send_ecn_echo()
11517 chk->asoc = &stcb->asoc; in sctp_send_ecn_echo()
11518 chk->send_size = sizeof(struct sctp_ecne_chunk); in sctp_send_ecn_echo()
11519 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER); in sctp_send_ecn_echo()
11520 if (chk->data == NULL) { in sctp_send_ecn_echo()
11524 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_ecn_echo()
11525 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_ecn_echo()
11526 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_ecn_echo()
11527 chk->snd_count = 0; in sctp_send_ecn_echo()
11528 chk->whoTo = net; in sctp_send_ecn_echo()
11529 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_ecn_echo()
11531 stcb->asoc.ecn_echo_cnt_onq++; in sctp_send_ecn_echo()
11532 ecne = mtod(chk->data, struct sctp_ecne_chunk *); in sctp_send_ecn_echo()
11533 ecne->ch.chunk_type = SCTP_ECN_ECHO; in sctp_send_ecn_echo()
11534 ecne->ch.chunk_flags = 0; in sctp_send_ecn_echo()
11535 ecne->ch.chunk_length = htons(sizeof(struct sctp_ecne_chunk)); in sctp_send_ecn_echo()
11536 ecne->tsn = htonl(high_tsn); in sctp_send_ecn_echo()
11537 ecne->num_pkts_since_cwr = htonl(1); in sctp_send_ecn_echo()
11538 TAILQ_INSERT_HEAD(&stcb->asoc.control_send_queue, chk, sctp_next); in sctp_send_ecn_echo()
11539 asoc->ctrl_queue_cnt++; in sctp_send_ecn_echo()
11560 asoc = &stcb->asoc; in sctp_send_packet_dropped()
11562 if (asoc->pktdrop_supported == 0) { in sctp_send_packet_dropped()
11563 /*- in sctp_send_packet_dropped()
11568 if (stcb->sctp_socket == NULL) { in sctp_send_packet_dropped()
11575 chk->copy_by_ref = 0; in sctp_send_packet_dropped()
11576 chk->rec.chunk_id.id = SCTP_PACKET_DROPPED; in sctp_send_packet_dropped()
11577 chk->rec.chunk_id.can_take_data = 1; in sctp_send_packet_dropped()
11578 chk->flags = 0; in sctp_send_packet_dropped()
11579 len -= iphlen; in sctp_send_packet_dropped()
11580 chk->send_size = len; in sctp_send_packet_dropped()
11586 chk_length = ntohs(ch->chunk_length); in sctp_send_packet_dropped()
11591 switch (ch->chunk_type) { in sctp_send_packet_dropped()
11596 * We don't respond with an PKT-DROP to an ABORT in sctp_send_packet_dropped()
11597 * or PKT-DROP. We also do not respond to an in sctp_send_packet_dropped()
11598 * INIT-ACK, because we can't know if the initiation in sctp_send_packet_dropped()
11612 min(stcb->asoc.smallest_mtu, MCLBYTES)) { in sctp_send_packet_dropped()
11617 len = min(stcb->asoc.smallest_mtu, MCLBYTES) - SCTP_MAX_OVERHEAD; in sctp_send_packet_dropped()
11620 chk->asoc = &stcb->asoc; in sctp_send_packet_dropped()
11621 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); in sctp_send_packet_dropped()
11622 if (chk->data == NULL) { in sctp_send_packet_dropped()
11627 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_packet_dropped()
11628 drp = mtod(chk->data, struct sctp_pktdrop_chunk *); in sctp_send_packet_dropped()
11630 sctp_m_freem(chk->data); in sctp_send_packet_dropped()
11631 chk->data = NULL; in sctp_send_packet_dropped()
11634 chk->book_size = SCTP_SIZE32((chk->send_size + sizeof(struct sctp_pktdrop_chunk) + in sctp_send_packet_dropped()
11636 chk->book_size_scale = 0; in sctp_send_packet_dropped()
11638 drp->ch.chunk_flags = SCTP_PACKET_TRUNCATED; in sctp_send_packet_dropped()
11639 drp->trunc_len = htons(fullsz); in sctp_send_packet_dropped()
11644 chk->send_size = (uint16_t)(len - sizeof(struct sctp_pktdrop_chunk)); in sctp_send_packet_dropped()
11645 len = chk->send_size; in sctp_send_packet_dropped()
11648 drp->ch.chunk_flags = 0; in sctp_send_packet_dropped()
11649 drp->trunc_len = htons(0); in sctp_send_packet_dropped()
11652 drp->ch.chunk_flags |= SCTP_BADCRC; in sctp_send_packet_dropped()
11654 chk->send_size += sizeof(struct sctp_pktdrop_chunk); in sctp_send_packet_dropped()
11655 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_packet_dropped()
11656 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_packet_dropped()
11657 chk->snd_count = 0; in sctp_send_packet_dropped()
11660 chk->whoTo = net; in sctp_send_packet_dropped()
11661 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_packet_dropped()
11663 chk->whoTo = NULL; in sctp_send_packet_dropped()
11665 drp->ch.chunk_type = SCTP_PACKET_DROPPED; in sctp_send_packet_dropped()
11666 drp->ch.chunk_length = htons(chk->send_size); in sctp_send_packet_dropped()
11667 spc = SCTP_SB_LIMIT_RCV(stcb->sctp_socket); in sctp_send_packet_dropped()
11671 drp->bottle_bw = htonl(spc); in sctp_send_packet_dropped()
11672 if (asoc->my_rwnd) { in sctp_send_packet_dropped()
11673 drp->current_onq = htonl(asoc->size_on_reasm_queue + in sctp_send_packet_dropped()
11674 asoc->size_on_all_streams + in sctp_send_packet_dropped()
11675 asoc->my_rwnd_control_len + in sctp_send_packet_dropped()
11676 SCTP_SBAVAIL(&stcb->sctp_socket->so_rcv)); in sctp_send_packet_dropped()
11678 /*- in sctp_send_packet_dropped()
11682 drp->current_onq = htonl(spc); in sctp_send_packet_dropped()
11684 drp->reserved = 0; in sctp_send_packet_dropped()
11685 datap = drp->data; in sctp_send_packet_dropped()
11687 TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next); in sctp_send_packet_dropped()
11688 asoc->ctrl_queue_cnt++; in sctp_send_packet_dropped()
11702 asoc = &stcb->asoc; in sctp_send_cwr()
11703 TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) { in sctp_send_cwr()
11704 if ((chk->rec.chunk_id.id == SCTP_ECN_CWR) && (net == chk->whoTo)) { in sctp_send_cwr()
11711 cwr = mtod(chk->data, struct sctp_cwr_chunk *); in sctp_send_cwr()
11712 ctsn = ntohl(cwr->tsn); in sctp_send_cwr()
11714 cwr->tsn = htonl(high_tsn); in sctp_send_cwr()
11718 cwr->ch.chunk_flags |= SCTP_CWR_REDUCE_OVERRIDE; in sctp_send_cwr()
11727 chk->copy_by_ref = 0; in sctp_send_cwr()
11728 chk->rec.chunk_id.id = SCTP_ECN_CWR; in sctp_send_cwr()
11729 chk->rec.chunk_id.can_take_data = 1; in sctp_send_cwr()
11730 chk->flags = 0; in sctp_send_cwr()
11731 chk->asoc = asoc; in sctp_send_cwr()
11732 chk->send_size = sizeof(struct sctp_cwr_chunk); in sctp_send_cwr()
11733 chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER); in sctp_send_cwr()
11734 if (chk->data == NULL) { in sctp_send_cwr()
11738 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_cwr()
11739 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_cwr()
11740 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_cwr()
11741 chk->snd_count = 0; in sctp_send_cwr()
11742 chk->whoTo = net; in sctp_send_cwr()
11743 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_cwr()
11744 cwr = mtod(chk->data, struct sctp_cwr_chunk *); in sctp_send_cwr()
11745 cwr->ch.chunk_type = SCTP_ECN_CWR; in sctp_send_cwr()
11746 cwr->ch.chunk_flags = override; in sctp_send_cwr()
11747 cwr->ch.chunk_length = htons(sizeof(struct sctp_cwr_chunk)); in sctp_send_cwr()
11748 cwr->tsn = htonl(high_tsn); in sctp_send_cwr()
11749 TAILQ_INSERT_TAIL(&asoc->control_send_queue, chk, sctp_next); in sctp_send_cwr()
11750 asoc->ctrl_queue_cnt++; in sctp_send_cwr()
11763 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_stream_reset_out()
11764 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_stream_reset_out()
11768 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { in sctp_add_stream_reset_out()
11769 if ((stcb->asoc.strmout[i].state == SCTP_STREAM_RESET_PENDING) && in sctp_add_stream_reset_out()
11770 (stcb->asoc.strmout[i].chunks_on_queues == 0) && in sctp_add_stream_reset_out()
11771 TAILQ_EMPTY(&stcb->asoc.strmout[i].outqueue)) { in sctp_add_stream_reset_out()
11778 if (number_entries == stcb->asoc.streamoutcnt) { in sctp_add_stream_reset_out()
11785 req_out->ph.param_type = htons(SCTP_STR_RESET_OUT_REQUEST); in sctp_add_stream_reset_out()
11786 req_out->ph.param_length = htons(len); in sctp_add_stream_reset_out()
11787 req_out->request_seq = htonl(seq); in sctp_add_stream_reset_out()
11788 req_out->response_seq = htonl(resp_seq); in sctp_add_stream_reset_out()
11789 req_out->send_reset_at_tsn = htonl(last_sent); in sctp_add_stream_reset_out()
11792 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { in sctp_add_stream_reset_out()
11793 if ((stcb->asoc.strmout[i].state == SCTP_STREAM_RESET_PENDING) && in sctp_add_stream_reset_out()
11794 (stcb->asoc.strmout[i].chunks_on_queues == 0) && in sctp_add_stream_reset_out()
11795 TAILQ_EMPTY(&stcb->asoc.strmout[i].outqueue)) { in sctp_add_stream_reset_out()
11796 req_out->list_of_streams[at] = htons(i); in sctp_add_stream_reset_out()
11798 stcb->asoc.strmout[i].state = SCTP_STREAM_RESET_IN_FLIGHT; in sctp_add_stream_reset_out()
11805 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { in sctp_add_stream_reset_out()
11806 stcb->asoc.strmout[i].state = SCTP_STREAM_RESET_IN_FLIGHT; in sctp_add_stream_reset_out()
11810 /*- in sctp_add_stream_reset_out()
11815 req_out->list_of_streams[number_entries] = 0; in sctp_add_stream_reset_out()
11818 ch->chunk_length = htons(len + old_len); in sctp_add_stream_reset_out()
11819 chk->book_size = len + old_len; in sctp_add_stream_reset_out()
11820 chk->book_size_scale = 0; in sctp_add_stream_reset_out()
11821 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_add_stream_reset_out()
11822 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_add_stream_reset_out()
11835 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_stream_reset_in()
11836 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_stream_reset_in()
11842 req_in->ph.param_type = htons(SCTP_STR_RESET_IN_REQUEST); in sctp_add_stream_reset_in()
11843 req_in->ph.param_length = htons(len); in sctp_add_stream_reset_in()
11844 req_in->request_seq = htonl(seq); in sctp_add_stream_reset_in()
11847 req_in->list_of_streams[i] = htons(list[i]); in sctp_add_stream_reset_in()
11851 /*- in sctp_add_stream_reset_in()
11856 req_in->list_of_streams[number_entries] = 0; in sctp_add_stream_reset_in()
11859 ch->chunk_length = htons(len + old_len); in sctp_add_stream_reset_in()
11860 chk->book_size = len + old_len; in sctp_add_stream_reset_in()
11861 chk->book_size_scale = 0; in sctp_add_stream_reset_in()
11862 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_add_stream_reset_in()
11863 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_add_stream_reset_in()
11875 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_stream_reset_tsn()
11876 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_stream_reset_tsn()
11882 req_tsn->ph.param_type = htons(SCTP_STR_RESET_TSN_REQUEST); in sctp_add_stream_reset_tsn()
11883 req_tsn->ph.param_length = htons(len); in sctp_add_stream_reset_tsn()
11884 req_tsn->request_seq = htonl(seq); in sctp_add_stream_reset_tsn()
11887 ch->chunk_length = htons(len + old_len); in sctp_add_stream_reset_tsn()
11888 chk->send_size = len + old_len; in sctp_add_stream_reset_tsn()
11889 chk->book_size = SCTP_SIZE32(chk->send_size); in sctp_add_stream_reset_tsn()
11890 chk->book_size_scale = 0; in sctp_add_stream_reset_tsn()
11891 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size); in sctp_add_stream_reset_tsn()
11903 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_stream_reset_result()
11904 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_stream_reset_result()
11910 resp->ph.param_type = htons(SCTP_STR_RESET_RESPONSE); in sctp_add_stream_reset_result()
11911 resp->ph.param_length = htons(len); in sctp_add_stream_reset_result()
11912 resp->response_seq = htonl(resp_seq); in sctp_add_stream_reset_result()
11913 resp->result = ntohl(result); in sctp_add_stream_reset_result()
11916 ch->chunk_length = htons(len + old_len); in sctp_add_stream_reset_result()
11917 chk->book_size = len + old_len; in sctp_add_stream_reset_result()
11918 chk->book_size_scale = 0; in sctp_add_stream_reset_result()
11919 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_add_stream_reset_result()
11920 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_add_stream_reset_result()
11933 asoc = &stcb->asoc; in sctp_send_deferred_reset_response()
11936 * Reset our last reset action to the new one IP -> response in sctp_send_deferred_reset_response()
11940 asoc->last_reset_action[0] = response; in sctp_send_deferred_reset_response()
11941 if (asoc->stream_reset_outstanding) { in sctp_send_deferred_reset_response()
11949 chk->copy_by_ref = 0; in sctp_send_deferred_reset_response()
11950 chk->rec.chunk_id.id = SCTP_STREAM_RESET; in sctp_send_deferred_reset_response()
11951 chk->rec.chunk_id.can_take_data = 0; in sctp_send_deferred_reset_response()
11952 chk->flags = 0; in sctp_send_deferred_reset_response()
11953 chk->asoc = &stcb->asoc; in sctp_send_deferred_reset_response()
11954 chk->book_size = sizeof(struct sctp_chunkhdr); in sctp_send_deferred_reset_response()
11955 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_send_deferred_reset_response()
11956 chk->book_size_scale = 0; in sctp_send_deferred_reset_response()
11957 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); in sctp_send_deferred_reset_response()
11958 if (chk->data == NULL) { in sctp_send_deferred_reset_response()
11963 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_deferred_reset_response()
11965 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_deferred_reset_response()
11966 chk->snd_count = 0; in sctp_send_deferred_reset_response()
11967 if (stcb->asoc.alternate) { in sctp_send_deferred_reset_response()
11968 chk->whoTo = stcb->asoc.alternate; in sctp_send_deferred_reset_response()
11970 chk->whoTo = stcb->asoc.primary_destination; in sctp_send_deferred_reset_response()
11972 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_send_deferred_reset_response()
11973 ch->chunk_type = SCTP_STREAM_RESET; in sctp_send_deferred_reset_response()
11974 ch->chunk_flags = 0; in sctp_send_deferred_reset_response()
11975 ch->chunk_length = htons(chk->book_size); in sctp_send_deferred_reset_response()
11976 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_deferred_reset_response()
11977 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_deferred_reset_response()
11978 sctp_add_stream_reset_result(chk, ent->seq, response); in sctp_send_deferred_reset_response()
11980 TAILQ_INSERT_TAIL(&asoc->control_send_queue, in sctp_send_deferred_reset_response()
11983 asoc->ctrl_queue_cnt++; in sctp_send_deferred_reset_response()
11995 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_stream_reset_result_tsn()
11996 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_stream_reset_result_tsn()
12002 resp->ph.param_type = htons(SCTP_STR_RESET_RESPONSE); in sctp_add_stream_reset_result_tsn()
12003 resp->ph.param_length = htons(len); in sctp_add_stream_reset_result_tsn()
12004 resp->response_seq = htonl(resp_seq); in sctp_add_stream_reset_result_tsn()
12005 resp->result = htonl(result); in sctp_add_stream_reset_result_tsn()
12006 resp->senders_next_tsn = htonl(send_una); in sctp_add_stream_reset_result_tsn()
12007 resp->receivers_next_tsn = htonl(recv_next); in sctp_add_stream_reset_result_tsn()
12010 ch->chunk_length = htons(len + old_len); in sctp_add_stream_reset_result_tsn()
12011 chk->book_size = len + old_len; in sctp_add_stream_reset_result_tsn()
12012 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_add_stream_reset_result_tsn()
12013 chk->book_size_scale = 0; in sctp_add_stream_reset_result_tsn()
12014 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_add_stream_reset_result_tsn()
12027 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_an_out_stream()
12028 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_an_out_stream()
12036 addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_OUT_STREAMS); in sctp_add_an_out_stream()
12037 addstr->ph.param_length = htons(len); in sctp_add_an_out_stream()
12038 addstr->request_seq = htonl(seq); in sctp_add_an_out_stream()
12039 addstr->number_of_streams = htons(adding); in sctp_add_an_out_stream()
12040 addstr->reserved = 0; in sctp_add_an_out_stream()
12043 ch->chunk_length = htons(len + old_len); in sctp_add_an_out_stream()
12044 chk->send_size = len + old_len; in sctp_add_an_out_stream()
12045 chk->book_size = SCTP_SIZE32(chk->send_size); in sctp_add_an_out_stream()
12046 chk->book_size_scale = 0; in sctp_add_an_out_stream()
12047 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size); in sctp_add_an_out_stream()
12060 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_add_an_in_stream()
12061 old_len = len = SCTP_SIZE32(ntohs(ch->chunk_length)); in sctp_add_an_in_stream()
12068 addstr->ph.param_type = htons(SCTP_STR_RESET_ADD_IN_STREAMS); in sctp_add_an_in_stream()
12069 addstr->ph.param_length = htons(len); in sctp_add_an_in_stream()
12070 addstr->request_seq = htonl(seq); in sctp_add_an_in_stream()
12071 addstr->number_of_streams = htons(adding); in sctp_add_an_in_stream()
12072 addstr->reserved = 0; in sctp_add_an_in_stream()
12075 ch->chunk_length = htons(len + old_len); in sctp_add_an_in_stream()
12076 chk->send_size = len + old_len; in sctp_add_an_in_stream()
12077 chk->book_size = SCTP_SIZE32(chk->send_size); in sctp_add_an_in_stream()
12078 chk->book_size_scale = 0; in sctp_add_an_in_stream()
12079 SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size); in sctp_add_an_in_stream()
12091 asoc = &stcb->asoc; in sctp_send_stream_reset_out_if_possible()
12092 asoc->trigger_reset = 0; in sctp_send_stream_reset_out_if_possible()
12093 if (asoc->stream_reset_outstanding) { in sctp_send_stream_reset_out_if_possible()
12101 chk->copy_by_ref = 0; in sctp_send_stream_reset_out_if_possible()
12102 chk->rec.chunk_id.id = SCTP_STREAM_RESET; in sctp_send_stream_reset_out_if_possible()
12103 chk->rec.chunk_id.can_take_data = 0; in sctp_send_stream_reset_out_if_possible()
12104 chk->flags = 0; in sctp_send_stream_reset_out_if_possible()
12105 chk->asoc = &stcb->asoc; in sctp_send_stream_reset_out_if_possible()
12106 chk->book_size = sizeof(struct sctp_chunkhdr); in sctp_send_stream_reset_out_if_possible()
12107 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_send_stream_reset_out_if_possible()
12108 chk->book_size_scale = 0; in sctp_send_stream_reset_out_if_possible()
12109 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); in sctp_send_stream_reset_out_if_possible()
12110 if (chk->data == NULL) { in sctp_send_stream_reset_out_if_possible()
12115 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_stream_reset_out_if_possible()
12118 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_stream_reset_out_if_possible()
12119 chk->snd_count = 0; in sctp_send_stream_reset_out_if_possible()
12120 if (stcb->asoc.alternate) { in sctp_send_stream_reset_out_if_possible()
12121 chk->whoTo = stcb->asoc.alternate; in sctp_send_stream_reset_out_if_possible()
12123 chk->whoTo = stcb->asoc.primary_destination; in sctp_send_stream_reset_out_if_possible()
12125 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_send_stream_reset_out_if_possible()
12126 ch->chunk_type = SCTP_STREAM_RESET; in sctp_send_stream_reset_out_if_possible()
12127 ch->chunk_flags = 0; in sctp_send_stream_reset_out_if_possible()
12128 ch->chunk_length = htons(chk->book_size); in sctp_send_stream_reset_out_if_possible()
12129 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_stream_reset_out_if_possible()
12130 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_stream_reset_out_if_possible()
12131 seq = stcb->asoc.str_reset_seq_out; in sctp_send_stream_reset_out_if_possible()
12132 … (sctp_add_stream_reset_out(stcb, chk, seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending… in sctp_send_stream_reset_out_if_possible()
12134 asoc->stream_reset_outstanding++; in sctp_send_stream_reset_out_if_possible()
12136 m_freem(chk->data); in sctp_send_stream_reset_out_if_possible()
12137 chk->data = NULL; in sctp_send_stream_reset_out_if_possible()
12141 asoc->str_reset = chk; in sctp_send_stream_reset_out_if_possible()
12143 TAILQ_INSERT_TAIL(&asoc->control_send_queue, in sctp_send_stream_reset_out_if_possible()
12146 asoc->ctrl_queue_cnt++; in sctp_send_stream_reset_out_if_possible()
12148 if (stcb->asoc.send_sack) { in sctp_send_stream_reset_out_if_possible()
12151 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo); in sctp_send_stream_reset_out_if_possible()
12172 asoc = &stcb->asoc; in sctp_send_str_reset_req()
12173 if (asoc->stream_reset_outstanding) { in sctp_send_str_reset_req()
12174 /*- in sctp_send_str_reset_req()
12193 if (number_entries > (MCLBYTES - in sctp_send_str_reset_req()
12194 SCTP_MIN_OVERHEAD - in sctp_send_str_reset_req()
12195 sizeof(struct sctp_chunkhdr) - in sctp_send_str_reset_req()
12206 chk->copy_by_ref = 0; in sctp_send_str_reset_req()
12207 chk->rec.chunk_id.id = SCTP_STREAM_RESET; in sctp_send_str_reset_req()
12208 chk->rec.chunk_id.can_take_data = 0; in sctp_send_str_reset_req()
12209 chk->flags = 0; in sctp_send_str_reset_req()
12210 chk->asoc = &stcb->asoc; in sctp_send_str_reset_req()
12211 chk->book_size = sizeof(struct sctp_chunkhdr); in sctp_send_str_reset_req()
12212 chk->send_size = SCTP_SIZE32(chk->book_size); in sctp_send_str_reset_req()
12213 chk->book_size_scale = 0; in sctp_send_str_reset_req()
12214 chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); in sctp_send_str_reset_req()
12215 if (chk->data == NULL) { in sctp_send_str_reset_req()
12220 SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD); in sctp_send_str_reset_req()
12223 chk->sent = SCTP_DATAGRAM_UNSENT; in sctp_send_str_reset_req()
12224 chk->snd_count = 0; in sctp_send_str_reset_req()
12225 if (stcb->asoc.alternate) { in sctp_send_str_reset_req()
12226 chk->whoTo = stcb->asoc.alternate; in sctp_send_str_reset_req()
12228 chk->whoTo = stcb->asoc.primary_destination; in sctp_send_str_reset_req()
12230 atomic_add_int(&chk->whoTo->ref_count, 1); in sctp_send_str_reset_req()
12231 ch = mtod(chk->data, struct sctp_chunkhdr *); in sctp_send_str_reset_req()
12232 ch->chunk_type = SCTP_STREAM_RESET; in sctp_send_str_reset_req()
12233 ch->chunk_flags = 0; in sctp_send_str_reset_req()
12234 ch->chunk_length = htons(chk->book_size); in sctp_send_str_reset_req()
12235 SCTP_BUF_LEN(chk->data) = chk->send_size; in sctp_send_str_reset_req()
12237 seq = stcb->asoc.str_reset_seq_out; in sctp_send_str_reset_req()
12241 …= sctp_add_stream_reset_out(stcb, chk, seq, (stcb->asoc.str_reset_seq_in - 1), (stcb->asoc.sending… in sctp_send_str_reset_req()
12244 asoc->stream_reset_outstanding++; in sctp_send_str_reset_req()
12248 ((stcb->asoc.strm_realoutsize - stcb->asoc.streamoutcnt) < adding_o)) { in sctp_send_str_reset_req()
12257 oldstream = stcb->asoc.strmout; in sctp_send_str_reset_req()
12259 SCTP_MALLOC(stcb->asoc.strmout, struct sctp_stream_out *, in sctp_send_str_reset_req()
12260 (stcb->asoc.streamoutcnt + adding_o) * sizeof(struct sctp_stream_out), in sctp_send_str_reset_req()
12262 if (stcb->asoc.strmout == NULL) { in sctp_send_str_reset_req()
12265 stcb->asoc.strmout = oldstream; in sctp_send_str_reset_req()
12275 stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, false); in sctp_send_str_reset_req()
12276 for (i = 0; i < stcb->asoc.streamoutcnt; i++) { in sctp_send_str_reset_req()
12277 TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); in sctp_send_str_reset_req()
12283 stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], &oldstream[i]); in sctp_send_str_reset_req()
12284 stcb->asoc.strmout[i].chunks_on_queues = oldstream[i].chunks_on_queues; in sctp_send_str_reset_req()
12287 stcb->asoc.strmout[i].abandoned_sent[j] = oldstream[i].abandoned_sent[j]; in sctp_send_str_reset_req()
12288 stcb->asoc.strmout[i].abandoned_unsent[j] = oldstream[i].abandoned_unsent[j]; in sctp_send_str_reset_req()
12291 stcb->asoc.strmout[i].abandoned_sent[0] = oldstream[i].abandoned_sent[0]; in sctp_send_str_reset_req()
12292 stcb->asoc.strmout[i].abandoned_unsent[0] = oldstream[i].abandoned_unsent[0]; in sctp_send_str_reset_req()
12294 stcb->asoc.strmout[i].next_mid_ordered = oldstream[i].next_mid_ordered; in sctp_send_str_reset_req()
12295 stcb->asoc.strmout[i].next_mid_unordered = oldstream[i].next_mid_unordered; in sctp_send_str_reset_req()
12296 stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete; in sctp_send_str_reset_req()
12297 stcb->asoc.strmout[i].sid = i; in sctp_send_str_reset_req()
12298 stcb->asoc.strmout[i].state = oldstream[i].state; in sctp_send_str_reset_req()
12302 TAILQ_INSERT_TAIL(&stcb->asoc.strmout[i].outqueue, sp, next); in sctp_send_str_reset_req()
12306 stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc); in sctp_send_str_reset_req()
12307 for (i = stcb->asoc.streamoutcnt; i < (stcb->asoc.streamoutcnt + adding_o); i++) { in sctp_send_str_reset_req()
12308 TAILQ_INIT(&stcb->asoc.strmout[i].outqueue); in sctp_send_str_reset_req()
12309 stcb->asoc.strmout[i].chunks_on_queues = 0; in sctp_send_str_reset_req()
12312 stcb->asoc.strmout[i].abandoned_sent[j] = 0; in sctp_send_str_reset_req()
12313 stcb->asoc.strmout[i].abandoned_unsent[j] = 0; in sctp_send_str_reset_req()
12316 stcb->asoc.strmout[i].abandoned_sent[0] = 0; in sctp_send_str_reset_req()
12317 stcb->asoc.strmout[i].abandoned_unsent[0] = 0; in sctp_send_str_reset_req()
12319 stcb->asoc.strmout[i].next_mid_ordered = 0; in sctp_send_str_reset_req()
12320 stcb->asoc.strmout[i].next_mid_unordered = 0; in sctp_send_str_reset_req()
12321 stcb->asoc.strmout[i].sid = i; in sctp_send_str_reset_req()
12322 stcb->asoc.strmout[i].last_msg_incomplete = 0; in sctp_send_str_reset_req()
12323 stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], NULL); in sctp_send_str_reset_req()
12324 stcb->asoc.strmout[i].state = SCTP_STREAM_CLOSED; in sctp_send_str_reset_req()
12326 stcb->asoc.strm_realoutsize = stcb->asoc.streamoutcnt + adding_o; in sctp_send_str_reset_req()
12331 asoc->strm_pending_add_size = adding_o; in sctp_send_str_reset_req()
12332 asoc->peer_req_out = peer_asked; in sctp_send_str_reset_req()
12335 asoc->stream_reset_outstanding++; in sctp_send_str_reset_req()
12340 asoc->stream_reset_outstanding++; in sctp_send_str_reset_req()
12345 asoc->stream_reset_outstanding++; in sctp_send_str_reset_req()
12349 asoc->stream_reset_outstanding++; in sctp_send_str_reset_req()
12351 asoc->str_reset = chk; in sctp_send_str_reset_req()
12353 TAILQ_INSERT_TAIL(&asoc->control_send_queue, in sctp_send_str_reset_req()
12356 asoc->ctrl_queue_cnt++; in sctp_send_str_reset_req()
12357 if (stcb->asoc.send_sack) { in sctp_send_str_reset_req()
12360 sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, stcb->sctp_ep, stcb, chk->whoTo); in sctp_send_str_reset_req()
12422 sp->data = m_uiotombuf(uio, M_WAITOK, sp->length, resv_upfront, 0); in sctp_copy_one()
12423 if (sp->data == NULL) { in sctp_copy_one()
12428 sp->tail_mbuf = m_last(sp->data); in sctp_copy_one()
12443 /*- in sctp_copy_it_in()
12460 sp->act_flags = 0; in sctp_copy_it_in()
12461 sp->sender_all_done = 0; in sctp_copy_it_in()
12462 sp->sinfo_flags = srcv->sinfo_flags; in sctp_copy_it_in()
12463 sp->timetolive = srcv->sinfo_timetolive; in sctp_copy_it_in()
12464 sp->ppid = srcv->sinfo_ppid; in sctp_copy_it_in()
12465 sp->context = srcv->sinfo_context; in sctp_copy_it_in()
12466 sp->fsn = 0; in sctp_copy_it_in()
12467 (void)SCTP_GETTIME_TIMEVAL(&sp->ts); in sctp_copy_it_in()
12468 sp->sid = srcv->sinfo_stream; in sctp_copy_it_in()
12469 sp->length = (uint32_t)min(uio->uio_resid, max_send_len); in sctp_copy_it_in()
12470 if ((sp->length == (uint32_t)uio->uio_resid) && in sctp_copy_it_in()
12472 (srcv->sinfo_flags & SCTP_EOF) || in sctp_copy_it_in()
12473 (user_marks_eor && (srcv->sinfo_flags & SCTP_EOR)))) { in sctp_copy_it_in()
12474 sp->msg_is_complete = 1; in sctp_copy_it_in()
12476 sp->msg_is_complete = 0; in sctp_copy_it_in()
12478 sp->sender_all_done = 0; in sctp_copy_it_in()
12479 sp->some_taken = 0; in sctp_copy_it_in()
12480 sp->put_last_out = 0; in sctp_copy_it_in()
12482 sp->data = sp->tail_mbuf = NULL; in sctp_copy_it_in()
12483 if (sp->length == 0) { in sctp_copy_it_in()
12486 if (srcv->sinfo_keynumber_valid) { in sctp_copy_it_in()
12487 sp->auth_keyid = srcv->sinfo_keynumber; in sctp_copy_it_in()
12489 sp->auth_keyid = stcb->asoc.authinfo.active_keyid; in sctp_copy_it_in()
12491 if (sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.peer_auth_chunks)) { in sctp_copy_it_in()
12492 sctp_auth_key_acquire(stcb, sp->auth_keyid); in sctp_copy_it_in()
12493 sp->holds_key_ref = 1; in sctp_copy_it_in()
12501 if (sp->sinfo_flags & SCTP_ADDR_OVER) { in sctp_copy_it_in()
12502 sp->net = net; in sctp_copy_it_in()
12503 atomic_add_int(&sp->net->ref_count, 1); in sctp_copy_it_in()
12505 sp->net = NULL; in sctp_copy_it_in()
12531 /* process cmsg snd/rcv info (maybe a assoc-id) */ in sctp_sosend()
12537 if ((addr != NULL) && (addr->sa_family == AF_INET6)) { in sctp_sosend()
12540 if (addr->sa_len != sizeof(struct sockaddr_in6)) { in sctp_sosend()
12545 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { in sctp_sosend()
12612 switch (raddr->sa.sa_family) { in sctp_lower_sosend()
12615 if (raddr->sin.sin_len != sizeof(struct sockaddr_in)) { in sctp_lower_sosend()
12619 port = raddr->sin.sin_port; in sctp_lower_sosend()
12624 if (raddr->sin6.sin6_len != sizeof(struct sockaddr_in6)) { in sctp_lower_sosend()
12628 port = raddr->sin6.sin6_port; in sctp_lower_sosend()
12639 if (uio->uio_resid < 0) { in sctp_lower_sosend()
12643 sndlen = uio->uio_resid; in sctp_lower_sosend()
12650 t_inp = inp = (struct sctp_inpcb *)so->so_pcb; in sctp_lower_sosend()
12657 /*- in sctp_lower_sosend()
12664 if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) && in sctp_lower_sosend()
12670 atomic_add_int(&inp->total_sends, 1); in sctp_lower_sosend()
12674 sinfo_assoc_id = sndrcvninfo->sinfo_assoc_id; in sctp_lower_sosend()
12675 sinfo_flags = sndrcvninfo->sinfo_flags; in sctp_lower_sosend()
12686 sinfo_flags = inp->def_send.sinfo_flags; in sctp_lower_sosend()
12687 sinfo_assoc_id = inp->def_send.sinfo_assoc_id; in sctp_lower_sosend()
12701 (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE)) { in sctp_lower_sosend()
12708 if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) || in sctp_lower_sosend()
12709 (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { in sctp_lower_sosend()
12710 stcb = LIST_FIRST(&inp->sctp_asoc_list); in sctp_lower_sosend()
12722 /*- in sctp_lower_sosend()
12751 if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || in sctp_lower_sosend()
12752 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { in sctp_lower_sosend()
12756 if (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) && in sctp_lower_sosend()
12757 (addr->sa_family == AF_INET6)) { in sctp_lower_sosend()
12798 /*- in sctp_lower_sosend()
12799 * User asks to abort a non-existent assoc, in sctp_lower_sosend()
12800 * or EOF a non-existent assoc with no data in sctp_lower_sosend()
12806 vrf_id = inp->def_vrf_id; in sctp_lower_sosend()
12809 inp->sctp_ep.pre_open_stream_count, in sctp_lower_sosend()
12810 inp->sctp_ep.port, in sctp_lower_sosend()
12827 (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); in sctp_lower_sosend()
12840 /*- in sctp_lower_sosend()
12853 asoc = &stcb->asoc; in sctp_lower_sosend()
12854 if ((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) || in sctp_lower_sosend()
12855 (asoc->state & SCTP_STATE_WAS_ABORTED)) { in sctp_lower_sosend()
12856 if (asoc->state & SCTP_STATE_WAS_ABORTED) { in sctp_lower_sosend()
12869 atomic_add_int(&asoc->refcnt, 1); in sctp_lower_sosend()
12873 sndrcvninfo_buf = asoc->def_send; in sctp_lower_sosend()
12875 sinfo_flags = sndrcvninfo->sinfo_flags; in sctp_lower_sosend()
12920 max_out = asoc->smallest_mtu - sizeof(struct sctp_paramhdr); in sctp_lower_sosend()
12921 max_out -= sizeof(struct sctp_abort_msg); in sctp_lower_sosend()
12926 ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT); in sctp_lower_sosend()
12927 ph->param_length = htons((uint16_t)(sizeof(struct sctp_paramhdr) + tot_out)); in sctp_lower_sosend()
12934 if ((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) || in sctp_lower_sosend()
12935 (asoc->state & SCTP_STATE_WAS_ABORTED)) { in sctp_lower_sosend()
12937 if (asoc->state & SCTP_STATE_WAS_ABORTED) { in sctp_lower_sosend()
12949 /*- in sctp_lower_sosend()
12952 * send the users note :-0 in sctp_lower_sosend()
12963 atomic_subtract_int(&asoc->refcnt, 1); in sctp_lower_sosend()
12967 sctp_abort_an_association(stcb->sctp_ep, stcb, mm, false, SCTP_SO_LOCKED); in sctp_lower_sosend()
12983 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
12985 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
12995 ((port != 0) && (port != stcb->rport))) { in sctp_lower_sosend()
13000 if (asoc->alternate != NULL) { in sctp_lower_sosend()
13001 net = asoc->alternate; in sctp_lower_sosend()
13003 net = asoc->primary_destination; in sctp_lower_sosend()
13016 if (sndlen > (ssize_t)asoc->smallest_mtu) { in sctp_lower_sosend()
13021 sinfo_stream = sndrcvninfo->sinfo_stream; in sctp_lower_sosend()
13023 if (sinfo_stream >= asoc->streamoutcnt) { in sctp_lower_sosend()
13028 if ((asoc->strmout[sinfo_stream].state != SCTP_STREAM_OPEN) && in sctp_lower_sosend()
13029 (asoc->strmout[sinfo_stream].state != SCTP_STREAM_OPENING)) { in sctp_lower_sosend()
13033 if (asoc->strmout[sinfo_stream].state > SCTP_STREAM_OPEN) { in sctp_lower_sosend()
13040 atomic_add_int(&stcb->total_sends, 1); in sctp_lower_sosend()
13047 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13053 if ((SCTP_SB_LIMIT_SND(so) < (amount + inqueue_bytes + asoc->sb_send_resv)) || in sctp_lower_sosend()
13054 (asoc->chunks_on_out_queue >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) { in sctp_lower_sosend()
13064 atomic_add_int(&asoc->sb_send_resv, (int)sndlen); in sctp_lower_sosend()
13069 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13071 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13076 p->td_ru.ru_msgsnd++; in sctp_lower_sosend()
13079 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13081 max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes; in sctp_lower_sosend()
13087 (sndlen > (ssize_t)SCTP_SB_LIMIT_SND(stcb->sctp_socket))) { in sctp_lower_sosend()
13095 /*- in sctp_lower_sosend()
13096 * For non-eeor the whole message must fit in in sctp_lower_sosend()
13106 …((asoc->chunks_on_out_queue + asoc->stream_queue_cnt) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue… in sctp_lower_sosend()
13108 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13109 SOCKBUF_LOCK(&so->so_snd); in sctp_lower_sosend()
13111 …((asoc->stream_queue_cnt + asoc->chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue… in sctp_lower_sosend()
13116 asoc->stream_queue_cnt, in sctp_lower_sosend()
13117 asoc->chunks_on_out_queue, in sctp_lower_sosend()
13123 stcb->block_entry = &be; in sctp_lower_sosend()
13127 if (so->so_error != 0) { in sctp_lower_sosend()
13128 error = so->so_error; in sctp_lower_sosend()
13134 SOCKBUF_UNLOCK(&so->so_snd); in sctp_lower_sosend()
13136 stcb->block_entry = NULL; in sctp_lower_sosend()
13140 if ((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) || in sctp_lower_sosend()
13141 (asoc->state & SCTP_STATE_WAS_ABORTED)) { in sctp_lower_sosend()
13142 if (asoc->state & SCTP_STATE_WAS_ABORTED) { in sctp_lower_sosend()
13155 asoc, asoc->total_output_queue_size); in sctp_lower_sosend()
13157 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13158 SOCKBUF_LOCK(&so->so_snd); in sctp_lower_sosend()
13161 max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes; in sctp_lower_sosend()
13165 SOCKBUF_UNLOCK(&so->so_snd); in sctp_lower_sosend()
13171 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13173 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13177 * sndlen covers for mbuf case uio_resid covers for the non-mbuf in sctp_lower_sosend()
13185 if ((asoc->stream_locked) && in sctp_lower_sosend()
13186 (asoc->stream_locked_on != sinfo_stream)) { in sctp_lower_sosend()
13190 strm = &asoc->strmout[sinfo_stream]; in sctp_lower_sosend()
13191 if (strm->last_msg_incomplete == 0) { in sctp_lower_sosend()
13196 if ((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) || in sctp_lower_sosend()
13197 (asoc->state & SCTP_STATE_WAS_ABORTED)) { in sctp_lower_sosend()
13198 if (asoc->state & SCTP_STATE_WAS_ABORTED) { in sctp_lower_sosend()
13219 (asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) { in sctp_lower_sosend()
13220 if (sp->data != 0) { in sctp_lower_sosend()
13221 sctp_m_freem(sp->data); in sctp_lower_sosend()
13222 sp->data = NULL; in sctp_lower_sosend()
13223 sp->tail_mbuf = NULL; in sctp_lower_sosend()
13224 sp->length = 0; in sctp_lower_sosend()
13226 if (sp->net != NULL) { in sctp_lower_sosend()
13227 sctp_free_remote_addr(sp->net); in sctp_lower_sosend()
13228 sp->net = NULL; in sctp_lower_sosend()
13235 strm = &asoc->strmout[sinfo_stream]; in sctp_lower_sosend()
13236 if (sp->msg_is_complete) { in sctp_lower_sosend()
13237 strm->last_msg_incomplete = 0; in sctp_lower_sosend()
13238 asoc->stream_locked = 0; in sctp_lower_sosend()
13244 strm->last_msg_incomplete = 1; in sctp_lower_sosend()
13245 if (asoc->idata_supported == 0) { in sctp_lower_sosend()
13246 asoc->stream_locked = 1; in sctp_lower_sosend()
13247 asoc->stream_locked_on = sinfo_stream; in sctp_lower_sosend()
13249 sp->sender_all_done = 0; in sctp_lower_sosend()
13251 sctp_snd_sb_alloc(stcb, sp->length); in sctp_lower_sosend()
13252 atomic_add_int(&asoc->stream_queue_cnt, 1); in sctp_lower_sosend()
13256 sp->processing = 1; in sctp_lower_sosend()
13257 TAILQ_INSERT_TAIL(&strm->outqueue, sp, next); in sctp_lower_sosend()
13258 asoc->ss_functions.sctp_ss_add_to_stream(stcb, asoc, strm, sp); in sctp_lower_sosend()
13260 sp = TAILQ_LAST(&strm->outqueue, sctp_streamhead); in sctp_lower_sosend()
13267 strm->last_msg_incomplete = 0; in sctp_lower_sosend()
13271 if (sp->processing != 0) { in sctp_lower_sosend()
13275 sp->processing = 1; in sctp_lower_sosend()
13281 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13283 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13286 while (uio->uio_resid > 0) { in sctp_lower_sosend()
13290 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13292 max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes; in sctp_lower_sosend()
13298 (uio->uio_resid <= max_len)) { in sctp_lower_sosend()
13304 if ((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) || in sctp_lower_sosend()
13305 (asoc->state & SCTP_STATE_WAS_ABORTED)) { in sctp_lower_sosend()
13311 if (asoc->state & SCTP_STATE_WAS_ABORTED) { in sctp_lower_sosend()
13328 sp->processing = 0; in sctp_lower_sosend()
13333 if (sp->tail_mbuf != NULL) { in sctp_lower_sosend()
13335 SCTP_BUF_NEXT(sp->tail_mbuf) = mm; in sctp_lower_sosend()
13338 sp->data = mm; in sctp_lower_sosend()
13340 sp->tail_mbuf = new_tail; in sctp_lower_sosend()
13342 atomic_add_int(&sp->length, sndout); in sctp_lower_sosend()
13344 sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY; in sctp_lower_sosend()
13348 if ((uio->uio_resid == 0) && in sctp_lower_sosend()
13352 sp->msg_is_complete = 1; in sctp_lower_sosend()
13354 sp->msg_is_complete = 0; in sctp_lower_sosend()
13360 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13362 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13365 if (uio->uio_resid == 0) { in sctp_lower_sosend()
13369 /* PR-SCTP? */ in sctp_lower_sosend()
13370 if ((asoc->prsctp_supported) && (asoc->sent_queue_cnt_removeable > 0)) { in sctp_lower_sosend()
13376 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13378 max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes; in sctp_lower_sosend()
13387 /* Non-blocking io in place out */ in sctp_lower_sosend()
13389 sp->processing = 0; in sctp_lower_sosend()
13406 if ((net->flight_size > net->cwnd) && in sctp_lower_sosend()
13407 (asoc->sctp_cmt_on_off == 0)) { in sctp_lower_sosend()
13410 } else if (asoc->ifp_had_enobuf) { in sctp_lower_sosend()
13412 if (net->flight_size > (2 * net->mtu)) { in sctp_lower_sosend()
13415 asoc->ifp_had_enobuf = 0; in sctp_lower_sosend()
13417 un_sent = asoc->total_output_queue_size - asoc->total_flight; in sctp_lower_sosend()
13419 (asoc->total_flight > 0) && in sctp_lower_sosend()
13420 (asoc->stream_queue_cnt < SCTP_MAX_DATA_BUNDLING) && in sctp_lower_sosend()
13421 (un_sent < (int)(asoc->smallest_mtu - SCTP_MIN_OVERHEAD))) { in sctp_lower_sosend()
13422 /*- in sctp_lower_sosend()
13443 sctp_misc_ints(SCTP_CWNDLOG_PRESEND, asoc->total_output_queue_size, in sctp_lower_sosend()
13444 asoc->total_flight, in sctp_lower_sosend()
13445 asoc->chunks_on_out_queue, asoc->total_flight_count); in sctp_lower_sosend()
13451 /*- in sctp_lower_sosend()
13456 * and I don't need to start output :-D in sctp_lower_sosend()
13463 /*- in sctp_lower_sosend()
13470 * so_snd buffer to get the wakeup. After the LOCK in sctp_lower_sosend()
13472 * LOCK the so->so_snd to do the actual sowwakeup(). So in sctp_lower_sosend()
13475 * wakeup flag in place. in sctp_lower_sosend()
13477 …inqueue_bytes = asoc->total_output_queue_size - (asoc->chunks_on_out_queue * SCTP_DATA_CHUNK_OVERH… in sctp_lower_sosend()
13478 SOCKBUF_LOCK(&so->so_snd); in sctp_lower_sosend()
13483 asoc, uio->uio_resid); in sctp_lower_sosend()
13486 stcb->block_entry = &be; in sctp_lower_sosend()
13490 if (so->so_error != 0) in sctp_lower_sosend()
13491 error = so->so_error; in sctp_lower_sosend()
13496 SOCKBUF_UNLOCK(&so->so_snd); in sctp_lower_sosend()
13498 stcb->block_entry = NULL; in sctp_lower_sosend()
13499 if ((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) || in sctp_lower_sosend()
13500 (asoc->state & SCTP_STATE_WAS_ABORTED)) { in sctp_lower_sosend()
13501 if (asoc->state & SCTP_STATE_WAS_ABORTED) { in sctp_lower_sosend()
13515 sp->processing = 0; in sctp_lower_sosend()
13520 SOCKBUF_UNLOCK(&so->so_snd); in sctp_lower_sosend()
13524 asoc, asoc->total_output_queue_size); in sctp_lower_sosend()
13530 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13532 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13536 strm = &asoc->strmout[sinfo_stream]; in sctp_lower_sosend()
13538 if (sp->msg_is_complete == 0) { in sctp_lower_sosend()
13539 strm->last_msg_incomplete = 1; in sctp_lower_sosend()
13540 if (asoc->idata_supported == 0) { in sctp_lower_sosend()
13541 asoc->stream_locked = 1; in sctp_lower_sosend()
13542 asoc->stream_locked_on = sinfo_stream; in sctp_lower_sosend()
13545 sp->sender_all_done = 1; in sctp_lower_sosend()
13546 strm->last_msg_incomplete = 0; in sctp_lower_sosend()
13547 asoc->stream_locked = 0; in sctp_lower_sosend()
13549 sp->processing = 0; in sctp_lower_sosend()
13552 strm->last_msg_incomplete = 0; in sctp_lower_sosend()
13553 asoc->stream_locked = 0; in sctp_lower_sosend()
13555 if (uio->uio_resid == 0) { in sctp_lower_sosend()
13572 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13574 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13581 if (TAILQ_EMPTY(&asoc->send_queue) && in sctp_lower_sosend()
13582 TAILQ_EMPTY(&asoc->sent_queue) && in sctp_lower_sosend()
13584 if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc)) { in sctp_lower_sosend()
13599 if (asoc->alternate != NULL) { in sctp_lower_sosend()
13600 netp = asoc->alternate; in sctp_lower_sosend()
13602 netp = asoc->primary_destination; in sctp_lower_sosend()
13605 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, in sctp_lower_sosend()
13607 sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, in sctp_lower_sosend()
13611 /*- in sctp_lower_sosend()
13615 /*- in sctp_lower_sosend()
13619 * SHUTDOWN-PENDING in sctp_lower_sosend()
13624 if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc)) { in sctp_lower_sosend()
13628 if (TAILQ_EMPTY(&asoc->send_queue) && in sctp_lower_sosend()
13629 TAILQ_EMPTY(&asoc->sent_queue) && in sctp_lower_sosend()
13630 (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) { in sctp_lower_sosend()
13636 atomic_subtract_int(&asoc->refcnt, 1); in sctp_lower_sosend()
13644 sctp_abort_an_association(stcb->sctp_ep, stcb, in sctp_lower_sosend()
13659 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13661 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13664 some_on_control = !TAILQ_EMPTY(&asoc->control_send_queue); in sctp_lower_sosend()
13680 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13682 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13685 if ((net->flight_size > net->cwnd) && in sctp_lower_sosend()
13686 (asoc->sctp_cmt_on_off == 0)) { in sctp_lower_sosend()
13689 } else if (asoc->ifp_had_enobuf) { in sctp_lower_sosend()
13691 if (net->flight_size > (2 * net->mtu)) { in sctp_lower_sosend()
13694 asoc->ifp_had_enobuf = 0; in sctp_lower_sosend()
13696 un_sent = asoc->total_output_queue_size - asoc->total_flight; in sctp_lower_sosend()
13698 (asoc->total_flight > 0) && in sctp_lower_sosend()
13699 (asoc->stream_queue_cnt < SCTP_MAX_DATA_BUNDLING) && in sctp_lower_sosend()
13700 (un_sent < (int)(asoc->smallest_mtu - SCTP_MIN_OVERHEAD))) { in sctp_lower_sosend()
13701 /*- in sctp_lower_sosend()
13722 sctp_misc_ints(SCTP_CWNDLOG_PRESEND, asoc->total_output_queue_size, in sctp_lower_sosend()
13723 asoc->total_flight, in sctp_lower_sosend()
13724 asoc->chunks_on_out_queue, asoc->total_flight_count); in sctp_lower_sosend()
13729 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13731 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13735 if ((queue_only == 0) && (nagle_applies == 0) && (asoc->peers_rwnd && un_sent)) { in sctp_lower_sosend()
13738 (asoc->peers_rwnd == 0) && in sctp_lower_sosend()
13739 (asoc->total_flight == 0)) { in sctp_lower_sosend()
13753 queue_only, asoc->peers_rwnd, un_sent, in sctp_lower_sosend()
13754 asoc->total_flight, asoc->chunks_on_out_queue, in sctp_lower_sosend()
13755 asoc->total_output_queue_size, error); in sctp_lower_sosend()
13759 KASSERT((asoc->state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0, in sctp_lower_sosend()
13761 KASSERT((asoc->state & SCTP_STATE_WAS_ABORTED) == 0, in sctp_lower_sosend()
13771 atomic_subtract_int(&asoc->sb_send_resv, (int)sndlen); in sctp_lower_sosend()
13774 atomic_subtract_int(&asoc->refcnt, 1); in sctp_lower_sosend()
13805 if (stcb->asoc.auth_supported == 0) { in sctp_add_auth_chunk()
13809 if (!sctp_auth_is_required_chunk(chunk, stcb->asoc.peer_auth_chunks)) { in sctp_add_auth_chunk()
13823 auth->ch.chunk_type = SCTP_AUTHENTICATION; in sctp_add_auth_chunk()
13824 auth->ch.chunk_flags = 0; in sctp_add_auth_chunk()
13826 sctp_get_hmac_digest_len(stcb->asoc.peer_hmac_id); in sctp_add_auth_chunk()
13827 auth->ch.chunk_length = htons(chunk_len); in sctp_add_auth_chunk()
13828 auth->hmac_id = htons(stcb->asoc.peer_hmac_id); in sctp_add_auth_chunk()
13854 if (ro == NULL || ro->ro_nh == NULL || src6->sin6_family != AF_INET6) in sctp_v6src_match_nexthop()
13860 if (pfx->ndpr_stateflags & NDPRF_DETACHED) in sctp_v6src_match_nexthop()
13862 if (IN6_ARE_MASKED_ADDR_EQUAL(&pfx->ndpr_prefix.sin6_addr, in sctp_v6src_match_nexthop()
13863 &src6->sin6_addr, &pfx->ndpr_mask)) in sctp_v6src_match_nexthop()
13878 LIST_FOREACH(pfxrtr, &pfx->ndpr_advrtrs, pfr_entry) { in sctp_v6src_match_nexthop()
13882 memcpy(&gw6.sin6_addr, &pfxrtr->router->rtaddr, in sctp_v6src_match_nexthop()
13887 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &ro->ro_nh->gw_sa); in sctp_v6src_match_nexthop()
13888 if (sctp_cmpaddr((struct sockaddr *)&gw6, &ro->ro_nh->gw_sa)) { in sctp_v6src_match_nexthop()
13908 if (ro == NULL || ro->ro_nh == NULL || in sctp_v4src_match_nexthop()
13909 sifa->address.sa.sa_family != AF_INET) { in sctp_v4src_match_nexthop()
13912 ifa = (struct ifaddr *)sifa->ifa; in sctp_v4src_match_nexthop()
13913 mask = (struct sockaddr_in *)(ifa->ifa_netmask); in sctp_v4src_match_nexthop()
13914 sin = &sifa->address.sin; in sctp_v4src_match_nexthop()
13915 srcnetaddr.s_addr = (sin->sin_addr.s_addr & mask->sin_addr.s_addr); in sctp_v4src_match_nexthop()
13917 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &sifa->address.sa); in sctp_v4src_match_nexthop()
13920 sin = &ro->ro_nh->gw4_sa; in sctp_v4src_match_nexthop()
13921 gwnetaddr.s_addr = (sin->sin_addr.s_addr & mask->sin_addr.s_addr); in sctp_v4src_match_nexthop()
13923 SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, &ro->ro_nh->gw_sa); in sctp_v4src_match_nexthop()