Changeset 218849 in webkit


Ignore:
Timestamp:
Jun 27, 2017 3:54:19 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Refresh usrsctp to Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp and libsrtp to ccf84786f8ef803cb9c75e919e5a3976b9f5a67
https://bugs.webkit.org/show_bug.cgi?id=173673

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-27
Reviewed by Sam Weinig.

  • Source/third_party/libsrtp/README.chromium:
  • Source/third_party/libsrtp/srtp/srtp.c:

(srtp_stream_init_keys):
(srtp_calc_aead_iv_srtcp):
(srtp_protect_rtcp_aead):
(srtp_unprotect_rtcp_aead):

  • Source/third_party/libsrtp/test/srtp_driver.c:

(srtp_validate_encrypted_extensions_headers_gcm):

  • Source/third_party/usrsctp/usrsctplib/.gitignore: Added.
  • Source/third_party/usrsctp/usrsctplib/CMakeLists.txt:
  • Source/third_party/usrsctp/usrsctplib/Makefile.am:
  • Source/third_party/usrsctp/usrsctplib/README.md:
  • Source/third_party/usrsctp/usrsctplib/configure.ac:
  • Source/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt:
  • Source/third_party/usrsctp/usrsctplib/programs/Makefile.am:
  • Source/third_party/usrsctp/usrsctplib/programs/client.c:

(main):

  • Source/third_party/usrsctp/usrsctplib/programs/datachan_serv.c:

(main):

  • Source/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c: Added.

(handle_packets):

  • Source/third_party/usrsctp/usrsctplib/programs/test_timer.c: Added.

(main):

  • Source/third_party/usrsctp/usrsctplib/usrsctp.pc.in: Added.
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c:

(sctp_cwnd_update_after_fr):
(sctp_hs_cwnd_update_after_fr):
(sctp_htcp_cwnd_update_after_fr):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c:

(sctp_build_readq_entry):
(sctp_place_control_in_stream):
(sctp_abort_in_reasm):
(sctp_queue_data_to_stream):
(sctp_build_readq_entry_from_ctl):
(sctp_handle_old_unordered_data):
(sctp_inject_old_unordered_data):
(sctp_deliver_reasm_check):
(sctp_add_chk_to_control):
(sctp_queue_data_for_reasm):
(sctp_find_reasm_entry):
(sctp_process_a_data_chunk):
(sctp_sack_check):
(sctp_process_segment_range):
(sctp_check_for_revoked):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:

(sctp_process_init):
(sctp_process_cookie_existing):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c:

(sctp_ss_rr_add):
(sctp_ss_fcfs_select):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c:

(sctp_recover_sent_list):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c:

(sctp_init):
(sctp_pathmtu_adjustment):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c:

(sctp_log_strm_del):
(sctp_init_asoc):
(sctp_notify_send_failed):
(sctp_notify_send_failed2):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c:

(m_get):
(mbuf_initialize):

  • Source/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c:
  • Source/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h:
  • WebKit/patch-usrsctp: Added.
Location:
trunk/Source/ThirdParty/libwebrtc
Files:
5 added
48 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r218699 r218849  
     12017-06-27  Youenn Fablet  <youenn@apple.com>
     2
     3        Refresh usrsctp to Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp and libsrtp to ccf84786f8ef803cb9c75e919e5a3976b9f5a67
     4        https://bugs.webkit.org/show_bug.cgi?id=173673
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Source/third_party/libsrtp/README.chromium:
     9        * Source/third_party/libsrtp/srtp/srtp.c:
     10        (srtp_stream_init_keys):
     11        (srtp_calc_aead_iv_srtcp):
     12        (srtp_protect_rtcp_aead):
     13        (srtp_unprotect_rtcp_aead):
     14        * Source/third_party/libsrtp/test/srtp_driver.c:
     15        (srtp_validate_encrypted_extensions_headers_gcm):
     16        * Source/third_party/usrsctp/usrsctplib/.gitignore: Added.
     17        * Source/third_party/usrsctp/usrsctplib/CMakeLists.txt:
     18        * Source/third_party/usrsctp/usrsctplib/Makefile.am:
     19        * Source/third_party/usrsctp/usrsctplib/README.md:
     20        * Source/third_party/usrsctp/usrsctplib/configure.ac:
     21        * Source/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt:
     22        * Source/third_party/usrsctp/usrsctplib/programs/Makefile.am:
     23        * Source/third_party/usrsctp/usrsctplib/programs/client.c:
     24        (main):
     25        * Source/third_party/usrsctp/usrsctplib/programs/datachan_serv.c:
     26        (main):
     27        * Source/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c: Added.
     28        (handle_packets):
     29        * Source/third_party/usrsctp/usrsctplib/programs/test_timer.c: Added.
     30        (main):
     31        * Source/third_party/usrsctp/usrsctplib/usrsctp.pc.in: Added.
     32        * Source/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt:
     33        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c:
     34        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h:
     35        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c:
     36        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h:
     37        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c:
     38        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h:
     39        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c:
     40        (sctp_cwnd_update_after_fr):
     41        (sctp_hs_cwnd_update_after_fr):
     42        (sctp_htcp_cwnd_update_after_fr):
     43        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h:
     44        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c:
     45        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h:
     46        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h:
     47        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c:
     48        (sctp_build_readq_entry):
     49        (sctp_place_control_in_stream):
     50        (sctp_abort_in_reasm):
     51        (sctp_queue_data_to_stream):
     52        (sctp_build_readq_entry_from_ctl):
     53        (sctp_handle_old_unordered_data):
     54        (sctp_inject_old_unordered_data):
     55        (sctp_deliver_reasm_check):
     56        (sctp_add_chk_to_control):
     57        (sctp_queue_data_for_reasm):
     58        (sctp_find_reasm_entry):
     59        (sctp_process_a_data_chunk):
     60        (sctp_sack_check):
     61        (sctp_process_segment_range):
     62        (sctp_check_for_revoked):
     63        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h:
     64        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c:
     65        (sctp_process_init):
     66        (sctp_process_cookie_existing):
     67        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h:
     68        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c:
     69        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h:
     70        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c:
     71        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h:
     72        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h:
     73        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c:
     74        (sctp_ss_rr_add):
     75        (sctp_ss_fcfs_select):
     76        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h:
     77        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c:
     78        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c:
     79        (sctp_recover_sent_list):
     80        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h:
     81        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c:
     82        (sctp_init):
     83        (sctp_pathmtu_adjustment):
     84        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h:
     85        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c:
     86        (sctp_log_strm_del):
     87        (sctp_init_asoc):
     88        (sctp_notify_send_failed):
     89        (sctp_notify_send_failed2):
     90        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h:
     91        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c:
     92        * Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h:
     93        * Source/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c:
     94        (m_get):
     95        (mbuf_initialize):
     96        * Source/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h:
     97        * Source/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c:
     98        * Source/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h:
     99        * WebKit/patch-usrsctp: Added.
     100
    11012017-06-22  Youenn Fablet  <youenn@apple.com>
    2102
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/libsrtp/README.chromium

    r210942 r218849  
    33Version: 2cbd85085037dc7bf2eda48d4cf62e2829056e2d
    44License: 3-clause BSD
    5 License File: srtp/LICENSE
     5License File: LICENSE
    66Security Critical: Yes
    77
     
    1515
    1616  Patched in https://github.com/cisco/libsrtp/pull/209.
     17
     18  Patched in https://github.com/cisco/libsrtp/pull/259.
     19
     20  Patched in https://github.com/cisco/libsrtp/pull/262.
     21
     22  Patched in https://github.com/cisco/libsrtp/pull/287.
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/libsrtp/srtp/srtp.c

    r210942 r218849  
    766766      rtp_xtn_hdr_base_key_len = base_key_length(srtp->rtp_xtn_hdr_cipher->type, rtp_xtn_hdr_keylen);
    767767      rtp_xtn_hdr_salt_len = rtp_xtn_hdr_keylen - rtp_xtn_hdr_base_key_len;
     768      if (rtp_xtn_hdr_salt_len > rtp_salt_len) {
     769        switch (srtp->rtp_cipher->type->id) {
     770          case SRTP_AES_128_GCM:
     771          case SRTP_AES_256_GCM:
     772            /* The shorter GCM salt is padded to the required ICM salt length. */
     773            rtp_xtn_hdr_salt_len = rtp_salt_len;
     774            break;
     775          default:
     776            /* zeroize temp buffer */
     777            octet_string_set_to_zero(tmp_key, MAX_SRTP_KEY_LEN);
     778            return srtp_err_status_bad_param;
     779        }
     780      }
    768781      memset(tmp_xtn_hdr_key, 0x0, MAX_SRTP_KEY_LEN);
    769782      memcpy(tmp_xtn_hdr_key, key, (rtp_xtn_hdr_base_key_len + rtp_xtn_hdr_salt_len));
     
    28622875 *         *hdr    - The RTP header, used to get the SSRC value
    28632876 *
     2877 * Returns: srtp_err_status_ok if no error or srtp_err_status_bad_param
     2878 *          if seq_num is invalid
     2879 *
    28642880 */
    2865 static void srtp_calc_aead_iv_srtcp(srtp_stream_ctx_t *stream, v128_t *iv,
    2866                                     uint32_t seq_num, srtcp_hdr_t *hdr)
     2881static srtp_err_status_t
     2882srtp_calc_aead_iv_srtcp(srtp_stream_ctx_t *stream, v128_t *iv,
     2883                        uint32_t seq_num, srtcp_hdr_t *hdr)
    28672884{
    28682885    v128_t      in;
     
    28752892    memcpy(&in.v16[1], &hdr->ssrc, 4); /* still in network order! */
    28762893    in.v16[3] = 0;
    2877     in.v32[2] = 0x7FFFFFFF & htonl(seq_num); /* bit 32 is suppose to be zero */
     2894
     2895    /*
     2896     *  The SRTCP index (seq_num) spans bits 0 through 30 inclusive.
     2897     *  The most significant bit should be zero.
     2898     */
     2899    if (seq_num & 0x80000000UL) {
     2900        return srtp_err_status_bad_param;
     2901    }
     2902    in.v32[2] = htonl(seq_num);
    28782903
    28792904    debug_print(mod_srtp, "Pre-salted RTCP IV = %s\n", v128_hex_string(&in));
     
    28892914     */
    28902915    v128_xor(iv, &in, &salt);
     2916
     2917    return srtp_err_status_ok;
    28912918}
    28922919
     
    29562983
    29572984    /*
    2958      * Calculating the IV and pass it down to the cipher
    2959      */
    2960     srtp_calc_aead_iv_srtcp(stream, &iv, seq_num, hdr);
     2985     * Calculate and set the IV
     2986     */
     2987    status = srtp_calc_aead_iv_srtcp(stream, &iv, seq_num, hdr);
     2988    if (status) {
     2989        return srtp_err_status_cipher_fail;
     2990    }
    29612991    status = srtp_cipher_set_iv(stream->rtcp_cipher, (uint8_t*)&iv, srtp_direction_encrypt);
    29622992    if (status) {
     
    31033133     * Calculate and set the IV
    31043134     */
    3105     srtp_calc_aead_iv_srtcp(stream, &iv, seq_num, hdr);
     3135    status = srtp_calc_aead_iv_srtcp(stream, &iv, seq_num, hdr);
     3136    if (status) {
     3137        return srtp_err_status_cipher_fail;
     3138    }
    31063139    status = srtp_cipher_set_iv(stream->rtcp_cipher, (uint8_t*)&iv, srtp_direction_decrypt);
    31073140    if (status) {
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/libsrtp/test/srtp_driver.c

    r210942 r218849  
    19441944        0x90, 0x0f, 0x12, 0x34, 0xde, 0xca, 0xfb, 0xad,
    19451945        0xca, 0xfe, 0xba, 0xbe, 0xBE, 0xDE, 0x00, 0x06,
    1946         0x17, 0x58, 0x8A, 0x92, 0x70, 0xF4, 0xE1, 0x5E,
    1947         0x1C, 0x22, 0x00, 0x00, 0xC8, 0x30, 0x95, 0x46,
    1948         0xA9, 0x94, 0xF0, 0xBC, 0x54, 0x78, 0x97, 0x00,
     1946        0x17, 0x12, 0xe0, 0x20, 0x5b, 0xfa, 0x94, 0x9b,
     1947        0x1C, 0x22, 0x00, 0x00, 0xC8, 0x30, 0xbb, 0x46,
     1948        0x73, 0x27, 0x78, 0xd9, 0x92, 0x9a, 0xab, 0x00,
    19491949        0x0e, 0xca, 0x0c, 0xf9, 0x5e, 0xe9, 0x55, 0xb2,
    19501950        0x6c, 0xd3, 0xd2, 0x88, 0xb4, 0x9f, 0x6c, 0xa9,
    1951         0xbb, 0x4e, 0x15, 0xc2, 0xe9, 0xf2, 0x66, 0x78
     1951        0xf4, 0xb1, 0xb7, 0x59, 0x71, 0x9e, 0xb5, 0xbc
    19521952    };
    19531953    srtp_t srtp_snd, srtp_recv;
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/CMakeLists.txt

    r210942 r218849  
    11#
    22# Copyright (C) 2015-2015 Oleg Alexeenkov
    3 # Copyright (C) 2015-2015 Felix Weinrank
     3# Copyright (C) 2015-2017 Felix Weinrank
    44#
    55# All rights reserved.
     
    3838endif()
    3939
    40 # Enable verbose output in DEBUG mode
    41 if (${CMAKE_BUILD_TYPE} MATCHES "DEBUG")
    42     message(STATUS "enabling verbose outout")
    43     set(CMAKE_VERBOSE_MAKEFILE on)
    44 endif()
    45 
    4640add_subdirectory(usrsctplib)
    4741add_subdirectory(programs)
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/Makefile.am

    r210942 r218849  
    3232EXTRA_DIST = bootstrap Makefile.nmake
    3333ACLOCAL_AMFLAGS = -I m4
     34# pkgconfig_DATA = usrsctp.pc
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/README.md

    r210942 r218849  
    55See [manual](Manual.md) for more information.
    66
    7 The status of continous integration testing is available from [grid](http://212.201.121.110:18010/grid) and [waterfall](http://212.201.121.110:18010/waterfall).
     7The status of continuous integration testing is available from [grid](http://212.201.121.110:18010/grid) and [waterfall](http://212.201.121.110:18010/waterfall).
    88If you are only interested in a single branch, just append `?branch=BRANCHNAME` to the URL, for example [waterfall](http://212.201.121.110:18010/waterfall?branch=master).
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/configure.ac

    r210942 r218849  
    3737AC_CONFIG_MACRO_DIR([m4])
    3838
     39dnl Disable pkg_config support for now
     40dnl PKG_PROG_PKG_CONFIG
     41dnl PKG_INSTALLDIR
     42
    3943LIBCFLAGS="-DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__"
     44APPCFLAGS=""
     45
    4046case $host_os in
    4147darwin*)
    42   CFLAGS="$CFLAGS -std=c99 -D__APPLE_USE_RFC_2292"
     48  CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
    4349  LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin"
    4450  ;;
     
    9197fi
    9298
    93 LIBCFLAGS="$CFLAGS $LIBCFLAGS"
    94 
    9599AC_ARG_ENABLE(invariants,
    96100  AC_HELP_STRING( [--enable-invariants],
     
    115119    enable_inet=$enableval,enable_inet=yes)
    116120if test x$enable_inet = xyes; then
     121        APPCFLAGS="$APPCFLAGS -DINET"
    117122        AC_DEFINE(INET, 1, [Support IPv4])
    118123fi
     
    123128    enable_inet6=$enableval,enable_inet6=yes)
    124129if test x$enable_inet6 = xyes; then
     130        APPCFLAGS="$APPCFLAGS -DINET6"
    125131        AC_DEFINE(INET6, 1, [Support IPv6])
    126132fi
     
    132138AC_CHECK_FUNCS(inet_addr, , AC_CHECK_LIB(nsl, inet_addr))
    133139
     140AC_CHECK_HEADERS(stdatomic.h)
    134141AC_CHECK_HEADERS(sys/queue.h)
    135142AC_CHECK_HEADERS(linux/if_addr.h, [], [], [#include <sys/socket.h>])
     
    175182
    176183AC_SUBST([LIBCFLAGS])
     184AC_SUBST([APPCFLAGS])
     185dnl AC_CONFIG_FILES([usrsctp.pc])
    177186AC_OUTPUT(Makefile usrsctplib/Makefile programs/Makefile)
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt

    r210942 r218849  
    4646
    4747#################################################
    48 # CHECK FOR TYPES AND FUNCTIONS
    49 #################################################
    50 
    51 # xxx warum machen wir die checks?
    52 check_type_size("size_t" HAVE_SIZE_T)
    53 check_type_size("ssize_t" HAVE_SSIZE_T)
    54 
    55 check_function_exists("socket" HAVE_SOCKET)
    56 check_function_exists("inet_addr" HAVE_INET_ADDR)
    57 
    58 
    59 #################################################
    6048# CHECK INCLUDES
    6149#################################################
    6250
    63 check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
    64 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
    65 check_include_file(sys/queue.h HAVE_SYS_QUEUE_H)
    66 check_include_file(linux/if_addr.h HAVE_LINUX_IF_ADDR_H)
    67 check_include_file(linux/rtnetlink.h HAVE_LINUX_RTNETLINK_H)
    68 check_include_file(netinet/ip_icmp.h HAVE_NETINET_IP_ICMP_H)
    6951check_include_file(usrsctp.h HAVE_USRSCTP_H)
    7052
     
    7557
    7658check_struct_has_member("struct sockaddr" "sa_len" "sys/types.h;sys/socket.h" HAVE_SA_LEN)
    77 if(HAVE_SA_LEN)
    78         add_definitions(-DHAVE_SA_LEN)
    79 endif()
     59if (HAVE_SA_LEN)
     60    add_definitions(-DHAVE_SA_LEN)
     61endif ()
    8062
    8163check_struct_has_member("struct sockaddr_in" "sin_len" "sys/types.h;netinet/in.h" HAVE_SIN_LEN)
    82 if(HAVE_SIN_LEN)
    83         add_definitions(-DHAVE_SIN_LEN)
    84 endif()
     64if (HAVE_SIN_LEN)
     65    add_definitions(-DHAVE_SIN_LEN)
     66endif ()
    8567
    8668check_struct_has_member("struct sockaddr_in6" "sin6_len" "sys/types.h;netinet/in.h" HAVE_SIN6_LEN)
    87 if(HAVE_SIN6_LEN)
    88         add_definitions(-DHAVE_SIN6_LEN)
    89 endif()
     69if (HAVE_SIN6_LEN)
     70    add_definitions(-DHAVE_SIN6_LEN)
     71endif ()
    9072
    9173check_struct_has_member("struct sockaddr_conn" "sconn_len" "usrsctp.h" HAVE_SCONN_LEN)
    92 if(HAVE_SCONN_LEN)
    93         add_definitions(-DHAVE_SCONN_LEN)
    94 endif()
     74if (HAVE_SCONN_LEN)
     75    add_definitions(-DHAVE_SCONN_LEN)
     76endif ()
    9577
    9678
     
    10183option(SCTP_DEBUG "Provide debug information" 1)
    10284if (SCTP_DEBUG)
    103         add_definitions(-DSCTP_DEBUG)
    104 endif()
     85    add_definitions(-DSCTP_DEBUG)
     86endif ()
    10587
    10688option(INET "Support IPv4 " 1)
    10789if (INET)
    108         add_definitions(-DINET)
    109 endif()
     90    add_definitions(-DINET)
     91endif ()
    11092
    11193option(INET6 "Support IPv6 " 1)
    11294if (INET6)
    113         add_definitions(-DINET6)
    114 endif()
     95    add_definitions(-DINET6)
     96endif ()
    11597
    11698option(LINK_STATIC "Link static" 0)
     
    118100# xxx enable W32 support for shared lib ...
    119101if (LINK_STATIC OR WIN32)
    120         set(LINK_STATIC "usrsctp-static")
     102    set(LINK_STATIC "usrsctp-static")
    121103else()
    122         set(LINK_STATIC "usrsctp")
    123 endif()
     104    set(LINK_STATIC "usrsctp")
     105endif ()
    124106
    125107option(WERROR "Warning as error" ON)
     
    131113
    132114if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    133         add_definitions(-D_GNU_SOURCE)
    134 endif()
     115    add_definitions(-D_GNU_SOURCE)
     116endif ()
    135117
    136118if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    137         add_definitions(-D__APPLE_USE_RFC_2292)
    138 endif()
     119    add_definitions(-D__APPLE_USE_RFC_2292)
     120endif ()
    139121
    140122
     
    143125#################################################
    144126
    145 FIND_PACKAGE(Threads)
     127find_package(Threads)
    146128
    147129
     
    150132#################################################
    151133
    152 SET (check_PROGRAMS
    153         client.c
    154         datachan_serv.c
    155         daytime_server.c
    156         discard_server.c
    157         echo_server.c
    158         ekr_client.c
    159         ekr_loop.c
    160         ekr_peer.c
    161         ekr_server.c
    162         http_client.c
    163         rtcweb.c
    164         test_libmgmt.c
    165         tsctp.c
     134set(CHECK_PROGRAMS
     135    client.c
     136    datachan_serv.c
     137    daytime_server.c
     138    discard_server.c
     139    echo_server.c
     140    ekr_client.c
     141    ekr_loop.c
     142    ekr_loop_offload.c
     143    ekr_peer.c
     144    ekr_server.c
     145    http_client.c
     146    rtcweb.c
     147    test_libmgmt.c
     148    test_timer.c
     149    tsctp.c
    166150)
    167151
    168152# SETTINGS FOR UNIX COMPILER
    169 IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xGNU")
    170         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -std=c99")
    171         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c99")
    172         if (WERROR)
    173                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
    174                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
    175         endif()
    176 ENDIF ()
     153if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xGNU")
     154    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -std=c99")
     155    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c99")
     156    if (WERROR)
     157        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
     158        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
     159    endif ()
     160endif ()
    177161
    178162# SETTINGS FOR VISUAL STUDIO COMPILER
    179 IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
    180         IF (CMAKE_C_FLAGS MATCHES "/W[0-4]")
    181                 STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    182         ELSE ()
    183                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
    184         ENDIF ()
     163if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
     164    if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
     165        string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
     166    else ()
     167        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
     168    endif ()
    185169
    186         IF (WERROR)
    187                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
    188         ENDIF()
    189 ENDIF ()
     170    if (WERROR)
     171        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
     172    endif ()
     173endif ()
    190174
    191 FOREACH (source_file ${check_PROGRAMS})
    192         GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
    193         ADD_EXECUTABLE (
    194                 ${source_file_we}
    195                 ${source_file}
    196         )
     175foreach (SOURCE_FILE ${CHECK_PROGRAMS})
     176    get_filename_component(SOURCE_FILE_WE ${SOURCE_FILE} NAME_WE)
     177    add_executable(
     178        ${SOURCE_FILE_WE}
     179        ${SOURCE_FILE}
     180    )
    197181
    198         TARGET_LINK_LIBRARIES (${source_file_we}
    199                 ${LINK_STATIC}
    200                 ${CMAKE_THREAD_LIBS_INIT}
    201         )
     182    target_link_libraries(${SOURCE_FILE_WE}
     183        ${LINK_STATIC}
     184        ${CMAKE_THREAD_LIBS_INIT}
     185    )
    202186
    203         ADD_TEST (${source_file_we} ${source_file_we})
    204 ENDFOREACH ()
     187    add_test(${SOURCE_FILE_WE} ${SOURCE_FILE_WE})
     188endforeach ()
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/programs/Makefile.am

    r210942 r218849  
    3030
    3131AM_CPPFLAGS = -I$(srcdir)/../usrsctplib
    32 EXTRA_DIST = Makefile.nmake tsctp.c daytime_server.c discard_server.c echo_server.c client.c rtcweb.c ekr_client.c ekr_server.c ekr_loop.c test_libmgmt.c http_client.c
     32EXTRA_DIST = Makefile.nmake tsctp.c daytime_server.c discard_server.c echo_server.c client.c rtcweb.c ekr_client.c ekr_server.c ekr_loop.c ekr_loop_offload.c test_libmgmt.c http_client.c
    3333
    34 noinst_PROGRAMS = tsctp daytime_server discard_server echo_server client rtcweb ekr_client ekr_server ekr_peer ekr_loop test_libmgmt http_client
     34noinst_PROGRAMS = tsctp daytime_server discard_server echo_server client rtcweb ekr_client ekr_server ekr_peer ekr_loop ekr_loop_offload test_libmgmt test_timer http_client
    3535test_libmgmt_SOURCES = test_libmgmt.c
    3636test_libmgmt_LDADD = ../usrsctplib/libusrsctp.la
     37test_timer_SOURCES = test_timer.c
     38test_timer_LDADD = ../usrsctplib/libusrsctp.la
    3739tsctp_SOURCES = tsctp.c
    3840tsctp_LDADD = ../usrsctplib/libusrsctp.la
     
    5557ekr_loop_SOURCES = ekr_loop.c
    5658ekr_loop_LDADD = ../usrsctplib/libusrsctp.la
     59ekr_loop_offload_SOURCES = ekr_loop_offload.c
     60ekr_loop_offload_LDADD = ../usrsctplib/libusrsctp.la
    5761http_client_SOURCES = http_client.c
    5862http_client_LDADD = ../usrsctplib/libusrsctp.la
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/programs/client.c

    r210942 r218849  
    9898        int i, n;
    9999
     100        if (argc < 3) {
     101                printf("%s", "Usage: client remote_addr remote_port local_port local_encaps_port remote_encaps_port\n");
     102                return (-1);
     103        }
    100104        if (argc > 4) {
    101105                usrsctp_init(atoi(argv[4]), NULL, debug_printf);
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/programs/datachan_serv.c

    r210942 r218849  
    471471                prinfo.pr_policy = SCTP_PR_SCTP_TTL;
    472472                break;
     473              default:
     474                flags = 0;
     475                prinfo.pr_policy = 0;
     476                break;
    473477            }
    474478                                                sndinfo.snd_sid = stream;
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt

    r210942 r218849  
    11#
    22# Copyright (C) 2015-2015 Oleg Alexeenkov
    3 # Copyright (C) 2015-2015 Felix Weinrank
     3# Copyright (C) 2015-2017 Felix Weinrank
    44#
    55# All rights reserved.
     
    4141include(CheckFunctionExists)
    4242include(CheckStructHasMember)
    43 include(CheckIncludeFile)
     43include(CheckIncludeFiles)
    4444include(CMakePushCheckState)
    4545include(CheckTypeSize)
    4646
    47 SET (VERSION "1.0.0")
    48 
    49 SET (prefix ${CMAKE_INSTALL_PREFIX})
    50 SET (exec_prefix "\${prefix}")
    51 SET (libdir "\${exec_prefix}/lib")
    52 SET (includedir "\${prefix}/include/usrsctp")
    53 SET (CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
     47set(VERSION "1.0.0")
     48
     49set(prefix ${CMAKE_INSTALL_PREFIX})
     50set(exec_prefix "\${prefix}")
     51set(libdir "\${exec_prefix}/lib")
     52set(includedir "\${prefix}/include/usrsctp")
     53set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
     54set(CMAKE_MACOSX_RPATH 1)
    5455
    5556
     
    5859#################################################
    5960
    60 check_type_size("size_t" HAVE_SIZE_T)
    61 check_type_size("ssize_t" HAVE_SSIZE_T)
    62 
    63 check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
    64 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
    65 check_include_file(sys/queue.h HAVE_SYS_QUEUE_H)
    66 check_include_file(linux/if_addr.h HAVE_LINUX_IF_ADDR_H)
    67 check_include_file(linux/rtnetlink.h HAVE_LINUX_RTNETLINK_H)
    68 check_include_file(netinet/ip_icmp.h HAVE_NETINET_IP_ICMP_H)
    69 check_include_file(usrsctp.h HAVE_USRSCTP_H)
    70 
    71 check_function_exists("socket" HAVE_SOCKET)
    72 check_function_exists("inet_addr" HAVE_INET_ADDR)
     61check_include_files("sys/queue.h" HAVE_SYS_QUEUE_H)
     62if (HAVE_SYS_QUEUE_H)
     63    add_definitions(-DHAVE_SYS_QUEUE_H)
     64endif ()
     65
     66check_include_files("sys/socket.h;linux/if_addr.h" HAVE_LINUX_IF_ADDR_H)
     67if (HAVE_LINUX_IF_ADDR_H)
     68    add_definitions(-DHAVE_LINUX_IF_ADDR_H)
     69endif ()
     70
     71check_include_files("sys/socket.h;linux/rtnetlink.h" HAVE_LINUX_RTNETLINK_H)
     72if (HAVE_LINUX_RTNETLINK_H)
     73    add_definitions(-DHAVE_LINUX_RTNETLINK_H)
     74endif ()
     75
     76check_include_files("sys/types.h;netinet/in.h;netinet/ip.h;netinet/ip_icmp.h" HAVE_NETINET_IP_ICMP_H)
     77if (HAVE_NETINET_IP_ICMP_H)
     78    add_definitions(-DHAVE_NETINET_IP_ICMP_H)
     79endif ()
     80
     81check_include_files("stdatomic.h" HAVE_STDATOMIC_H)
     82if (HAVE_STDATOMIC_H)
     83    add_definitions(-DHAVE_STDATOMIC_H)
     84endif ()
    7385
    7486add_definitions(-D__Userspace__)
     
    8294
    8395check_struct_has_member("struct sockaddr" "sa_len" "sys/types.h;sys/socket.h" HAVE_SA_LEN)
    84 if(HAVE_SA_LEN)
    85         message(STATUS "HAVE_SA_LEN")
    86         add_definitions(-DHAVE_SA_LEN)
    87 endif()
     96if (HAVE_SA_LEN)
     97    message(STATUS "HAVE_SA_LEN")
     98    add_definitions(-DHAVE_SA_LEN)
     99endif ()
    88100
    89101check_struct_has_member("struct sockaddr_in" "sin_len" "sys/types.h;netinet/in.h" HAVE_SIN_LEN)
    90 if(HAVE_SIN_LEN)
    91         message(STATUS "HAVE_SIN_LEN")
    92         add_definitions(-DHAVE_SIN_LEN)
    93 endif()
     102if (HAVE_SIN_LEN)
     103    message(STATUS "HAVE_SIN_LEN")
     104    add_definitions(-DHAVE_SIN_LEN)
     105endif ()
    94106
    95107check_struct_has_member("struct sockaddr_in6" "sin6_len" "sys/types.h;netinet/in.h" HAVE_SIN6_LEN)
    96 if(HAVE_SIN6_LEN)
    97         message(STATUS "HAVE_SIN6_LEN")
    98         add_definitions(-DHAVE_SIN6_LEN)
    99 endif()
     108if (HAVE_SIN6_LEN)
     109    message(STATUS "HAVE_SIN6_LEN")
     110    add_definitions(-DHAVE_SIN6_LEN)
     111endif ()
    100112
    101113check_struct_has_member("struct sockaddr_conn" "sconn_len" "usrsctp.h" HAVE_SCONN_LEN)
    102 if(HAVE_SCONN_LEN)
    103         message(STATUS "HAVE_SCONN_LEN")
    104         add_definitions(-DHAVE_SCONN_LEN)
    105 endif()
     114if (HAVE_SCONN_LEN)
     115    message(STATUS "HAVE_SCONN_LEN")
     116    add_definitions(-DHAVE_SCONN_LEN)
     117endif ()
    106118
    107119
     
    111123
    112124if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    113         add_definitions(-D_GNU_SOURCE)
    114 endif()
     125    add_definitions(-D_GNU_SOURCE)
     126endif ()
    115127
    116128if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
    117         add_definitions(-U__FreeBSD__)
    118 endif()
     129    add_definitions(-U__FreeBSD__)
     130endif ()
    119131
    120132if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    121         add_definitions(-U__APPLE__)
    122         add_definitions(-D__APPLE_USE_RFC_2292)
    123 endif()
     133    add_definitions(-U__APPLE__)
     134    add_definitions(-D__APPLE_USE_RFC_2292)
     135    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
     136    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
     137endif ()
    124138
    125139if (${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
    126         add_definitions(-U__DragonFly__)
    127 endif()
     140    add_definitions(-U__DragonFly__)
     141endif ()
    128142
    129143if (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
    130         add_definitions(-U__NetBSD__)
    131 endif()
     144    add_definitions(-U__NetBSD__)
     145endif ()
    132146
    133147if (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
    134         add_definitions(-U__OpenBSD__)
    135 endif()
     148    add_definitions(-U__OpenBSD__)
     149endif ()
    136150
    137151
     
    142156option(INVARIANTS "Add runtime checks" 0)
    143157if (INVARIANTS)
    144         add_definitions(-DINVARIANTS)
    145 endif()
     158    add_definitions(-DINVARIANTS)
     159endif ()
    146160
    147161option(SCTP_DEBUG "Provide debug information" 1)
    148162if (SCTP_DEBUG)
    149         add_definitions(-DSCTP_DEBUG)
    150 endif()
     163    add_definitions(-DSCTP_DEBUG)
     164endif ()
    151165
    152166option(INET "Support IPv4 " 1)
    153167if (INET)
    154         add_definitions(-DINET)
    155 endif()
     168    add_definitions(-DINET)
     169endif ()
    156170
    157171option(INET6 "Support IPv6 " 1)
    158172if (INET6)
    159         add_definitions(-DINET6)
    160 endif()
     173    add_definitions(-DINET6)
     174endif ()
    161175
    162176option(SCTP_SIMPLE_ALLOCATOR " " 1)
    163177if (SCTP_SIMPLE_ALLOCATOR)
    164         add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
    165 endif()
     178    add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
     179endif ()
    166180
    167181option(SCTP_PROCESS_LEVEL_LOCKS " " 1)
    168182if (SCTP_PROCESS_LEVEL_LOCKS)
    169         add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
    170 endif()
     183    add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
     184endif ()
    171185
    172186option(SCTP_WITH_NO_CSUM "Disable SCTP checksum" 0)
    173187if (SCTP_WITH_NO_CSUM)
    174         add_definitions(-DSCTP_WITH_NO_CSUM)
    175 endif()
     188    add_definitions(-DSCTP_WITH_NO_CSUM)
     189endif ()
    176190
    177191option(SCTP_MBUF_LOGGING " " 0)
    178192if (SCTP_MBUF_LOGGING)
    179         add_definitions(-DSCTP_MBUF_LOGGING)
    180 endif()
     193    add_definitions(-DSCTP_MBUF_LOGGING)
     194endif ()
    181195
    182196option(SCTP_PACKET_LOGGING " " 0)
    183197if (SCTP_PACKET_LOGGING)
    184         add_definitions(-DSCTP_PACKET_LOGGING)
    185 endif()
     198    add_definitions(-DSCTP_PACKET_LOGGING)
     199endif ()
    186200
    187201option(SCTP_SO_LOCK_TESTING " " 0)
    188202if (SCTP_SO_LOCK_TESTING)
    189         add_definitions(-DSCTP_SO_LOCK_TESTING)
    190 endif()
     203    add_definitions(-DSCTP_SO_LOCK_TESTING)
     204endif ()
    191205
    192206option(SCTP_EMBEDDED_V6_SCOPE " " 0)
    193207if (SCTP_EMBEDDED_V6_SCOPE)
    194         add_definitions(-DSCTP_EMBEDDED_V6_SCOPE)
    195 endif()
     208    add_definitions(-DSCTP_EMBEDDED_V6_SCOPE)
     209endif ()
    196210
    197211option(SCTP_KAME " " 0)
    198212if (SCTP_KAME)
    199         add_definitions(-DSCTP_KAME)
    200 endif()
     213    add_definitions(-DSCTP_KAME)
     214endif ()
    201215
    202216option(WERROR "Warning as error" ON)
     
    204218include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/netinet ${PROJECT_SOURCE_DIR}/netinet6)
    205219
    206 LIST (APPEND usrsctp_root_HEADERS
    207         user_atomic.h       user_inpcb.h    user_ip_icmp.h  user_mbuf.h   user_recv_thread.h  user_socketvar.h  usrsctp.h
    208         user_environment.h  user_ip6_var.h  user_malloc.h   user_queue.h  user_route.h        user_uma.h
    209 )
    210 
    211 LIST (APPEND usrsctp_netinet_HEADERS
    212         netinet/sctp_asconf.h    netinet/sctp_constants.h  netinet/sctp_indata.h          netinet/sctp_os_userspace.h  netinet/sctp_process_lock.h  netinet/sctp_timer.h
    213         netinet/sctp_auth.h      netinet/sctp_crc32.h      netinet/sctp_input.h           netinet/sctp_output.h        netinet/sctp_sha1.h          netinet/sctp_uio.h
    214         netinet/sctp_bsd_addr.h  netinet/sctp.h            netinet/sctp_lock_userspace.h  netinet/sctp_pcb.h           netinet/sctp_structs.h       netinet/sctputil.h
    215         netinet/sctp_callout.h   netinet/sctp_header.h     netinet/sctp_os.h              netinet/sctp_peeloff.h       netinet/sctp_sysctl.h        netinet/sctp_var.h
    216 )
    217 
    218 LIST (APPEND usrsctp_netinet6_HEADERS
     220list(APPEND usrsctp_root_HEADERS
     221    user_atomic.h       user_inpcb.h    user_ip_icmp.h  user_mbuf.h   user_recv_thread.h  user_socketvar.h  usrsctp.h
     222    user_environment.h  user_ip6_var.h  user_malloc.h   user_queue.h  user_route.h        user_uma.h
     223)
     224
     225list(APPEND usrsctp_netinet_HEADERS
     226    netinet/sctp_asconf.h    netinet/sctp_constants.h  netinet/sctp_indata.h          netinet/sctp_os_userspace.h  netinet/sctp_process_lock.h  netinet/sctp_timer.h
     227    netinet/sctp_auth.h      netinet/sctp_crc32.h      netinet/sctp_input.h           netinet/sctp_output.h        netinet/sctp_sha1.h          netinet/sctp_uio.h
     228    netinet/sctp_bsd_addr.h  netinet/sctp.h            netinet/sctp_lock_userspace.h  netinet/sctp_pcb.h           netinet/sctp_structs.h       netinet/sctputil.h
     229    netinet/sctp_callout.h   netinet/sctp_header.h     netinet/sctp_os.h              netinet/sctp_peeloff.h       netinet/sctp_sysctl.h        netinet/sctp_var.h
     230)
     231
     232list(APPEND usrsctp_netinet6_HEADERS
    219233netinet6/sctp6_var.h
    220234)
    221235
    222 LIST (APPEND usrsctp_HEADERS
    223         ${usrsctp_root_HEADERS}
    224         ${usrsctp_netinet_HEADERS}
    225         ${usrsctp_netinet6_HEADERS}
    226 )
    227 
    228 LIST (APPEND usrsctp_SOURCES
    229         netinet6/sctp6_usrreq.c  netinet/sctp_callout.c       netinet/sctp_input.c    netinet/sctp_sha1.c          netinet/sctp_userspace.c  user_mbuf.c
    230         netinet/sctp_asconf.c    netinet/sctp_cc_functions.c  netinet/sctp_output.c   netinet/sctp_ss_functions.c  netinet/sctp_usrreq.c     user_recv_thread.c
    231         netinet/sctp_auth.c      netinet/sctp_crc32.c         netinet/sctp_pcb.c      netinet/sctp_sysctl.c        netinet/sctputil.c        user_socket.c
    232         netinet/sctp_bsd_addr.c  netinet/sctp_indata.c        netinet/sctp_peeloff.c  netinet/sctp_timer.c         user_environment.c
     236list(APPEND usrsctp_HEADERS
     237    ${usrsctp_root_HEADERS}
     238    ${usrsctp_netinet_HEADERS}
     239    ${usrsctp_netinet6_HEADERS}
     240)
     241
     242list(APPEND usrsctp_SOURCES
     243    netinet6/sctp6_usrreq.c  netinet/sctp_callout.c       netinet/sctp_input.c    netinet/sctp_sha1.c          netinet/sctp_userspace.c  user_mbuf.c
     244    netinet/sctp_asconf.c    netinet/sctp_cc_functions.c  netinet/sctp_output.c   netinet/sctp_ss_functions.c  netinet/sctp_usrreq.c     user_recv_thread.c
     245    netinet/sctp_auth.c      netinet/sctp_crc32.c         netinet/sctp_pcb.c      netinet/sctp_sysctl.c        netinet/sctputil.c        user_socket.c
     246    netinet/sctp_bsd_addr.c  netinet/sctp_indata.c        netinet/sctp_peeloff.c  netinet/sctp_timer.c         user_environment.c
    233247)
    234248
     
    236250add_library(usrsctp-static STATIC ${usrsctp_SOURCES} ${usrsctp_HEADERS})
    237251
    238 if(WIN32)
    239         message(STATUS "link library: ws2_32")
    240         target_link_libraries(usrsctp ws2_32)
    241         target_link_libraries(usrsctp-static ws2_32)
     252if (WIN32)
     253    message(STATUS "link library: ws2_32")
     254    target_link_libraries(usrsctp ws2_32)
     255    target_link_libraries(usrsctp-static ws2_32)
     256endif ()
     257
     258set_target_properties(usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp")
     259set_target_properties(usrsctp PROPERTIES IMPORT_SUFFIX "_import.lib")
     260set_target_properties(usrsctp PROPERTIES SOVERSION 1 VERSION 1.0.0)
     261
     262# SETTINGS FOR UNIX COMPILER
     263if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xGNU")
     264    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wextra -Wall -std=c99 -Wno-unused-parameter")
     265    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wextra -Wall -std=c99 -Wno-unused-parameter")
     266    if (WERROR)
     267        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
     268        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
     269    endif ()
     270endif ()
     271
     272# SETTINGS FOR VISUAL STUDIO COMPILER
     273if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
     274    if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
     275        STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
     276    ELSE ()
     277        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
     278    endif ()
     279
     280    if (WERROR)
     281        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
     282    endif()
     283endif ()
     284
     285if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC90" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC10")
     286    SET_SOURCE_FILES_PROPERTIES(${usrsctp_SOURCES} PROPERTIES LANGUAGE C)
    242287endif()
    243288
    244 SET_TARGET_PROPERTIES (usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp")
    245 SET_TARGET_PROPERTIES (usrsctp PROPERTIES IMPORT_SUFFIX "_import.lib")
    246 SET_TARGET_PROPERTIES (usrsctp PROPERTIES SOVERSION 1 VERSION 1.0.0)
    247 
    248 # SETTINGS FOR UNIX COMPILER
    249 IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xGNU")
    250         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -std=c99")
    251         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c99")
    252         if (WERROR)
    253                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
    254                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
    255         endif()
    256 ENDIF ()
    257 
    258 # SETTINGS FOR VISUAL STUDIO COMPILER
    259 IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
    260         IF (CMAKE_C_FLAGS MATCHES "/W[0-4]")
    261                 STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    262         ELSE ()
    263                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
    264         ENDIF ()
    265 
    266         IF (WERROR)
    267                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
    268         ENDIF()
    269 ENDIF ()
    270 
    271 IF ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC90" OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC10")
    272     SET_SOURCE_FILES_PROPERTIES(${usrsctp_SOURCES} PROPERTIES LANGUAGE C)
    273 ENDIF()
    274 
    275 IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
     289if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
    276290    SET(CMAKE_INSTALL_LIBDIR lib)
    277 ENDIF ()
     291endif ()
    278292
    279293
     
    282296#################################################
    283297
    284 INSTALL (TARGETS usrsctp usrsctp-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
    285 INSTALL (FILES usrsctp.h DESTINATION include)
     298install(TARGETS usrsctp usrsctp-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
     299install(FILES usrsctp.h DESTINATION include)
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 298847 2016-04-30 14:25:00Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 237715 2012-06-28 16:01:08Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 309607 2016-12-06 10:21:25Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 302928 2016-07-16 07:48:01Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 271673 2014-09-16 14:20:33Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 298942 2016-05-02 20:56:11Z pfg $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    307307
    308308#if defined(__Userspace_os_Windows)
     309#ifdef MALLOC
     310#undef MALLOC
     311#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
     312#endif
     313#ifdef FREE
     314#undef FREE
     315#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
     316#endif
    309317static void
    310318sctp_init_ifns_for_vrf(int vrfid)
     
    336344        if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
    337345                SCTP_PRINTF("GetAdaptersV4Addresses() failed with error code %d\n", Err);
    338                 GlobalFree(pAdapterAddrs);
     346                FREE(pAdapterAddrs);
    339347                return;
    340348        }
     
    361369                }
    362370        }
    363         GlobalFree(pAdapterAddrs);
     371        FREE(pAdapterAddrs);
    364372#endif
    365373#ifdef INET6
     
    381389        if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
    382390                SCTP_PRINTF("GetAdaptersV6Addresses() failed with error code %d\n", Err);
    383                 GlobalFree(pAdapterAddrs);
     391                FREE(pAdapterAddrs);
    384392                return;
    385393        }
     
    403411                }
    404412        }
    405         GlobalFree(pAdapterAddrs);
     413        FREE(pAdapterAddrs);
    406414#endif
    407415}
     
    569577
    570578        IFNET_RLOCK();
    571         TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_list) {
     579        TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
    572580                if (sctp_is_desired_interface_type(ifn) == 0) {
    573581                        /* non desired type */
     
    579587                IF_ADDR_LOCK(ifn);
    580588#endif
    581                 TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) {
     589                TAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) {
    582590                        if (ifa->ifa_addr == NULL) {
    583591                                continue;
     
    746754
    747755        IFNET_RLOCK();
    748         TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_list) {
     756        TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
    749757                if (!(*pred)(ifn)) {
    750758                        continue;
    751759                }
    752                 TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) {
     760                TAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) {
    753761                        sctp_addr_change(ifa, add ? RTM_ADD : RTM_DELETE);
    754762                }
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 237540 2012-06-24 21:25:54Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 298942 2016-05-02 20:56:11Z pfg $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    213213                                        asoc->fast_recovery_tsn = asoc->sending_seq - 1;
    214214                                } else {
    215                                         asoc->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
     215                                        asoc->fast_recovery_tsn = lchk->rec.data.tsn - 1;
    216216                                }
    217217
     
    226226                                        net->fast_recovery_tsn = asoc->sending_seq - 1;
    227227                                } else {
    228                                         net->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
     228                                        net->fast_recovery_tsn = lchk->rec.data.tsn - 1;
    229229                                }
    230230
     
    18071807                                        asoc->fast_recovery_tsn = asoc->sending_seq - 1;
    18081808                                } else {
    1809                                         asoc->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
     1809                                        asoc->fast_recovery_tsn = lchk->rec.data.tsn - 1;
    18101810                                }
    18111811
     
    18201820                                        net->fast_recovery_tsn = asoc->sending_seq - 1;
    18211821                                } else {
    1822                                         net->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
     1822                                        net->fast_recovery_tsn = lchk->rec.data.tsn - 1;
    18231823                                }
    18241824
     
    23342334                                        asoc->fast_recovery_tsn = asoc->sending_seq - 1;
    23352335                                } else {
    2336                                         asoc->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
     2336                                        asoc->fast_recovery_tsn = lchk->rec.data.tsn - 1;
    23372337                                }
    23382338
     
    23472347                                        net->fast_recovery_tsn = asoc->sending_seq - 1;
    23482348                                } else {
    2349                                         net->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
     2349                                        net->fast_recovery_tsn = lchk->rec.data.tsn - 1;
    23502350                                }
    23512351
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 302949 2016-07-17 13:14:51Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 309682 2016-12-07 19:30:59Z tuexen $");
    3636#endif
    3737
     
    924924#define SCTP_TSN_GT(a, b) SCTP_UINT32_GT(a, b)
    925925#define SCTP_TSN_GE(a, b) SCTP_UINT32_GE(a, b)
    926 #define SCTP_MSGID_GT(o, a, b) ((o == 1) ? SCTP_UINT16_GT((uint16_t)a, (uint16_t)b) : SCTP_UINT32_GT(a, b))
    927 #define SCTP_MSGID_GE(o, a, b) ((o == 1) ? SCTP_UINT16_GE((uint16_t)a, (uint16_t)b) : SCTP_UINT32_GE(a, b))
     926#define SCTP_MID_GT(i, a, b) (((i) == 1) ? SCTP_UINT32_GT(a, b) : SCTP_UINT16_GT((uint16_t)a, (uint16_t)b))
     927#define SCTP_MID_GE(i, a, b) (((i) == 1) ? SCTP_UINT32_GE(a, b) : SCTP_UINT16_GE((uint16_t)a, (uint16_t)b))
     928#define SCTP_MID_EQ(i, a, b) (((i) == 1) ? a == b : (uint16_t)a == (uint16_t)b)
    928929
    929930/* Mapping array manipulation routines */
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 235828 2012-05-23 11:26:28Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    697697}
    698698
    699 
     699#if defined(__Userspace__)
     700uint32_t
     701#else
    700702static uint32_t
     703#endif
    701704calculate_crc32c(uint32_t crc32c,
    702705                 const unsigned char *buffer,
     
    711714#endif /* FreeBSD < 80000 || other OS */
    712715
     716#if defined(__Userspace__)
     717uint32_t
     718#else
    713719static uint32_t
     720#endif
    714721sctp_finalize_crc32c(uint32_t crc32c)
    715722{
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 235828 2012-05-23 11:26:28Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 309607 2016-12-06 10:21:25Z tuexen $");
    3636#endif
    3737
     
    4949#if defined(__Userspace__)
    5050#if !defined(SCTP_WITH_NO_CSUM)
     51uint32_t calculate_crc32c(uint32_t, const unsigned char *, unsigned int);
     52uint32_t sctp_finalize_crc32c(uint32_t);
    5153uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
    5254#endif
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_header.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 302949 2016-07-17 13:14:51Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z tuexen $");
    3636#endif
    3737
     
    154154struct sctp_data {
    155155        uint32_t tsn;
    156         uint16_t stream_id;
    157         uint16_t stream_sequence;
    158         uint32_t protocol_id;
     156        uint16_t sid;
     157        uint16_t ssn;
     158        uint32_t ppid;
    159159        /* user data follows */
    160160} SCTP_PACKED;
     
    167167struct sctp_idata {
    168168        uint32_t tsn;
    169         uint16_t stream_id;
     169        uint16_t sid;
    170170        uint16_t reserved;      /* Where does the SSN go? */
    171         uint32_t msg_id;
     171        uint32_t mid;
    172172        union {
    173                 uint32_t protocol_id;
     173                uint32_t ppid;
    174174                uint32_t fsn;   /* Fragment Sequence Number */
    175175        } ppid_fsn;
     
    410410
    411411struct sctp_strseq {
    412         uint16_t stream;
    413         uint16_t sequence;
     412        uint16_t sid;
     413        uint16_t ssn;
    414414} SCTP_PACKED;
    415415
    416416struct sctp_strseq_mid {
    417         uint16_t stream;
     417        uint16_t sid;
    418418        uint16_t flags;
    419         uint32_t msg_id;
     419        uint32_t mid;
    420420};
    421421
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 303927 2016-08-10 17:19:33Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    138138    struct sctp_nets *net,
    139139    uint32_t tsn, uint32_t ppid,
    140     uint32_t context, uint16_t stream_no,
    141     uint32_t stream_seq, uint8_t flags,
     140    uint32_t context, uint16_t sid,
     141    uint32_t mid, uint8_t flags,
    142142    struct mbuf *dm)
    143143{
     
    149149        }
    150150        memset(read_queue_e, 0, sizeof(struct sctp_queued_to_read));
    151         read_queue_e->sinfo_stream = stream_no;
    152         read_queue_e->sinfo_ssn = stream_seq;
     151        read_queue_e->sinfo_stream = sid;
    153152        read_queue_e->sinfo_flags = (flags << 8);
    154153        read_queue_e->sinfo_ppid = ppid;
     
    157156        read_queue_e->sinfo_cumtsn = tsn;
    158157        read_queue_e->sinfo_assoc_id = sctp_get_associd(stcb);
     158        read_queue_e->mid = mid;
    159159        read_queue_e->top_fsn = read_queue_e->fsn_included = 0xffffffff;
    160160        TAILQ_INIT(&read_queue_e->reasm);
     
    356356        struct sctp_queued_to_read *at;
    357357        struct sctp_readhead *q;
    358         uint8_t bits, unordered;
    359 
    360         bits = (control->sinfo_flags >> 8);
    361         unordered = bits & SCTP_DATA_UNORDERED;
     358        uint8_t flags, unordered;
     359
     360        flags = (control->sinfo_flags >> 8);
     361        unordered = flags & SCTP_DATA_UNORDERED;
    362362        if (unordered) {
    363363                q = &strm->uno_inqueue;
     
    374374                q = &strm->inqueue;
    375375        }
    376         if ((bits & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
    377                 control->end_added = control->last_frag_seen = control->first_frag_seen = 1;
     376        if ((flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
     377                control->end_added = 1;
     378                control->first_frag_seen = 1;
     379                control->last_frag_seen = 1;
    378380        }
    379381        if (TAILQ_EMPTY(q)) {
     
    388390        } else {
    389391                TAILQ_FOREACH(at, q, next_instrm) {
    390                         if (SCTP_TSN_GT(at->msg_id, control->msg_id)) {
     392                        if (SCTP_MID_GT(asoc->idata_supported, at->mid, control->mid)) {
    391393                                /*
    392394                                 * one in queue is bigger than the
     
    400402                                }
    401403                                break;
    402                         } else if (at->msg_id == control->msg_id) {
     404                        } else if (SCTP_MID_EQ(asoc->idata_supported, at->mid, control->mid)) {
    403405                                /*
    404406                                 * Gak, He sent me a duplicate msg
     
    416418                                                                  SCTP_STR_LOG_FROM_INSERT_TL);
    417419                                        }
    418                                         TAILQ_INSERT_AFTER(q,
    419                                                            at, control, next_instrm);
     420                                        TAILQ_INSERT_AFTER(q, at, control, next_instrm);
    420421                                        if (unordered) {
    421422                                                control->on_strm_q = SCTP_ON_UNORDERED ;
     
    445446                         opspot,
    446447                         control->fsn_included,
    447                          chk->rec.data.TSN_seq,
    448                          chk->rec.data.stream_number,
    449                          chk->rec.data.fsn_num, chk->rec.data.stream_seq);
     448                         chk->rec.data.tsn,
     449                         chk->rec.data.sid,
     450                         chk->rec.data.fsn, chk->rec.data.mid);
    450451        } else {
    451452                snprintf(msg, sizeof(msg),
     
    453454                         opspot,
    454455                         control->fsn_included,
    455                          chk->rec.data.TSN_seq,
    456                          chk->rec.data.stream_number,
    457                          chk->rec.data.fsn_num,
    458                          (uint16_t)chk->rec.data.stream_seq);
     456                         chk->rec.data.tsn,
     457                         chk->rec.data.sid,
     458                         chk->rec.data.fsn,
     459                         (uint16_t)chk->rec.data.mid);
    459460        }
    460461        oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
     
    492493static void
    493494sctp_queue_data_to_stream(struct sctp_tcb *stcb,
    494     struct sctp_stream_in *strm,
    495495    struct sctp_association *asoc,
    496496    struct sctp_queued_to_read *control, int *abort_flag, int *need_reasm)
     
    518518        uint32_t nxt_todel;
    519519        struct mbuf *op_err;
     520        struct sctp_stream_in *strm;
    520521        char msg[SCTP_DIAG_INFO_LEN];
    521522
     523        strm = &asoc->strmin[control->sinfo_stream];
    522524        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_STR_LOGGING_ENABLE) {
    523525                sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INTO_STRD);
    524526        }
    525         if (SCTP_MSGID_GT((!asoc->idata_supported), strm->last_sequence_delivered, control->sinfo_ssn)) {
     527        if (SCTP_MID_GT((asoc->idata_supported), strm->last_mid_delivered, control->mid)) {
    526528                /* The incoming sseq is behind where we last delivered? */
    527529                SCTPDBG(SCTP_DEBUG_INDATA1, "Duplicate S-SEQ: %u delivered: %u from peer, Abort association\n",
    528                         control->sinfo_ssn, strm->last_sequence_delivered);
    529         protocol_error:
     530                        strm->last_mid_delivered, control->mid);
    530531                /*
    531532                 * throw it in the stream so it gets cleaned up in
     
    533534                 */
    534535                TAILQ_INSERT_HEAD(&strm->inqueue, control, next_instrm);
    535                 snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
    536                          strm->last_sequence_delivered, control->sinfo_tsn,
    537                          control->sinfo_stream, control->sinfo_ssn);
     536                if (asoc->idata_supported) {
     537                        snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
     538                                 strm->last_mid_delivered, control->sinfo_tsn,
     539                                 control->sinfo_stream, control->mid);
     540                } else {
     541                        snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
     542                                 (uint16_t)strm->last_mid_delivered,
     543                                 control->sinfo_tsn,
     544                                 control->sinfo_stream,
     545                                 (uint16_t)control->mid);
     546                }
    538547                op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
    539548                stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_2;
     
    543552
    544553        }
    545         if ((SCTP_TSN_GE(asoc->cumulative_tsn, control->sinfo_tsn)) && (asoc->idata_supported == 0)) {
    546                 goto protocol_error;
    547         }
    548554        queue_needed = 1;
    549555        asoc->size_on_all_streams += control->length;
    550556        sctp_ucount_incr(asoc->cnt_on_all_streams);
    551         nxt_todel = strm->last_sequence_delivered + 1;
    552         if (nxt_todel == control->sinfo_ssn) {
     557        nxt_todel = strm->last_mid_delivered + 1;
     558        if (SCTP_MID_EQ(asoc->idata_supported, nxt_todel, control->mid)) {
    553559#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
    554560                struct socket *so;
     
    569575                        sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_IMMED_DEL);
    570576                }
    571                 /* EY it wont be queued if it could be delivered directly*/
     577                /* EY it wont be queued if it could be delivered directly */
    572578                queue_needed = 0;
    573579                asoc->size_on_all_streams -= control->length;
    574580                sctp_ucount_decr(asoc->cnt_on_all_streams);
    575                 strm->last_sequence_delivered++;
     581                strm->last_mid_delivered++;
    576582                sctp_mark_non_revokable(asoc, control->sinfo_tsn);
    577583                sctp_add_to_readq(stcb->sctp_ep, stcb,
     
    581587                TAILQ_FOREACH_SAFE(control, &strm->inqueue, next_instrm, at) {
    582588                        /* all delivered */
    583                         nxt_todel = strm->last_sequence_delivered + 1;
    584                         if ((nxt_todel == control->sinfo_ssn) &&
     589                        nxt_todel = strm->last_mid_delivered + 1;
     590                        if (SCTP_MID_EQ(asoc->idata_supported, nxt_todel, control->mid) &&
    585591                            (((control->sinfo_flags >> 8) & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG)) {
    586592                                asoc->size_on_all_streams -= control->length;
     
    595601                                }
    596602                                control->on_strm_q = 0;
    597                                 strm->last_sequence_delivered++;
     603                                strm->last_mid_delivered++;
    598604                                /*
    599605                                 * We ignore the return of deliver_data here
     
    613619                                                  SCTP_SO_LOCKED);
    614620                                continue;
    615                         } else if (nxt_todel == control->sinfo_ssn) {
     621                        } else if (SCTP_MID_EQ(asoc->idata_supported, nxt_todel, control->mid)) {
    616622                                *need_reasm = 1;
    617623                        }
     
    629635                if (sctp_place_control_in_stream(strm, asoc, control)) {
    630636                        snprintf(msg, sizeof(msg),
    631                                  "Queue to str msg_id: %u duplicate",
    632                                  control->msg_id);
     637                                 "Queue to str MID: %u duplicate",
     638                                 control->mid);
    633639                        sctp_clean_up_control(stcb, control);
    634640                        op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
     
    741747        memset(nc, 0, sizeof(struct sctp_queued_to_read));
    742748        nc->sinfo_stream = control->sinfo_stream;
    743         nc->sinfo_ssn = control->sinfo_ssn;
     749        nc->mid = control->mid;
    744750        TAILQ_INIT(&nc->reasm);
    745751        nc->top_fsn = control->top_fsn;
    746         nc->msg_id = control->msg_id;
     752        nc->mid = control->mid;
    747753        nc->sinfo_flags = control->sinfo_flags;
    748754        nc->sinfo_ppid = control->sinfo_ppid;
     
    782788{
    783789        /* Special handling for the old un-ordered data chunk.
    784          * All the chunks/TSN's go to msg_id 0. So
     790         * All the chunks/TSN's go to mid 0. So
    785791         * we have to do the old style watching to see
    786792         * if we have it all. If you return one, no other
     
    805811        /* Now what can we add? */
    806812        TAILQ_FOREACH_SAFE(chk, &control->reasm, sctp_next, lchk) {
    807                 if (chk->rec.data.fsn_num == fsn) {
     813                if (chk->rec.data.fsn == fsn) {
    808814                        /* Ok lets add it */
    809815                        sctp_alloc_a_readq(stcb, nc);
     
    828834                                        if (tchk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) {
    829835                                                TAILQ_REMOVE(&control->reasm, tchk, sctp_next);
     836                                                asoc->size_on_reasm_queue -= tchk->send_size;
     837                                                sctp_ucount_decr(asoc->cnt_on_reasm_queue);
    830838                                                nc->first_frag_seen = 1;
    831                                                 nc->fsn_included = tchk->rec.data.fsn_num;
     839                                                nc->fsn_included = tchk->rec.data.fsn;
    832840                                                nc->data = tchk->data;
    833                                                 nc->sinfo_ppid = tchk->rec.data.payloadtype;
    834                                                 nc->sinfo_tsn = tchk->rec.data.TSN_seq;
    835                                                 sctp_mark_non_revokable(asoc, tchk->rec.data.TSN_seq);
     841                                                nc->sinfo_ppid = tchk->rec.data.ppid;
     842                                                nc->sinfo_tsn = tchk->rec.data.tsn;
     843                                                sctp_mark_non_revokable(asoc, tchk->rec.data.tsn);
    836844                                                tchk->data = NULL;
    837845                                                sctp_free_a_chunk(stcb, tchk, SCTP_SO_NOT_LOCKED);
     
    920928                SCTPDBG(SCTP_DEBUG_XXX,
    921929                        "chunk is a first fsn: %u becomes fsn_included\n",
    922                         chk->rec.data.fsn_num);
     930                        chk->rec.data.fsn);
    923931                if (control->first_frag_seen) {
    924932                        /*
     
    931939                        uint32_t tmp;
    932940
    933                         if (SCTP_TSN_GT(chk->rec.data.fsn_num, control->fsn_included)) {
     941                        if (SCTP_TSN_GT(chk->rec.data.fsn, control->fsn_included)) {
    934942                                /* Easy way the start of a new guy beyond the lowest */
    935943                                goto place_chunk;
    936944                        }
    937                         if ((chk->rec.data.fsn_num == control->fsn_included) ||
     945                        if ((chk->rec.data.fsn == control->fsn_included) ||
    938946                            (control->pdapi_started)) {
    939947                                /*
     
    967975                        /* Fix the FSN included */
    968976                        tmp = control->fsn_included;
    969                         control->fsn_included = chk->rec.data.fsn_num;
    970                         chk->rec.data.fsn_num = tmp;
     977                        control->fsn_included = chk->rec.data.fsn;
     978                        chk->rec.data.fsn = tmp;
    971979                        /* Fix the TSN included */
    972980                        tmp = control->sinfo_tsn;
    973                         control->sinfo_tsn = chk->rec.data.TSN_seq;
    974                         chk->rec.data.TSN_seq = tmp;
     981                        control->sinfo_tsn = chk->rec.data.tsn;
     982                        chk->rec.data.tsn = tmp;
    975983                        /* Fix the PPID included */
    976984                        tmp = control->sinfo_ppid;
    977                         control->sinfo_ppid = chk->rec.data.payloadtype;
    978                         chk->rec.data.payloadtype = tmp;
     985                        control->sinfo_ppid = chk->rec.data.ppid;
     986                        chk->rec.data.ppid = tmp;
    979987                        /* Fix tail pointer */
    980988                        goto place_chunk;
    981989                }
    982990                control->first_frag_seen = 1;
    983                 control->top_fsn = control->fsn_included = chk->rec.data.fsn_num;
    984                 control->sinfo_tsn = chk->rec.data.TSN_seq;
    985                 control->sinfo_ppid = chk->rec.data.payloadtype;
     991                control->fsn_included = chk->rec.data.fsn;
     992                control->top_fsn = chk->rec.data.fsn;
     993                control->sinfo_tsn = chk->rec.data.tsn;
     994                control->sinfo_ppid = chk->rec.data.ppid;
    986995                control->data = chk->data;
    987                 sctp_mark_non_revokable(asoc, chk->rec.data.TSN_seq);
     996                sctp_mark_non_revokable(asoc, chk->rec.data.tsn);
    988997                chk->data = NULL;
    989998                sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
     
    9941003        inserted = 0;
    9951004        TAILQ_FOREACH(at, &control->reasm, sctp_next) {
    996                 if (SCTP_TSN_GT(at->rec.data.fsn_num, chk->rec.data.fsn_num)) {
     1005                if (SCTP_TSN_GT(at->rec.data.fsn, chk->rec.data.fsn)) {
    9971006                        /*
    9981007                         * This one in queue is bigger than the new one, insert
     
    10041013                        TAILQ_INSERT_BEFORE(at, chk, sctp_next);
    10051014                        break;
    1006                 } else if (at->rec.data.fsn_num == chk->rec.data.fsn_num) {
     1015                } else if (at->rec.data.fsn == chk->rec.data.fsn) {
    10071016                        /*
    10081017                         * They sent a duplicate fsn number. This
     
    10211030                asoc->size_on_reasm_queue += chk->send_size;
    10221031                sctp_ucount_incr(asoc->cnt_on_reasm_queue);
    1023                 control->top_fsn = chk->rec.data.fsn_num;
     1032                control->top_fsn = chk->rec.data.fsn;
    10241033                TAILQ_INSERT_TAIL(&control->reasm, chk, sctp_next);
    10251034        }
     
    10381047         * we need to remove them from the stream's queue.
    10391048         */
    1040         struct sctp_queued_to_read *control, *nctl=NULL;
     1049        struct sctp_queued_to_read *control, *nctl = NULL;
    10411050        uint32_t next_to_del;
    10421051        uint32_t pd_point;
     
    10511060        control = TAILQ_FIRST(&strm->uno_inqueue);
    10521061
    1053         if ((control) &&
     1062        if ((control != NULL) &&
    10541063            (asoc->idata_supported == 0)) {
    10551064                /* Special handling needed for "old" data format */
     
    10641073        while (control) {
    10651074                SCTPDBG(SCTP_DEBUG_XXX, "Looking at control: %p e(%d) ssn: %u top_fsn: %u inc_fsn: %u -uo\n",
    1066                         control, control->end_added, control->sinfo_ssn, control->top_fsn, control->fsn_included);
     1075                        control, control->end_added, control->mid, control->top_fsn, control->fsn_included);
    10671076                nctl = TAILQ_NEXT(control, next_instrm);
    10681077                if (control->end_added) {
     
    11091118                return (ret);
    11101119        }
    1111         if (strm->last_sequence_delivered == control->sinfo_ssn) {
     1120        if (SCTP_MID_EQ(asoc->idata_supported, strm->last_mid_delivered, control->mid)) {
    11121121                /* Ok the guy at the top was being partially delivered
    11131122                 * completed, so we remove it. Note
     
    11181127                SCTPDBG(SCTP_DEBUG_XXX,
    11191128                        "Looking at control: %p e(%d) ssn: %u top_fsn: %u inc_fsn: %u (lastdel: %u)- o\n",
    1120                         control, control->end_added, control->sinfo_ssn,
     1129                        control, control->end_added, control->mid,
    11211130                        control->top_fsn, control->fsn_included,
    1122                         strm->last_sequence_delivered);
     1131                        strm->last_mid_delivered);
    11231132                if (control->end_added) {
    11241133                        if (control->on_strm_q) {
     
    11511160        }
    11521161deliver_more:
    1153         next_to_del = strm->last_sequence_delivered + 1;
     1162        next_to_del = strm->last_mid_delivered + 1;
    11541163        if (control) {
    11551164                SCTPDBG(SCTP_DEBUG_XXX,
    11561165                        "Looking at control: %p e(%d) ssn: %u top_fsn: %u inc_fsn: %u (nxtdel: %u)- o\n",
    1157                         control, control->end_added, control->sinfo_ssn, control->top_fsn, control->fsn_included,
     1166                        control, control->end_added, control->mid, control->top_fsn, control->fsn_included,
    11581167                        next_to_del);
    11591168                nctl = TAILQ_NEXT(control, next_instrm);
    1160                 if ((control->sinfo_ssn == next_to_del) &&
     1169                if (SCTP_MID_EQ(asoc->idata_supported, control->mid, next_to_del) &&
    11611170                    (control->first_frag_seen)) {
    11621171                        int done;
     
    11951204                                                  inp_read_lock_held, SCTP_SO_NOT_LOCKED);
    11961205                        }
    1197                         strm->last_sequence_delivered = next_to_del;
     1206                        strm->last_mid_delivered = next_to_del;
    11981207                        if (done) {
    11991208                                control = nctl;
     
    12381247                sctp_add_to_tail_pointer(control, chk->data);
    12391248        }
    1240         control->fsn_included = chk->rec.data.fsn_num;
     1249        control->fsn_included = chk->rec.data.fsn;
    12411250        asoc->size_on_reasm_queue -= chk->send_size;
    12421251        sctp_ucount_decr(asoc->cnt_on_reasm_queue);
    1243         sctp_mark_non_revokable(asoc, chk->rec.data.TSN_seq);
     1252        sctp_mark_non_revokable(asoc, chk->rec.data.tsn);
    12441253        chk->data = NULL;
    12451254        if (chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) {
    12461255                control->first_frag_seen = 1;
     1256                control->sinfo_tsn = chk->rec.data.tsn;
     1257                control->sinfo_ppid = chk->rec.data.ppid;
    12471258        }
    12481259        if (chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) {
     
    12851296static void
    12861297sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
    1287                           struct sctp_stream_in *strm,
    12881298                          struct sctp_queued_to_read *control,
    12891299                          struct sctp_tmit_chunk *chk,
     
    12931303        uint32_t next_fsn;
    12941304        struct sctp_tmit_chunk *at, *nat;
     1305        struct sctp_stream_in *strm;
    12951306        int do_wakeup, unordered;
    12961307
     1308        strm = &asoc->strmin[control->sinfo_stream];
    12971309        /*
    12981310         * For old un-ordered data chunks.
     
    13421354                SCTPDBG(SCTP_DEBUG_XXX,
    13431355                        "chunk is a first fsn: %u becomes fsn_included\n",
    1344                         chk->rec.data.fsn_num);
     1356                        chk->rec.data.fsn);
    13451357                if (control->first_frag_seen) {
    13461358                        /*
     
    13561368                }
    13571369                control->first_frag_seen = 1;
    1358                 control->fsn_included = chk->rec.data.fsn_num;
     1370                control->sinfo_ppid = chk->rec.data.ppid;
     1371                control->sinfo_tsn = chk->rec.data.tsn;
     1372                control->fsn_included = chk->rec.data.fsn;
    13591373                control->data = chk->data;
    1360                 sctp_mark_non_revokable(asoc, chk->rec.data.TSN_seq);
     1374                sctp_mark_non_revokable(asoc, chk->rec.data.tsn);
    13611375                chk->data = NULL;
    13621376                sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
     
    13671381                if (control->last_frag_seen == 0) {
    13681382                        /* Still willing to raise highest FSN seen */
    1369                         if (SCTP_TSN_GT(chk->rec.data.fsn_num, control->top_fsn)) {
     1383                        if (SCTP_TSN_GT(chk->rec.data.fsn, control->top_fsn)) {
    13701384                                SCTPDBG(SCTP_DEBUG_XXX,
    13711385                                        "We have a new top_fsn: %u\n",
    1372                                         chk->rec.data.fsn_num);
    1373                                 control->top_fsn = chk->rec.data.fsn_num;
     1386                                        chk->rec.data.fsn);
     1387                                control->top_fsn = chk->rec.data.fsn;
    13741388                        }
    13751389                        if (chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) {
    13761390                                SCTPDBG(SCTP_DEBUG_XXX,
    13771391                                        "The last fsn is now in place fsn: %u\n",
    1378                                         chk->rec.data.fsn_num);
     1392                                        chk->rec.data.fsn);
    13791393                                control->last_frag_seen = 1;
    13801394                        }
     
    13861400                                 * (which is the TSN).
    13871401                                 */
    1388                                 if (SCTP_TSN_GE(control->fsn_included, chk->rec.data.fsn_num)) {
     1402                                if (SCTP_TSN_GE(control->fsn_included, chk->rec.data.fsn)) {
    13891403                                        /* We have already delivered up to this so its a dup */
    13901404                                        sctp_abort_in_reasm(stcb, control, chk,
     
    13991413                                SCTPDBG(SCTP_DEBUG_XXX,
    14001414                                        "Duplicate last fsn: %u (top: %u) -- abort\n",
    1401                                         chk->rec.data.fsn_num, control->top_fsn);
     1415                                        chk->rec.data.fsn, control->top_fsn);
    14021416                                sctp_abort_in_reasm(stcb, control,
    14031417                                                    chk, abort_flag,
     
    14131427                                 */
    14141428
    1415                                 if (SCTP_TSN_GE(control->fsn_included, chk->rec.data.fsn_num)) {
     1429                                if (SCTP_TSN_GE(control->fsn_included, chk->rec.data.fsn)) {
    14161430                                        /* We have already delivered up to this so its a dup */
    14171431                                        SCTPDBG(SCTP_DEBUG_XXX,
    14181432                                                "New fsn: %u is already seen in included_fsn: %u -- abort\n",
    1419                                                 chk->rec.data.fsn_num, control->fsn_included);
     1433                                                chk->rec.data.fsn, control->fsn_included);
    14201434                                        sctp_abort_in_reasm(stcb, control, chk,
    14211435                                                            abort_flag,
     
    14251439                        }
    14261440                        /* validate not beyond top FSN if we have seen last one */
    1427                         if (SCTP_TSN_GT(chk->rec.data.fsn_num, control->top_fsn)) {
     1441                        if (SCTP_TSN_GT(chk->rec.data.fsn, control->top_fsn)) {
    14281442                                SCTPDBG(SCTP_DEBUG_XXX,
    14291443                                        "New fsn: %u is beyond or at top_fsn: %u -- abort\n",
    1430                                         chk->rec.data.fsn_num,
     1444                                        chk->rec.data.fsn,
    14311445                                        control->top_fsn);
    14321446                                sctp_abort_in_reasm(stcb, control, chk,
     
    14431457                SCTPDBG(SCTP_DEBUG_XXX,
    14441458                        "chunk is a not first fsn: %u needs to be inserted\n",
    1445                         chk->rec.data.fsn_num);
     1459                        chk->rec.data.fsn);
    14461460                TAILQ_FOREACH(at, &control->reasm, sctp_next) {
    1447                         if (SCTP_TSN_GT(at->rec.data.fsn_num, chk->rec.data.fsn_num)) {
     1461                        if (SCTP_TSN_GT(at->rec.data.fsn, chk->rec.data.fsn)) {
    14481462                                /*
    14491463                                 * This one in queue is bigger than the new one, insert
     
    14521466                                SCTPDBG(SCTP_DEBUG_XXX,
    14531467                                        "Insert it before fsn: %u\n",
    1454                                         at->rec.data.fsn_num);
     1468                                        at->rec.data.fsn);
    14551469                                asoc->size_on_reasm_queue += chk->send_size;
    14561470                                sctp_ucount_incr(asoc->cnt_on_reasm_queue);
     
    14581472                                inserted = 1;
    14591473                                break;
    1460                         } else if (at->rec.data.fsn_num == chk->rec.data.fsn_num) {
     1474                        } else if (at->rec.data.fsn == chk->rec.data.fsn) {
    14611475                                /* Gak, He sent me a duplicate str seq number */
    14621476                                /*
     
    14691483                                SCTPDBG(SCTP_DEBUG_XXX,
    14701484                                        "Duplicate to fsn: %u -- abort\n",
    1471                                         at->rec.data.fsn_num);
     1485                                        at->rec.data.fsn);
    14721486                                sctp_abort_in_reasm(stcb, control,
    14731487                                                    chk, abort_flag,
     
    14791493                        /* Goes on the end */
    14801494                        SCTPDBG(SCTP_DEBUG_XXX, "Inserting at tail of list fsn: %u\n",
    1481                                 chk->rec.data.fsn_num);
     1495                                chk->rec.data.fsn);
    14821496                        asoc->size_on_reasm_queue += chk->send_size;
    14831497                        sctp_ucount_incr(asoc->cnt_on_reasm_queue);
     
    14971511                next_fsn = control->fsn_included + 1;
    14981512                TAILQ_FOREACH_SAFE(at, &control->reasm, sctp_next, nat) {
    1499                         if (at->rec.data.fsn_num == next_fsn) {
     1513                        if (at->rec.data.fsn == next_fsn) {
    15001514                                /* We can add this one now to the control */
    15011515                                SCTPDBG(SCTP_DEBUG_XXX,
    15021516                                        "Adding more to control: %p at: %p fsn: %u next_fsn: %u included: %u\n",
    15031517                                        control, at,
    1504                                         at->rec.data.fsn_num,
     1518                                        at->rec.data.fsn,
    15051519                                        next_fsn, control->fsn_included);
    15061520                                TAILQ_REMOVE(&control->reasm, at, sctp_next);
     
    15391553
    15401554static struct sctp_queued_to_read *
    1541 sctp_find_reasm_entry(struct sctp_stream_in *strm, uint32_t msg_id, int ordered, int old)
     1555sctp_find_reasm_entry(struct sctp_stream_in *strm, uint32_t mid, int ordered, int idata_supported)
    15421556{
    15431557        struct sctp_queued_to_read *control;
     
    15451559        if (ordered) {
    15461560                TAILQ_FOREACH(control, &strm->inqueue, next_instrm) {
    1547                         if (control->msg_id == msg_id) {
     1561                        if (SCTP_MID_EQ(idata_supported, control->mid, mid)) {
    15481562                                break;
    15491563                        }
    15501564                }
    15511565        } else {
    1552                 if (old) {
     1566                if (idata_supported) {
     1567                        TAILQ_FOREACH(control, &strm->uno_inqueue, next_instrm) {
     1568                                if (SCTP_MID_EQ(idata_supported, control->mid, mid)) {
     1569                                        break;
     1570                                }
     1571                        }
     1572                } else {
    15531573                        control = TAILQ_FIRST(&strm->uno_inqueue);
    1554                         return (control);
    1555                 }
    1556                 TAILQ_FOREACH(control, &strm->uno_inqueue, next_instrm) {
    1557                         if (control->msg_id == msg_id) {
    1558                                 break;
    1559                         }
    15601574                }
    15611575        }
     
    15671581                          struct mbuf **m, int offset,  int chk_length,
    15681582                          struct sctp_nets *net, uint32_t *high_tsn, int *abort_flag,
    1569                           int *break_flag, int last_chunk, uint8_t chtype)
     1583                          int *break_flag, int last_chunk, uint8_t chk_type)
    15701584{
    15711585        /* Process a data chunk */
    15721586        /* struct sctp_tmit_chunk *chk; */
    1573         struct sctp_data_chunk *ch;
    1574         struct sctp_idata_chunk *nch, chunk_buf;
    15751587        struct sctp_tmit_chunk *chk;
    1576         uint32_t tsn, fsn, gap, msg_id;
     1588        uint32_t tsn, fsn, gap, mid;
    15771589        struct mbuf *dmbuf;
    15781590        int the_len;
    15791591        int need_reasm_check = 0;
    1580         uint16_t strmno;
     1592        uint16_t sid;
    15811593        struct mbuf *op_err;
    15821594        char msg[SCTP_DIAG_INFO_LEN];
    1583         struct sctp_queued_to_read *control=NULL;
    1584         uint32_t protocol_id;
    1585         uint8_t chunk_flags;
     1595        struct sctp_queued_to_read *control = NULL;
     1596        uint32_t ppid;
     1597        uint8_t chk_flags;
    15861598        struct sctp_stream_reset_list *liste;
    1587         struct sctp_stream_in *strm;
    15881599        int ordered;
    15891600        size_t clen;
    15901601        int created_control = 0;
    1591         uint8_t old_data;
    1592 
    1593         chk = NULL;
    1594         if (chtype == SCTP_IDATA) {
    1595                 nch = (struct sctp_idata_chunk *)sctp_m_getptr(*m, offset,
    1596                                                                sizeof(struct sctp_idata_chunk), (uint8_t *)&chunk_buf);
    1597                 ch = (struct sctp_data_chunk *)nch;
     1602
     1603        if (chk_type == SCTP_IDATA) {
     1604                struct sctp_idata_chunk *chunk, chunk_buf;
     1605
     1606                chunk = (struct sctp_idata_chunk *)sctp_m_getptr(*m, offset,
     1607                                                                 sizeof(struct sctp_idata_chunk), (uint8_t *)&chunk_buf);
     1608                chk_flags = chunk->ch.chunk_flags;
    15981609                clen = sizeof(struct sctp_idata_chunk);
    1599                 tsn = ntohl(ch->dp.tsn);
    1600                 msg_id = ntohl(nch->dp.msg_id);
    1601                 protocol_id = nch->dp.ppid_fsn.protocol_id;
    1602                 if (ch->ch.chunk_flags & SCTP_DATA_FIRST_FRAG)
     1610                tsn = ntohl(chunk->dp.tsn);
     1611                sid = ntohs(chunk->dp.sid);
     1612                mid = ntohl(chunk->dp.mid);
     1613                if (chk_flags & SCTP_DATA_FIRST_FRAG) {
    16031614                        fsn = 0;
    1604                 else
    1605                         fsn = ntohl(nch->dp.ppid_fsn.fsn);
    1606                 old_data = 0;
     1615                        ppid = chunk->dp.ppid_fsn.ppid;
     1616                } else {
     1617                        fsn = ntohl(chunk->dp.ppid_fsn.fsn);
     1618                        ppid = 0xffffffff; /* Use as an invalid value. */
     1619                }
    16071620        } else {
    1608                 ch = (struct sctp_data_chunk *)sctp_m_getptr(*m, offset,
    1609                                                              sizeof(struct sctp_data_chunk), (uint8_t *)&chunk_buf);
    1610                 tsn = ntohl(ch->dp.tsn);
    1611                 protocol_id = ch->dp.protocol_id;
     1621                struct sctp_data_chunk *chunk, chunk_buf;
     1622
     1623                chunk = (struct sctp_data_chunk *)sctp_m_getptr(*m, offset,
     1624                                                                sizeof(struct sctp_data_chunk), (uint8_t *)&chunk_buf);
     1625                chk_flags = chunk->ch.chunk_flags;
    16121626                clen = sizeof(struct sctp_data_chunk);
     1627                tsn = ntohl(chunk->dp.tsn);
     1628                sid = ntohs(chunk->dp.sid);
     1629                mid = (uint32_t)(ntohs(chunk->dp.ssn));
    16131630                fsn = tsn;
    1614                 msg_id = (uint32_t)(ntohs(ch->dp.stream_sequence));
    1615                 nch = NULL;
    1616                 old_data = 1;
    1617         }
    1618         chunk_flags = ch->ch.chunk_flags;
     1631                ppid = chunk->dp.ppid;
     1632        }
    16191633        if ((size_t)chk_length == clen) {
    16201634                /*
     
    16221636                 * empty data chunk.
    16231637                 */
    1624                 op_err = sctp_generate_no_user_data_cause(ch->dp.tsn);
     1638                op_err = sctp_generate_no_user_data_cause(tsn);
    16251639                stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_14;
    16261640                sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED);
     
    16281642                return (0);
    16291643        }
    1630         if ((chunk_flags & SCTP_DATA_SACK_IMMEDIATELY) == SCTP_DATA_SACK_IMMEDIATELY) {
     1644        if ((chk_flags & SCTP_DATA_SACK_IMMEDIATELY) == SCTP_DATA_SACK_IMMEDIATELY) {
    16311645                asoc->send_sack = 1;
    16321646        }
    1633         ordered = ((chunk_flags & SCTP_DATA_UNORDERED) == 0);
     1647        ordered = ((chk_flags & SCTP_DATA_UNORDERED) == 0);
    16341648        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
    16351649                sctp_log_map(tsn, asoc->cumulative_tsn, asoc->highest_tsn_inside_map, SCTP_MAP_TSN_ENTERS);
     
    16381652                return (0);
    16391653        }
    1640         SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, ch->ch.chunk_type, tsn);
     1654        SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, chk_type, tsn);
    16411655        if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) {
    16421656                /* It is a duplicate */
     
    17011715
    17021716        /* Is the stream valid? */
    1703         strmno = ntohs(ch->dp.stream_id);
    1704 
    1705         if (strmno >= asoc->streamincnt) {
     1717        if (sid >= asoc->streamincnt) {
    17061718                struct sctp_error_invalid_stream *cause;
    17071719
     
    17201732                        cause->cause.code = htons(SCTP_CAUSE_INVALID_STREAM);
    17211733                        cause->cause.length = htons(sizeof(struct sctp_error_invalid_stream));
    1722                         cause->stream_id = ch->dp.stream_id;
     1734                        cause->stream_id = htons(sid);
    17231735                        cause->reserved = htons(0);
    17241736                        sctp_queue_op_err(stcb, op_err);
     
    17361748                return (0);
    17371749        }
    1738         strm = &asoc->strmin[strmno];
    17391750        /*
    17401751         * If its a fragmented message, lets see if we can
    17411752         * find the control on the reassembly queues.
    17421753         */
    1743         if ((chtype == SCTP_IDATA) &&
    1744             ((chunk_flags & SCTP_DATA_FIRST_FRAG) == 0) &&
     1754        if ((chk_type == SCTP_IDATA) &&
     1755            ((chk_flags & SCTP_DATA_FIRST_FRAG) == 0) &&
    17451756            (fsn == 0)) {
    17461757                /*
     
    17511762                 */
    17521763                snprintf(msg, sizeof(msg), "FSN zero for MID=%8.8x, but flags=%2.2x",
    1753                          msg_id, chunk_flags);
     1764                         mid, chk_flags);
    17541765                goto err_out;
    17551766        }
    1756         control = sctp_find_reasm_entry(strm, msg_id, ordered, old_data);
     1767        control = sctp_find_reasm_entry(&asoc->strmin[sid], mid, ordered, asoc->idata_supported);
    17571768        SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags:0x%x look for control on queues %p\n",
    1758                 chunk_flags, control);
    1759         if ((chunk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
     1769                chk_flags, control);
     1770        if ((chk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
    17601771                /* See if we can find the re-assembly entity */
    17611772                if (control != NULL) {
    17621773                        /* We found something, does it belong? */
    1763                         if (ordered && (msg_id != control->sinfo_ssn)) {
    1764                                 snprintf(msg, sizeof(msg), "Reassembly problem (MID=%8.8x)", msg_id);
     1774                        if (ordered && (mid != control->mid)) {
     1775                                snprintf(msg, sizeof(msg), "Reassembly problem (MID=%8.8x)", mid);
    17651776                        err_out:
    17661777                                op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
     
    17901801                 */
    17911802                if (control != NULL) {
    1792                         if (ordered || (old_data == 0)) {
    1793                                 SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x dup detected on msg_id: %u\n",
    1794                                         chunk_flags, msg_id);
    1795                                 snprintf(msg, sizeof(msg), "Duplicate MID=%8.8x detected.", msg_id);
     1803                        if (ordered || asoc->idata_supported) {
     1804                                SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x dup detected on MID: %u\n",
     1805                                        chk_flags, mid);
     1806                                snprintf(msg, sizeof(msg), "Duplicate MID=%8.8x detected.", mid);
    17961807                                goto err_out;
    17971808                        } else {
     
    18381849                }
    18391850                /* now is it in the mapping array of what we have accepted? */
    1840                 if (nch == NULL) {
     1851                if (chk_type == SCTP_DATA) {
    18411852                        if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_map) &&
    18421853                            SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) {
     
    18701881        }
    18711882        asoc->in_tsnlog[asoc->tsn_in_at].tsn = tsn;
    1872         asoc->in_tsnlog[asoc->tsn_in_at].strm = strmno;
    1873         asoc->in_tsnlog[asoc->tsn_in_at].seq = msg_id;
     1883        asoc->in_tsnlog[asoc->tsn_in_at].strm = sid;
     1884        asoc->in_tsnlog[asoc->tsn_in_at].seq = mid;
    18741885        asoc->in_tsnlog[asoc->tsn_in_at].sz = chk_length;
    18751886        asoc->in_tsnlog[asoc->tsn_in_at].flgs = chunk_flags;
     
    18861897         * only validate the FIRST fragment so the bit must be set.
    18871898         */
    1888         if ((chunk_flags & SCTP_DATA_FIRST_FRAG) &&
     1899        if ((chk_flags & SCTP_DATA_FIRST_FRAG) &&
    18891900            (TAILQ_EMPTY(&asoc->resetHead)) &&
    1890             (chunk_flags & SCTP_DATA_UNORDERED) == 0 &&
    1891             SCTP_MSGID_GE(old_data, asoc->strmin[strmno].last_sequence_delivered, msg_id)) {
     1901            (chk_flags & SCTP_DATA_UNORDERED) == 0 &&
     1902            SCTP_MID_GE(asoc->idata_supported, asoc->strmin[sid].last_mid_delivered, mid)) {
    18921903                /* The incoming sseq is behind where we last delivered? */
    18931904                SCTPDBG(SCTP_DEBUG_INDATA1, "EVIL/Broken-Dup S-SEQ: %u delivered: %u from peer, Abort!\n",
    1894                         msg_id, asoc->strmin[strmno].last_sequence_delivered);
    1895 
    1896                 snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
    1897                          asoc->strmin[strmno].last_sequence_delivered,
    1898                          tsn, strmno, msg_id);
     1905                        mid, asoc->strmin[sid].last_mid_delivered);
     1906
     1907                if (asoc->idata_supported) {
     1908                        snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
     1909                                 asoc->strmin[sid].last_mid_delivered,
     1910                                 tsn,
     1911                                 sid,
     1912                                 mid);
     1913                } else {
     1914                        snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
     1915                                 (uint16_t)asoc->strmin[sid].last_mid_delivered,
     1916                                 tsn,
     1917                                 sid,
     1918                                 (uint16_t)mid);
     1919                }
    18991920                op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
    19001921                stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_16;
     
    19031924                return (0);
    19041925        }
    1905         /************************************
    1906          * From here down we may find ch-> invalid
    1907          * so its a good idea NOT to use it.
    1908          *************************************/
    1909         if (nch) {
     1926        if (chk_type == SCTP_IDATA) {
    19101927                the_len = (chk_length - sizeof(struct sctp_idata_chunk));
    19111928        } else {
     
    19131930        }
    19141931        if (last_chunk == 0) {
    1915                 if (nch) {
     1932                if (chk_type == SCTP_IDATA) {
    19161933                        dmbuf = SCTP_M_COPYM(*m,
    19171934                                             (offset + sizeof(struct sctp_idata_chunk)),
     
    19321949                dmbuf = *m;
    19331950                /* lop off the top part */
    1934                 if (nch) {
     1951                if (chk_type == SCTP_IDATA) {
    19351952                        m_adj(dmbuf, (offset + sizeof(struct sctp_idata_chunk)));
    19361953                } else {
     
    19601977        }
    19611978        /*
    1962          * Now no matter what we need a control, get one
     1979         * Now no matter what, we need a control, get one
    19631980         * if we don't have one (we may have gotten it
    19641981         * above when we found the message was fragmented
     
    19671984                sctp_alloc_a_readq(stcb, control);
    19681985                sctp_build_readq_entry_mac(control, stcb, asoc->context, net, tsn,
    1969                                            protocol_id,
    1970                                            strmno, msg_id,
    1971                                            chunk_flags,
    1972                                            NULL, fsn, msg_id);
     1986                                           ppid,
     1987                                           sid,
     1988                                           chk_flags,
     1989                                           NULL, fsn, mid);
    19731990                if (control == NULL) {
    19741991                        SCTP_STAT_INCR(sctps_nomem);
    19751992                        return (0);
    19761993                }
    1977                 if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
     1994                if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
    19781995                        control->data = dmbuf;
    19791996                        control->tail_mbuf = NULL;
    1980                         control->end_added = control->last_frag_seen = control->first_frag_seen = 1;
    1981                         control->top_fsn = control->fsn_included = fsn;
     1997                        control->end_added = 1;
     1998                        control->last_frag_seen = 1;
     1999                        control->first_frag_seen = 1;
     2000                        control->fsn_included = fsn;
     2001                        control->top_fsn = fsn;
    19822002                }
    19832003                created_control = 1;
    19842004        }
    1985         SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x ordered: %d msgid: %u control: %p\n",
    1986                 chunk_flags, ordered, msg_id, control);
    1987         if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG &&
     2005        SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x ordered: %d MID: %u control: %p\n",
     2006                chk_flags, ordered, mid, control);
     2007        if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG &&
    19882008            TAILQ_EMPTY(&asoc->resetHead) &&
    19892009            ((ordered == 0) ||
    1990              ((uint16_t)(asoc->strmin[strmno].last_sequence_delivered + 1) == msg_id &&
    1991               TAILQ_EMPTY(&asoc->strmin[strmno].inqueue)))) {
     2010             (SCTP_MID_EQ(asoc->idata_supported, asoc->strmin[sid].last_mid_delivered + 1, mid) &&
     2011              TAILQ_EMPTY(&asoc->strmin[sid].inqueue)))) {
    19922012                /* Candidate for express delivery */
    19932013                /*
     
    20022022                        asoc->highest_tsn_inside_nr_map = tsn;
    20032023                }
    2004                 SCTPDBG(SCTP_DEBUG_XXX, "Injecting control: %p to be read (msg_id: %u)\n",
    2005                         control, msg_id);
     2024                SCTPDBG(SCTP_DEBUG_XXX, "Injecting control: %p to be read (MID: %u)\n",
     2025                        control, mid);
    20062026
    20072027                sctp_add_to_readq(stcb->sctp_ep, stcb,
     
    20092029                                  1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
    20102030
    2011                 if ((chunk_flags & SCTP_DATA_UNORDERED) == 0) {
     2031                if ((chk_flags & SCTP_DATA_UNORDERED) == 0) {
    20122032                        /* for ordered, bump what we delivered */
    2013                         strm->last_sequence_delivered++;
     2033                        asoc->strmin[sid].last_mid_delivered++;
    20142034                }
    20152035                SCTP_STAT_INCR(sctps_recvexpress);
    20162036                if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_STR_LOGGING_ENABLE) {
    2017                         sctp_log_strm_del_alt(stcb, tsn, msg_id, strmno,
     2037                        sctp_log_strm_del_alt(stcb, tsn, mid, sid,
    20182038                                              SCTP_STR_LOG_FROM_EXPRS_DEL);
    20192039                }
     
    20232043
    20242044        /* Now will we need a chunk too? */
    2025         if ((chunk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
     2045        if ((chk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
    20262046                sctp_alloc_a_chunk(stcb, chk);
    20272047                if (chk == NULL) {
     
    20342054                        return (0);
    20352055                }
    2036                 chk->rec.data.TSN_seq = tsn;
     2056                chk->rec.data.tsn = tsn;
    20372057                chk->no_fr_allowed = 0;
    2038                 chk->rec.data.fsn_num = fsn;
    2039                 chk->rec.data.stream_seq = msg_id;
    2040                 chk->rec.data.stream_number = strmno;
    2041                 chk->rec.data.payloadtype = protocol_id;
     2058                chk->rec.data.fsn = fsn;
     2059                chk->rec.data.mid = mid;
     2060                chk->rec.data.sid = sid;
     2061                chk->rec.data.ppid = ppid;
    20422062                chk->rec.data.context = stcb->asoc.context;
    20432063                chk->rec.data.doing_fast_retransmit = 0;
    2044                 chk->rec.data.rcv_flags = chunk_flags;
     2064                chk->rec.data.rcv_flags = chk_flags;
    20452065                chk->asoc = asoc;
    20462066                chk->send_size = the_len;
    20472067                chk->whoTo = net;
    2048                 SCTPDBG(SCTP_DEBUG_XXX, "Building ck: %p for control: %p to be read (msg_id: %u)\n",
     2068                SCTPDBG(SCTP_DEBUG_XXX, "Building ck: %p for control: %p to be read (MID: %u)\n",
    20492069                        chk,
    2050                         control, msg_id);
     2070                        control, mid);
    20512071                atomic_add_int(&net->ref_count, 1);
    20522072                chk->data = dmbuf;
     
    20652085        }
    20662086        /* Now is it complete (i.e. not fragmented)? */
    2067         if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
     2087        if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
    20682088                /*
    20692089                 * Special check for when streams are resetting. We
     
    21082128                        goto finish_express_del;
    21092129                }
    2110                 if (chunk_flags & SCTP_DATA_UNORDERED) {
     2130                if (chk_flags & SCTP_DATA_UNORDERED) {
    21112131                        /* queue directly into socket buffer */
    2112                         SCTPDBG(SCTP_DEBUG_XXX, "Unordered data to be read control: %p msg_id: %u\n",
    2113                                 control, msg_id);
     2132                        SCTPDBG(SCTP_DEBUG_XXX, "Unordered data to be read control: %p MID: %u\n",
     2133                                control, mid);
    21142134                        sctp_mark_non_revokable(asoc, control->sinfo_tsn);
    21152135                        sctp_add_to_readq(stcb->sctp_ep, stcb,
     
    21192139
    21202140                } else {
    2121                         SCTPDBG(SCTP_DEBUG_XXX, "Queue control: %p for reordering msg_id: %u\n", control,
    2122                                 msg_id);
    2123                         sctp_queue_data_to_stream(stcb, strm, asoc, control, abort_flag, &need_reasm_check);
     2141                        SCTPDBG(SCTP_DEBUG_XXX, "Queue control: %p for reordering MID: %u\n", control,
     2142                                mid);
     2143                        sctp_queue_data_to_stream(stcb, asoc, control, abort_flag, &need_reasm_check);
    21242144                        if (*abort_flag) {
    21252145                                if (last_chunk) {
     
    21342154        need_reasm_check = 1;
    21352155        SCTPDBG(SCTP_DEBUG_XXX,
    2136                 "Queue data to stream for reasm control: %p msg_id: %u\n",
    2137                 control, msg_id);
    2138         sctp_queue_data_for_reasm(stcb, asoc, strm, control, chk, created_control, abort_flag, tsn);
     2156                "Queue data to stream for reasm control: %p MID: %u\n",
     2157                control, mid);
     2158        sctp_queue_data_for_reasm(stcb, asoc, control, chk, created_control, abort_flag, tsn);
    21392159        if (*abort_flag) {
    21402160                /*
     
    21642184        /* Set it present please */
    21652185        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_STR_LOGGING_ENABLE) {
    2166                 sctp_log_strm_del_alt(stcb, tsn, msg_id, strmno, SCTP_STR_LOG_FROM_MARK_TSN);
     2186                sctp_log_strm_del_alt(stcb, tsn, mid, sid, SCTP_STR_LOG_FROM_MARK_TSN);
    21672187        }
    21682188        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
    21692189                sctp_log_map(asoc->mapping_array_base_tsn, asoc->cumulative_tsn,
    21702190                             asoc->highest_tsn_inside_map, SCTP_MAP_PREPARE_SLIDE);
     2191        }
     2192        if (need_reasm_check) {
     2193                (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[sid], SCTP_READ_LOCK_NOT_HELD);
     2194                need_reasm_check = 0;
    21712195        }
    21722196        /* check the special flag for stream resets */
     
    21912215                        TAILQ_FOREACH_SAFE(ctl, &asoc->pending_reply_queue, next, nctl) {
    21922216                                TAILQ_REMOVE(&asoc->pending_reply_queue, ctl, next);
    2193                                 sctp_queue_data_to_stream(stcb, strm, asoc, ctl, abort_flag, &need_reasm_check);
     2217                                sctp_queue_data_to_stream(stcb, asoc, ctl, abort_flag, &need_reasm_check);
    21942218                                if (*abort_flag) {
    21952219                                        return (0);
     2220                                }
     2221                                if (need_reasm_check) {
     2222                                        (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[ctl->sinfo_stream], SCTP_READ_LOCK_NOT_HELD);
     2223                                        need_reasm_check = 0;
    21962224                                }
    21972225                        }
     
    22072235                                 */
    22082236                                TAILQ_REMOVE(&asoc->pending_reply_queue, ctl, next);
    2209                                 sctp_queue_data_to_stream(stcb, strm, asoc, ctl, abort_flag, &need_reasm_check);
     2237                                sctp_queue_data_to_stream(stcb, asoc, ctl, abort_flag, &need_reasm_check);
    22102238                                if (*abort_flag) {
    22112239                                        return (0);
    22122240                                }
    2213                         }
    2214                 }
    2215                 /*
    2216                  * Now service re-assembly to pick up anything that has been
    2217                  * held on reassembly queue?
    2218                  */
    2219                 (void)sctp_deliver_reasm_check(stcb, asoc, strm, SCTP_READ_LOCK_NOT_HELD);
    2220                 need_reasm_check = 0;
    2221         }
    2222 
    2223         if (need_reasm_check) {
    2224                 /* Another one waits ? */
    2225                 (void)sctp_deliver_reasm_check(stcb, asoc, strm, SCTP_READ_LOCK_NOT_HELD);
     2241                                if (need_reasm_check) {
     2242                                        (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[ctl->sinfo_stream], SCTP_READ_LOCK_NOT_HELD);
     2243                                        need_reasm_check = 0;
     2244                                }
     2245                        }
     2246                }
    22262247        }
    22272248        return (1);
     
    24382459        struct sctp_association *asoc;
    24392460        uint32_t highest_tsn;
    2440 
     2461        int is_a_gap;
     2462
     2463        sctp_slide_mapping_arrays(stcb);
    24412464        asoc = &stcb->asoc;
    24422465        if (SCTP_TSN_GT(asoc->highest_tsn_inside_nr_map, asoc->highest_tsn_inside_map)) {
     
    24452468                highest_tsn = asoc->highest_tsn_inside_map;
    24462469        }
     2470        /* Is there a gap now? */
     2471        is_a_gap = SCTP_TSN_GT(highest_tsn, stcb->asoc.cumulative_tsn);
    24472472
    24482473        /*
     
    24622487                }
    24632488                sctp_send_shutdown(stcb,
    2464                                    ((stcb->asoc.alternate) ? stcb->asoc.alternate : stcb->asoc.primary_destination));
    2465                 sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED);
     2489                                   ((stcb->asoc.alternate) ? stcb->asoc.alternate : stcb->asoc.primary_destination));
     2490                if (is_a_gap) {
     2491                        sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED);
     2492                }
    24662493        } else {
    2467                 int is_a_gap;
    2468 
    2469                 /* is there a gap now ? */
    2470                 is_a_gap = SCTP_TSN_GT(highest_tsn, stcb->asoc.cumulative_tsn);
    2471 
    24722494                /*
    24732495                 * CMT DAC algorithm: increase number of packets
     
    28312853                            (tp1->whoTo->find_pseudo_cumack == 1) &&
    28322854                            (tp1->snd_count == 1)) {
    2833                                 tp1->whoTo->pseudo_cumack = tp1->rec.data.TSN_seq;
     2855                                tp1->whoTo->pseudo_cumack = tp1->rec.data.tsn;
    28342856                                tp1->whoTo->find_pseudo_cumack = 0;
    28352857                        }
     
    28372859                            (tp1->whoTo->find_rtx_pseudo_cumack == 1) &&
    28382860                            (tp1->snd_count > 1)) {
    2839                                 tp1->whoTo->rtx_pseudo_cumack = tp1->rec.data.TSN_seq;
     2861                                tp1->whoTo->rtx_pseudo_cumack = tp1->rec.data.tsn;
    28402862                                tp1->whoTo->find_rtx_pseudo_cumack = 0;
    28412863                        }
    2842                         if (tp1->rec.data.TSN_seq == theTSN) {
     2864                        if (tp1->rec.data.tsn == theTSN) {
    28432865                                if (tp1->sent != SCTP_DATAGRAM_UNSENT) {
    28442866                                        /*-
     
    28542876                                                 * i.e. ACKED or RESEND.
    28552877                                                 */
    2856                                                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq,
     2878                                                if (SCTP_TSN_GT(tp1->rec.data.tsn,
    28572879                                                                *biggest_newly_acked_tsn)) {
    2858                                                         *biggest_newly_acked_tsn = tp1->rec.data.TSN_seq;
     2880                                                        *biggest_newly_acked_tsn = tp1->rec.data.tsn;
    28592881                                                }
    28602882                                                /*-
     
    28682890                                                        tp1->whoTo->saw_newack = 1;
    28692891
    2870                                                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq,
     2892                                                if (SCTP_TSN_GT(tp1->rec.data.tsn,
    28712893                                                                tp1->whoTo->this_sack_highest_newack)) {
    28722894                                                        tp1->whoTo->this_sack_highest_newack =
    2873                                                                 tp1->rec.data.TSN_seq;
     2895                                                                tp1->rec.data.tsn;
    28742896                                                }
    28752897                                                /*-
     
    28812903                                                                sctp_log_sack(*this_sack_lowest_newack,
    28822904                                                                              last_tsn,
    2883                                                                               tp1->rec.data.TSN_seq,
     2905                                                                              tp1->rec.data.tsn,
    28842906                                                                              0,
    28852907                                                                              0,
    28862908                                                                              SCTP_LOG_TSN_ACKED);
    28872909                                                        }
    2888                                                         *this_sack_lowest_newack = tp1->rec.data.TSN_seq;
     2910                                                        *this_sack_lowest_newack = tp1->rec.data.tsn;
    28892911                                                }
    28902912                                                /*-
     
    28962918                                                 * retransmissions.
    28972919                                                 */
    2898                                                 if (tp1->rec.data.TSN_seq == tp1->whoTo->pseudo_cumack) {
     2920                                                if (tp1->rec.data.tsn == tp1->whoTo->pseudo_cumack) {
    28992921                                                        if (tp1->rec.data.chunk_was_revoked == 0) {
    29002922                                                                tp1->whoTo->new_pseudo_cumack = 1;
     
    29032925                                                }
    29042926                                                if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) {
    2905                                                         sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
     2927                                                        sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.tsn, SCTP_CWND_LOG_FROM_SACK);
    29062928                                                }
    2907                                                 if (tp1->rec.data.TSN_seq == tp1->whoTo->rtx_pseudo_cumack) {
     2929                                                if (tp1->rec.data.tsn == tp1->whoTo->rtx_pseudo_cumack) {
    29082930                                                        if (tp1->rec.data.chunk_was_revoked == 0) {
    29092931                                                                tp1->whoTo->new_pseudo_cumack = 1;
     
    29142936                                                        sctp_log_sack(*biggest_newly_acked_tsn,
    29152937                                                                      last_tsn,
    2916                                                                       tp1->rec.data.TSN_seq,
     2938                                                                      tp1->rec.data.tsn,
    29172939                                                                      frag_strt,
    29182940                                                                      frag_end,
     
    29242946                                                                       tp1->book_size,
    29252947                                                                       (uint32_t)(uintptr_t)tp1->whoTo,
    2926                                                                        tp1->rec.data.TSN_seq);
     2948                                                                       tp1->rec.data.tsn);
    29272949                                                }
    29282950                                                sctp_flight_size_decrease(tp1);
     
    29632985                                        }
    29642986                                        if (tp1->sent <= SCTP_DATAGRAM_RESEND) {
    2965                                                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq,
     2987                                                if (SCTP_TSN_GT(tp1->rec.data.tsn,
    29662988                                                                stcb->asoc.this_sack_highest_gap)) {
    29672989                                                        stcb->asoc.this_sack_highest_gap =
    2968                                                                 tp1->rec.data.TSN_seq;
     2990                                                                tp1->rec.data.tsn;
    29692991                                                }
    29702992                                                if (tp1->sent == SCTP_DATAGRAM_RESEND) {
     
    29923014                                        if (nr_sacking &&
    29933015                                            (tp1->sent != SCTP_DATAGRAM_NR_ACKED)) {
    2994                                                 if (stcb->asoc.strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) {
    2995                                                         stcb->asoc.strmout[tp1->rec.data.stream_number].chunks_on_queues--;
     3016                                                if (stcb->asoc.strmout[tp1->rec.data.sid].chunks_on_queues > 0) {
     3017                                                        stcb->asoc.strmout[tp1->rec.data.sid].chunks_on_queues--;
    29963018#ifdef INVARIANTS
    29973019                                                } else {
    2998                                                         panic("No chunks on the queues for sid %u.", tp1->rec.data.stream_number);
     3020                                                        panic("No chunks on the queues for sid %u.", tp1->rec.data.sid);
    29993021#endif
    30003022                                                }
    3001                                                 if ((stcb->asoc.strmout[tp1->rec.data.stream_number].chunks_on_queues == 0) &&
    3002                                                     (stcb->asoc.strmout[tp1->rec.data.stream_number].state == SCTP_STREAM_RESET_PENDING) &&
    3003                                                     TAILQ_EMPTY(&stcb->asoc.strmout[tp1->rec.data.stream_number].outqueue)) {
     3023                                                if ((stcb->asoc.strmout[tp1->rec.data.sid].chunks_on_queues == 0) &&
     3024                                                    (stcb->asoc.strmout[tp1->rec.data.sid].state == SCTP_STREAM_RESET_PENDING) &&
     3025                                                    TAILQ_EMPTY(&stcb->asoc.strmout[tp1->rec.data.sid].outqueue)) {
    30043026                                                        stcb->asoc.trigger_reset = 1;
    30053027                                                }
     
    30153037                                }
    30163038                                break;
    3017                         }       /* if (tp1->TSN_seq == theTSN) */
    3018                         if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, theTSN)) {
     3039                        }       /* if (tp1->tsn == theTSN) */
     3040                        if (SCTP_TSN_GT(tp1->rec.data.tsn, theTSN)) {
    30193041                                break;
    30203042                        }
     
    31083130
    31093131        TAILQ_FOREACH(tp1, &asoc->sent_queue, sctp_next) {
    3110                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cumack)) {
     3132                if (SCTP_TSN_GT(tp1->rec.data.tsn, cumack)) {
    31113133                        /*
    31123134                         * ok this guy is either ACK or MARKED. If it is
     
    31153137                         * again.
    31163138                         */
    3117                         if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, biggest_tsn_acked)) {
     3139                        if (SCTP_TSN_GT(tp1->rec.data.tsn, biggest_tsn_acked)) {
    31183140                                break;
    31193141                        }
     
    31303152                                                       tp1->book_size,
    31313153                                                       (uint32_t)(uintptr_t)tp1->whoTo,
    3132                                                        tp1->rec.data.TSN_seq);
     3154                                                       tp1->rec.data.tsn);
    31333155                                }
    31343156                                sctp_flight_size_increase(tp1);
     
    31413163                                        sctp_log_sack(asoc->last_acked_seq,
    31423164                                                      cumack,
    3143                                                       tp1->rec.data.TSN_seq,
     3165                                                      tp1->rec.data.tsn,
    31443166                                                      0,
    31453167                                                      0,
     
    31773199                sending_seq = asoc->sending_seq;
    31783200        } else {
    3179                 sending_seq = tp1->rec.data.TSN_seq;
     3201                sending_seq = tp1->rec.data.tsn;
    31803202        }
    31813203
     
    32003222                        if (tp1->sent < SCTP_DATAGRAM_RESEND)
    32013223                                sctp_log_fr(biggest_tsn_newly_acked,
    3202                                             tp1->rec.data.TSN_seq,
     3224                                            tp1->rec.data.tsn,
    32033225                                            tp1->sent,
    32043226                                            SCTP_FR_LOG_CHECK_STRIKE);
    32053227                }
    3206                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, biggest_tsn_acked) ||
     3228                if (SCTP_TSN_GT(tp1->rec.data.tsn, biggest_tsn_acked) ||
    32073229                    tp1->sent == SCTP_DATAGRAM_UNSENT) {
    32083230                        /* done */
     
    32273249
    32283250                }
    3229                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, asoc->this_sack_highest_gap)) {
     3251                if (SCTP_TSN_GT(tp1->rec.data.tsn, asoc->this_sack_highest_gap)) {
    32303252                        /* we are beyond the tsn in the sack  */
    32313253                        break;
     
    32513273                         */
    32523274                        continue;
    3253                 } else if (tp1->whoTo && SCTP_TSN_GT(tp1->rec.data.TSN_seq,
     3275                } else if (tp1->whoTo && SCTP_TSN_GT(tp1->rec.data.tsn,
    32543276                                                     tp1->whoTo->this_sack_highest_newack)) {
    32553277                        /*
     
    32803302                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    32813303                                sctp_log_fr(biggest_tsn_newly_acked,
    3282                                             tp1->rec.data.TSN_seq,
     3304                                            tp1->rec.data.tsn,
    32833305                                            tp1->sent,
    32843306                                            SCTP_FR_LOG_STRIKE_CHUNK);
     
    33013323                                 */
    33023324                                if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) &&
    3303                                     SCTP_TSN_GT(this_sack_lowest_newack, tp1->rec.data.TSN_seq)) {
     3325                                    SCTP_TSN_GT(this_sack_lowest_newack, tp1->rec.data.tsn)) {
    33043326                                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    33053327                                                sctp_log_fr(16 + num_dests_sacked,
    3306                                                             tp1->rec.data.TSN_seq,
     3328                                                            tp1->rec.data.tsn,
    33073329                                                            tp1->sent,
    33083330                                                            SCTP_FR_LOG_STRIKE_CHUNK);
     
    33423364                                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    33433365                                                sctp_log_fr(biggest_tsn_newly_acked,
    3344                                                             tp1->rec.data.TSN_seq,
     3366                                                            tp1->rec.data.tsn,
    33453367                                                            tp1->sent,
    33463368                                                            SCTP_FR_LOG_STRIKE_CHUNK);
     
    33703392                                                    (num_dests_sacked == 1) &&
    33713393                                                    SCTP_TSN_GT(this_sack_lowest_newack,
    3372                                                                 tp1->rec.data.TSN_seq)) {
     3394                                                                tp1->rec.data.tsn)) {
    33733395                                                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    33743396                                                                sctp_log_fr(32 + num_dests_sacked,
    3375                                                                             tp1->rec.data.TSN_seq,
     3397                                                                            tp1->rec.data.tsn,
    33763398                                                                            tp1->sent,
    33773399                                                                            SCTP_FR_LOG_STRIKE_CHUNK);
     
    33883410                         * SFR algo covers HTNA.
    33893411                         */
    3390                 } else if (SCTP_TSN_GT(tp1->rec.data.TSN_seq,
     3412                } else if (SCTP_TSN_GT(tp1->rec.data.tsn,
    33913413                                       biggest_tsn_newly_acked)) {
    33923414                        /*
     
    34003422                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    34013423                                sctp_log_fr(biggest_tsn_newly_acked,
    3402                                             tp1->rec.data.TSN_seq,
     3424                                            tp1->rec.data.tsn,
    34033425                                            tp1->sent,
    34043426                                            SCTP_FR_LOG_STRIKE_CHUNK);
     
    34213443                                 */
    34223444                                if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) &&
    3423                                     SCTP_TSN_GT(this_sack_lowest_newack, tp1->rec.data.TSN_seq)) {
     3445                                    SCTP_TSN_GT(this_sack_lowest_newack, tp1->rec.data.tsn)) {
    34243446                                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    34253447                                                sctp_log_fr(48 + num_dests_sacked,
    3426                                                             tp1->rec.data.TSN_seq,
     3448                                                            tp1->rec.data.tsn,
    34273449                                                            tp1->sent,
    34283450                                                            SCTP_FR_LOG_STRIKE_CHUNK);
     
    34413463                                               tp1->book_size,
    34423464                                               (uint32_t)(uintptr_t)tp1->whoTo,
    3443                                                tp1->rec.data.TSN_seq);
     3465                                               tp1->rec.data.tsn);
    34443466                        }
    34453467                        if (tp1->whoTo) {
     
    34783500                        /* SCTP_PRINTF("OK, we are now ready to FR this guy\n"); */
    34793501                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    3480                                 sctp_log_fr(tp1->rec.data.TSN_seq, tp1->snd_count,
     3502                                sctp_log_fr(tp1->rec.data.tsn, tp1->snd_count,
    34813503                                            0, SCTP_FR_MARKED);
    34823504                        }
     
    35383560                        /*
    35393561                         * SCTP_PRINTF("Marking TSN for FR new value %x\n",
    3540                          * (uint32_t)tpi->rec.data.TSN_seq);
     3562                         * (uint32_t)tpi->rec.data.tsn);
    35413563                         */
    35423564                        if (TAILQ_EMPTY(&asoc->send_queue)) {
     
    35613583                                ttt = TAILQ_FIRST(&asoc->send_queue);
    35623584                                tp1->rec.data.fast_retran_tsn =
    3563                                         ttt->rec.data.TSN_seq;
     3585                                        ttt->rec.data.tsn;
    35643586                        }
    35653587
     
    36093631                                sctp_misc_ints(SCTP_FWD_TSN_CHECK,
    36103632                                               asoc->advanced_peer_ack_point,
    3611                                                tp1->rec.data.TSN_seq, 0, 0);
     3633                                               tp1->rec.data.tsn, 0, 0);
    36123634                        }
    36133635                }
     
    36613683                    (tp1->sent == SCTP_DATAGRAM_NR_ACKED)) {
    36623684                        /* advance PeerAckPoint goes forward */
    3663                         if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, asoc->advanced_peer_ack_point)) {
    3664                                 asoc->advanced_peer_ack_point = tp1->rec.data.TSN_seq;
     3685                        if (SCTP_TSN_GT(tp1->rec.data.tsn, asoc->advanced_peer_ack_point)) {
     3686                                asoc->advanced_peer_ack_point = tp1->rec.data.tsn;
    36653687                                a_adv = tp1;
    3666                         } else if (tp1->rec.data.TSN_seq == asoc->advanced_peer_ack_point) {
     3688                        } else if (tp1->rec.data.tsn == asoc->advanced_peer_ack_point) {
    36673689                                /* No update but we do save the chk */
    36683690                                a_adv = tp1;
     
    37003722                if (chk->sent < SCTP_DATAGRAM_RESEND) {
    37013723                        SCTP_PRINTF("Chk TSN: %u size: %d inflight cnt: %d\n",
    3702                                     chk->rec.data.TSN_seq,
     3724                                    chk->rec.data.tsn,
    37033725                                    chk->send_size,
    37043726                                    chk->snd_count);
     
    37433765                               tp1->book_size,
    37443766                               (uint32_t)(uintptr_t)tp1->whoTo,
    3745                                tp1->rec.data.TSN_seq);
     3767                               tp1->rec.data.tsn);
    37463768                return;
    37473769        }
     
    37623784                               tp1->book_size,
    37633785                               (uint32_t)(uintptr_t)tp1->whoTo,
    3764                                tp1->rec.data.TSN_seq);
     3786                               tp1->rec.data.tsn);
    37653787        }
    37663788}
     
    38343856                tp1 = TAILQ_LAST(&asoc->sent_queue,
    38353857                                 sctpchunk_listhead);
    3836                 send_s = tp1->rec.data.TSN_seq + 1;
     3858                send_s = tp1->rec.data.tsn + 1;
    38373859        } else {
    38383860                send_s = asoc->sending_seq;
     
    38633885                /* process the new consecutive TSN first */
    38643886                TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) {
    3865                         if (SCTP_TSN_GE(cumack, tp1->rec.data.TSN_seq)) {
     3887                        if (SCTP_TSN_GE(cumack, tp1->rec.data.tsn)) {
    38663888                                if (tp1->sent == SCTP_DATAGRAM_UNSENT) {
    38673889                                        SCTP_PRINTF("Warning, an unsent is now acked?\n");
     
    38793901                                                                       tp1->book_size,
    38803902                                                                       (uint32_t)(uintptr_t)tp1->whoTo,
    3881                                                                        tp1->rec.data.TSN_seq);
     3903                                                                       tp1->rec.data.tsn);
    38823904                                                }
    38833905                                                sctp_flight_size_decrease(tp1);
     
    39373959                                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) {
    39383960                                                /* sa_ignore NO_NULL_CHK */
    3939                                                 sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
     3961                                                sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.tsn, SCTP_CWND_LOG_FROM_SACK);
    39403962                                        }
    39413963                                }
     
    39493971                                }
    39503972                                if (tp1->sent != SCTP_DATAGRAM_NR_ACKED) {
    3951                                         if (asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) {
    3952                                                 asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues--;
     3973                                        if (asoc->strmout[tp1->rec.data.sid].chunks_on_queues > 0) {
     3974                                                asoc->strmout[tp1->rec.data.sid].chunks_on_queues--;
    39533975#ifdef INVARIANTS
    39543976                                        } else {
    3955                                                 panic("No chunks on the queues for sid %u.", tp1->rec.data.stream_number);
     3977                                                panic("No chunks on the queues for sid %u.", tp1->rec.data.sid);
    39563978#endif
    39573979                                        }
    39583980                                }
    3959                                 if ((asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues == 0) &&
    3960                                     (asoc->strmout[tp1->rec.data.stream_number].state == SCTP_STREAM_RESET_PENDING) &&
    3961                                     TAILQ_EMPTY(&asoc->strmout[tp1->rec.data.stream_number].outqueue)) {
     3981                                if ((asoc->strmout[tp1->rec.data.sid].chunks_on_queues == 0) &&
     3982                                    (asoc->strmout[tp1->rec.data.sid].state == SCTP_STREAM_RESET_PENDING) &&
     3983                                    TAILQ_EMPTY(&asoc->strmout[tp1->rec.data.sid].outqueue)) {
    39623984                                        asoc->trigger_reset = 1;
    39633985                                }
     
    39723994                                        sctp_log_sack(asoc->last_acked_seq,
    39733995                                                      cumack,
    3974                                                       tp1->rec.data.TSN_seq,
     3996                                                      tp1->rec.data.tsn,
    39753997                                                      0,
    39763998                                                      0,
     
    43954417                tp1 = TAILQ_LAST(&asoc->sent_queue,
    43964418                                 sctpchunk_listhead);
    4397                 send_s = tp1->rec.data.TSN_seq + 1;
     4419                send_s = tp1->rec.data.tsn + 1;
    43984420        } else {
    43994421                tp1 = NULL;
     
    44124434                if (tp1) {
    44134435                        SCTP_PRINTF("Got send_s from tsn:%x + 1 of tp1: %p\n",
    4414                                     tp1->rec.data.TSN_seq, (void *)tp1);
     4436                                    tp1->rec.data.tsn, (void *)tp1);
    44154437                }
    44164438        hopeless_peer:
     
    44884510        /* process the new consecutive TSN first */
    44894511        TAILQ_FOREACH(tp1, &asoc->sent_queue, sctp_next) {
    4490                 if (SCTP_TSN_GE(last_tsn, tp1->rec.data.TSN_seq)) {
     4512                if (SCTP_TSN_GE(last_tsn, tp1->rec.data.tsn)) {
    44914513                        if (tp1->sent != SCTP_DATAGRAM_UNSENT) {
    44924514                                accum_moved = 1;
     
    45174539                                                                       tp1->book_size,
    45184540                                                                       (uint32_t)(uintptr_t)tp1->whoTo,
    4519                                                                        tp1->rec.data.TSN_seq);
     4541                                                                       tp1->rec.data.tsn);
    45204542                                                }
    45214543                                                sctp_flight_size_decrease(tp1);
     
    45294551
    45304552                                        /* CMT SFR and DAC algos */
    4531                                         this_sack_lowest_newack = tp1->rec.data.TSN_seq;
     4553                                        this_sack_lowest_newack = tp1->rec.data.tsn;
    45324554                                        tp1->whoTo->saw_newack = 1;
    45334555
     
    45774599                                                sctp_log_sack(asoc->last_acked_seq,
    45784600                                                              cum_ack,
    4579                                                               tp1->rec.data.TSN_seq,
     4601                                                              tp1->rec.data.tsn,
    45804602                                                              0,
    45814603                                                              0,
     
    45834605                                        }
    45844606                                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) {
    4585                                                 sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
     4607                                                sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.tsn, SCTP_CWND_LOG_FROM_SACK);
    45864608                                        }
    45874609                                }
     
    46724694
    46734695        TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) {
    4674                 if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cum_ack)) {
     4696                if (SCTP_TSN_GT(tp1->rec.data.tsn, cum_ack)) {
    46754697                        break;
    46764698                }
    46774699                if (tp1->sent != SCTP_DATAGRAM_NR_ACKED) {
    4678                         if (asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues > 0) {
    4679                                 asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues--;
     4700                        if (asoc->strmout[tp1->rec.data.sid].chunks_on_queues > 0) {
     4701                                asoc->strmout[tp1->rec.data.sid].chunks_on_queues--;
    46804702#ifdef INVARIANTS
    46814703                        } else {
    4682                                 panic("No chunks on the queues for sid %u.", tp1->rec.data.stream_number);
     4704                                panic("No chunks on the queues for sid %u.", tp1->rec.data.sid);
    46834705#endif
    46844706                        }
    46854707                }
    4686                 if ((asoc->strmout[tp1->rec.data.stream_number].chunks_on_queues == 0) &&
    4687                     (asoc->strmout[tp1->rec.data.stream_number].state == SCTP_STREAM_RESET_PENDING) &&
    4688                     TAILQ_EMPTY(&asoc->strmout[tp1->rec.data.stream_number].outqueue)) {
     4708                if ((asoc->strmout[tp1->rec.data.sid].chunks_on_queues == 0) &&
     4709                    (asoc->strmout[tp1->rec.data.sid].state == SCTP_STREAM_RESET_PENDING) &&
     4710                    TAILQ_EMPTY(&asoc->strmout[tp1->rec.data.sid].outqueue)) {
    46894711                        asoc->trigger_reset = 1;
    46904712                }
     
    47074729                        sctp_log_sack(asoc->last_acked_seq,
    47084730                                      cum_ack,
    4709                                       tp1->rec.data.TSN_seq,
     4731                                      tp1->rec.data.tsn,
    47104732                                      0,
    47114733                                      0,
     
    48134835                                                       tp1->book_size,
    48144836                                                       (uint32_t)(uintptr_t)tp1->whoTo,
    4815                                                        tp1->rec.data.TSN_seq);
     4837                                                       tp1->rec.data.tsn);
    48164838                                }
    48174839                                sctp_flight_size_increase(tp1);
     
    51815203        struct sctp_queued_to_read *ctl, *nctl;
    51825204        struct sctp_association *asoc;
    5183         uint32_t tt;
    5184         int need_reasm_check = 0, old;
     5205        uint32_t mid;
     5206        int need_reasm_check = 0;
    51855207
    51865208        asoc = &stcb->asoc;
    5187         tt = strmin->last_sequence_delivered;
    5188         if (asoc->idata_supported) {
    5189                 old = 0;
    5190         } else {
    5191                 old = 1;
    5192         }
     5209        mid = strmin->last_mid_delivered;
    51935210        /*
    51945211         * First deliver anything prior to and including the stream no that
     
    51965213         */
    51975214        TAILQ_FOREACH_SAFE(ctl, &strmin->inqueue, next_instrm, nctl) {
    5198                 if (SCTP_MSGID_GE(old, tt, ctl->sinfo_ssn)) {
     5215                if (SCTP_MID_GE(asoc->idata_supported, mid, ctl->mid)) {
    51995216                        /* this is deliverable now */
    52005217                        if (((ctl->sinfo_flags >> 8) & SCTP_DATA_NOT_FRAG)  == SCTP_DATA_NOT_FRAG) {
     
    52285245                                if (ctl->first_frag_seen) {
    52295246                                        /* Make it so this is next to deliver, we restore later */
    5230                                         strmin->last_sequence_delivered = ctl->sinfo_ssn - 1;
     5247                                        strmin->last_mid_delivered = ctl->mid - 1;
    52315248                                        need_reasm_check = 1;
    52325249                                        break;
     
    52415258                int ret;
    52425259                ret = sctp_deliver_reasm_check(stcb, &stcb->asoc, strmin, SCTP_READ_LOCK_HELD);
    5243                 if (SCTP_MSGID_GT(old, tt, strmin->last_sequence_delivered)) {
     5260                if (SCTP_MID_GT(asoc->idata_supported, mid, strmin->last_mid_delivered)) {
    52445261                        /* Restore the next to deliver unless we are ahead */
    5245                         strmin->last_sequence_delivered = tt;
     5262                        strmin->last_mid_delivered = mid;
    52465263                }
    52475264                if (ret == 0) {
     
    52555272         * now ready.
    52565273         */
    5257         tt = strmin->last_sequence_delivered + 1;
     5274        mid = strmin->last_mid_delivered + 1;
    52585275        TAILQ_FOREACH_SAFE(ctl, &strmin->inqueue, next_instrm, nctl) {
    5259                 if (tt == ctl->sinfo_ssn) {
     5276                if (SCTP_MID_EQ(asoc->idata_supported, mid, ctl->mid)) {
    52605277                        if (((ctl->sinfo_flags >> 8) & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
    52615278                                /* this is deliverable now */
     
    52775294                                sctp_ucount_decr(asoc->cnt_on_all_streams);
    52785295                                /* deliver it to at least the delivery-q */
    5279                                 strmin->last_sequence_delivered = ctl->sinfo_ssn;
     5296                                strmin->last_mid_delivered = ctl->mid;
    52805297                                if (stcb->sctp_socket) {
    52815298                                        sctp_mark_non_revokable(asoc, ctl->sinfo_tsn);
     
    52865303
    52875304                                }
    5288                                 tt = strmin->last_sequence_delivered + 1;
     5305                                mid = strmin->last_mid_delivered + 1;
    52895306                        } else {
    52905307                                /* Its a fragmented message */
    52915308                                if (ctl->first_frag_seen) {
    52925309                                        /* Make it so this is next to deliver */
    5293                                         strmin->last_sequence_delivered = ctl->sinfo_ssn - 1;
     5310                                        strmin->last_mid_delivered = ctl->mid - 1;
    52945311                                        need_reasm_check = 1;
    52955312                                        break;
     
    53105327sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
    53115328        struct sctp_association *asoc,
    5312         uint16_t stream, uint32_t seq, int ordered, int old, uint32_t cumtsn)
     5329        uint16_t stream, uint32_t mid, int ordered, uint32_t cumtsn)
    53135330{
    53145331        struct sctp_queued_to_read *control;
     
    53165333        struct sctp_tmit_chunk *chk, *nchk;
    53175334        int cnt_removed=0;
     5335
    53185336        /*
    53195337         * For now large messages held on the stream reasm that are
     
    53255343         */
    53265344        strm = &asoc->strmin[stream];
    5327         control = sctp_find_reasm_entry(strm, (uint32_t)seq, ordered, old);
     5345        control = sctp_find_reasm_entry(strm, mid, ordered, asoc->idata_supported);
    53285346        if (control == NULL) {
    53295347                /* Not found */
    53305348                return;
    53315349        }
     5350        if (!asoc->idata_supported && !ordered && SCTP_TSN_GT(control->fsn_included, cumtsn)) {
     5351                return;
     5352        }
    53325353        TAILQ_FOREACH_SAFE(chk, &control->reasm, sctp_next, nchk) {
    53335354                /* Purge hanging chunks */
    5334                 if (old && (ordered == 0)) {
    5335                         if (SCTP_TSN_GT(chk->rec.data.TSN_seq, cumtsn)) {
     5355                if (!asoc->idata_supported && (ordered == 0)) {
     5356                        if (SCTP_TSN_GT(chk->rec.data.tsn, cumtsn)) {
    53365357                                break;
    53375358                        }
     
    54855506                SCTP_INP_READ_LOCK(stcb->sctp_ep);
    54865507                for (sid = 0 ; sid < asoc->streamincnt; sid++) {
    5487                         sctp_flush_reassm_for_str_seq(stcb, asoc, sid, 0, 0, 1, new_cum_tsn);
     5508                        sctp_flush_reassm_for_str_seq(stcb, asoc, sid, 0, 0, new_cum_tsn);
    54885509                }
    54895510                SCTP_INP_READ_UNLOCK(stcb->sctp_ep);
     
    54975518                /* New method. */
    54985519                unsigned int num_str;
    5499                 uint32_t sequence;
    5500                 uint16_t stream;
     5520                uint32_t mid, cur_mid;
     5521                uint16_t sid;
    55015522                uint16_t ordered, flags;
    5502                 int old;
    55035523                struct sctp_strseq *stseq, strseqbuf;
    55045524                struct sctp_strseq_mid *stseq_m, strseqbuf_m;
     
    55085528                if (asoc->idata_supported) {
    55095529                        num_str = fwd_sz / sizeof(struct sctp_strseq_mid);
    5510                         old = 0;
    55115530                } else {
    55125531                        num_str = fwd_sz / sizeof(struct sctp_strseq);
    5513                         old = 1;
    55145532                }
    55155533                for (i = 0; i < num_str; i++) {
     
    55225540                                        break;
    55235541                                }
    5524                                 stream = ntohs(stseq_m->stream);
    5525                                 sequence = ntohl(stseq_m->msg_id);
     5542                                sid = ntohs(stseq_m->sid);
     5543                                mid = ntohl(stseq_m->mid);
    55265544                                flags = ntohs(stseq_m->flags);
    55275545                                if (flags & PR_SCTP_UNORDERED_FLAG) {
     
    55385556                                        break;
    55395557                                }
    5540                                 stream = ntohs(stseq->stream);
    5541                                 sequence = (uint32_t)ntohs(stseq->sequence);
     5558                                sid = ntohs(stseq->sid);
     5559                                mid = (uint32_t)ntohs(stseq->ssn);
    55425560                                ordered = 1;
    55435561                        }
     
    55515569                         * read entry into a PDI_ABORTED.
    55525570                         */
    5553                         if (stream >= asoc->streamincnt) {
     5571                        if (sid >= asoc->streamincnt) {
    55545572                                /* screwed up streams, stop!  */
    55555573                                break;
    55565574                        }
    5557                         if ((asoc->str_of_pdapi == stream) &&
    5558                             (asoc->ssn_of_pdapi == sequence)) {
     5575                        if ((asoc->str_of_pdapi == sid) &&
     5576                            (asoc->ssn_of_pdapi == mid)) {
    55595577                                /* If this is the one we were partially delivering
    55605578                                 * now then we no longer are. Note this will change
     
    55635581                                asoc->fragmented_delivery_inprogress = 0;
    55645582                        }
    5565                         strm = &asoc->strmin[stream];
    5566                         if (asoc->idata_supported == 0) {
    5567                                 uint16_t strm_at;
    5568 
    5569                                 for(strm_at = strm->last_sequence_delivered; SCTP_MSGID_GE(1, sequence, strm_at); strm_at++) {
    5570                                         sctp_flush_reassm_for_str_seq(stcb, asoc, stream, strm_at, ordered, old, new_cum_tsn);
    5571                                 }
    5572                         } else {
    5573                                 uint32_t strm_at;
    5574 
    5575                                 for(strm_at = strm->last_sequence_delivered; SCTP_MSGID_GE(0, sequence, strm_at); strm_at++) {
    5576                                         sctp_flush_reassm_for_str_seq(stcb, asoc, stream, strm_at, ordered, old, new_cum_tsn);
    5577                                 }
     5583                        strm = &asoc->strmin[sid];
     5584                        for (cur_mid = strm->last_mid_delivered; SCTP_MID_GE(asoc->idata_supported, mid, cur_mid); cur_mid++) {
     5585                                sctp_flush_reassm_for_str_seq(stcb, asoc, sid, cur_mid, ordered, new_cum_tsn);
    55785586                        }
    55795587                        TAILQ_FOREACH(ctl, &stcb->sctp_ep->read_queue, next) {
    5580                                 if ((ctl->sinfo_stream == stream) &&
    5581                                     (ctl->sinfo_ssn == sequence)) {
    5582                                         str_seq = (stream << 16) | (0x0000ffff & sequence);
     5588                                if ((ctl->sinfo_stream == sid) &&
     5589                                    (SCTP_MID_EQ(asoc->idata_supported, ctl->mid, mid))) {
     5590                                        str_seq = (sid << 16) | (0x0000ffff & mid);
    55835591                                        ctl->pdapi_aborted = 1;
    55845592                                        sv = stcb->asoc.control_pdapi;
     
    56035611                                        stcb->asoc.control_pdapi = sv;
    56045612                                        break;
    5605                                 } else if ((ctl->sinfo_stream == stream) &&
    5606                                            SCTP_MSGID_GT(old, ctl->sinfo_ssn, sequence)) {
     5613                                } else if ((ctl->sinfo_stream == sid) &&
     5614                                           SCTP_MID_GT(asoc->idata_supported, ctl->mid, mid)) {
    56075615                                        /* We are past our victim SSN */
    56085616                                        break;
    56095617                                }
    56105618                        }
    5611                         if (SCTP_MSGID_GT(old, sequence, strm->last_sequence_delivered)) {
     5619                        if (SCTP_MID_GT(asoc->idata_supported, mid, strm->last_mid_delivered)) {
    56125620                                /* Update the sequence number */
    5613                                 strm->last_sequence_delivered = sequence;
     5621                                strm->last_mid_delivered = mid;
    56145622                        }
    56155623                        /* now kick the stream the new way */
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 297663 2016-04-07 09:34:41Z rrs $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    4545    struct sctp_nets *net,
    4646    uint32_t tsn, uint32_t ppid,
    47     uint32_t context, uint16_t stream_no,
    48     uint32_t stream_seq, uint8_t flags,
     47    uint32_t context, uint16_t sid,
     48    uint32_t mid, uint8_t flags,
    4949    struct mbuf *dm);
    5050
    5151
    52 #define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, stream_no, stream_seq, flags, dm, tfsn, msgid) do { \
     52#define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \
    5353        if (_ctl) { \
    5454                atomic_add_int(&((net)->ref_count), 1); \
    5555                memset(_ctl, 0, sizeof(struct sctp_queued_to_read)); \
    56                 (_ctl)->sinfo_stream = stream_no; \
    57                 (_ctl)->sinfo_ssn = stream_seq; \
     56                (_ctl)->sinfo_stream = sid; \
    5857                TAILQ_INIT(&_ctl->reasm); \
    5958                (_ctl)->top_fsn = tfsn; \
    60                 (_ctl)->msg_id = msgid; \
     59                (_ctl)->mid = mid; \
    6160                (_ctl)->sinfo_flags = (flags << 8); \
    6261                (_ctl)->sinfo_ppid = ppid; \
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c

    r211848 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 304837 2016-08-26 07:49:23Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 313330 2017-02-06 08:49:57Z ae $");
    3636#endif
    3737
     
    344344                newcnt = ntohs(init->num_inbound_streams);
    345345                TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
    346                         if (chk->rec.data.stream_number >= newcnt) {
     346                        if (chk->rec.data.sid >= newcnt) {
    347347                                TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next);
    348348                                asoc->send_queue_cnt--;
    349                                 if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
    350                                         asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
     349                                if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
     350                                        asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
    351351#ifdef INVARIANTS
    352352                                } else {
    353                                         panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number);
     353                                        panic("No chunks on the queues for sid %u.", chk->rec.data.sid);
    354354#endif
    355355                                }
     
    436436        }
    437437        for (i = 0; i < asoc->streamincnt; i++) {
    438                 asoc->strmin[i].stream_no = i;
    439                 asoc->strmin[i].last_sequence_delivered = 0xffffffff;
     438                asoc->strmin[i].sid = i;
     439                asoc->strmin[i].last_mid_delivered = 0xffffffff;
    440440                TAILQ_INIT(&asoc->strmin[i].inqueue);
    441441                TAILQ_INIT(&asoc->strmin[i].uno_inqueue);
     
    17301730                                 * don't double things
    17311731                                 */
    1732                 struct timeval time_entered;
    17331732                                net->hb_responded = 1;
     1733                                struct timeval time_entered;
    17341734                                net->RTO = sctp_calculate_rto(stcb, asoc, net,
    17351735                                                              &time_entered,
    17361736                                                              sctp_align_unsafe_makecopy,
    17371737                                                              SCTP_RTT_FROM_NON_DATA);
    1738                 cookie->time_entered = time_entered;
     1738                                cookie->time_entered = time_entered;
     1739
    17391740                                if (stcb->asoc.sctp_autoclose_ticks &&
    17401741                                    (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE))) {
     
    20502051                        asoc->strmout[i].abandoned_unsent[0] = 0;
    20512052#endif
    2052                         stcb->asoc.strmout[i].stream_no = i;
     2053                        stcb->asoc.strmout[i].sid = i;
    20532054                        stcb->asoc.strmout[i].next_mid_ordered = 0;
    20542055                        stcb->asoc.strmout[i].next_mid_unordered = 0;
     
    24832484        (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
    24842485        if ((netp != NULL) && (*netp != NULL)) {
    2485         struct timeval time_entered;
    24862486                /* calculate the RTT and set the encaps port */
     2487                struct timeval time_entered;
    24872488                (*netp)->RTO = sctp_calculate_rto(stcb, asoc, *netp,
    24882489                                                  &time_entered, sctp_align_unsafe_makecopy,
    24892490                                                  SCTP_RTT_FROM_NON_DATA);
    2490         cookie->time_entered = time_entered;
     2491                cookie->time_entered = time_entered;
    24912492        }
    24922493        /* respond with a COOKIE-ACK */
     
    32243225                window_data_tsn = stcb->asoc.sending_seq - 1;
    32253226        } else {
    3226                 window_data_tsn = lchk->rec.data.TSN_seq;
     3227                window_data_tsn = lchk->rec.data.tsn;
    32273228        }
    32283229
     
    32303231        net = NULL;
    32313232        TAILQ_FOREACH(lchk, &stcb->asoc.sent_queue, sctp_next) {
    3232                 if (lchk->rec.data.TSN_seq == tsn) {
     3233                if (lchk->rec.data.tsn == tsn) {
    32333234                        net = lchk->whoTo;
    32343235                        net->ecn_prev_cwnd = lchk->rec.data.cwnd_at_send;
    32353236                        break;
    32363237                }
    3237                 if (SCTP_TSN_GT(lchk->rec.data.TSN_seq, tsn)) {
     3238                if (SCTP_TSN_GT(lchk->rec.data.tsn, tsn)) {
    32383239                        break;
    32393240                }
     
    34233424                tsn = ntohl(desc->tsn_ifany);
    34243425                TAILQ_FOREACH(tp1, &stcb->asoc.sent_queue, sctp_next) {
    3425                         if (tp1->rec.data.TSN_seq == tsn) {
     3426                        if (tp1->rec.data.tsn == tsn) {
    34263427                                /* found it */
    34273428                                break;
    34283429                        }
    3429                         if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, tsn)) {
     3430                        if (SCTP_TSN_GT(tp1->rec.data.tsn, tsn)) {
    34303431                                /* not found */
    34313432                                tp1 = NULL;
     
    34403441                        SCTP_STAT_INCR(sctps_pdrpdnfnd);
    34413442                        TAILQ_FOREACH(tp1, &stcb->asoc.sent_queue, sctp_next) {
    3442                                 if (tp1->rec.data.TSN_seq == tsn) {
     3443                                if (tp1->rec.data.tsn == tsn) {
    34433444                                        /* found it */
    34443445                                        break;
     
    35063507                                tp1->rec.data.fast_retran_tsn = stcb->asoc.sending_seq;
    35073508                        } else {
    3508                                 tp1->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.TSN_seq;
     3509                                tp1->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.tsn;
    35093510                        }
    35103511
     
    35223523                                               tp1->book_size,
    35233524                                               (uint32_t)(uintptr_t)stcb,
    3524                                                tp1->rec.data.TSN_seq);
     3525                                               tp1->rec.data.tsn);
    35253526                        }
    35263527                        if (tp1->sent < SCTP_DATAGRAM_RESEND) {
     
    36653666                                continue;
    36663667                        }
    3667                         stcb->asoc.strmin[temp].last_sequence_delivered = 0xffffffff;
     3668                        stcb->asoc.strmin[temp].last_mid_delivered = 0xffffffff;
    36683669                }
    36693670        } else {
    36703671                list = NULL;
    36713672                for (i = 0; i < stcb->asoc.streamincnt; i++) {
    3672                         stcb->asoc.strmin[i].last_sequence_delivered = 0xffffffff;
     3673                        stcb->asoc.strmin[i].last_mid_delivered = 0xffffffff;
    36733674                }
    36743675        }
     
    42114212                                TAILQ_INIT(&stcb->asoc.strmin[i].inqueue);
    42124213                                TAILQ_INIT(&stcb->asoc.strmin[i].uno_inqueue);
    4213                                 stcb->asoc.strmin[i].stream_no = i;
    4214                                 stcb->asoc.strmin[i].last_sequence_delivered = oldstrm[i].last_sequence_delivered;
     4214                                stcb->asoc.strmin[i].sid = i;
     4215                                stcb->asoc.strmin[i].last_mid_delivered = oldstrm[i].last_mid_delivered;
    42154216                                stcb->asoc.strmin[i].delivery_started = oldstrm[i].delivery_started;
    42164217                                stcb->asoc.strmin[i].pd_api_started = oldstrm[i].pd_api_started;
     
    42294230                                TAILQ_INIT(&stcb->asoc.strmin[i].inqueue);
    42304231                                TAILQ_INIT(&stcb->asoc.strmin[i].uno_inqueue);
    4231                                 stcb->asoc.strmin[i].stream_no = i;
    4232                                 stcb->asoc.strmin[i].last_sequence_delivered = 0xffffffff;
     4232                                stcb->asoc.strmin[i].sid = i;
     4233                                stcb->asoc.strmin[i].last_mid_delivered = 0xffffffff;
    42334234                                stcb->asoc.strmin[i].pd_api_started = 0;
    42344235                                stcb->asoc.strmin[i].delivery_started = 0;
     
    59996000                inp_decr = inp;
    60006001        }
    6001 #ifdef IPSEC
    6002         /*-
    6003          * I very much doubt any of the IPSEC stuff will work but I have no
    6004          * idea, so I will leave it in place.
    6005          */
    6006         if (inp != NULL) {
    6007                 switch (dst->sa_family) {
    6008 #ifdef INET
    6009                 case AF_INET:
    6010                         if (ipsec4_in_reject(m, &inp->ip_inp.inp)) {
    6011                                 SCTP_STAT_INCR(sctps_hdrops);
    6012                                 goto out;
    6013                         }
    6014                         break;
    6015 #endif
    6016 #ifdef INET6
    6017                 case AF_INET6:
    6018                         if (ipsec6_in_reject(m, &inp->ip_inp.inp)) {
    6019                                 SCTP_STAT_INCR(sctps_hdrops);
    6020                                 goto out;
    6021                         }
    6022                         break;
    6023 #endif
    6024                 default:
    6025                         break;
    6026                 }
    6027         }
    6028 #endif
    60296002        SCTPDBG(SCTP_DEBUG_INPUT1, "Ok, Common input processing called, m:%p iphlen:%d offset:%d length:%d stcb:%p\n",
    60306003                (void *)m, iphlen, offset, length, (void *)stcb);
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 284515 2015-06-17 15:20:14Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c

    r211848 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 304579 2016-08-22 01:45:29Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 313032 2017-02-01 00:10:29Z tuexen $");
    3636#endif
    3737
     
    37483748                                                stcb->asoc.strmout[i].abandoned_unsent[0] = 0;
    37493749#endif
    3750                                                 stcb->asoc.strmout[i].stream_no = i;
     3750                                                stcb->asoc.strmout[i].sid = i;
    37513751                                                stcb->asoc.strmout[i].last_msg_incomplete = 0;
    37523752                                                stcb->asoc.strmout[i].state = SCTP_STREAM_OPENING;
     
    50035003                SCTP_STAT_INCR(sctps_sendnocrc);
    50045004#else
    5005                 sctphdr->checksum = sctp_calculate_cksum(m, 0);
    5006                 SCTP_STAT_INCR(sctps_sendswcrc);
     5005                if (SCTP_BASE_VAR(crc32c_offloaded) == 0) {
     5006                        sctphdr->checksum = sctp_calculate_cksum(m, 0);
     5007                        SCTP_STAT_INCR(sctps_sendswcrc);
     5008                } else {
     5009                        SCTP_STAT_INCR(sctps_sendhwcrc);
     5010                }
    50075011#endif
    50085012                if (tos_value == 0) {
     
    50505054        struct sctp_paramhdr *ph;
    50515055        int cnt_inits_to = 0;
    5052         int ret;
     5056        int error;
    50535057        uint16_t num_ext, chunk_len, padding_len, parameter_len;
    50545058
     
    53135317        }
    53145318        SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n");
    5315         ret = sctp_lowlevel_chunk_output(inp, stcb, net,
    5316                                          (struct sockaddr *)&net->ro._l_addr,
    5317                                          m, 0, NULL, 0, 0, 0, 0,
    5318                                          inp->sctp_lport, stcb->rport, htonl(0),
    5319                                          net->port, NULL,
     5319        if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
     5320                                                (struct sockaddr *)&net->ro._l_addr,
     5321                                                m, 0, NULL, 0, 0, 0, 0,
     5322                                                inp->sctp_lport, stcb->rport, htonl(0),
     5323                                                net->port, NULL,
    53205324#if defined(__FreeBSD__)
    5321                                          0, 0,
    5322 #endif
    5323                                          so_locked);
    5324         SCTPDBG(SCTP_DEBUG_OUTPUT4, "lowlevel_output - %d\n", ret);
     5325                                                0, 0,
     5326#endif
     5327                                                so_locked))) {
     5328                SCTPDBG(SCTP_DEBUG_OUTPUT4, "Gak send error %d\n", error);
     5329                if (error == ENOBUFS) {
     5330                        stcb->asoc.ifp_had_enobuf = 1;
     5331                        SCTP_STAT_INCR(sctps_lowlevelerr);
     5332                }
     5333        } else {
     5334                stcb->asoc.ifp_had_enobuf = 0;
     5335        }
    53255336        SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
    53265337        (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time);
     
    59205931        int abort_flag;
    59215932        int nat_friendly = 0;
     5933        int error;
    59225934        struct socket *so;
    59235935        uint16_t num_ext, chunk_len, padding_len, parameter_len;
     
    60056017        memset(&stc, 0, sizeof(struct sctp_state_cookie));
    60066018
    6007     struct timeval time_entered;
    60086019        /* the time I built cookie */
     6020        struct timeval time_entered;
    60096021        (void)SCTP_GETTIME_TIMEVAL(&time_entered);
    6010     stc.time_entered = time_entered;
     6022        stc.time_entered = time_entered;
    60116023        /* populate any tie tags */
    60126024        if (asoc != NULL) {
     
    66016613        }
    66026614
    6603         (void)sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0,
    6604                                          0, 0,
    6605                                          inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag,
    6606                                          port, over_addr,
     6615        if ((error = sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0,
     6616                                                0, 0,
     6617                                                inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag,
     6618                                                port, over_addr,
    66076619#if defined(__FreeBSD__)
    6608                                          mflowtype, mflowid,
    6609 #endif
    6610                                          SCTP_SO_NOT_LOCKED);
     6620                                                mflowtype, mflowid,
     6621#endif
     6622                                                SCTP_SO_NOT_LOCKED))) {
     6623                SCTPDBG(SCTP_DEBUG_OUTPUT4, "Gak send error %d\n", error);
     6624                if (error == ENOBUFS) {
     6625                        if (asoc != NULL) {
     6626                                asoc->ifp_had_enobuf = 1;
     6627                        }
     6628                        SCTP_STAT_INCR(sctps_lowlevelerr);
     6629                }
     6630        } else {
     6631                if (asoc != NULL) {
     6632                        asoc->ifp_had_enobuf = 0;
     6633                }
     6634        }
    66116635        SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
    66126636}
     
    68506874        }
    68516875        (void)SCTP_GETTIME_TIMEVAL(&sp->ts);
    6852         sp->stream = srcv->sinfo_stream;
     6876        sp->sid = srcv->sinfo_stream;
    68536877        sp->msg_is_complete = 1;
    68546878        sp->sender_all_done = 1;
     
    74467470                data_list[i]->sent_rcv_time = net->last_sent_time;
    74477471                data_list[i]->rec.data.cwnd_at_send = net->cwnd;
    7448                 data_list[i]->rec.data.fast_retran_tsn = data_list[i]->rec.data.TSN_seq;
     7472                data_list[i]->rec.data.fast_retran_tsn = data_list[i]->rec.data.tsn;
    74497473                if (data_list[i]->whoTo == NULL) {
    74507474                        data_list[i]->whoTo = net;
     
    74537477                /* on to the sent queue */
    74547478                tp1 = TAILQ_LAST(&asoc->sent_queue, sctpchunk_listhead);
    7455                 if ((tp1) && SCTP_TSN_GT(tp1->rec.data.TSN_seq, data_list[i]->rec.data.TSN_seq)) {
     7479                if ((tp1) && SCTP_TSN_GT(tp1->rec.data.tsn, data_list[i]->rec.data.tsn)) {
    74567480                        struct sctp_tmit_chunk *tpp;
    74577481
     
    74647488                        }
    74657489                        tp1 = tpp;
    7466                         if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, data_list[i]->rec.data.TSN_seq)) {
     7490                        if (SCTP_TSN_GT(tp1->rec.data.tsn, data_list[i]->rec.data.tsn)) {
    74677491                                goto back_up_more;
    74687492                        }
     
    74937517                                       data_list[i]->book_size,
    74947518                                       (uint32_t)(uintptr_t)data_list[i]->whoTo,
    7495                                        data_list[i]->rec.data.TSN_seq);
     7519                                       data_list[i]->rec.data.tsn);
    74967520                }
    74977521                sctp_flight_size_increase(data_list[i]);
     
    75557579}
    75567580
    7557 
    7558 static int
    7559 sctp_can_we_split_this(struct sctp_tcb *stcb,
    7560                        uint32_t length,
    7561                        uint32_t goal_mtu, uint32_t frag_point, int eeor_on)
     7581static uint32_t
     7582sctp_can_we_split_this(struct sctp_tcb *stcb, uint32_t length,
     7583                       uint32_t space_left, uint32_t frag_point, int eeor_on)
    75627584{
    75637585        /* Make a decision on if I should split a
     
    75707592                 * be all the guy is putting in the hopper.
    75717593                 */
    7572                 if (goal_mtu >= length) {
     7594                if (space_left >= length) {
    75737595                        /*-
    75747596                         * If we have data outstanding,
     
    75867608                } else {
    75877609                        /* You can fill the rest */
    7588                         return (goal_mtu);
     7610                        return (space_left);
    75897611                }
    75907612        }
     
    75977619                return (length);
    75987620        }
    7599 
    7600         if ((length <= goal_mtu) ||
    7601             ((length - goal_mtu) < SCTP_BASE_SYSCTL(sctp_min_residual))) {
     7621        if ((length <= space_left) ||
     7622            ((length - space_left) < SCTP_BASE_SYSCTL(sctp_min_residual))) {
    76027623                /* Sub-optimial residual don't split in non-eeor mode. */
    76037624                return (0);
    76047625        }
    76057626        /* If we reach here length is larger
    7606          * than the goal_mtu. Do we wish to split
     7627         * than the space_left. Do we wish to split
    76077628         * it for the sake of packet putting together?
    76087629         */
    7609         if (goal_mtu >= min(SCTP_BASE_SYSCTL(sctp_min_split_point), frag_point)) {
     7630        if (space_left >= min(SCTP_BASE_SYSCTL(sctp_min_split_point), frag_point)) {
    76107631                /* Its ok to split it */
    7611                 return (min(goal_mtu, frag_point));
     7632                return (min(space_left, frag_point));
    76127633        }
    76137634        /* Nope, can't split */
    76147635        return (0);
    7615 
    76167636}
    76177637
     
    76197639sctp_move_to_outqueue(struct sctp_tcb *stcb,
    76207640                      struct sctp_stream_out *strq,
    7621                       uint32_t goal_mtu,
     7641                      uint32_t space_left,
    76227642                      uint32_t frag_point,
    76237643                      int *giveup,
     
    76607680                    (strq->last_msg_incomplete)) {
    76617681                        SCTP_PRINTF("Huh? Stream:%d lm_in_c=%d but queue is NULL\n",
    7662                                     strq->stream_no,
     7682                                    strq->sid,
    76637683                                    strq->last_msg_incomplete);
    76647684                        strq->last_msg_incomplete = 0;
     
    77787798                }
    77797799        } else {
    7780                 to_move = sctp_can_we_split_this(stcb, length, goal_mtu, frag_point, eeor_mode);
     7800                to_move = sctp_can_we_split_this(stcb, length, space_left, frag_point, eeor_mode);
    77817801                if (to_move) {
    77827802                        /*-
     
    80018021                if (rcv_flags & SCTP_DATA_UNORDERED) {
    80028022                        /* Just use 0. The receiver ignores the values. */
    8003                         chk->rec.data.stream_seq = 0;
     8023                        chk->rec.data.mid = 0;
    80048024                } else {
    8005                         chk->rec.data.stream_seq = strq->next_mid_ordered;
     8025                        chk->rec.data.mid = strq->next_mid_ordered;
    80068026                        if (rcv_flags & SCTP_DATA_LAST_FRAG) {
    80078027                                strq->next_mid_ordered++;
     
    80108030        } else {
    80118031                if (rcv_flags & SCTP_DATA_UNORDERED) {
    8012                         chk->rec.data.stream_seq = strq->next_mid_unordered;
     8032                        chk->rec.data.mid = strq->next_mid_unordered;
    80138033                        if (rcv_flags & SCTP_DATA_LAST_FRAG) {
    80148034                                strq->next_mid_unordered++;
    80158035                        }
    80168036                } else {
    8017                         chk->rec.data.stream_seq = strq->next_mid_ordered;
     8037                        chk->rec.data.mid = strq->next_mid_ordered;
    80188038                        if (rcv_flags & SCTP_DATA_LAST_FRAG) {
    80198039                                strq->next_mid_ordered++;
     
    80218041                }
    80228042        }
    8023         chk->rec.data.stream_number = sp->stream;
    8024         chk->rec.data.payloadtype = sp->ppid;
     8043        chk->rec.data.sid = sp->sid;
     8044        chk->rec.data.ppid = sp->ppid;
    80258045        chk->rec.data.context = sp->context;
    80268046        chk->rec.data.doing_fast_retransmit = 0;
     
    80418061        }
    80428062#if defined(__FreeBSD__) || defined(__Panda__)
    8043         chk->rec.data.TSN_seq = atomic_fetchadd_int(&asoc->sending_seq, 1);
     8063        chk->rec.data.tsn = atomic_fetchadd_int(&asoc->sending_seq, 1);
    80448064#else
    8045         chk->rec.data.TSN_seq = asoc->sending_seq++;
     8065        chk->rec.data.tsn = asoc->sending_seq++;
    80468066#endif
    80478067        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_AT_SEND_2_OUTQ) {
    80488068                sctp_misc_ints(SCTP_STRMOUT_LOG_SEND,
    80498069                               (uint32_t)(uintptr_t)stcb, sp->length,
    8050                                (uint32_t)((chk->rec.data.stream_number << 16) | chk->rec.data.stream_seq),
    8051                                chk->rec.data.TSN_seq);
     8070                               (uint32_t)((chk->rec.data.sid << 16) | (0x0000ffff & chk->rec.data.mid)),
     8071                               chk->rec.data.tsn);
    80528072        }
    80538073        if (stcb->asoc.idata_supported == 0) {
     
    80678087                asoc->tsn_out_wrapped = 1;
    80688088        }
    8069         asoc->out_tsnlog[asoc->tsn_out_at].tsn = chk->rec.data.TSN_seq;
    8070         asoc->out_tsnlog[asoc->tsn_out_at].strm = chk->rec.data.stream_number;
    8071         asoc->out_tsnlog[asoc->tsn_out_at].seq = chk->rec.data.stream_seq;
     8089        asoc->out_tsnlog[asoc->tsn_out_at].tsn = chk->rec.data.tsn;
     8090        asoc->out_tsnlog[asoc->tsn_out_at].strm = chk->rec.data.sid;
     8091        asoc->out_tsnlog[asoc->tsn_out_at].seq = chk->rec.data.mid;
    80728092        asoc->out_tsnlog[asoc->tsn_out_at].sz = chk->send_size;
    80738093        asoc->out_tsnlog[asoc->tsn_out_at].flgs = chk->rec.data.rcv_flags;
     
    80808100                dchkh->ch.chunk_type = SCTP_DATA;
    80818101                dchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
    8082                 dchkh->dp.tsn = htonl(chk->rec.data.TSN_seq);
    8083                 dchkh->dp.stream_id = htons((strq->stream_no & 0x0000ffff));
    8084                 dchkh->dp.stream_sequence = htons((uint16_t)chk->rec.data.stream_seq);
    8085                 dchkh->dp.protocol_id = chk->rec.data.payloadtype;
     8102                dchkh->dp.tsn = htonl(chk->rec.data.tsn);
     8103                dchkh->dp.sid = htons(strq->sid);
     8104                dchkh->dp.ssn = htons((uint16_t)chk->rec.data.mid);
     8105                dchkh->dp.ppid = chk->rec.data.ppid;
    80868106                dchkh->ch.chunk_length = htons(chk->send_size);
    80878107        } else {
    80888108                ndchkh->ch.chunk_type = SCTP_IDATA;
    80898109                ndchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
    8090                 ndchkh->dp.tsn = htonl(chk->rec.data.TSN_seq);
    8091                 ndchkh->dp.stream_id = htons(strq->stream_no);
     8110                ndchkh->dp.tsn = htonl(chk->rec.data.tsn);
     8111                ndchkh->dp.sid = htons(strq->sid);
    80928112                ndchkh->dp.reserved = htons(0);
    8093                 ndchkh->dp.msg_id = htonl(chk->rec.data.stream_seq);
     8113                ndchkh->dp.mid = htonl(chk->rec.data.mid);
    80948114                if (sp->fsn == 0)
    8095                         ndchkh->dp.ppid_fsn.protocol_id = chk->rec.data.payloadtype;
     8115                        ndchkh->dp.ppid_fsn.ppid = chk->rec.data.ppid;
    80968116                else
    80978117                        ndchkh->dp.ppid_fsn.fsn = htonl(sp->fsn);
     
    81718191        struct sctp_association *asoc;
    81728192        struct sctp_stream_out *strq;
    8173         int goal_mtu, moved_how_much, total_moved = 0, bail = 0;
    8174         int giveup;
     8193        uint32_t space_left, moved, total_moved;
     8194        int bail, giveup;
    81758195
    81768196        SCTP_TCB_LOCK_ASSERT(stcb);
    81778197        asoc = &stcb->asoc;
     8198        total_moved = 0;
    81788199        switch (net->ro._l_addr.sa.sa_family) {
    81798200#ifdef INET
    81808201                case AF_INET:
    8181                         goal_mtu = net->mtu - SCTP_MIN_V4_OVERHEAD;
     8202                        space_left = net->mtu - SCTP_MIN_V4_OVERHEAD;
    81828203                        break;
    81838204#endif
    81848205#ifdef INET6
    81858206                case AF_INET6:
    8186                         goal_mtu = net->mtu - SCTP_MIN_OVERHEAD;
     8207                        space_left = net->mtu - SCTP_MIN_OVERHEAD;
    81878208                        break;
    81888209#endif
    81898210#if defined(__Userspace__)
    81908211                case AF_CONN:
    8191                         goal_mtu = net->mtu - sizeof(struct sctphdr);
     8212                        space_left = net->mtu - sizeof(struct sctphdr);
    81928213                        break;
    81938214#endif
    81948215                default:
    81958216                        /* TSNH */
    8196                         goal_mtu = net->mtu;
     8217                        space_left = net->mtu;
    81978218                        break;
    81988219        }
    81998220        /* Need an allowance for the data chunk header too */
    82008221        if (stcb->asoc.idata_supported == 0) {
    8201                 goal_mtu -= sizeof(struct sctp_data_chunk);
     8222                space_left -= sizeof(struct sctp_data_chunk);
    82028223        } else {
    8203                 goal_mtu -= sizeof(struct sctp_idata_chunk);
     8224                space_left -= sizeof(struct sctp_idata_chunk);
    82048225        }
    82058226
    82068227        /* must make even word boundary */
    8207         goal_mtu &= 0xfffffffc;
     8228        space_left &= 0xfffffffc;
    82088229        strq = stcb->asoc.ss_functions.sctp_ss_select_stream(stcb, net, asoc);
    8209         while ((goal_mtu > 0) && strq) {
    8210                 giveup = 0;
    8211                 bail = 0;
    8212                 moved_how_much = sctp_move_to_outqueue(stcb, strq, goal_mtu, frag_point,
    8213                                                        &giveup, eeor_mode, &bail, so_locked);
    8214                 stcb->asoc.ss_functions.sctp_ss_scheduled(stcb, net, asoc, strq, moved_how_much);
    8215 
    8216                 if ((giveup) || bail) {
     8230        giveup = 0;
     8231        bail = 0;
     8232        while ((space_left > 0) && (strq != NULL)) {
     8233                moved = sctp_move_to_outqueue(stcb, strq, space_left, frag_point,
     8234                                              &giveup, eeor_mode, &bail, so_locked);
     8235                stcb->asoc.ss_functions.sctp_ss_scheduled(stcb, net, asoc, strq, moved);
     8236                if ((giveup != 0) || (bail != 0)) {
    82178237                        break;
    82188238                }
    82198239                strq = stcb->asoc.ss_functions.sctp_ss_select_stream(stcb, net, asoc);
    8220                 if (strq == NULL) {
    8221                         break;
    8222                 }
    8223                 total_moved += moved_how_much;
    8224                 goal_mtu -= (moved_how_much + sizeof(struct sctp_data_chunk));
    8225                 goal_mtu &= 0xfffffffc;
    8226         }
    8227         if (bail)
     8240                total_moved += moved;
     8241                space_left -= moved;
     8242                if (stcb->asoc.idata_supported == 0) {
     8243                        if (space_left >= sizeof(struct sctp_data_chunk)) {
     8244                                space_left -= sizeof(struct sctp_data_chunk);
     8245                        } else {
     8246                                space_left = 0;
     8247                        }
     8248                } else {
     8249                        if (space_left >= sizeof(struct sctp_idata_chunk)) {
     8250                                space_left -= sizeof(struct sctp_idata_chunk);
     8251                        } else {
     8252                                space_left = 0;
     8253                        }
     8254                }
     8255                space_left &= 0xfffffffc;
     8256        }
     8257        if (bail != 0)
    82288258                *quit_now = 1;
    82298259
     
    93249354                                }
    93259355                                if (error == ENOBUFS) {
     9356                                        asoc->ifp_had_enobuf = 1;
    93269357                                        SCTP_STAT_INCR(sctps_lowlevelerr);
    9327                                         asoc->ifp_had_enobuf = 1;
    93289358                                }
    93299359                                if (error == EHOSTUNREACH) {
     
    93549384                        if (bundle_at) {
    93559385                                /* setup for a RTO measurement */
    9356                                 tsns_sent = data_list[0]->rec.data.TSN_seq;
     9386                                tsns_sent = data_list[0]->rec.data.tsn;
    93579387                                /* fill time if not already filled */
    93589388                                if (*now_filled == 0) {
     
    97029732        struct sctp_tmit_chunk *chk;
    97039733
    9704         m_shutdown = sctp_get_mbuf_for_msg(sizeof(struct sctp_shutdown_chunk), 0, M_NOWAIT, 1, MT_HEADER);
    9705         if (m_shutdown == NULL) {
    9706                 /* no mbuf's */
    9707                 return;
    9708         }
    9709         SCTP_BUF_RESV_UF(m_shutdown, SCTP_MIN_OVERHEAD);
    9710         sctp_alloc_a_chunk(stcb, chk);
     9734        TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) {
     9735                if (chk->rec.chunk_id.id == SCTP_SHUTDOWN) {
     9736                        /* We already have a SHUTDOWN queued. Reuse it. */
     9737                        if (chk->whoTo) {
     9738                                sctp_free_remote_addr(chk->whoTo);
     9739                                chk->whoTo = NULL;
     9740                        }
     9741                        break;
     9742                }
     9743        }
    97119744        if (chk == NULL) {
    9712                 /* no memory */
    9713                 sctp_m_freem(m_shutdown);
    9714                 return;
    9715         }
    9716         chk->copy_by_ref = 0;
    9717         chk->rec.chunk_id.id = SCTP_SHUTDOWN;
    9718         chk->rec.chunk_id.can_take_data = 1;
    9719         chk->flags = 0;
    9720         chk->send_size = sizeof(struct sctp_shutdown_chunk);
    9721         chk->sent = SCTP_DATAGRAM_UNSENT;
    9722         chk->snd_count = 0;
    9723         chk->flags = 0;
    9724         chk->asoc = &stcb->asoc;
    9725         chk->data = m_shutdown;
    9726         chk->whoTo = net;
    9727         if (chk->whoTo) {
    9728                 atomic_add_int(&chk->whoTo->ref_count, 1);
    9729         }
    9730         shutdown_cp = mtod(m_shutdown, struct sctp_shutdown_chunk *);
    9731         shutdown_cp->ch.chunk_type = SCTP_SHUTDOWN;
    9732         shutdown_cp->ch.chunk_flags = 0;
    9733         shutdown_cp->ch.chunk_length = htons(chk->send_size);
    9734         shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn);
    9735         SCTP_BUF_LEN(m_shutdown) = chk->send_size;
    9736         TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
    9737         chk->asoc->ctrl_queue_cnt++;
     9745                m_shutdown = sctp_get_mbuf_for_msg(sizeof(struct sctp_shutdown_chunk), 0, M_NOWAIT, 1, MT_HEADER);
     9746                if (m_shutdown == NULL) {
     9747                        /* no mbuf's */
     9748                        return;
     9749                }
     9750                SCTP_BUF_RESV_UF(m_shutdown, SCTP_MIN_OVERHEAD);
     9751                sctp_alloc_a_chunk(stcb, chk);
     9752                if (chk == NULL) {
     9753                        /* no memory */
     9754                        sctp_m_freem(m_shutdown);
     9755                        return;
     9756                }
     9757                chk->copy_by_ref = 0;
     9758                chk->rec.chunk_id.id = SCTP_SHUTDOWN;
     9759                chk->rec.chunk_id.can_take_data = 1;
     9760                chk->flags = 0;
     9761                chk->send_size = sizeof(struct sctp_shutdown_chunk);
     9762                chk->sent = SCTP_DATAGRAM_UNSENT;
     9763                chk->snd_count = 0;
     9764                chk->flags = 0;
     9765                chk->asoc = &stcb->asoc;
     9766                chk->data = m_shutdown;
     9767                chk->whoTo = net;
     9768                if (chk->whoTo) {
     9769                        atomic_add_int(&chk->whoTo->ref_count, 1);
     9770                }
     9771                shutdown_cp = mtod(m_shutdown, struct sctp_shutdown_chunk *);
     9772                shutdown_cp->ch.chunk_type = SCTP_SHUTDOWN;
     9773                shutdown_cp->ch.chunk_flags = 0;
     9774                shutdown_cp->ch.chunk_length = htons(chk->send_size);
     9775                shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn);
     9776                SCTP_BUF_LEN(m_shutdown) = chk->send_size;
     9777                TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
     9778                chk->asoc->ctrl_queue_cnt++;
     9779        } else {
     9780                TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, sctp_next);
     9781                chk->whoTo = net;
     9782                if (chk->whoTo) {
     9783                        atomic_add_int(&chk->whoTo->ref_count, 1);
     9784                }
     9785                shutdown_cp = mtod(chk->data, struct sctp_shutdown_chunk *);
     9786                shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn);
     9787                TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
     9788        }
    97389789        return;
    97399790}
     
    1000410055#endif
    1000510056                                                        so_locked))) {
    10006                         SCTP_STAT_INCR(sctps_lowlevelerr);
     10057                        SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
     10058                        if (error == ENOBUFS) {
     10059                                asoc->ifp_had_enobuf = 1;
     10060                                SCTP_STAT_INCR(sctps_lowlevelerr);
     10061                        }
    1000710062                        return (error);
     10063                } else {
     10064                        asoc->ifp_had_enobuf = 0;
    1000810065                }
    1000910066                endofchain = NULL;
     
    1004910106                if (chk->data == NULL) {
    1005010107                        SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n",
    10051                                     chk->rec.data.TSN_seq, chk->snd_count, chk->sent);
     10108                                    chk->rec.data.tsn, chk->snd_count, chk->sent);
    1005210109                        continue;
    1005310110                }
     
    1005810115
    1005910116                        snprintf(msg, sizeof(msg), "TSN %8.8x retransmitted %d times, giving up",
    10060                                  chk->rec.data.TSN_seq, chk->snd_count);
     10117                                 chk->rec.data.tsn, chk->snd_count);
    1006110118                        op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
    1006210119                                                     msg);
     
    1009710154
    1009810155                        tsn = asoc->last_acked_seq + 1;
    10099                         if (tsn == chk->rec.data.TSN_seq) {
     10156                        if (tsn == chk->rec.data.tsn) {
    1010010157                                /*
    1010110158                                 * we make a special exception for this
     
    1028010337                                                                so_locked))) {
    1028110338                                /* error, we could not output */
    10282                                 SCTP_STAT_INCR(sctps_lowlevelerr);
     10339                                SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
     10340                                if (error == ENOBUFS) {
     10341                                        asoc->ifp_had_enobuf = 1;
     10342                                        SCTP_STAT_INCR(sctps_lowlevelerr);
     10343                                }
    1028310344                                return (error);
     10345                        } else {
     10346                                asoc->ifp_had_enobuf = 0;
    1028410347                        }
    1028510348                        endofchain = NULL;
     
    1030810371#endif
    1030910372                        if (bundle_at) {
    10310                                 tsns_sent = data_list[0]->rec.data.TSN_seq;
     10373                                tsns_sent = data_list[0]->rec.data.tsn;
    1031110374                        }
    1031210375                        for (i = 0; i < bundle_at; i++) {
     
    1035610419                                                       data_list[i]->book_size,
    1035710420                                                       (uint32_t)(uintptr_t)data_list[i]->whoTo,
    10358                                                        data_list[i]->rec.data.TSN_seq);
     10421                                                       data_list[i]->rec.data.tsn);
    1035910422                                }
    1036010423                                sctp_flight_size_increase(data_list[i]);
     
    1043510498
    1043610499void
    10437 sctp_chunk_output (struct sctp_inpcb *inp,
     10500sctp_chunk_output(struct sctp_inpcb *inp,
    1043810501    struct sctp_tcb *stcb,
    1043910502    int from_where,
     
    1077710840        unsigned int space_needed;
    1077810841        unsigned int cnt_of_skipped = 0;
    10779         int old;
    10780 
    10781         if (asoc->idata_supported) {
    10782                 old = 0;
    10783         } else {
    10784                 old = 1;
    10785         }
     10842
    1078610843        SCTP_TCB_LOCK_ASSERT(stcb);
    1078710844        TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
     
    1083910896                        break;
    1084010897                }
    10841                 if (old && (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED)) {
     10898                if (!asoc->idata_supported && (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED)) {
    1084210899                        /* We don't report these */
    1084310900                        continue;
     
    1084510902                cnt_of_skipped++;
    1084610903        }
    10847         if (old) {
     10904        if (asoc->idata_supported) {
     10905                space_needed = (sizeof(struct sctp_forward_tsn_chunk) +
     10906                                (cnt_of_skipped * sizeof(struct sctp_strseq_mid)));
     10907        } else {
    1084810908                space_needed = (sizeof(struct sctp_forward_tsn_chunk) +
    1084910909                                (cnt_of_skipped * sizeof(struct sctp_strseq)));
    10850         } else {
    10851                 space_needed = (sizeof(struct sctp_forward_tsn_chunk) +
    10852                                 (cnt_of_skipped * sizeof(struct sctp_strseq_mid)));
    1085310910        }
    1085410911        cnt_of_space = (unsigned int)M_TRAILINGSPACE(chk->data);
     
    1087910936                                       space_needed);
    1088010937                }
    10881                 if (old) {
    10882                         cnt_of_skipped = cnt_of_space - sizeof(struct sctp_forward_tsn_chunk);
     10938                cnt_of_skipped = cnt_of_space - sizeof(struct sctp_forward_tsn_chunk);
     10939                if (asoc->idata_supported) {
     10940                        cnt_of_skipped /= sizeof(struct sctp_strseq_mid);
     10941                } else {
    1088310942                        cnt_of_skipped /= sizeof(struct sctp_strseq);
    10884                 } else {
    10885                         cnt_of_skipped = cnt_of_space - sizeof(struct sctp_forward_tsn_chunk);
    10886                         cnt_of_skipped /= sizeof(struct sctp_strseq_mid);
    1088710943                }
    1088810944                /*-
     
    1090210958                if (at && SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_TRY_ADVANCE) {
    1090310959                        sctp_misc_ints(SCTP_FWD_TSN_CHECK,
    10904                                        0xff, cnt_of_skipped, at->rec.data.TSN_seq,
     10960                                       0xff, cnt_of_skipped, at->rec.data.tsn,
    1090510961                                       asoc->advanced_peer_ack_point);
    1090610962                }
     
    1091110967                 */
    1091210968                if (last) {
    10913                         advance_peer_ack_point = last->rec.data.TSN_seq;
    10914                 }
    10915                 if (old) {
     10969                        advance_peer_ack_point = last->rec.data.tsn;
     10970                }
     10971                if (asoc->idata_supported) {
     10972                        space_needed = sizeof(struct sctp_forward_tsn_chunk) +
     10973                                       cnt_of_skipped * sizeof(struct sctp_strseq_mid);
     10974                } else {
    1091610975                        space_needed = sizeof(struct sctp_forward_tsn_chunk) +
    1091710976                                       cnt_of_skipped * sizeof(struct sctp_strseq);
    10918                 } else {
    10919                         space_needed = sizeof(struct sctp_forward_tsn_chunk) +
    10920                                        cnt_of_skipped * sizeof(struct sctp_strseq_mid);
    1092110977                }
    1092210978        }
     
    1092610982        fwdtsn->ch.chunk_length = htons(chk->send_size);
    1092710983        fwdtsn->ch.chunk_flags = 0;
    10928         if (old) {
     10984        if (asoc->idata_supported) {
     10985                fwdtsn->ch.chunk_type = SCTP_IFORWARD_CUM_TSN;
     10986        } else {
    1092910987                fwdtsn->ch.chunk_type = SCTP_FORWARD_CUM_TSN;
    10930         } else {
    10931                 fwdtsn->ch.chunk_type = SCTP_IFORWARD_CUM_TSN;
    1093210988        }
    1093310989        fwdtsn->new_cumulative_tsn = htonl(advance_peer_ack_point);
     
    1093810994         * strseq pointer.
    1093910995         */
    10940         if (old) {
     10996        if (asoc->idata_supported) {
     10997                strseq_m = (struct sctp_strseq_mid *)fwdtsn;
     10998                strseq = NULL;
     10999        } else {
    1094111000                strseq = (struct sctp_strseq *)fwdtsn;
    10942         } else {
    10943                 strseq_m = (struct sctp_strseq_mid *)fwdtsn;
     11001                strseq_m = NULL;
    1094411002        }
    1094511003        /*-
     
    1096011018                        break;
    1096111019                }
    10962                 if (old && (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED)) {
     11020                if (!asoc->idata_supported && (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED)) {
    1096311021                        /* We don't report these */
    1096411022                        continue;
    1096511023                }
    10966                 if (at->rec.data.TSN_seq == advance_peer_ack_point) {
     11024                if (at->rec.data.tsn == advance_peer_ack_point) {
    1096711025                        at->rec.data.fwd_tsn_cnt = 0;
    1096811026                }
    10969                 if (old) {
    10970                         strseq->stream = htons(at->rec.data.stream_number);
    10971                         strseq->sequence = htons((uint16_t)at->rec.data.stream_seq);
    10972                         strseq++;
    10973                 } else {
    10974                         strseq_m->stream = htons(at->rec.data.stream_number);
     11027                if (asoc->idata_supported) {
     11028                        strseq_m->sid = htons(at->rec.data.sid);
    1097511029                        if (at->rec.data.rcv_flags & SCTP_DATA_UNORDERED) {
    1097611030                                strseq_m->flags = htons(PR_SCTP_UNORDERED_FLAG);
     
    1097811032                                strseq_m->flags = 0;
    1097911033                        }
    10980                         strseq_m->msg_id = htonl(at->rec.data.stream_seq);
     11034                        strseq_m->mid = htonl(at->rec.data.mid);
    1098111035                        strseq_m++;
     11036                } else {
     11037                        strseq->sid = htons(at->rec.data.sid);
     11038                        strseq->ssn = htons((uint16_t)at->rec.data.mid);
     11039                        strseq++;
    1098211040                }
    1098311041                i++;
     
    1139611454        uint32_t vtag;
    1139711455        uint32_t auth_offset = 0;
     11456        int error;
    1139811457        uint16_t cause_len, chunk_len, padding_len;
    1139911458
     
    1147411533                }
    1147511534        }
    11476         (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
    11477                                          (struct sockaddr *)&net->ro._l_addr,
    11478                                          m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0,
    11479                                          stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag),
    11480                                          stcb->asoc.primary_destination->port, NULL,
     11535        if ((error = sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
     11536                                                (struct sockaddr *)&net->ro._l_addr,
     11537                                                m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0,
     11538                                                stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag),
     11539                                                stcb->asoc.primary_destination->port, NULL,
    1148111540#if defined(__FreeBSD__)
    11482                                          0, 0,
    11483 #endif
    11484                                          so_locked);
     11541                                                0, 0,
     11542#endif
     11543                                                so_locked))) {
     11544                SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
     11545                if (error == ENOBUFS) {
     11546                        stcb->asoc.ifp_had_enobuf = 1;
     11547                        SCTP_STAT_INCR(sctps_lowlevelerr);
     11548                }
     11549        } else {
     11550                stcb->asoc.ifp_had_enobuf = 0;
     11551        }
    1148511552        SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
    1148611553}
     
    1149511562        struct sctp_shutdown_complete_chunk *shutdown_complete;
    1149611563        uint32_t vtag;
     11564        int error;
    1149711565        uint8_t flags;
    1149811566
     
    1151411582        shutdown_complete->ch.chunk_length = htons(sizeof(struct sctp_shutdown_complete_chunk));
    1151511583        SCTP_BUF_LEN(m_shutdown_comp) = sizeof(struct sctp_shutdown_complete_chunk);
    11516         (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
    11517                                          (struct sockaddr *)&net->ro._l_addr,
    11518                                          m_shutdown_comp, 0, NULL, 0, 1, 0, 0,
    11519                                          stcb->sctp_ep->sctp_lport, stcb->rport,
    11520                                          htonl(vtag),
    11521                                          net->port, NULL,
     11584        if ((error = sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
     11585                                                (struct sockaddr *)&net->ro._l_addr,
     11586                                                m_shutdown_comp, 0, NULL, 0, 1, 0, 0,
     11587                                                stcb->sctp_ep->sctp_lport, stcb->rport,
     11588                                                htonl(vtag),
     11589                                                net->port, NULL,
    1152211590#if defined(__FreeBSD__)
    11523                                          0, 0,
    11524 #endif
    11525                                          SCTP_SO_NOT_LOCKED);
     11591                                                0, 0,
     11592#endif
     11593                                                SCTP_SO_NOT_LOCKED))) {
     11594                SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
     11595                if (error == ENOBUFS) {
     11596                        stcb->asoc.ifp_had_enobuf = 1;
     11597                        SCTP_STAT_INCR(sctps_lowlevelerr);
     11598                }
     11599        } else {
     11600                stcb->asoc.ifp_had_enobuf = 0;
     11601        }
    1152611602        SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
    1152711603        return;
     
    1189811974                SCTP_STAT_INCR(sctps_sendnocrc);
    1189911975#else
    11900                 shout->checksum = sctp_calculate_cksum(mout, 0);
    11901                 SCTP_STAT_INCR(sctps_sendswcrc);
     11976                if (SCTP_BASE_VAR(crc32c_offloaded) == 0) {
     11977                        shout->checksum = sctp_calculate_cksum(mout, 0);
     11978                        SCTP_STAT_INCR(sctps_sendswcrc);
     11979                } else {
     11980                        SCTP_STAT_INCR(sctps_sendhwcrc);
     11981                }
    1190211982#endif
    1190311983#ifdef SCTP_PACKET_LOGGING
     
    1288312963                        stcb->asoc.strmout[i].next_mid_unordered = oldstream[i].next_mid_unordered;
    1288412964                        stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete;
    12885                         stcb->asoc.strmout[i].stream_no = i;
     12965                        stcb->asoc.strmout[i].sid = i;
    1288612966                        stcb->asoc.strmout[i].state = oldstream[i].state;
    1288712967                        /* FIX ME FIX ME */
     
    1291112991                        stcb->asoc.strmout[i].next_mid_ordered = 0;
    1291212992                        stcb->asoc.strmout[i].next_mid_unordered = 0;
    12913                         stcb->asoc.strmout[i].stream_no = i;
     12993                        stcb->asoc.strmout[i].sid = i;
    1291412994                        stcb->asoc.strmout[i].last_msg_incomplete = 0;
    1291512995                        stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], NULL);
     
    1322313303        (void)SCTP_GETTIME_TIMEVAL(&sp->ts);
    1322413304
    13225         sp->stream = srcv->sinfo_stream;
     13305        sp->sid = srcv->sinfo_stream;
    1322613306#if defined(__APPLE__)
    1322713307#if defined(APPLE_LEOPARD)
     
    1483814918
    1483914919        /* get prefix entry of address */
     14920#if defined(__FreeBSD__)
     14921        ND6_RLOCK();
     14922#endif
    1484014923        LIST_FOREACH(pfx, &MODULE_GLOBAL(nd_prefix), ndpr_entry) {
    1484114924                if (pfx->ndpr_stateflags & NDPRF_DETACHED)
     
    1484714930        /* no prefix entry in the prefix list */
    1484814931        if (pfx == NULL) {
     14932#if defined(__FreeBSD__)
     14933                ND6_RUNLOCK();
     14934#endif
    1484914935                SCTPDBG(SCTP_DEBUG_OUTPUT2, "No prefix entry for ");
    1485014936                SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, (struct sockaddr *)src6);
     
    1486814954                SCTPDBG(SCTP_DEBUG_OUTPUT2, "installed router is ");
    1486914955                SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT2, ro->ro_rt->rt_gateway);
    14870                 if (sctp_cmpaddr((struct sockaddr *)&gw6,
    14871                                 ro->ro_rt->rt_gateway)) {
     14956                if (sctp_cmpaddr((struct sockaddr *)&gw6, ro->ro_rt->rt_gateway)) {
     14957#if defined(__FreeBSD__)
     14958                        ND6_RUNLOCK();
     14959#endif
    1487214960                        SCTPDBG(SCTP_DEBUG_OUTPUT2, "pfxrouter is installed\n");
    1487314961                        return (1);
    1487414962                }
    1487514963        }
     14964#if defined(__FreeBSD__)
     14965        ND6_RUNLOCK();
     14966#endif
    1487614967        SCTPDBG(SCTP_DEBUG_OUTPUT2, "pfxrouter is not installed\n");
    1487714968        return (0);
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 295072 2016-01-30 12:58:38Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c

    r211817 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 303813 2016-08-07 12:51:13Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 313330 2017-02-06 08:49:57Z ae $");
    3636#endif
    3737
     
    28562856                return (ENOBUFS);
    28572857        }
    2858 #ifdef IPSEC
    2859 #if !(defined(__APPLE__))
    2860         error = ipsec_init_policy(so, &inp->ip_inp.inp.inp_sp);
    2861 #else
    2862         error = 0;
    2863 #endif
    2864         if (error != 0) {
    2865 #if defined(__FreeBSD__)
    2866                 crfree(inp->ip_inp.inp.inp_cred);
    2867 #endif
    2868                 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
    2869                 SCTP_INP_INFO_WUNLOCK();
    2870                 return error;
    2871         }
    2872 #endif                          /* IPSEC */
    28732858        SCTP_INCR_EP_COUNT();
    28742859        inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
     
    29132898#if defined(__FreeBSD__)
    29142899                crfree(inp->ip_inp.inp.inp_cred);
    2915 #ifdef IPSEC
    2916                 ipsec_delete_pcbpolicy(&inp->ip_inp.inp);
    2917 #endif
    29182900#endif
    29192901                SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
     
    29382920#if defined(__FreeBSD__)
    29392921                crfree(inp->ip_inp.inp.inp_cred);
    2940 #ifdef IPSEC
    2941                 ipsec_delete_pcbpolicy(&inp->ip_inp.inp);
    2942 #endif
    29432922#endif
    29442923                SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
     
    29552934#if defined(__FreeBSD__)
    29562935                crfree(inp->ip_inp.inp.inp_cred);
    2957 #ifdef IPSEC
    2958                 ipsec_delete_pcbpolicy(&inp->ip_inp.inp);
    2959 #endif
    29602936#endif
    29612937                SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
     
    29772953                SCTP_HASH_FREE(inp->sctp_tcbhash, inp->sctp_hashmark);
    29782954                so->so_pcb = NULL;
    2979 #if defined(__FreeBSD__)
    2980                 crfree(inp->ip_inp.inp.inp_cred);
    2981 #ifdef IPSEC
    2982                 ipsec_delete_pcbpolicy(&inp->ip_inp.inp);
    2983 #endif
    2984 #endif
    29852955                SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
    29862956                SCTP_UNLOCK_EXC(SCTP_BASE_INFO(sctbinfo).ipi_lock);
     
    42724242         * sctp_free_assoc() call.
    42734243         */
    4274 #ifdef IPSEC
    4275         ipsec_delete_pcbpolicy(ip_pcb);
    4276 #endif
    42774244#ifndef __Panda__
    42784245        if (ip_pcb->inp_options) {
     
    55905557                                                uint32_t strseq;
    55915558                                                stcb->asoc.control_pdapi = sq;
    5592                                                 strseq = (sq->sinfo_stream << 16) | sq->sinfo_ssn;
     5559                                                strseq = (sq->sinfo_stream << 16) | (sq->mid & 0x0000ffff);
    55935560                                                sctp_ulp_notify(SCTP_NOTIFY_PARTIAL_DELVIERY_INDICATION,
    55945561                                                                stcb,
     
    56905657                                socantrcvmore_locked(so);
    56915658#endif
     5659                                socantsendmore(so);
    56925660                                sctp_sowwakeup(inp, so);
    56935661                                sctp_sorwakeup(inp, so);
     
    58185786        /* pending send queue SHOULD be empty */
    58195787        TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
    5820                 if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
    5821                         asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
     5788                if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
     5789                        asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
    58225790#ifdef INVARIANTS
    58235791                } else {
    5824                         panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number);
     5792                        panic("No chunks on the queues for sid %u.", chk->rec.data.sid);
    58255793#endif
    58265794                }
     
    58505818        TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) {
    58515819                if (chk->sent != SCTP_DATAGRAM_NR_ACKED) {
    5852                         if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
    5853                                 asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
     5820                        if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
     5821                                asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
    58545822#ifdef INVARIANTS
    58555823                        } else {
    5856                                 panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number);
     5824                                panic("No chunks on the queues for sid %u.", chk->rec.data.sid);
    58575825#endif
    58585826                        }
     
    68456813#endif
    68466814#if defined(__Userspace__)
    6847         mbuf_init(NULL);
    6848     // atomic_init();
     6815        mbuf_initialize(NULL);
    68496816#if defined(INET) || defined(INET6)
    68506817        recv_thread_init();
     
    79277894                                TAILQ_FOREACH_SAFE(chk, &ctl->reasm, sctp_next, nchk) {
    79287895                                        cnt++;
    7929                                         SCTP_CALC_TSN_TO_GAP(gap, chk->rec.data.TSN_seq, asoc->mapping_array_base_tsn);
     7896                                        SCTP_CALC_TSN_TO_GAP(gap, chk->rec.data.tsn, asoc->mapping_array_base_tsn);
    79307897                                        asoc->size_on_reasm_queue = sctp_sbspace_sub(asoc->size_on_reasm_queue, chk->send_size);
    79317898                                        sctp_ucount_decr(asoc->cnt_on_reasm_queue);
     
    79697936                                TAILQ_FOREACH_SAFE(chk, &ctl->reasm, sctp_next, nchk) {
    79707937                                        cnt++;
    7971                                         SCTP_CALC_TSN_TO_GAP(gap, chk->rec.data.TSN_seq, asoc->mapping_array_base_tsn);
     7938                                        SCTP_CALC_TSN_TO_GAP(gap, chk->rec.data.tsn, asoc->mapping_array_base_tsn);
    79727939                                        asoc->size_on_reasm_queue = sctp_sbspace_sub(asoc->size_on_reasm_queue, chk->send_size);
    79737940                                        sctp_ucount_decr(asoc->cnt_on_reasm_queue);
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 298942 2016-05-02 20:56:11Z pfg $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    342342        int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df);
    343343        void (*debug_printf)(const char *format, ...);
     344        int crc32c_offloaded;
    344345#endif
    345346};
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 243516 2012-11-25 14:25:08Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c

    r210942 r218849  
    2929#ifdef __FreeBSD__
    3030#include <sys/cdefs.h>
    31 __FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 303793 2016-08-06 12:51:07Z tuexen $");
     31__FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 310590 2016-12-26 11:06:41Z tuexen $");
    3232#endif
    3333
     
    299299                } else {
    300300                        strqt = TAILQ_FIRST(&asoc->ss_data.out.wheel);
    301                         while (strqt != NULL && (strqt->stream_no < strq->stream_no)) {
     301                        while (strqt != NULL && (strqt->sid < strq->sid)) {
    302302                                strqt = TAILQ_NEXT(strqt, ss_params.rr.next_spoke);
    303303                        }
     
    866866default_again:
    867867        if (sp != NULL) {
    868                 strq = &asoc->strmout[sp->stream];
     868                strq = &asoc->strmout[sp->sid];
    869869        } else {
    870870                strq = NULL;
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 303792 2016-08-06 12:33:15Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    447447
    448448struct sctp_data_chunkrec {
    449         uint32_t TSN_seq;       /* the TSN of this transmit */
    450         uint32_t stream_seq;    /* the stream sequence number of this transmit */
    451         uint16_t stream_number; /* the stream number of this guy */
    452         uint32_t payloadtype;
     449        uint32_t tsn;           /* the TSN of this transmit */
     450        uint32_t mid;           /* the message identifier of this transmit */
     451        uint16_t sid;           /* the stream number of this guy */
     452        uint32_t ppid;
    453453        uint32_t context;       /* from send */
    454454        uint32_t cwnd_at_send;
     
    459459        uint32_t fast_retran_tsn;       /* sending_seq at the time of FR */
    460460        struct timeval timetodrop;      /* time we drop it from queue */
    461         uint32_t fsn_num;               /* Fragment Sequence Number */
     461        uint32_t fsn;                   /* Fragment Sequence Number */
    462462        uint8_t doing_fast_retransmit;
    463463        uint8_t rcv_flags;      /* flags pulled from data chunk on inbound for
     
    514514struct sctp_queued_to_read {    /* sinfo structure Pluse more */
    515515        uint16_t sinfo_stream;  /* off the wire */
    516         uint32_t sinfo_ssn;     /* off the wire */
    517516        uint16_t sinfo_flags;   /* SCTP_UNORDERED from wire use SCTP_EOF for
    518517                                 * EOR */
     
    524523        sctp_assoc_t sinfo_assoc_id;    /* our assoc id */
    525524        /* Non sinfo stuff */
    526         uint32_t msg_id;        /* Fragment Index */
     525        uint32_t mid;           /* Fragment Index */
    527526        uint32_t length;        /* length of data */
    528527        uint32_t held_length;   /* length held in sb */
     
    585584        uint32_t context;
    586585        uint16_t sinfo_flags;
    587         uint16_t stream;
     586        uint16_t sid;
    588587        uint16_t act_flags;
    589588        uint16_t auth_keyid;
     
    604603        struct sctp_readhead inqueue;
    605604        struct sctp_readhead uno_inqueue;
    606         uint32_t last_sequence_delivered;       /* used for re-order */
    607         uint16_t stream_no;
     605        uint32_t last_mid_delivered;    /* used for re-order */
     606        uint16_t sid;
    608607        uint8_t  delivery_started;
    609608        uint8_t  pd_api_started;
     
    687686        uint32_t next_mid_ordered;
    688687        uint32_t next_mid_unordered;
    689         uint16_t stream_no;
     688        uint16_t sid;
    690689        uint8_t last_msg_incomplete;
    691690        uint8_t state;
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 303024 2016-07-19 09:48:08Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 299273 2016-05-09 16:35:05Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 313030 2017-01-31 23:34:02Z tuexen $");
    3636#endif
    3737
     
    430430        asoc = &stcb->asoc;
    431431        TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) {
    432                 if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.TSN_seq)) {
     432                if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.tsn)) {
    433433                        SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n",
    434                                     (void *)chk, chk->rec.data.TSN_seq, asoc->last_acked_seq);
     434                                    (void *)chk, chk->rec.data.tsn, asoc->last_acked_seq);
    435435                        if (chk->sent != SCTP_DATAGRAM_NR_ACKED) {
    436                                 if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
    437                                         asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
    438                                 }
    439                         }
    440                         if ((asoc->strmout[chk->rec.data.stream_number].chunks_on_queues == 0) &&
    441                             (asoc->strmout[chk->rec.data.stream_number].state == SCTP_STREAM_RESET_PENDING) &&
    442                             TAILQ_EMPTY(&asoc->strmout[chk->rec.data.stream_number].outqueue)) {
     436                                if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
     437                                        asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
     438                                }
     439                        }
     440                        if ((asoc->strmout[chk->rec.data.sid].chunks_on_queues == 0) &&
     441                            (asoc->strmout[chk->rec.data.sid].state == SCTP_STREAM_RESET_PENDING) &&
     442                            TAILQ_EMPTY(&asoc->strmout[chk->rec.data.sid].outqueue)) {
    443443                                asoc->trigger_reset = 1;
    444444                        }
     
    463463        SCTP_PRINTF("after recover order is as follows\n");
    464464        TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
    465                 SCTP_PRINTF("chk:%p TSN:%x\n", (void *)chk, chk->rec.data.TSN_seq);
     465                SCTP_PRINTF("chk:%p TSN:%x\n", (void *)chk, chk->rec.data.tsn);
    466466        }
    467467}
     
    551551#endif
    552552        TAILQ_FOREACH_SAFE(chk, &stcb->asoc.sent_queue, sctp_next, nchk) {
    553                 if (SCTP_TSN_GE(stcb->asoc.last_acked_seq, chk->rec.data.TSN_seq)) {
     553                if (SCTP_TSN_GE(stcb->asoc.last_acked_seq, chk->rec.data.tsn)) {
    554554                        /* Strange case our list got out of order? */
    555555                        SCTP_PRINTF("Our list is out of order? last_acked:%x chk:%x\n",
    556                                     (unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.TSN_seq);
     556                                    (unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.tsn);
    557557                        recovery_cnt++;
    558558#ifdef INVARIANTS
     
    579579                        /* validate its been outstanding long enough */
    580580                        if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    581                                 sctp_log_fr(chk->rec.data.TSN_seq,
     581                                sctp_log_fr(chk->rec.data.tsn,
    582582                                            chk->sent_rcv_time.tv_sec,
    583583                                            chk->sent_rcv_time.tv_usec,
     
    647647                                if (fir == 0) {
    648648                                        fir = 1;
    649                                         tsnfirst = chk->rec.data.TSN_seq;
    650                                 }
    651                                 tsnlast = chk->rec.data.TSN_seq;
     649                                        tsnfirst = chk->rec.data.tsn;
     650                                }
     651                                tsnlast = chk->rec.data.tsn;
    652652                                if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
    653                                         sctp_log_fr(chk->rec.data.TSN_seq, chk->snd_count,
     653                                        sctp_log_fr(chk->rec.data.tsn, chk->snd_count,
    654654                                                    0, SCTP_FR_T3_MARKED);
    655655                                }
     
    667667                                                       chk->book_size,
    668668                                                       (uint32_t)(uintptr_t)chk->whoTo,
    669                                                        chk->rec.data.TSN_seq);
     669                                                       chk->rec.data.tsn);
    670670                                }
    671671                                sctp_flight_size_decrease(chk);
     
    697697                                        chk->rec.data.fast_retran_tsn = stcb->asoc.sending_seq;
    698698                                } else {
    699                                         chk->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.TSN_seq;
     699                                        chk->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.tsn;
    700700                                }
    701701                        }
     
    727727                SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
    728728                        tsnlast);
    729                 SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%ld\n",
    730                         num_mk, (u_long)stcb->asoc.peers_rwnd);
    731                 SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
    732                         tsnlast);
    733                 SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%d\n",
     729                SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%u\n",
    734730                        num_mk,
    735                         (int)stcb->asoc.peers_rwnd);
     731                        stcb->asoc.peers_rwnd);
    736732        }
    737733#endif
     
    795791                                                       chk->book_size,
    796792                                                       (uint32_t)(uintptr_t)chk->whoTo,
    797                                                        chk->rec.data.TSN_seq);
     793                                                       chk->rec.data.tsn);
    798794                                }
    799795
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 302950 2016-07-17 13:33:35Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 309607 2016-12-06 10:21:25Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 304573 2016-08-22 00:40:45Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 313031 2017-01-31 23:36:31Z tuexen $");
    3636#endif
    3737
     
    148148        SCTP_BASE_VAR(conn_output) = conn_output;
    149149        SCTP_BASE_VAR(debug_printf) = debug_printf;
     150        SCTP_BASE_VAR(crc32c_offloaded) = 0;
    150151#endif
    151152        sctp_pcb_init();
     
    255256        stcb->asoc.smallest_mtu = nxtsz;
    256257        /* now off to subtract IP_DF flag if needed */
    257         overhead = IP_HDR_SIZE;
     258        overhead = IP_HDR_SIZE + sizeof(struct sctphdr);
    258259        if (sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.peer_auth_chunks)) {
    259260                overhead += sctp_get_auth_chunk_len(stcb->asoc.peer_hmac_id);
     
    282283                                                       chk->book_size,
    283284                                                       (uint32_t)(uintptr_t)chk->whoTo,
    284                                                        chk->rec.data.TSN_seq);
     285                                                       chk->rec.data.tsn);
    285286                                }
    286287                                /* Clear any time so NO RTT is being done */
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 301114 2016-06-01 10:14:04Z bz $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 309682 2016-12-07 19:30:59Z tuexen $");
    3636#endif
    3737
     
    341341                stcb->asoc.fs_index = 0;\
    342342        stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
    343         stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \
     343        stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
    344344        stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
    345345        stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
     
    362362                stcb->asoc.fs_index = 0;\
    363363        stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
    364         stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \
     364        stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
    365365        stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
    366366        stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 304736 2016-08-24 06:22:53Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
     
    311311        sctp_clog.x.strlog.stcb = control->stcb;
    312312        sctp_clog.x.strlog.n_tsn = control->sinfo_tsn;
    313         sctp_clog.x.strlog.n_sseq = control->sinfo_ssn;
     313        sctp_clog.x.strlog.n_sseq = (uint16_t)control->mid;
    314314        sctp_clog.x.strlog.strm = control->sinfo_stream;
    315315        if (poschk != NULL) {
    316316                sctp_clog.x.strlog.e_tsn = poschk->sinfo_tsn;
    317                 sctp_clog.x.strlog.e_sseq = poschk->sinfo_ssn;
     317                sctp_clog.x.strlog.e_sseq = (uint16_t)poschk->mid;
    318318        } else {
    319319                sctp_clog.x.strlog.e_tsn = 0;
     
    12131213                asoc->strmout[i].abandoned_unsent[0] = 0;
    12141214#endif
    1215                 asoc->strmout[i].stream_no = i;
     1215                asoc->strmout[i].sid = i;
    12161216                asoc->strmout[i].last_msg_incomplete = 0;
    12171217                asoc->strmout[i].state = SCTP_STREAM_OPENING;
     
    31183118                ssfe->ssfe_error = error;
    31193119                /* not exactly what the user sent in, but should be close :) */
    3120                 ssfe->ssfe_info.snd_sid = chk->rec.data.stream_number;
     3120                ssfe->ssfe_info.snd_sid = chk->rec.data.sid;
    31213121                ssfe->ssfe_info.snd_flags = chk->rec.data.rcv_flags;
    3122                 ssfe->ssfe_info.snd_ppid = chk->rec.data.payloadtype;
     3122                ssfe->ssfe_info.snd_ppid = chk->rec.data.ppid;
    31233123                ssfe->ssfe_info.snd_context = chk->rec.data.context;
    31243124                ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb);
     
    31363136                ssf->ssf_error = error;
    31373137                /* not exactly what the user sent in, but should be close :) */
    3138                 ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number;
    3139                 ssf->ssf_info.sinfo_ssn = (uint16_t)chk->rec.data.stream_seq;
     3138                ssf->ssf_info.sinfo_stream = chk->rec.data.sid;
     3139                ssf->ssf_info.sinfo_ssn = (uint16_t)chk->rec.data.mid;
    31403140                ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags;
    3141                 ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype;
     3141                ssf->ssf_info.sinfo_ppid = chk->rec.data.ppid;
    31423142                ssf->ssf_info.sinfo_context = chk->rec.data.context;
    31433143                ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
     
    32223222                ssfe->ssfe_error = error;
    32233223                /* not exactly what the user sent in, but should be close :) */
    3224                 ssfe->ssfe_info.snd_sid = sp->stream;
     3224                ssfe->ssfe_info.snd_sid = sp->sid;
    32253225                if (sp->some_taken) {
    32263226                        ssfe->ssfe_info.snd_flags = SCTP_DATA_LAST_FRAG;
     
    32403240                ssf->ssf_error = error;
    32413241                /* not exactly what the user sent in, but should be close :) */
    3242                 ssf->ssf_info.sinfo_stream = sp->stream;
     3242                ssf->ssf_info.sinfo_stream = sp->sid;
    32433243                ssf->ssf_info.sinfo_ssn = 0;
    32443244                if (sp->some_taken) {
     
    40284028                asoc->sent_queue_cnt--;
    40294029                if (chk->sent != SCTP_DATAGRAM_NR_ACKED) {
    4030                         if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
    4031                                 asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
     4030                        if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
     4031                                asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
    40324032#ifdef INVARIANTS
    40334033                        } else {
    4034                                 panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number);
     4034                                panic("No chunks on the queues for sid %u.", chk->rec.data.sid);
    40354035#endif
    40364036                        }
     
    40524052                TAILQ_REMOVE(&asoc->send_queue, chk, sctp_next);
    40534053                asoc->send_queue_cnt--;
    4054                 if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
    4055                         asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
     4054                if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
     4055                        asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
    40564056#ifdef INVARIANTS
    40574057                } else {
    4058                         panic("No chunks on the queues for sid %u.", chk->rec.data.stream_number);
     4058                        panic("No chunks on the queues for sid %u.", chk->rec.data.sid);
    40594059#endif
    40604060                }
     
    48414841                memset(&rcv, 0, sizeof(struct sctp_rcvinfo));
    48424842                rcv.rcv_sid = control->sinfo_stream;
    4843                 rcv.rcv_ssn = control->sinfo_ssn;
     4843                rcv.rcv_ssn = (uint16_t)control->mid;
    48444844                rcv.rcv_flags = control->sinfo_flags;
    48454845                rcv.rcv_ppid = control->sinfo_ppid;
     
    50545054                no_user_data_cause->cause.code = htons(SCTP_CAUSE_NO_USER_DATA);
    50555055                no_user_data_cause->cause.length = htons(len);
    5056                 no_user_data_cause->tsn = tsn; /* tsn is passed in as NBO */
     5056                no_user_data_cause->tsn = htonl(tsn);
    50575057        }
    50585058        return (m);
     
    51055105        struct sctp_tmit_chunk *chk = NULL, *tp2;
    51065106        struct sctp_stream_queue_pending *sp;
    5107         uint16_t stream = 0, seq = 0;
     5107        uint32_t mid;
     5108        uint16_t sid;
    51085109        uint8_t foundeom = 0;
    51095110        int ret_sz = 0;
     
    51185119        }
    51195120#endif
    5120         stream = tp1->rec.data.stream_number;
    5121         seq = tp1->rec.data.stream_seq;
     5121        sid = tp1->rec.data.sid;
     5122        mid = tp1->rec.data.mid;
    51225123        if (sent || !(tp1->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG)) {
    51235124                stcb->asoc.abandoned_sent[0]++;
    51245125                stcb->asoc.abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++;
    5125                 stcb->asoc.strmout[stream].abandoned_sent[0]++;
     5126                stcb->asoc.strmout[sid].abandoned_sent[0]++;
    51265127#if defined(SCTP_DETAILED_STR_STATS)
    51275128                stcb->asoc.strmout[stream].abandoned_sent[PR_SCTP_POLICY(tp1->flags)]++;
     
    51305131                stcb->asoc.abandoned_unsent[0]++;
    51315132                stcb->asoc.abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++;
    5132                 stcb->asoc.strmout[stream].abandoned_unsent[0]++;
     5133                stcb->asoc.strmout[sid].abandoned_unsent[0]++;
    51335134#if defined(SCTP_DETAILED_STR_STATS)
    51345135                stcb->asoc.strmout[stream].abandoned_unsent[PR_SCTP_POLICY(tp1->flags)]++;
     
    51845185                 */
    51855186                TAILQ_FOREACH_SAFE(tp1, &stcb->asoc.send_queue, sctp_next, tp2) {
    5186                         if ((tp1->rec.data.stream_number != stream) ||
    5187                             (tp1->rec.data.stream_seq != seq)) {
     5187                        if ((tp1->rec.data.sid != sid) ||
     5188                            (!SCTP_MID_EQ(stcb->asoc.idata_supported, tp1->rec.data.mid, mid))) {
    51885189                                break;
    51895190                        }
     
    52255226                 */
    52265227                SCTP_TCB_SEND_LOCK(stcb);
    5227                 strq = &stcb->asoc.strmout[stream];
     5228                strq = &stcb->asoc.strmout[sid];
    52285229                sp = TAILQ_FIRST(&strq->outqueue);
    52295230                if (sp != NULL) {
     
    52525253                                if (stcb->asoc.idata_supported == 0) {
    52535254                                        if (sp->sinfo_flags & SCTP_UNORDERED) {
    5254                                                 chk->rec.data.stream_seq = 0;
     5255                                                chk->rec.data.mid = 0;
    52555256                                        } else {
    5256                                                 chk->rec.data.stream_seq = strq->next_mid_ordered;
     5257                                                chk->rec.data.mid = strq->next_mid_ordered;
    52575258                                        }
    52585259                                } else {
    52595260                                        if (sp->sinfo_flags & SCTP_UNORDERED) {
    5260                                                 chk->rec.data.stream_seq = strq->next_mid_unordered;
     5261                                                chk->rec.data.mid = strq->next_mid_unordered;
    52615262                                        } else {
    5262                                                 chk->rec.data.stream_seq = strq->next_mid_ordered;
     5263                                                chk->rec.data.mid = strq->next_mid_ordered;
    52635264                                        }
    52645265                                }
    5265                                 chk->rec.data.stream_number = sp->stream;
    5266                                 chk->rec.data.payloadtype = sp->ppid;
     5266                                chk->rec.data.sid = sp->sid;
     5267                                chk->rec.data.ppid = sp->ppid;
    52675268                                chk->rec.data.context = sp->context;
    52685269                                chk->flags = sp->act_flags;
    52695270                                chk->whoTo = NULL;
    52705271#if defined(__FreeBSD__) || defined(__Panda__)
    5271                                 chk->rec.data.TSN_seq = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1);
     5272                                chk->rec.data.tsn = atomic_fetchadd_int(&stcb->asoc.sending_seq, 1);
    52725273#else
    5273                                 chk->rec.data.TSN_seq = stcb->asoc.sending_seq++;
     5274                                chk->rec.data.tsn = stcb->asoc.sending_seq++;
    52745275#endif
    52755276                                strq->chunks_on_queues++;
     
    60566057        if ((sinfo != NULL) && (filling_sinfo != 0)) {
    60576058                sinfo->sinfo_stream = control->sinfo_stream;
    6058                 sinfo->sinfo_ssn = (uint16_t)control->sinfo_ssn;
     6059                sinfo->sinfo_ssn = (uint16_t)control->mid;
    60596060                sinfo->sinfo_flags = control->sinfo_flags;
    60606061                sinfo->sinfo_ppid = control->sinfo_ppid;
     
    61286129                entry->vtag = control->sinfo_assoc_id;
    61296130                entry->strm = control->sinfo_stream;
    6130                 entry->seq = control->sinfo_ssn;
     6131                entry->seq = (uint16_t)control->mid;
    61316132                entry->sz = control->length;
    61326133                entry->flgs = control->sinfo_flags;
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 298508 2016-04-23 09:15:58Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 310590 2016-12-26 11:06:41Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 302138 2016-06-23 09:13:15Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 313330 2017-02-06 08:49:57Z ae $");
    3636#endif
    3737
     
    6565#define APPLE_FILE_NO 9
    6666#endif
    67 #ifdef IPSEC
    68 #include <netipsec/ipsec.h>
    69 #include <netipsec/ipsec6.h>
    70 #endif /* IPSEC */
    71 
    7267#if !defined(__Userspace__)
    7368extern struct protosw inetsw[];
     
    799794        inp6->inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
    800795#endif
    801         /*
    802          * Hmm what about the IPSEC stuff that is missing here but in
    803          * sctp_attach()?
    804          */
    805796        SCTP_INP_WUNLOCK(inp);
    806797        return (0);
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h

    r210942 r218849  
    3333#ifdef __FreeBSD__
    3434#include <sys/cdefs.h>
    35 __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 298132 2016-04-16 21:34:49Z tuexen $");
     35__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 309607 2016-12-06 10:21:25Z tuexen $");
    3636#endif
    3737
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c

    r210942 r218849  
    122122#endif
    123123        /* Mbuf master zone, zone_mbuf, has already been
    124          * created in mbuf_init() */
     124         * created in mbuf_initialize() */
    125125        mret = SCTP_ZONE_GET(zone_mbuf, struct mbuf);
    126126#if defined(SCTP_SIMPLE_ALLOCATOR)
     
    328328/************ End functions to substitute umem_cache_alloc and umem_cache_free **************/
    329329
    330 /* __Userspace__
    331  * TODO: mbuf_init must be called in the initialization routines
    332  * of userspace stack.
    333  */
    334330void
    335 mbuf_init(void *dummy)
     331mbuf_initialize(void *dummy)
    336332{
    337333
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.h

    r210942 r218849  
    5959
    6060/* mbuf initialization function */
    61 void mbuf_init(void *);
     61void mbuf_initialize(void *);
    6262
    6363#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c

    r210942 r218849  
    4040#include <netinet/sctp_input.h>
    4141#include <netinet/sctp_peeloff.h>
     42#include <netinet/sctp_crc32.h>
    4243#ifdef INET6
    4344#include <netinet6/sctp6_var.h>
     
    33083309
    33093310void
     3311usrsctp_enable_crc32c_offload(void)
     3312{
     3313        SCTP_BASE_VAR(crc32c_offloaded) = 1;
     3314}
     3315
     3316void
     3317usrsctp_disable_crc32c_offload(void)
     3318{
     3319        SCTP_BASE_VAR(crc32c_offloaded) = 0;
     3320}
     3321
     3322/* Compute the CRC32C in network byte order */
     3323uint32_t
     3324usrsctp_crc32c(void *buffer, size_t length)
     3325{
     3326        uint32_t base = 0xffffffff;
     3327
     3328        base = calculate_crc32c(0xffffffff, (unsigned char *)buffer, (unsigned int) length);
     3329        base = sctp_finalize_crc32c(base);
     3330        return (base);
     3331}
     3332
     3333void
    33103334usrsctp_conninput(void *addr, const void *buffer, size_t length, uint8_t ecn_bits)
    33113335{
     
    33483372                                     sh, ch,
    33493373#if !defined(SCTP_WITH_NO_CSUM)
    3350                                      1,
     3374                                     SCTP_BASE_VAR(crc32c_offloaded) == 1 ? 0 : 1,
    33513375#endif
    33523376                                     ecn_bits,
     
    34023426USRSCTP_SYSCTL_SET_DEF(sctp_path_rtx_max_default)
    34033427USRSCTP_SYSCTL_SET_DEF(sctp_add_more_threshold)
     3428USRSCTP_SYSCTL_SET_DEF(sctp_nr_incoming_streams_default)
    34043429USRSCTP_SYSCTL_SET_DEF(sctp_nr_outgoing_streams_default)
    34053430USRSCTP_SYSCTL_SET_DEF(sctp_cmt_on_off)
     
    34823507USRSCTP_SYSCTL_GET_DEF(sctp_path_rtx_max_default)
    34833508USRSCTP_SYSCTL_GET_DEF(sctp_add_more_threshold)
     3509USRSCTP_SYSCTL_GET_DEF(sctp_nr_incoming_streams_default)
    34843510USRSCTP_SYSCTL_GET_DEF(sctp_nr_outgoing_streams_default)
    34853511USRSCTP_SYSCTL_GET_DEF(sctp_cmt_on_off)
  • trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h

    r210942 r218849  
    8787
    8888typedef uint32_t sctp_assoc_t;
     89
     90#if defined(_WIN32) && defined(_MSC_VER)
     91#pragma pack (push, 1)
     92#define SCTP_PACKED
     93#else
     94#define SCTP_PACKED __attribute__((packed))
     95#endif
     96
     97struct sctp_common_header {
     98        uint16_t source_port;
     99        uint16_t destination_port;
     100        uint32_t verification_tag;
     101        uint32_t crc32c;
     102} SCTP_PACKED;
     103
     104#if defined(_WIN32) && defined(_MSC_VER)
     105#pragma pack()
     106#endif
     107#undef SCTP_PACKED
    89108
    90109#define AF_CONN 123
     
    9911010void
    9921011usrsctp_freedumpbuffer(char *);
     1012
     1013void
     1014usrsctp_enable_crc32c_offload(void);
     1015
     1016void
     1017usrsctp_disable_crc32c_offload(void);
     1018
     1019uint32_t
     1020usrsctp_crc32c(void *, size_t);
    9931021
    9941022#define USRSCTP_SYSCTL_DECL(__field)                \
Note: See TracChangeset for help on using the changeset viewer.