├── .github └── workflows │ ├── build-with-cmake.yml │ └── cifuzz.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE.md ├── Makefile.am ├── Makefile.nmake ├── Manual.md ├── Manual.tex ├── README.md ├── bootstrap ├── cmake └── FindMbedTLS.cmake ├── configure.ac ├── fuzzer ├── CMakeLists.txt ├── CORPUS_CONNECT │ ├── addip-000000 │ ├── addip-000001 │ ├── addip-000002 │ ├── addip-000003 │ ├── addip-000004 │ ├── addip-000005 │ ├── addip-000006 │ ├── addip-000007 │ ├── addip-000008 │ ├── addip-000009 │ ├── addip-000010 │ ├── addip-000011 │ ├── asconf-001 │ ├── asconf-002 │ ├── asconf-ack-001 │ ├── asconf-ack-002 │ ├── asconf-ack-003 │ ├── clusterfuzz-testcase-fuzzer_connect-4524087830118400 │ ├── clusterfuzz-testcase-fuzzer_connect-4706780001861632 │ ├── clusterfuzz-testcase-fuzzer_connect-4750230994812928 │ ├── clusterfuzz-testcase-fuzzer_connect-4790592673153024 │ ├── clusterfuzz-testcase-fuzzer_connect-4846769996562432 │ ├── clusterfuzz-testcase-fuzzer_connect-5127495803469824 │ ├── clusterfuzz-testcase-fuzzer_connect-5204536192401408 │ ├── clusterfuzz-testcase-fuzzer_connect-5631536029499392 │ ├── clusterfuzz-testcase-fuzzer_connect-5634380847906816 │ ├── clusterfuzz-testcase-fuzzer_connect-5645105154752512 │ ├── clusterfuzz-testcase-fuzzer_connect-5649242005176320 │ ├── clusterfuzz-testcase-fuzzer_connect-5649768725872640 │ ├── clusterfuzz-testcase-fuzzer_connect-5667542357245952 │ ├── clusterfuzz-testcase-fuzzer_connect-5676652788449280 │ ├── clusterfuzz-testcase-fuzzer_connect-5686965006761984 │ ├── clusterfuzz-testcase-fuzzer_connect-5688015225094144 │ ├── clusterfuzz-testcase-fuzzer_connect-5722044720742400 │ ├── clusterfuzz-testcase-fuzzer_connect-5734997805236224 │ ├── clusterfuzz-testcase-fuzzer_connect-5736809862004736 │ ├── clusterfuzz-testcase-fuzzer_connect-5737686959915008 │ ├── clusterfuzz-testcase-fuzzer_connect-5741506257747968 │ ├── clusterfuzz-testcase-fuzzer_connect-5759310927233024 │ ├── clusterfuzz-testcase-fuzzer_unconnected-5767885871382528 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-4630702305050624 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-4651341199966208 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-4750230994812928 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-4790592673153024 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5141658569277440 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5686965006761984 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5703269247352832 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5738321340006400 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360 │ ├── clusterfuzz-testcase-minimized-fuzzer_connect-5989617778819072.fuzz │ ├── clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816 │ ├── crash-05e67e673bace8eba6b1b2498e734133c98e3674 │ ├── crash-0a63175dc6b51474dc08197431ec36d11db5e77b │ ├── crash-27ffd53d682a7908bf7569e32d904f049066b5d6 │ ├── data-1.bin │ ├── dummy-01 │ ├── ecn-cwr-000001 │ ├── ecn-echo-000001 │ ├── forward-tsn-000001 │ ├── heartbeat-ack-0001 │ ├── heartbeat-ack-0002 │ ├── init-ack-01 │ ├── init-ack-1.bin │ ├── leak-00bd871f5ce0596083fe8642c803c97f424b0c70 │ ├── leak-4e7e4f4a8318a1da7e35d9907d49e78d4a34dfc8 │ ├── rtcweb-000000 │ ├── rtcweb-000001 │ ├── rtcweb-000002 │ ├── rtcweb-000003 │ ├── rtcweb-000004 │ ├── rtcweb-000005 │ ├── rtcweb-000005-dopped │ ├── rtcweb-000005-sack │ ├── rtcweb-000005-sack-express │ ├── rtcweb-000006 │ ├── rtcweb-000007 │ ├── rtcweb-000008 │ ├── rtcweb-000009 │ ├── rtcweb-000010 │ ├── rtcweb-000011 │ ├── rtcweb-000011-dropped │ ├── rtcweb-000012 │ ├── rtcweb-000013 │ ├── rtcweb-000014 │ ├── rtcweb-000015 │ ├── rtcweb-000015-dropped │ ├── rtcweb-000016 │ ├── rtcweb-000017 │ ├── rtcweb-000018 │ ├── shutdown-000001 │ ├── shutdown-1.bin │ ├── shutdown-ack-1.bin │ ├── shutdown-complete-1.bin │ ├── timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 │ ├── tsctp-000000 │ ├── tsctp-000000-dropped │ ├── tsctp-000001 │ ├── tsctp-000002 │ ├── tsctp-000003 │ ├── tsctp-000004 │ ├── tsctp-000005 │ ├── tsctp-000006 │ ├── tsctp-000007 │ ├── tsctp-000008 │ ├── tsctp-000009 │ ├── tsctp-000010 │ ├── tsctp-i-data-000000 │ ├── tsctp-i-data-000001 │ ├── tsctp-i-data-000002 │ ├── tsctp-i-data-000003 │ ├── tsctp-i-data-000004 │ ├── tsctp-i-data-000005 │ ├── tsctp-i-data-000006 │ ├── tsctp-i-data-000007 │ ├── tsctp-i-data-000008 │ ├── tsctp-i-data-000009 │ └── tsctp-i-data-000010 ├── CORPUS_FRAGMENT │ ├── fragment-data-0001 │ ├── fragment-data-0002 │ ├── fragment-data-0003 │ ├── fragment-data-0004 │ ├── fragment-data-0005 │ ├── fragment-idata-0001 │ ├── fragment-idata-0002 │ ├── fragment-idata-0003 │ ├── fragment-idata-0004 │ ├── fragment-idata-0005 │ ├── nrsackfile-001 │ ├── nrsackfile-002 │ ├── nrsackfile-003 │ ├── nrsackfile-004 │ ├── nrsackfile-005 │ ├── nrsackfile-006 │ ├── nrsackfile-007 │ ├── nrsackfile-008 │ ├── sackfile-001 │ ├── sackfile-002 │ ├── sackfile-003 │ ├── sackfile-004 │ ├── sackfile-005 │ └── sackfile-006 ├── CORPUS_LISTEN │ ├── crash-05a51aa145847f45c22aff604a670abba80063aa │ └── init-1.bin ├── build-fuzzer.sh ├── check-input.sh ├── crashtest.py ├── fuzzer_connect.c ├── fuzzer_connect_multi.sh ├── fuzzer_fragment.c ├── fuzzer_fragment.sh ├── fuzzer_listen.c ├── fuzzer_listen.sh └── pcap2corpus.c ├── gen-def.py ├── meson.build ├── meson_options.txt ├── programs ├── CMakeLists.txt ├── Makefile.am ├── Makefile.nmake ├── chargen_server_upcall.c ├── client.c ├── client_upcall.c ├── daytime_server.c ├── daytime_server_upcall.c ├── discard_server.c ├── discard_server_upcall.c ├── echo_server.c ├── echo_server_upcall.c ├── ekr_client.c ├── ekr_loop.c ├── ekr_loop_upcall.c ├── ekr_peer.c ├── ekr_server.c ├── http_client.c ├── http_client_upcall.c ├── meson.build ├── programs_helper.c ├── programs_helper.h ├── rtcweb.c ├── st_client.c ├── test_libmgmt.c ├── test_timer.c ├── tsctp.c └── tsctp_upcall.c ├── usrsctp.pc.in └── usrsctplib ├── CMakeLists.txt ├── Makefile.am ├── Makefile.nmake ├── meson.build ├── netinet ├── meson.build ├── sctp.h ├── sctp_asconf.c ├── sctp_asconf.h ├── sctp_auth.c ├── sctp_auth.h ├── sctp_bsd_addr.c ├── sctp_bsd_addr.h ├── sctp_callout.c ├── sctp_callout.h ├── sctp_cc_functions.c ├── sctp_constants.h ├── sctp_crc32.c ├── sctp_crc32.h ├── sctp_header.h ├── sctp_indata.c ├── sctp_indata.h ├── sctp_input.c ├── sctp_input.h ├── sctp_lock_userspace.h ├── sctp_os.h ├── sctp_os_userspace.h ├── sctp_output.c ├── sctp_output.h ├── sctp_pcb.c ├── sctp_pcb.h ├── sctp_peeloff.c ├── sctp_peeloff.h ├── sctp_process_lock.h ├── sctp_sha1.c ├── sctp_sha1.h ├── sctp_ss_functions.c ├── sctp_structs.h ├── sctp_sysctl.c ├── sctp_sysctl.h ├── sctp_timer.c ├── sctp_timer.h ├── sctp_uio.h ├── sctp_userspace.c ├── sctp_usrreq.c ├── sctp_var.h ├── sctputil.c └── sctputil.h ├── netinet6 ├── meson.build ├── sctp6_usrreq.c └── sctp6_var.h ├── user_atomic.h ├── user_environment.c ├── user_environment.h ├── user_inpcb.h ├── user_ip6_var.h ├── user_ip_icmp.h ├── user_malloc.h ├── user_mbuf.c ├── user_mbuf.h ├── user_queue.h ├── user_recv_thread.c ├── user_recv_thread.h ├── user_route.h ├── user_socket.c ├── user_socketvar.h ├── user_uma.h └── usrsctp.h /.github/workflows/build-with-cmake.yml: -------------------------------------------------------------------------------- 1 | name: Build with CMake 2 | 3 | on: 4 | push: 5 | branches: [ master, github-actions ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | strategy: 13 | matrix: 14 | platform: [ubuntu-latest, macos-latest, windows-latest] 15 | cmake_build_type: [Debug, RelWithDebInfo] 16 | sctp_invariants: [ON, OFF] 17 | sctp_inet6: [ON, OFF] 18 | sctp_inet: [ON, OFF] 19 | sctp_debug: [ON, OFF] 20 | 21 | runs-on: ${{ matrix.platform }} 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | with: 26 | path: 'usrsctp_source' 27 | 28 | - name: Prepare dirs 29 | shell: bash 30 | run: | 31 | mkdir -p cmake_build 32 | mkdir -p cmake_install 33 | 34 | - name: Generate CMake project 35 | shell: bash 36 | run: | 37 | cd cmake_build 38 | cmake -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \ 39 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 40 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ 41 | -Dsctp_debug=${{ matrix.sctp_debug }} \ 42 | -Dsctp_invariants=${{ matrix.sctp_invariants }} \ 43 | -Dsctp_inet6=${{ matrix.sctp_inet6 }} \ 44 | -Dsctp_inet=${{ matrix.sctp_inet }} \ 45 | -Dsctp_build_programs=ON \ 46 | -Dsctp_build_fuzzer=OFF \ 47 | -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cmake_install \ 48 | ${GITHUB_WORKSPACE}/usrsctp_source 49 | 50 | - name: Build and install project 51 | shell: bash 52 | run: | 53 | cmake --build cmake_build \ 54 | --parallel 2 \ 55 | --config ${{ matrix.cmake_build_type }} \ 56 | --target install \ 57 | --clean-first 58 | -------------------------------------------------------------------------------- /.github/workflows/cifuzz.yml: -------------------------------------------------------------------------------- 1 | name: CIFuzz 2 | on: 3 | push: 4 | branches: [ master, github-actions ] 5 | pull_request: 6 | branches: [ master ] 7 | 8 | jobs: 9 | Fuzzing: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Build Fuzzers 13 | id: build 14 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 15 | with: 16 | oss-fuzz-project-name: 'usrsctp' 17 | dry-run: false 18 | - name: Run Fuzzers 19 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 20 | with: 21 | oss-fuzz-project-name: 'usrsctp' 22 | fuzz-seconds: 600 23 | dry-run: false 24 | - name: Upload Crash 25 | uses: actions/upload-artifact@v4 26 | if: failure() && steps.build.outcome == 'success' 27 | with: 28 | name: artifacts 29 | path: ./out/artifacts 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM 33 | 34 | # Automake and make releated stuff 35 | Makefile 36 | Makefile.in 37 | .deps 38 | .libs 39 | /autom4te.cache 40 | /aclocal.m4 41 | /compile 42 | /configure 43 | /depcomp 44 | /install-sh 45 | /missing 46 | /stamp-h1 47 | /config.guess 48 | /config.log 49 | /config.status 50 | /config.sub 51 | /libtool 52 | /ltmain.sh 53 | /m4 54 | /usrsctp.pc 55 | .dirstamp 56 | 57 | # binaries 58 | programs/chargen_server_upcall 59 | programs/client 60 | programs/client_upcall 61 | programs/daytime_server 62 | programs/daytime_server_upcall 63 | programs/discard_server 64 | programs/discard_server_upcall 65 | programs/echo_server 66 | programs/echo_server_upcall 67 | programs/ekr_client 68 | programs/ekr_loop 69 | programs/ekr_loop_upcall 70 | programs/ekr_peer 71 | programs/ekr_server 72 | programs/http_client 73 | programs/http_client_upcall 74 | programs/rtcweb 75 | programs/st_client 76 | programs/tsctp 77 | programs/test_libmgmt 78 | programs/test_timer 79 | 80 | # callgrind 81 | callgrind.out* 82 | 83 | # cmake build 84 | /build 85 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Randall Stewart and Michael Tuexen 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of usrsctp nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011-2012 Michael Tuexen 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | if COND_PROGRAMS 32 | MAYBEPROGRAMS = programs 33 | endif 34 | 35 | SUBDIRS = usrsctplib $(MAYBEPROGRAMS) 36 | EXTRA_DIST = bootstrap Makefile.nmake 37 | ACLOCAL_AMFLAGS = -I m4 38 | # pkgconfig_DATA = usrsctp.pc 39 | -------------------------------------------------------------------------------- /Makefile.nmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011-2012 Michael Tuexen 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | all: 32 | cd usrsctplib 33 | nmake -f Makefile.nmake 34 | cd .. 35 | cd programs 36 | nmake all -f Makefile.nmake 37 | cd .. 38 | 39 | clean: 40 | cd usrsctplib 41 | nmake clean -f Makefile.nmake 42 | cd .. 43 | cd programs 44 | nmake clean -f Makefile.nmake 45 | cd .. 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # usrsctp 2 | [![Coverity Scan Build Status](https://scan.coverity.com/projects/13430/badge.svg)](https://scan.coverity.com/projects/usrsctp) 3 | 4 | ![GitHub Actions Build Status (CMake-based build only)](https://github.com/sctplab/usrsctp/workflows/Build%20with%20CMake/badge.svg) 5 | 6 | This is a userland SCTP stack supporting FreeBSD, OpenBSD, Linux, Mac OS X and Windows. 7 | 8 | See [manual](Manual.md) for more information. 9 | 10 | The status of continuous integration testing is available from our [Buildbot](http://buildbot.nplab.de:18010/#/console). 11 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright (C) 2011-2012 Michael Tuexen 4 | # 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 3. Neither the name of the project nor the names of its contributors 16 | # may be used to endorse or promote products derived from this software 17 | # without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | # SUCH DAMAGE. 30 | # 31 | 32 | #bail out on error 33 | set -e 34 | 35 | #detect (g)libtoolize 36 | if which libtoolize >/dev/null 37 | then 38 | _LIBTOOLIZE=`which libtoolize` 39 | elif which glibtoolize >/dev/null 40 | then 41 | _LIBTOOLIZE=`which glibtoolize` 42 | else 43 | echo "ERROR: I cannot find libtoolize or glibtoolize!" 44 | exit 1 45 | fi 46 | 47 | #execute (g)libtoolize 48 | ${_LIBTOOLIZE} 49 | 50 | #execute aclocal 51 | if [ -e /usr/local/share/aclocal ] 52 | then 53 | aclocal -I /usr/local/share/aclocal 54 | elif [ -e /usr/share/aclocal ] 55 | then 56 | aclocal -I /usr/share/aclocal 57 | else 58 | aclocal 59 | fi 60 | 61 | #execute autoconf 62 | autoconf 63 | 64 | #generate the ./configure 65 | automake --foreign --add-missing --copy 66 | 67 | -------------------------------------------------------------------------------- /cmake/FindMbedTLS.cmake: -------------------------------------------------------------------------------- 1 | find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) 2 | 3 | find_library(MBEDTLS_LIBRARY mbedtls) 4 | find_library(MBEDX509_LIBRARY mbedx509) 5 | find_library(MBEDCRYPTO_LIBRARY mbedcrypto) 6 | 7 | set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}") 8 | 9 | include(FindPackageHandleStandardArgs) 10 | find_package_handle_standard_args(MbedTLS DEFAULT_MSG 11 | MBEDTLS_LIBRARY MBEDTLS_INCLUDE_DIRS MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) 12 | 13 | mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) 14 | 15 | if(NOT TARGET MbedTLS) 16 | message("in mbedtls ${MBEDTLS_LIBRARY}") 17 | add_library(MbedTLS UNKNOWN IMPORTED) 18 | set_target_properties(MbedTLS PROPERTIES 19 | INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" 20 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" 21 | IMPORTED_LOCATION "${MBEDTLS_LIBRARY}") 22 | endif() 23 | 24 | if(NOT TARGET MbedCrypto) 25 | add_library(MbedCrypto UNKNOWN IMPORTED) 26 | set_target_properties(MbedCrypto PROPERTIES 27 | INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" 28 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" 29 | IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}") 30 | endif() 31 | 32 | if(NOT TARGET MbedX509) 33 | add_library(MbedX509 UNKNOWN IMPORTED) 34 | set_target_properties(MbedX509 PROPERTIES 35 | INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" 36 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" 37 | IMPORTED_LOCATION "${MBEDX509_LIBRARY}") 38 | endif() 39 | -------------------------------------------------------------------------------- /fuzzer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015-2020 Felix Weinrank 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | #project(usrsctp-fuzzer C) 32 | 33 | ################################################# 34 | # INCLUDE MODULES 35 | ################################################# 36 | 37 | include(CheckIncludeFile) 38 | 39 | 40 | ################################################# 41 | # CHECK INCLUDES 42 | ################################################# 43 | 44 | include_directories(${CMAKE_SOURCE_DIR}/usrsctplib) 45 | 46 | 47 | ################################################# 48 | # OS DEPENDENT 49 | ################################################# 50 | 51 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 52 | add_definitions(-D_GNU_SOURCE) 53 | endif () 54 | 55 | if (CMAKE_SYSTEM_NAME MATCHES "Darwin") 56 | add_definitions(-D__APPLE_USE_RFC_2292) 57 | endif () 58 | 59 | ################################################# 60 | # COMPILER FLAGS 61 | ################################################# 62 | 63 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-variable") 64 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer") 65 | 66 | 67 | ################################################# 68 | # PROGRAMS 69 | ################################################# 70 | 71 | # FUZZING_STAGE LEVELS 72 | # 0 - MULTI - based on input 73 | # 1 - COOKIE_WAIT 74 | # 2 - COOKIE_ECHO 75 | # 3 - ESTABLISHED 76 | # 4 - DATA SENT 77 | # 5 - DATA RECEIVED 78 | 79 | add_executable(fuzzer_listen fuzzer_listen.c ../programs/programs_helper.c) 80 | target_link_libraries(fuzzer_listen usrsctp) 81 | 82 | add_executable(fuzzer_listen_verbose fuzzer_listen.c ../programs/programs_helper.c) 83 | target_compile_definitions(fuzzer_listen_verbose PRIVATE FUZZ_VERBOSE) 84 | target_link_libraries(fuzzer_listen_verbose usrsctp) 85 | 86 | add_executable(fuzzer_fragment fuzzer_fragment.c ../programs/programs_helper.c) 87 | target_link_libraries(fuzzer_fragment usrsctp) 88 | 89 | add_executable(fuzzer_connect_multi fuzzer_connect.c ../programs/programs_helper.c) 90 | target_compile_definitions(fuzzer_connect_multi PRIVATE FUZZING_STAGE=0) 91 | target_link_libraries(fuzzer_connect_multi usrsctp) 92 | 93 | add_executable(fuzzer_connect_multi_verbose fuzzer_connect.c ../programs/programs_helper.c) 94 | target_compile_definitions(fuzzer_connect_multi_verbose PRIVATE FUZZING_STAGE=0 FUZZ_VERBOSE) 95 | target_link_libraries(fuzzer_connect_multi_verbose usrsctp) 96 | 97 | # add_executable(fuzzer_connect_cookie_wait fuzzer_connect.c) 98 | # target_compile_definitions(fuzzer_connect_cookie_wait PRIVATE FUZZING_STAGE=1) 99 | # target_link_libraries(fuzzer_connect_cookie_wait usrsctp) 100 | 101 | # add_executable(fuzzer_connect_cookie_echoed fuzzer_connect.c) 102 | # target_compile_definitions(fuzzer_connect_cookie_echoed PRIVATE FUZZING_STAGE=2) 103 | # target_link_libraries(fuzzer_connect_cookie_echoed usrsctp) 104 | 105 | # add_executable(fuzzer_connect_established fuzzer_connect.c) 106 | # target_compile_definitions(fuzzer_connect_established PRIVATE FUZZING_STAGE=3) 107 | # target_link_libraries(fuzzer_connect_established usrsctp) 108 | 109 | # add_executable(fuzzer_connect_data_sent fuzzer_connect.c) 110 | # target_compile_definitions(fuzzer_connect_data_sent PRIVATE FUZZING_STAGE=4) 111 | # target_link_libraries(fuzzer_connect_data_sent usrsctp) 112 | 113 | # add_executable(fuzzer_connect_data_received fuzzer_connect.c) 114 | # target_compile_definitions(fuzzer_connect_data_received PRIVATE FUZZING_STAGE=5) 115 | # target_link_libraries(fuzzer_connect_data_received usrsctp) 116 | -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000000 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000003 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000006: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000006 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000007: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000007 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000008 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000009: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000009 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000010: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000010 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/addip-000011: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/addip-000011 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/asconf-001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/asconf-001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/asconf-002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/asconf-002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/asconf-ack-001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/asconf-ack-001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/asconf-ack-002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/asconf-ack-002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/asconf-ack-003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/asconf-ack-003 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4524087830118400: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4524087830118400 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4706780001861632: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4706780001861632 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4750230994812928: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4750230994812928 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4790592673153024: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4790592673153024 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4846769996562432: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-4846769996562432 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5127495803469824: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5127495803469824 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5631536029499392: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5631536029499392 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5667542357245952: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5667542357245952 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5686965006761984: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5686965006761984 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5737686959915008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5737686959915008 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4630702305050624: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4630702305050624 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4651341199966208: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4651341199966208 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4750230994812928: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4750230994812928 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4790592673153024: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-4790592673153024 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5141658569277440: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5141658569277440 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5686965006761984: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5686965006761984 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5703269247352832: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5703269247352832 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5738321340006400: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5738321340006400 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5989617778819072.fuzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5989617778819072.fuzz -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/crash-05e67e673bace8eba6b1b2498e734133c98e3674: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/crash-05e67e673bace8eba6b1b2498e734133c98e3674 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77b -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/data-1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/data-1.bin -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/dummy-01: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/dummy-01 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/ecn-cwr-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/ecn-cwr-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/ecn-echo-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/ecn-echo-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/forward-tsn-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/forward-tsn-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/heartbeat-ack-0001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/heartbeat-ack-0001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/heartbeat-ack-0002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/heartbeat-ack-0002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/init-ack-01: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/init-ack-01 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/init-ack-1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/init-ack-1.bin -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/leak-4e7e4f4a8318a1da7e35d9907d49e78d4a34dfc8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/leak-4e7e4f4a8318a1da7e35d9907d49e78d4a34dfc8 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000000 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000003: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000005-dopped: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000005-dopped -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000005-sack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000005-sack -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000005-sack-express: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000005-sack-express -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000006: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000006 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000007: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000007 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000008 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000009: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000009 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000010: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000010 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000011: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000011 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000011-dropped: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000011-dropped -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000012: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000012 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000013: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000013 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000014: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000014 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000015: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000015 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000015-dropped: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000015-dropped -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000016: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/rtcweb-000016 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000017: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/rtcweb-000018: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/shutdown-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/shutdown-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/shutdown-1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/shutdown-1.bin -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000000 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000000-dropped: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000000-dropped -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000003: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000006: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000006 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000007: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000007 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-000008 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000009: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-000010: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000000 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000003: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000006: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000006 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000007: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000007 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_CONNECT/tsctp-i-data-000008 -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000009: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_CONNECT/tsctp-i-data-000010: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-data-0001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-data-0001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-data-0002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-data-0002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-data-0003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-data-0003 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-data-0004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-data-0004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-data-0005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-data-0005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-idata-0001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-idata-0001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-idata-0002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-idata-0002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-idata-0003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-idata-0003 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-idata-0004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-idata-0004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/fragment-idata-0005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/fragment-idata-0005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-003 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-006: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-006 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-007: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-007 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/nrsackfile-008: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/nrsackfile-008 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/sackfile-001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/sackfile-001 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/sackfile-002: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/sackfile-002 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/sackfile-003: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/sackfile-003 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/sackfile-004: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/sackfile-004 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/sackfile-005: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/sackfile-005 -------------------------------------------------------------------------------- /fuzzer/CORPUS_FRAGMENT/sackfile-006: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_FRAGMENT/sackfile-006 -------------------------------------------------------------------------------- /fuzzer/CORPUS_LISTEN/crash-05a51aa145847f45c22aff604a670abba80063aa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_LISTEN/crash-05a51aa145847f45c22aff604a670abba80063aa -------------------------------------------------------------------------------- /fuzzer/CORPUS_LISTEN/init-1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sctplab/usrsctp/881513ab3fc75b4c53ffce7b22b08e7b07fcc67a/fuzzer/CORPUS_LISTEN/init-1.bin -------------------------------------------------------------------------------- /fuzzer/build-fuzzer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | NPROC=1 5 | 6 | # OS detection 7 | if [ "$(uname)" = "Linux" ]; then 8 | NPROC=$(nproc) 9 | CC=clang-12 10 | elif [ "$(uname)" = "Darwin" ]; then 11 | NPROC=$(sysctl -n hw.ncpu) 12 | CC=clang 13 | elif [ "$(uname)" = "FreeBSD" ]; then 14 | NPROC=$(sysctl -n hw.ncpu) 15 | CC=cc 16 | else 17 | echo "Error: $(uname) not supported, sorry!" 18 | exit 1 19 | fi 20 | 21 | # Check if we have a compiler 22 | if ! [ -x "$(command -v $CC)" ]; then 23 | echo "Error: $CC is not installed!" >&2 24 | exit 1 25 | fi 26 | 27 | echo "OS :" $(uname) 28 | echo "CC :" $CC 29 | echo "NP :" $NPROC 30 | 31 | # Go to script directory 32 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 33 | cd "$SCRIPT_DIR" 34 | cd ".." 35 | 36 | pwd 37 | 38 | # Find and then delete all files under current directory (.) that: 39 | # 1. contains "cmake" (case-&insensitive) in its path (wholename) 40 | # 2. name is not CMakeLists.txt 41 | find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete 42 | 43 | # Build with ASAN / MSAN 44 | cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" . 45 | #cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" . 46 | 47 | make -j"$NPROC" 48 | -------------------------------------------------------------------------------- /fuzzer/check-input.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # usage: check-input.sh input_data 5 | # 6 | 7 | set -e # stop on error 8 | set -u # uinitialized variables -> error! 9 | 10 | #make 11 | 12 | C_RED='\033[0;31m' # RED 13 | C_GRN='\033[0;32m' # RED 14 | C_NOC='\033[0m' # No Color 15 | 16 | echo "Fuzzer Input: $1" 17 | echo "########## Beginning Fuzzer Chain" 18 | echo "" 19 | 20 | set +e 21 | ./fuzzer_listen_verbose -timeout=10 $1 > $1.log 2>&1 22 | #./fuzzer_connect_multi_verbose -timeout=10 $1 > $1.log 2>&1 23 | FUZZER_RETVAL=$? 24 | set -e 25 | 26 | echo "Fuzzer returncode: $FUZZER_RETVAL" 27 | 28 | if [ "$FUZZER_RETVAL" -eq "0" ]; then 29 | echo -e "$C_RED" 30 | echo "$1 - NOT REPRODUCABLE" 31 | echo -e "$C_NOC" 32 | exit $FUZZER_RETVAL 33 | elif [ "$FUZZER_RETVAL" -eq "77" ]; then 34 | echo -e "$C_GRN" 35 | echo "$1 - REPRODUCABLE" 36 | echo -e "$C_NOC" 37 | else 38 | echo "Unexpected return code: $FUZZER_RETVAL - handle with care..!" 39 | #exit 40 | fi 41 | 42 | grep "# SCTP_PACKET" $1.log > $1.pcap-log 43 | text2pcap -n -l 248 -D -t "%H:%M:%S." $1.pcap-log $1.pcapng 44 | rm $1.pcap-log 45 | 46 | echo "" 47 | echo "LOG: $1.log" 48 | echo "PCAP: $1.pcapng" 49 | echo "" 50 | 51 | # Open Wireshark if we have an X session 52 | #if [ -z ${DISPLAY+x} ]; then 53 | #echo "\$DISPLAY unset, skipping wireshark" 54 | #else 55 | #wireshark $1.pcapng 56 | #fi 57 | 58 | exit $FUZZER_RETVAL 59 | -------------------------------------------------------------------------------- /fuzzer/crashtest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import glob 3 | import subprocess 4 | import os 5 | import re 6 | 7 | reportdir = "reports/" 8 | 9 | class bcolors: 10 | HEADER = '\033[95m' 11 | OKBLUE = '\033[94m' 12 | OKGREEN = '\033[92m' 13 | WARNING = '\033[93m' 14 | FAIL = '\033[91m' 15 | ENDC = '\033[0m' 16 | BOLD = '\033[1m' 17 | UNDERLINE = '\033[4m' 18 | 19 | 20 | print("Testing crashfiles") 21 | 22 | FNULL = open(os.devnull, "w") 23 | crashfiles = [] 24 | crashfiles.extend(glob.glob("*")) 25 | pattern = re.compile("^(leak-|timeout-|crash-)\w+$") 26 | 27 | filecounter = 1 28 | 29 | FNULL = open(os.devnull, 'w') 30 | 31 | for filename in crashfiles: 32 | 33 | if not pattern.match(filename): 34 | continue 35 | 36 | fuzzer_retval = subprocess.call(["./check-input.sh", filename, "batchmode"], stdout=FNULL, stderr=subprocess.STDOUT) 37 | 38 | if fuzzer_retval == 0: 39 | print(bcolors.FAIL, "[", filecounter, "]", filename,"- not reproducable", bcolors.ENDC) 40 | else: 41 | print(bcolors.OKGREEN, "[", filecounter, "]", filename, "- reproducable", bcolors.ENDC) 42 | 43 | filecounter = filecounter + 1 44 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_connect_multi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0:detect_leaks=1 4 | ulimit -c unlimited 5 | mkdir -p CORPUS_CONNECT 6 | 7 | NPROC=1 8 | 9 | if [[ "$OSTYPE" == "linux-gnu" ]]; then 10 | NPROC=$(nproc) 11 | elif [[ "$OSTYPE" == "darwin"* ]]; then 12 | NPROC=$(sysctl -n hw.ncpu) 13 | elif [[ "$OSTYPE" == "freebsd"* ]]; then 14 | NPROC=$(sysctl -n hw.ncpu) 15 | else 16 | exit 1 17 | fi 18 | 19 | echo "$NPROC" 20 | 21 | 22 | ./fuzzer_connect_multi -jobs=64 -timeout=10 -max_len=32000 -use_value_profile=1 CORPUS_CONNECT 23 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_fragment.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0 3 | ulimit -c unlimited 4 | mkdir -p CORPUS_LISTEN 5 | ./fuzzer_fragment -jobs=32 -timeout=10 -max_len=4086 CORPUS_FRAGMENT 6 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_listen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2020 Felix Weinrank 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "../programs/programs_helper.h" 36 | 37 | #define FUZZ_FAST 1 38 | 39 | #ifdef FUZZ_VERBOSE 40 | #define fuzzer_printf(...) debug_printf(__VA_ARGS__) 41 | #else 42 | #define fuzzer_printf(...) 43 | #endif 44 | 45 | struct sockaddr_conn sconn; 46 | struct socket *s_l; 47 | 48 | static void 49 | dump_packet(const void *buffer, size_t bufferlen, int inout) 50 | { 51 | #ifdef FUZZ_VERBOSE 52 | char *dump_buf; 53 | 54 | if ((dump_buf = usrsctp_dumppacket(buffer, bufferlen, inout)) != NULL) { 55 | fprintf(stderr, "%s", dump_buf); 56 | usrsctp_freedumpbuffer(dump_buf); 57 | } 58 | #endif // FUZZ_VERBOSE 59 | } 60 | 61 | static int 62 | conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df) 63 | { 64 | dump_packet(buf, length, SCTP_DUMP_OUTBOUND); 65 | return (0); 66 | } 67 | 68 | static void 69 | handle_upcall(struct socket *sock, void *arg, int flgs) 70 | { 71 | struct socket *conn_sock; 72 | struct sockaddr_in remote_addr; 73 | socklen_t addr_len = sizeof(struct sockaddr_in); 74 | 75 | memset(&remote_addr, 0, sizeof(struct sockaddr_in)); 76 | if (((conn_sock = usrsctp_accept(sock, (struct sockaddr *) &remote_addr, &addr_len)) == NULL) && (errno != EINPROGRESS)) { 77 | perror("usrsctp_accept"); 78 | } 79 | 80 | usrsctp_close(conn_sock); 81 | } 82 | 83 | int 84 | init_fuzzer(void) { 85 | static uint8_t initialized = 0; 86 | struct sctp_event event; 87 | uint16_t event_types[] = { 88 | SCTP_ASSOC_CHANGE, 89 | SCTP_PEER_ADDR_CHANGE, 90 | SCTP_SEND_FAILED_EVENT, 91 | SCTP_REMOTE_ERROR, 92 | SCTP_SHUTDOWN_EVENT, 93 | SCTP_ADAPTATION_INDICATION, 94 | SCTP_PARTIAL_DELIVERY_EVENT}; 95 | unsigned long i; 96 | struct linger so_linger; 97 | int result; 98 | 99 | #if defined(FUZZ_FAST) 100 | if (initialized) { 101 | return 0; 102 | } 103 | #endif 104 | 105 | #ifdef FUZZ_VERBOSE 106 | usrsctp_init(0, conn_output, debug_printf_stack); 107 | #else 108 | usrsctp_init(0, conn_output, NULL); 109 | #endif 110 | 111 | usrsctp_enable_crc32c_offload(); 112 | 113 | #ifdef SCTP_DEBUG 114 | usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL); 115 | #endif 116 | usrsctp_register_address((void *)1); 117 | 118 | if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, 0)) == NULL) { 119 | perror("usrsctp_socket"); 120 | exit(EXIT_FAILURE); 121 | } 122 | usrsctp_set_non_blocking(s_l, 1); 123 | 124 | /* Bind the server side. */ 125 | memset(&sconn, 0, sizeof(struct sockaddr_conn)); 126 | sconn.sconn_family = AF_CONN; 127 | #ifdef HAVE_SCONN_LEN 128 | sconn.sconn_len = sizeof(struct sockaddr_conn); 129 | #endif 130 | sconn.sconn_port = htons(5001); 131 | sconn.sconn_addr = (void *)1; 132 | if (usrsctp_bind(s_l, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) { 133 | perror("usrsctp_bind"); 134 | exit(EXIT_FAILURE); 135 | } 136 | 137 | memset(&event, 0, sizeof(event)); 138 | event.se_assoc_id = SCTP_FUTURE_ASSOC; 139 | event.se_on = 1; 140 | for (i = 0; i < sizeof(event_types)/sizeof(uint16_t); i++) { 141 | event.se_type = event_types[i]; 142 | if (usrsctp_setsockopt(s_l, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)) < 0) { 143 | perror("setsockopt SCTP_EVENT s_l"); 144 | exit(EXIT_FAILURE); 145 | } 146 | } 147 | 148 | /* Make server side passive... */ 149 | if (usrsctp_listen(s_l, 1) < 0) { 150 | perror("usrsctp_listen"); 151 | exit(EXIT_FAILURE); 152 | } 153 | 154 | so_linger.l_onoff = 1; 155 | so_linger.l_linger = 0; 156 | result = usrsctp_setsockopt(s_l, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(struct linger)); 157 | FUZZER_ASSERT(result == 0); 158 | 159 | usrsctp_set_upcall(s_l, handle_upcall, NULL); 160 | 161 | initialized = 1; 162 | 163 | return (0); 164 | } 165 | 166 | int 167 | LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size) 168 | { 169 | init_fuzzer(); 170 | 171 | if (data_size < 8 || data_size > 65535) { 172 | // Skip too small and too large packets 173 | return (0); 174 | } 175 | 176 | dump_packet(data, data_size, SCTP_DUMP_INBOUND); 177 | 178 | usrsctp_conninput((void *)1, data, data_size, 0); 179 | 180 | #if !defined(FUZZ_FAST) 181 | usrsctp_close(s_l); 182 | while (usrsctp_finish() != 0) { 183 | //sleep(1); 184 | } 185 | #endif 186 | 187 | return (0); 188 | } 189 | 190 | 191 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_listen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0 3 | ulimit -c unlimited 4 | mkdir -p CORPUS_LISTEN 5 | ./fuzzer_listen -jobs=36 -timeout=10 -max_len=4086 CORPUS_LISTEN 6 | -------------------------------------------------------------------------------- /fuzzer/pcap2corpus.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2017 Michael Tuexen 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | */ 27 | 28 | /* 29 | * Compile: cc -Wall -Werror -pedantic pcap2corpus.c -lpcap -o pcap2corpus 30 | * 31 | * Usage: pcap2corpus infile outfile_prefix [expression] 32 | * if no expression, a pcap filter, is provided, sctp is used. 33 | */ 34 | #define _GNU_SOURCE 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | static unsigned long nr_read = 0; 46 | static unsigned long nr_decaps = 0; 47 | 48 | #define PRE_PADDING 1 49 | 50 | struct args { 51 | struct bpf_program bpf_prog; 52 | char *filename_prefix; 53 | int (*is_ipv4)(const void *); 54 | int (*is_ipv6)(const void *); 55 | int linktype; 56 | unsigned int offset; 57 | }; 58 | 59 | /* 60 | * SCTP protocol - RFC4960. 61 | */ 62 | struct sctphdr { 63 | uint16_t src_port; /* source port */ 64 | uint16_t dest_port; /* destination port */ 65 | uint32_t v_tag; /* verification tag of packet */ 66 | uint32_t checksum; /* CRC32C checksum */ 67 | /* chunks follow... */ 68 | } __attribute__((packed)); 69 | 70 | static int 71 | loopback_is_ipv4(const void *bytes) 72 | { 73 | uint32_t family; 74 | 75 | family = *(const uint32_t *)bytes; 76 | return (family == 2); 77 | } 78 | 79 | static int 80 | loopback_is_ipv6(const void *bytes) 81 | { 82 | uint32_t family; 83 | 84 | family = *(const uint32_t *)bytes; 85 | return (family == 24 || family == 28 || family == 30); 86 | } 87 | 88 | static int 89 | ethernet_is_ipv4(const void *bytes) 90 | { 91 | const struct ether_header *ether_hdr; 92 | 93 | ether_hdr = (const struct ether_header *)bytes; 94 | return (ntohs(ether_hdr->ether_type) == ETHERTYPE_IP); 95 | } 96 | 97 | static int 98 | ethernet_is_ipv6(const void *bytes) 99 | { 100 | const struct ether_header *ether_hdr; 101 | 102 | ether_hdr = (const struct ether_header *)bytes; 103 | return (ntohs(ether_hdr->ether_type) == ETHERTYPE_IPV6); 104 | } 105 | 106 | static void 107 | packet_handler(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *bytes_in) 108 | { 109 | struct args *args; 110 | const u_char *bytes_out; 111 | FILE *file; 112 | char *filename; 113 | const struct ip *ip4_hdr_in; 114 | const struct ip6_hdr *ip6_hdr_in; 115 | size_t offset, length; 116 | int null = 0; 117 | 118 | args = (struct args *)(void *)user; 119 | bytes_out = NULL; 120 | if (pcap_offline_filter(&args->bpf_prog, pkthdr, bytes_in) == 0) { 121 | goto out; 122 | } 123 | if (pkthdr->caplen < args->offset) { 124 | goto out; 125 | } 126 | if (args->is_ipv4(bytes_in)) { 127 | offset = args->offset + sizeof(struct ip) + sizeof(struct sctphdr); 128 | if (pkthdr->caplen < offset) { 129 | goto out; 130 | } 131 | ip4_hdr_in = (const struct ip *)(const void *)(bytes_in + args->offset); 132 | if (ip4_hdr_in->ip_p == IPPROTO_SCTP) { 133 | unsigned int ip4_hdr_len; 134 | 135 | ip4_hdr_len = ip4_hdr_in->ip_hl << 2; 136 | offset = args->offset + ip4_hdr_len + sizeof(struct sctphdr); 137 | if (pkthdr->caplen < offset) { 138 | goto out; 139 | } 140 | bytes_out = bytes_in + offset; 141 | length = pkthdr->caplen - offset; 142 | } 143 | } 144 | if (args->is_ipv6(bytes_in)) { 145 | offset = args->offset + sizeof(struct ip6_hdr) + sizeof(struct sctphdr); 146 | if (pkthdr->caplen < offset) { 147 | goto out; 148 | } 149 | ip6_hdr_in = (const struct ip6_hdr *)(bytes_in + args->offset); 150 | if (ip6_hdr_in->ip6_nxt == IPPROTO_SCTP) { 151 | bytes_out = bytes_in + offset; 152 | length = pkthdr->caplen - offset; 153 | } 154 | } 155 | out: 156 | nr_read++; 157 | if (bytes_out != NULL) { 158 | if (asprintf(&filename, "%s-%06lu", args->filename_prefix, nr_decaps) < 0) { 159 | return; 160 | } 161 | file = fopen(filename, "w"); 162 | fwrite(&null, 1, PRE_PADDING, file); 163 | fwrite(bytes_out, length, 1, file); 164 | fclose(file); 165 | free(filename); 166 | nr_decaps++; 167 | } 168 | } 169 | 170 | static char * 171 | get_filter(int argc, char *argv[]) 172 | { 173 | char *result, *c; 174 | size_t len; 175 | int i; 176 | 177 | if (argc == 3) { 178 | if (asprintf(&result, "%s", "sctp") < 0) { 179 | return (NULL); 180 | } 181 | } else { 182 | len = 0; 183 | for (i = 3; i < argc; i++) { 184 | len += strlen(argv[i]) + 1; 185 | } 186 | result = malloc(len); 187 | c = result; 188 | for (i = 3; i < argc; i++) { 189 | c = stpcpy(c, argv[i]); 190 | if (i < argc - 1) { 191 | *c++ = ' '; 192 | } 193 | } 194 | } 195 | return (result); 196 | } 197 | 198 | int 199 | main(int argc, char *argv[]) 200 | { 201 | char errbuf[PCAP_ERRBUF_SIZE]; 202 | pcap_t *pcap_reader; 203 | char *filter; 204 | struct args args; 205 | 206 | if (argc < 3) { 207 | fprintf(stderr, "Usage: %s infile outfile_prefix [expression]\n", argv[0]); 208 | return (-1); 209 | } 210 | args.filename_prefix = argv[2]; 211 | pcap_reader = pcap_open_offline(argv[1], errbuf); 212 | if (pcap_reader == NULL) { 213 | fprintf(stderr, "Can't open input file %s: %s\n", argv[1], errbuf); 214 | return (-1); 215 | } 216 | args.linktype = pcap_datalink(pcap_reader); 217 | switch (args.linktype) { 218 | case DLT_NULL: 219 | args.is_ipv4 = loopback_is_ipv4; 220 | args.is_ipv6 = loopback_is_ipv6; 221 | args.offset = sizeof(uint32_t); 222 | break; 223 | case DLT_EN10MB: 224 | args.is_ipv4 = ethernet_is_ipv4; 225 | args.is_ipv6 = ethernet_is_ipv6; 226 | args.offset = sizeof(struct ether_header); 227 | break; 228 | default: 229 | fprintf(stderr, "Datalink type %d not supported\n", args.linktype); 230 | pcap_close(pcap_reader); 231 | return (-1); 232 | } 233 | filter = get_filter(argc, argv); 234 | if (pcap_compile(pcap_reader, &args.bpf_prog, filter, 1, PCAP_NETMASK_UNKNOWN) < 0) { 235 | fprintf(stderr, "Can't compile filter %s: %s\n", filter, pcap_geterr(pcap_reader)); 236 | free(filter); 237 | pcap_close(pcap_reader); 238 | return (-1); 239 | } 240 | free(filter); 241 | pcap_dispatch(pcap_reader, 0, packet_handler, (u_char *)&args); 242 | pcap_close(pcap_reader); 243 | fprintf(stderr, "%lu packets processed\n", nr_read); 244 | fprintf(stderr, "%lu packets decapsulated\n", nr_decaps); 245 | return (0); 246 | } 247 | -------------------------------------------------------------------------------- /gen-def.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # gen-def.py usrsctp.lib 4 | import re 5 | import sys 6 | import subprocess 7 | from shutil import which 8 | 9 | try: 10 | lib_file = sys.argv[1] 11 | except: 12 | print('Usage: gen-def.py LIB-FILE') 13 | exit(-1) 14 | 15 | print('EXPORTS') 16 | 17 | if which('dumpbin'): 18 | dumpbin_cmd = subprocess.run(['dumpbin', '/linkermember:1', lib_file], 19 | stdout=subprocess.PIPE) 20 | 21 | pattern = re.compile('\s*[0-9a-fA-F]+ _?(?Pusrsctp_[^\s]*)') 22 | 23 | for line in dumpbin_cmd.stdout.decode('utf-8').splitlines(): 24 | match = pattern.match(line) 25 | if match: 26 | print(match.group('functionname')) 27 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('sctp_invariants', type: 'boolean', value: false, 2 | description: 'Add runtime checks') 3 | option('sctp_debug', type: 'boolean', value: false, 4 | description: 'Provide debug information') 5 | option('sctp_inet', type: 'boolean', value: true, 6 | description: 'Support IPv4') 7 | option('sctp_inet6', type: 'boolean', value: true, 8 | description: 'Support IPv6') 9 | option('sctp_build_programs', type: 'boolean', value: true, 10 | description: 'Build example programs') 11 | -------------------------------------------------------------------------------- /programs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015-2015 Oleg Alexeenkov 3 | # Copyright (C) 2015-2020 Felix Weinrank 4 | # 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 3. Neither the name of the project nor the names of its contributors 16 | # may be used to endorse or promote products derived from this software 17 | # without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | # SUCH DAMAGE. 30 | # 31 | 32 | 33 | ################################################# 34 | # INCLUDE MODULES 35 | ################################################# 36 | 37 | include(CheckIncludeFile) 38 | 39 | 40 | ################################################# 41 | # CHECK INCLUDES 42 | ################################################# 43 | 44 | include_directories(${CMAKE_SOURCE_DIR}/usrsctplib) 45 | 46 | 47 | ################################################# 48 | # OS DEPENDENT 49 | ################################################# 50 | 51 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 52 | add_definitions(-D_GNU_SOURCE) 53 | endif () 54 | 55 | if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "iOS") 56 | add_definitions(-D__APPLE_USE_RFC_2292) 57 | endif () 58 | 59 | if (MSYS OR MINGW) 60 | message(STATUS "MSYS / MINGW") 61 | add_definitions(-D__USE_MINGW_ANSI_STDIO) 62 | # 0x0601 = Windows 7 API 63 | add_definitions(-DWINVER=0x0601) 64 | add_definitions(-D_WIN32_WINNT=0x0601) 65 | 66 | if (CMAKE_C_COMPILER_ID MATCHES "GNU") 67 | message(STATUS "MSYS / MINGW + GCC") 68 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format") 69 | endif () 70 | endif () 71 | 72 | 73 | ################################################# 74 | # MISC 75 | ################################################# 76 | 77 | find_package(Threads) 78 | 79 | 80 | ################################################# 81 | # PROGRAMS 82 | ################################################# 83 | 84 | list(APPEND check_programs 85 | chargen_server_upcall.c 86 | client.c 87 | client_upcall.c 88 | daytime_server.c 89 | daytime_server_upcall.c 90 | discard_server.c 91 | discard_server_upcall.c 92 | echo_server.c 93 | echo_server_upcall.c 94 | ekr_client.c 95 | ekr_loop.c 96 | ekr_loop_upcall.c 97 | ekr_peer.c 98 | ekr_server.c 99 | http_client.c 100 | http_client_upcall.c 101 | rtcweb.c 102 | st_client.c 103 | test_libmgmt.c 104 | test_timer.c 105 | tsctp.c 106 | tsctp_upcall.c 107 | ) 108 | 109 | foreach (source_file ${check_programs}) 110 | get_filename_component(source_file_we ${source_file} NAME_WE) 111 | add_executable( 112 | ${source_file_we} 113 | ${source_file} 114 | programs_helper.c 115 | ) 116 | 117 | target_link_libraries( 118 | ${source_file_we} 119 | "usrsctp" 120 | ${CMAKE_THREAD_LIBS_INIT} 121 | ) 122 | 123 | if (APPLE) 124 | set_target_properties( 125 | ${source_file_we} 126 | PROPERTIES 127 | XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER 128 | com.github.sctplab.usrsctp.${source_file_we} 129 | ) 130 | endif() 131 | endforeach () 132 | -------------------------------------------------------------------------------- /programs/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011-2012 Michael Tuexen 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | AM_CPPFLAGS = -I$(srcdir)/../usrsctplib 32 | EXTRA_DIST = \ 33 | Makefile.nmake \ 34 | test_libmgmt.c \ 35 | test_timer.c \ 36 | tsctp.c \ 37 | chargen_server_upcall.c \ 38 | daytime_server.c \ 39 | daytime_server_upcall.c \ 40 | discard_server.c \ 41 | discard_server_upcall.c \ 42 | echo_server.c \ 43 | echo_server_upcall.c \ 44 | client.c \ 45 | client_upcall.c \ 46 | rtcweb.c \ 47 | ekr_client.c \ 48 | ekr_server.c \ 49 | ekr_loop.c \ 50 | ekr_loop_upcall.c \ 51 | ekr_peer.c \ 52 | test_libmgmt.c \ 53 | http_client.c \ 54 | http_client_upcall.c \ 55 | st_client.c 56 | 57 | noinst_PROGRAMS = \ 58 | test_libmgmt \ 59 | test_timer \ 60 | tsctp \ 61 | chargen_server_upcall \ 62 | daytime_server \ 63 | daytime_server_upcall \ 64 | discard_server \ 65 | discard_server_upcall \ 66 | echo_server \ 67 | echo_server_upcall \ 68 | client \ 69 | client_upcall \ 70 | rtcweb \ 71 | ekr_client \ 72 | ekr_server \ 73 | ekr_loop \ 74 | ekr_loop_upcall \ 75 | ekr_peer \ 76 | test_libmgmt \ 77 | http_client \ 78 | http_client_upcall \ 79 | st_client 80 | 81 | test_libmgmt_SOURCES = programs_helper.c test_libmgmt.c 82 | test_libmgmt_LDADD = ../usrsctplib/libusrsctp.la 83 | test_timer_SOURCES = programs_helper.c test_timer.c 84 | test_timer_LDADD = ../usrsctplib/libusrsctp.la 85 | tsctp_SOURCES = programs_helper.c tsctp.c 86 | tsctp_LDADD = ../usrsctplib/libusrsctp.la 87 | chargen_server_upcall_SOURCES = programs_helper.c chargen_server_upcall.c 88 | chargen_server_upcall_LDADD = ../usrsctplib/libusrsctp.la 89 | daytime_server_SOURCES = programs_helper.c daytime_server.c 90 | daytime_server_LDADD = ../usrsctplib/libusrsctp.la 91 | daytime_server_upcall_SOURCES = programs_helper.c daytime_server_upcall.c 92 | daytime_server_upcall_LDADD = ../usrsctplib/libusrsctp.la 93 | discard_server_SOURCES = programs_helper.c discard_server.c 94 | discard_server_LDADD = ../usrsctplib/libusrsctp.la 95 | discard_server_upcall_SOURCES = programs_helper.c discard_server_upcall.c 96 | discard_server_upcall_LDADD = ../usrsctplib/libusrsctp.la 97 | echo_server_SOURCES = programs_helper.c echo_server.c 98 | echo_server_LDADD = ../usrsctplib/libusrsctp.la 99 | echo_server_upcall_SOURCES = programs_helper.c echo_server_upcall.c 100 | echo_server_upcall_LDADD = ../usrsctplib/libusrsctp.la 101 | client_SOURCES = programs_helper.c client.c 102 | client_LDADD = ../usrsctplib/libusrsctp.la 103 | client_upcall_SOURCES = programs_helper.c client_upcall.c 104 | client_upcall_LDADD = ../usrsctplib/libusrsctp.la 105 | rtcweb_SOURCES = programs_helper.c rtcweb.c 106 | rtcweb_LDADD = ../usrsctplib/libusrsctp.la 107 | ekr_server_SOURCES = programs_helper.c ekr_server.c 108 | ekr_server_LDADD = ../usrsctplib/libusrsctp.la 109 | ekr_client_SOURCES = programs_helper.c ekr_client.c 110 | ekr_client_LDADD = ../usrsctplib/libusrsctp.la 111 | ekr_peer_SOURCES = programs_helper.c ekr_peer.c 112 | ekr_peer_LDADD = ../usrsctplib/libusrsctp.la 113 | ekr_loop_SOURCES = programs_helper.c ekr_loop.c 114 | ekr_loop_LDADD = ../usrsctplib/libusrsctp.la 115 | ekr_loop_upcall_SOURCES = programs_helper.c ekr_loop_upcall.c 116 | ekr_loop_upcall_LDADD = ../usrsctplib/libusrsctp.la 117 | http_client_SOURCES = programs_helper.c http_client.c 118 | http_client_LDADD = ../usrsctplib/libusrsctp.la 119 | http_client_upcall_SOURCES = programs_helper.c http_client_upcall.c 120 | http_client_upcall_LDADD = ../usrsctplib/libusrsctp.la 121 | st_client_SOURCES = programs_helper.c st_client.c 122 | st_client_LDADD = ../usrsctplib/libusrsctp.la 123 | -------------------------------------------------------------------------------- /programs/Makefile.nmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011-2012 Michael Tuexen 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | CFLAGS=/W3 /WX /I..\usrsctplib 32 | 33 | CVARSDLL=-DINET -DINET6 34 | 35 | LINKFLAGS=/LIBPATH:..\usrsctplib usrsctp.lib 36 | 37 | .c.obj:: 38 | $(CC) $(CVARSDLL) $(CFLAGS) -Fd.\ -c $< 39 | 40 | all: \ 41 | programs_helper.obj \ 42 | client \ 43 | client_upcall \ 44 | daytime_server \ 45 | daytime_server_upcall \ 46 | discard_server \ 47 | discard_server_upcall \ 48 | echo_server \ 49 | echo_server_upcall \ 50 | tsctp \ 51 | rtcweb \ 52 | ekr_client \ 53 | ekr_server \ 54 | ekr_peer \ 55 | ekr_loop \ 56 | ekr_loop_upcall \ 57 | test_libmgmt \ 58 | http_client \ 59 | http_client_upcall \ 60 | st_client 61 | 62 | programs_helper.obj : programs_helper.c programs_helper.h 63 | cl $(CVARSDLL) $(CFLAGS) -c programs_helper.c 64 | 65 | client: 66 | $(CC) $(CFLAGS) $(CVARSDLL) -c client.c 67 | link -out:client.exe client.obj programs_helper.obj $(LINKFLAGS) 68 | 69 | client_upcall: 70 | $(CC) $(CFLAGS) $(CVARSDLL) -c client_upcall.c 71 | link -out:client_upcall.exe client_upcall.obj programs_helper.obj $(LINKFLAGS) 72 | 73 | daytime_server: 74 | $(CC) $(CFLAGS) $(CVARSDLL) -c daytime_server.c 75 | link -out:daytime_server.exe daytime_server.obj programs_helper.obj $(LINKFLAGS) 76 | 77 | daytime_server_upcall: 78 | $(CC) $(CFLAGS) $(CVARSDLL) -c daytime_server_upcall.c 79 | link -out:daytime_server_upcall.exe daytime_server_upcall.obj programs_helper.obj $(LINKFLAGS) 80 | 81 | discard_server: 82 | $(CC) $(CFLAGS) $(CVARSDLL) -c discard_server.c 83 | link -out:discard_server.exe discard_server.obj programs_helper.obj $(LINKFLAGS) 84 | 85 | discard_server_upcall: 86 | $(CC) $(CFLAGS) $(CVARSDLL) -c discard_server_upcall.c 87 | link -out:discard_server_upcall.exe discard_server_upcall.obj programs_helper.obj $(LINKFLAGS) 88 | 89 | echo_server: 90 | $(CC) $(CFLAGS) $(CVARSDLL) -c echo_server.c 91 | link -out:echo_server.exe echo_server.obj programs_helper.obj $(LINKFLAGS) 92 | 93 | echo_server_upcall: 94 | $(CC) $(CFLAGS) $(CVARSDLL) -c echo_server_upcall.c 95 | link -out:echo_server_upcall.exe echo_server_upcall.obj programs_helper.obj $(LINKFLAGS) 96 | 97 | tsctp: 98 | $(CC) $(CFLAGS) $(CVARSDLL) -c tsctp.c 99 | link -out:tsctp.exe tsctp.obj programs_helper.obj $(LINKFLAGS) 100 | 101 | rtcweb: 102 | $(CC) $(CFLAGS) $(CVARSDLL) -c rtcweb.c 103 | link -out:rtcweb.exe rtcweb.obj programs_helper.obj $(LINKFLAGS) 104 | 105 | ekr_client: 106 | $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_client.c 107 | link -out:ekr_client.exe ekr_client.obj programs_helper.obj $(LINKFLAGS) 108 | 109 | ekr_server: 110 | $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_server.c 111 | link -out:ekr_server.exe ekr_server.obj programs_helper.obj $(LINKFLAGS) 112 | 113 | ekr_peer: 114 | $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_peer.c 115 | link -out:ekr_peer.exe ekr_peer.obj programs_helper.obj $(LINKFLAGS) 116 | 117 | ekr_loop: 118 | $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop.c 119 | link -out:ekr_loop.exe ekr_loop.obj programs_helper.obj $(LINKFLAGS) 120 | 121 | ekr_loop_upcall: 122 | $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_upcall.c 123 | link -out:ekr_loop_upcall.exe ekr_loop_upcall.obj programs_helper.obj $(LINKFLAGS) 124 | 125 | test_libmgmt: 126 | $(CC) $(CFLAGS) $(CVARSDLL) -c test_libmgmt.c 127 | link -out:test_libmgmt.exe test_libmgmt.obj programs_helper.obj $(LINKFLAGS) 128 | 129 | http_client: 130 | $(CC) $(CFLAGS) $(CVARSDLL) -c http_client.c 131 | link -out:http_client.exe http_client.obj programs_helper.obj $(LINKFLAGS) 132 | 133 | http_client_upcall: 134 | $(CC) $(CFLAGS) $(CVARSDLL) -c http_client_upcall.c 135 | link -out:http_client_upcall.exe http_client_upcall.obj programs_helper.obj $(LINKFLAGS) 136 | 137 | st_client: 138 | $(CC) $(CFLAGS) $(CVARSDLL) -c st_client.c 139 | link -out:st_client.exe st_client.obj programs_helper.obj $(LINKFLAGS) 140 | 141 | clean: 142 | del /F client.exe 143 | del /F client.obj 144 | del /F client_upcall.exe 145 | del /F client_upcall.obj 146 | del /F daytime_server.exe 147 | del /F daytime_server.obj 148 | del /F daytime_server_upcall.exe 149 | del /F daytime_server_upcall.obj 150 | del /F discard_server.exe 151 | del /F discard_server.obj 152 | del /F discard_server_upcall.exe 153 | del /F discard_server_upcall.obj 154 | del /F echo_server.exe 155 | del /F echo_server.obj 156 | del /F echo_server_upcall.exe 157 | del /F echo_server_upcall.obj 158 | del /F tsctp.exe 159 | del /F tsctp.obj 160 | del /F rtcweb.exe 161 | del /F rtcweb.obj 162 | del /F ekr_client.exe 163 | del /F ekr_client.obj 164 | del /F ekr_server.exe 165 | del /F ekr_server.obj 166 | del /F ekr_peer.exe 167 | del /F ekr_peer.obj 168 | del /F ekr_loop.exe 169 | del /F ekr_loop.obj 170 | del /F ekr_loop_upcall.exe 171 | del /F ekr_loop_upcall.obj 172 | del /F test_libmgmt.exe 173 | del /F test_libmgmt.obj 174 | del /F http_client.exe 175 | del /F http_client.obj 176 | del /F http_client_upcall.exe 177 | del /F http_client_upcall.obj 178 | del /F st_client.exe 179 | del /F st_client.obj 180 | -------------------------------------------------------------------------------- /programs/chargen_server_upcall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Michael Tuexen 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Usage: chargen_server_upcall [local_encaps_port] [remote_encaps_port] 33 | */ 34 | 35 | #ifdef _WIN32 36 | #define _CRT_SECURE_NO_WARNINGS 37 | #endif 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #ifndef _WIN32 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #endif 51 | #include 52 | #include "programs_helper.h" 53 | 54 | #define BUFFERSIZE 10240 55 | #define PORT 19 56 | 57 | char buffer[95]; 58 | int done = 0; 59 | int send_done = 0; 60 | 61 | static void 62 | initBuffer(void) { 63 | int i, j; 64 | for (i = 32, j = 0; i < 126; i++, j++) { 65 | buffer[j] = i; 66 | } 67 | } 68 | 69 | unsigned int signCounter = 0; 70 | static void 71 | handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags); 72 | 73 | static void 74 | handle_accept(struct socket *upcall_socket, void *upcall_data, int upcall_flags) 75 | { 76 | struct socket *conn_sock; 77 | 78 | if (((conn_sock = usrsctp_accept(upcall_socket, NULL, NULL)) == NULL) 79 | && (errno != EINPROGRESS)) { 80 | perror("usrsctp_accept"); 81 | return; 82 | } 83 | done = 0; 84 | printf("connection accepted from socket %p\n", (void *)conn_sock); 85 | usrsctp_set_upcall(conn_sock, handle_upcall, NULL); 86 | } 87 | 88 | static void 89 | handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags) 90 | { 91 | int events = usrsctp_get_events(upcall_socket); 92 | 93 | if (events & SCTP_EVENT_READ && !send_done) { 94 | char *buf; 95 | struct sctp_recvv_rn rn; 96 | ssize_t n; 97 | struct sockaddr_storage addr; 98 | buf = malloc(BUFFERSIZE); 99 | int recv_flags = 0; 100 | socklen_t len = (socklen_t)sizeof(struct sockaddr_storage); 101 | unsigned int infotype = 0; 102 | socklen_t infolen = sizeof(struct sctp_recvv_rn); 103 | memset(&rn, 0, sizeof(struct sctp_recvv_rn)); 104 | 105 | n = usrsctp_recvv(upcall_socket, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn, 106 | &infolen, &infotype, &recv_flags); 107 | if (n < 0) { 108 | perror("usrsctp_recvv"); 109 | done = 1; 110 | usrsctp_close(upcall_socket); 111 | printf("client socket %p closed\n", (void *)upcall_socket); 112 | upcall_socket = NULL; 113 | return; 114 | } 115 | if (n == 0) { 116 | done = 1; 117 | usrsctp_close(upcall_socket); 118 | printf("client socket %p closed\n", (void *)upcall_socket); 119 | upcall_socket = NULL; 120 | return; 121 | } 122 | if (n > 0) { 123 | if (recv_flags & MSG_NOTIFICATION) { 124 | printf("Notification of length %d received.\n", (int)n); 125 | } else { 126 | printf("data of size %d received\n", (int)n); 127 | } 128 | } 129 | free(buf); 130 | } 131 | 132 | if ((events & SCTP_EVENT_WRITE) && !done) { 133 | struct sctp_sndinfo snd_info; 134 | snd_info.snd_sid = 0; 135 | snd_info.snd_flags = 0; 136 | snd_info.snd_ppid = 0; 137 | snd_info.snd_context = 0; 138 | snd_info.snd_assoc_id = 0; 139 | if (usrsctp_sendv(upcall_socket, buffer, strlen(buffer), NULL, 0, &snd_info, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { 140 | if (errno != EAGAIN && errno != EWOULDBLOCK) { 141 | send_done = 1; 142 | usrsctp_close(upcall_socket); 143 | printf("client socket %p closed\n", (void *)upcall_socket); 144 | return; 145 | } 146 | } 147 | } 148 | 149 | return; 150 | } 151 | 152 | int 153 | main(int argc, char *argv[]) 154 | { 155 | struct socket *listening_socket; 156 | struct sockaddr_in6 addr; 157 | struct sctp_udpencaps encaps; 158 | struct sctp_assoc_value av; 159 | const int on = 1; 160 | 161 | if (argc > 1) { 162 | usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack); 163 | } else { 164 | usrsctp_init(9899, NULL, debug_printf_stack); 165 | } 166 | #ifdef SCTP_DEBUG 167 | usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); 168 | #endif 169 | usrsctp_sysctl_set_sctp_blackhole(2); 170 | usrsctp_sysctl_set_sctp_no_csum_on_loopback(0); 171 | 172 | if ((listening_socket = usrsctp_socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { 173 | perror("usrsctp_socket"); 174 | } 175 | usrsctp_set_non_blocking(listening_socket, 1); 176 | if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, (const void*)&on, (socklen_t)sizeof(int)) < 0) { 177 | perror("usrsctp_setsockopt SCTP_I_WANT_MAPPED_V4_ADDR"); 178 | } 179 | memset(&av, 0, sizeof(struct sctp_assoc_value)); 180 | av.assoc_id = SCTP_ALL_ASSOC; 181 | av.assoc_value = 47; 182 | 183 | if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_CONTEXT, (const void*)&av, (socklen_t)sizeof(struct sctp_assoc_value)) < 0) { 184 | perror("usrsctp_setsockopt SCTP_CONTEXT"); 185 | } 186 | if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) { 187 | perror("usrsctp_setsockopt SCTP_RECVRCVINFO"); 188 | } 189 | if (argc > 2) { 190 | memset(&encaps, 0, sizeof(struct sctp_udpencaps)); 191 | encaps.sue_address.ss_family = AF_INET6; 192 | encaps.sue_port = htons(atoi(argv[2])); 193 | if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) { 194 | perror("usrsctp_setsockopt SCTP_REMOTE_UDP_ENCAPS_PORT"); 195 | } 196 | } 197 | 198 | initBuffer(); 199 | 200 | memset((void *)&addr, 0, sizeof(struct sockaddr_in6)); 201 | #ifdef HAVE_SIN6_LEN 202 | addr.sin6_len = sizeof(struct sockaddr_in6); 203 | #endif 204 | addr.sin6_family = AF_INET6; 205 | addr.sin6_port = htons(PORT); 206 | addr.sin6_addr = in6addr_any; 207 | if (usrsctp_bind(listening_socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in6)) < 0) { 208 | perror("usrsctp_bind"); 209 | } 210 | if (usrsctp_listen(listening_socket, 1) < 0) { 211 | perror("usrsctp_listen"); 212 | } 213 | usrsctp_set_upcall(listening_socket, handle_accept, NULL); 214 | 215 | while (1) { 216 | #ifdef _WIN32 217 | Sleep(1*1000); 218 | #else 219 | sleep(1); 220 | #endif 221 | } 222 | return (0); 223 | } 224 | -------------------------------------------------------------------------------- /programs/daytime_server.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Michael Tuexen 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Usage: daytime_server [local_encaps_port] [remote_encaps_port] 33 | * 34 | * Example 35 | * Server: $ ./daytime_server 11111 22222 36 | * Client: $ ./client 127.0.0.1 13 0 22222 11111 37 | */ 38 | 39 | #ifdef _WIN32 40 | #define _CRT_SECURE_NO_WARNINGS 41 | #endif 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #ifndef _WIN32 49 | #include 50 | #include 51 | #include 52 | #include 53 | #endif 54 | #include 55 | #include "programs_helper.h" 56 | 57 | #define PORT 13 58 | #define DAYTIME_PPID 40 59 | #define SLEEP 1 60 | 61 | int 62 | main(int argc, char *argv[]) 63 | { 64 | struct socket *sock, *conn_sock; 65 | struct sockaddr_in addr; 66 | struct sctp_udpencaps encaps; 67 | socklen_t addr_len; 68 | char buffer[80]; 69 | time_t now; 70 | struct sctp_sndinfo sndinfo; 71 | 72 | if (argc > 1) { 73 | usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack); 74 | } else { 75 | usrsctp_init(9899, NULL, debug_printf_stack); 76 | } 77 | #ifdef SCTP_DEBUG 78 | usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); 79 | #endif 80 | usrsctp_sysctl_set_sctp_blackhole(2); 81 | usrsctp_sysctl_set_sctp_no_csum_on_loopback(0); 82 | 83 | if ((sock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { 84 | perror("usrsctp_socket"); 85 | } 86 | if (argc > 2) { 87 | memset(&encaps, 0, sizeof(struct sctp_udpencaps)); 88 | encaps.sue_address.ss_family = AF_INET; 89 | encaps.sue_port = htons(atoi(argv[2])); 90 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) { 91 | perror("setsockopt"); 92 | } 93 | } 94 | memset((void *)&addr, 0, sizeof(struct sockaddr_in)); 95 | #ifdef HAVE_SIN_LEN 96 | addr.sin_len = sizeof(struct sockaddr_in); 97 | #endif 98 | addr.sin_family = AF_INET; 99 | addr.sin_port = htons(PORT); 100 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 101 | if (usrsctp_bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { 102 | perror("usrsctp_bind"); 103 | } 104 | if (usrsctp_listen(sock, 1) < 0) { 105 | perror("usrsctp_listen"); 106 | } 107 | while (1) { 108 | addr_len = 0; 109 | if ((conn_sock = usrsctp_accept(sock, NULL, &addr_len)) == NULL) { 110 | continue; 111 | } 112 | time(&now); 113 | #ifdef _WIN32 114 | if (_snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { 115 | #else 116 | if (snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { 117 | #endif 118 | buffer[0] = '\0'; 119 | } 120 | sndinfo.snd_sid = 0; 121 | sndinfo.snd_flags = 0; 122 | sndinfo.snd_ppid = htonl(DAYTIME_PPID); 123 | sndinfo.snd_context = 0; 124 | sndinfo.snd_assoc_id = 0; 125 | if (usrsctp_sendv(conn_sock, buffer, strlen(buffer), NULL, 0, (void *)&sndinfo, 126 | (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) { 127 | perror("usrsctp_sendv"); 128 | } 129 | usrsctp_close(conn_sock); 130 | } 131 | return (0); 132 | } 133 | -------------------------------------------------------------------------------- /programs/daytime_server_upcall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2013 Michael Tuexen 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Usage: daytime_server_upcall [local_encaps_port] [remote_encaps_port] 33 | */ 34 | 35 | #ifdef _WIN32 36 | #define _CRT_SECURE_NO_WARNINGS 37 | #endif 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #ifndef _WIN32 45 | #include 46 | #include 47 | #include 48 | #include 49 | #endif 50 | #include 51 | #include "programs_helper.h" 52 | 53 | #define DAYTIME_PPID 40 54 | #define PORT 13 55 | 56 | static void 57 | handle_accept(struct socket *sock, void *data, int flags) 58 | { 59 | struct socket *conn_sock; 60 | char buffer[80]; 61 | time_t now; 62 | socklen_t addr_len = 0; 63 | struct sctp_sndinfo sndinfo; 64 | 65 | if (((conn_sock = usrsctp_accept(sock, NULL, &addr_len)) == NULL) 66 | && (errno != EINPROGRESS)) { 67 | perror("usrsctp_accept"); 68 | return; 69 | } 70 | time(&now); 71 | #ifdef _WIN32 72 | if (_snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { 73 | #else 74 | if (snprintf(buffer, sizeof(buffer), "%s", ctime(&now)) < 0) { 75 | #endif 76 | buffer[0] = '\0'; 77 | } 78 | sndinfo.snd_sid = 0; 79 | sndinfo.snd_flags = 0; 80 | sndinfo.snd_ppid = htonl(DAYTIME_PPID); 81 | sndinfo.snd_context = 0; 82 | sndinfo.snd_assoc_id = 0; 83 | usrsctp_sendv(conn_sock, buffer, strlen(buffer), NULL, 0, (void *)&sndinfo, 84 | (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0); 85 | usrsctp_close(conn_sock); 86 | } 87 | 88 | int 89 | main(int argc, char *argv[]) 90 | { 91 | struct socket *sock; 92 | struct sockaddr_in addr; 93 | struct sctp_udpencaps encaps; 94 | 95 | if (argc > 1) { 96 | usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack); 97 | } else { 98 | usrsctp_init(9899, NULL, debug_printf_stack); 99 | } 100 | #ifdef SCTP_DEBUG 101 | usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); 102 | #endif 103 | usrsctp_sysctl_set_sctp_blackhole(2); 104 | usrsctp_sysctl_set_sctp_no_csum_on_loopback(0); 105 | 106 | if ((sock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { 107 | perror("usrsctp_socket"); 108 | } 109 | usrsctp_set_non_blocking(sock, 1); 110 | if (argc > 2) { 111 | memset(&encaps, 0, sizeof(struct sctp_udpencaps)); 112 | encaps.sue_address.ss_family = AF_INET; 113 | encaps.sue_port = htons(atoi(argv[2])); 114 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) { 115 | perror("setsockopt"); 116 | } 117 | } 118 | memset((void *)&addr, 0, sizeof(struct sockaddr_in)); 119 | #ifdef HAVE_SIN_LEN 120 | addr.sin_len = sizeof(struct sockaddr_in); 121 | #endif 122 | addr.sin_family = AF_INET; 123 | addr.sin_port = htons(PORT); 124 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 125 | if (usrsctp_bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { 126 | perror("usrsctp_bind"); 127 | } 128 | if (usrsctp_listen(sock, 1) < 0) { 129 | perror("usrsctp_listen"); 130 | } 131 | 132 | usrsctp_set_upcall(sock, handle_accept, NULL); 133 | 134 | while (1) { 135 | #ifdef _WIN32 136 | Sleep(1*1000); 137 | #else 138 | sleep(1); 139 | #endif 140 | } 141 | return (0); 142 | } 143 | -------------------------------------------------------------------------------- /programs/discard_server_upcall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Michael Tuexen 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Usage: discard_server_upcall [local_encaps_port] [remote_encaps_port] 33 | */ 34 | 35 | #ifdef _WIN32 36 | #define _CRT_SECURE_NO_WARNINGS 37 | #endif 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #ifndef _WIN32 44 | #include 45 | #include 46 | #include 47 | #include 48 | #endif 49 | #include 50 | #include "programs_helper.h" 51 | 52 | #define BUFFERSIZE 10240 53 | #define PORT 9 54 | 55 | 56 | static void 57 | handle_upcall(struct socket *sock, void *data, int flgs) 58 | { 59 | char namebuf[INET6_ADDRSTRLEN]; 60 | const char *name; 61 | uint16_t port; 62 | char *buf; 63 | int events; 64 | 65 | while ((events = usrsctp_get_events(sock)) && (events & SCTP_EVENT_READ)) { 66 | struct sctp_recvv_rn rn; 67 | ssize_t n; 68 | struct sockaddr_storage addr; 69 | buf = malloc(BUFFERSIZE); 70 | int flags = 0; 71 | socklen_t len = (socklen_t)sizeof(struct sockaddr_storage); 72 | unsigned int infotype = 0; 73 | socklen_t infolen = sizeof(struct sctp_recvv_rn); 74 | memset(&rn, 0, sizeof(struct sctp_recvv_rn)); 75 | n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn, 76 | &infolen, &infotype, &flags); 77 | if (n < 0) { 78 | perror("usrsctp_recvv"); 79 | } 80 | if (n > 0) { 81 | if (flags & MSG_NOTIFICATION) { 82 | printf("Notification of length %d received.\n", (int)n); 83 | } else { 84 | /* 85 | #ifdef _WIN32 86 | _write(_fileno(stdout), buf, (unsigned int)n); 87 | #else 88 | if (write(fileno(stdout), buf, n) < 0) { 89 | perror("write"); 90 | } 91 | #endif 92 | */ 93 | switch (addr.ss_family) { 94 | #ifdef INET 95 | case AF_INET: { 96 | struct sockaddr_in addr4; 97 | memcpy(&addr4, (struct sockaddr_in *)&addr, sizeof(struct sockaddr_in)); 98 | name = inet_ntop(AF_INET, &addr4.sin_addr, namebuf, INET_ADDRSTRLEN); 99 | port = ntohs(addr4.sin_port); 100 | break; 101 | } 102 | #endif 103 | #ifdef INET6 104 | case AF_INET6: { 105 | struct sockaddr_in6 addr6; 106 | memcpy(&addr6, (struct sockaddr_in6 *)&addr, sizeof(struct sockaddr_in6)); 107 | name = inet_ntop(AF_INET6, &addr6.sin6_addr, namebuf, INET6_ADDRSTRLEN), 108 | port = ntohs(addr6.sin6_port); 109 | break; 110 | } 111 | #endif 112 | default: 113 | name = NULL; 114 | port = 0; 115 | break; 116 | } 117 | 118 | if (name == NULL) { 119 | printf("inet_ntop failed\n"); 120 | free(buf); 121 | return; 122 | } 123 | 124 | printf("Msg of length %d received from %s:%u on stream %d with SSN %u and TSN %u, PPID %u, context %u.\n", 125 | (int)n, 126 | namebuf, 127 | port, 128 | rn.recvv_rcvinfo.rcv_sid, 129 | rn.recvv_rcvinfo.rcv_ssn, 130 | rn.recvv_rcvinfo.rcv_tsn, 131 | (uint32_t)ntohl(rn.recvv_rcvinfo.rcv_ppid), 132 | rn.recvv_rcvinfo.rcv_context); 133 | } 134 | } 135 | free(buf); 136 | } 137 | return; 138 | } 139 | 140 | int 141 | main(int argc, char *argv[]) 142 | { 143 | struct socket *sock; 144 | struct sockaddr_in6 addr; 145 | struct sctp_udpencaps encaps; 146 | struct sctp_event event; 147 | uint16_t event_types[] = {SCTP_ASSOC_CHANGE, 148 | SCTP_PEER_ADDR_CHANGE, 149 | SCTP_REMOTE_ERROR, 150 | SCTP_SHUTDOWN_EVENT, 151 | SCTP_ADAPTATION_INDICATION, 152 | SCTP_PARTIAL_DELIVERY_EVENT}; 153 | unsigned int i; 154 | struct sctp_assoc_value av; 155 | const int on = 1; 156 | 157 | if (argc > 1) { 158 | usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack); 159 | } else { 160 | usrsctp_init(9899, NULL, debug_printf_stack); 161 | } 162 | #ifdef SCTP_DEBUG 163 | usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE); 164 | #endif 165 | usrsctp_sysctl_set_sctp_blackhole(2); 166 | usrsctp_sysctl_set_sctp_no_csum_on_loopback(0); 167 | 168 | if ((sock = usrsctp_socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) { 169 | perror("usrsctp_socket"); 170 | } 171 | usrsctp_set_non_blocking(sock, 1); 172 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, (const void*)&on, (socklen_t)sizeof(int)) < 0) { 173 | perror("usrsctp_setsockopt SCTP_I_WANT_MAPPED_V4_ADDR"); 174 | } 175 | memset(&av, 0, sizeof(struct sctp_assoc_value)); 176 | av.assoc_id = SCTP_ALL_ASSOC; 177 | av.assoc_value = 47; 178 | 179 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_CONTEXT, (const void*)&av, (socklen_t)sizeof(struct sctp_assoc_value)) < 0) { 180 | perror("usrsctp_setsockopt SCTP_CONTEXT"); 181 | } 182 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) { 183 | perror("usrsctp_setsockopt SCTP_RECVRCVINFO"); 184 | } 185 | if (argc > 2) { 186 | memset(&encaps, 0, sizeof(struct sctp_udpencaps)); 187 | encaps.sue_address.ss_family = AF_INET6; 188 | encaps.sue_port = htons(atoi(argv[2])); 189 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) { 190 | perror("usrsctp_setsockopt SCTP_REMOTE_UDP_ENCAPS_PORT"); 191 | } 192 | } 193 | memset(&event, 0, sizeof(event)); 194 | event.se_assoc_id = SCTP_FUTURE_ASSOC; 195 | event.se_on = 1; 196 | for (i = 0; i < (unsigned int)(sizeof(event_types)/sizeof(uint16_t)); i++) { 197 | event.se_type = event_types[i]; 198 | if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)) < 0) { 199 | perror("usrsctp_setsockopt SCTP_EVENT"); 200 | } 201 | } 202 | 203 | usrsctp_set_upcall(sock, handle_upcall, NULL); 204 | 205 | memset((void *)&addr, 0, sizeof(struct sockaddr_in6)); 206 | #ifdef HAVE_SIN6_LEN 207 | addr.sin6_len = sizeof(struct sockaddr_in6); 208 | #endif 209 | addr.sin6_family = AF_INET6; 210 | addr.sin6_port = htons(PORT); 211 | addr.sin6_addr = in6addr_any; 212 | if (usrsctp_bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in6)) < 0) { 213 | perror("usrsctp_bind"); 214 | } 215 | if (usrsctp_listen(sock, 1) < 0) { 216 | perror("usrsctp_listen"); 217 | } 218 | while (1) { 219 | #ifdef _WIN32 220 | Sleep(1*1000); 221 | #else 222 | sleep(1); 223 | #endif 224 | } 225 | return (0); 226 | } 227 | -------------------------------------------------------------------------------- /programs/meson.build: -------------------------------------------------------------------------------- 1 | # Helper sources for all programs 2 | programs_helper_sources = files('programs_helper.c') 3 | 4 | # Programs and their sources 5 | programs = { 6 | 'chargen_server_upcall': files('chargen_server_upcall.c'), 7 | 'client': files('client.c'), 8 | 'st_client': files('st_client.c'), 9 | 'client_upcall': files('client_upcall.c'), 10 | 'daytime_server': files('daytime_server.c'), 11 | 'daytime_server_upcall': files('daytime_server_upcall.c'), 12 | 'discard_server': files('discard_server.c'), 13 | 'discard_server_upcall': files('discard_server_upcall.c'), 14 | 'echo_server': files('echo_server.c'), 15 | 'echo_server_upcall': files('echo_server_upcall.c'), 16 | 'ekr_client': files('ekr_client.c'), 17 | 'ekr_loop': files('ekr_loop.c'), 18 | 'ekr_loop_upcall': files('ekr_loop_upcall.c'), 19 | 'ekr_peer': files('ekr_peer.c'), 20 | 'ekr_server': files('ekr_server.c'), 21 | 'http_client': files('http_client.c'), 22 | 'http_client_upcall': files('http_client_upcall.c'), 23 | 'rtcweb': files('rtcweb.c'), 24 | 'test_libmgmt': files('test_libmgmt.c'), 25 | 'test_timer': files('test_timer.c'), 26 | 'tsctp': files('tsctp.c'), 27 | } 28 | 29 | -------------------------------------------------------------------------------- /programs/programs_helper.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2020 Felix Weinrank 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __PROGRAMS_HELPER_H__ 29 | #define __PROGRAMS_HELPER_H__ 30 | 31 | #ifndef _WIN32 32 | #define SCTP_PACKED __attribute__((packed)) 33 | #else 34 | #pragma pack (push, 1) 35 | #define SCTP_PACKED 36 | #endif 37 | 38 | struct sctp_chunk_header { 39 | uint8_t chunk_type; /* chunk type */ 40 | uint8_t chunk_flags; /* chunk flags */ 41 | uint16_t chunk_length; /* chunk length */ 42 | /* optional params follow */ 43 | } SCTP_PACKED; 44 | 45 | struct sctp_init_chunk { 46 | struct sctp_chunk_header ch; 47 | uint32_t initiate_tag; /* initiate tag */ 48 | uint32_t a_rwnd; /* a_rwnd */ 49 | uint16_t num_outbound_streams; /* OS */ 50 | uint16_t num_inbound_streams; /* MIS */ 51 | uint32_t initial_tsn; /* I-TSN */ 52 | /* optional param's follow */ 53 | } SCTP_PACKED; 54 | 55 | #ifdef _WIN32 56 | #pragma pack(pop) 57 | #endif 58 | 59 | #undef SCTP_PACKED 60 | 61 | void 62 | handle_notification(union sctp_notification *notif, size_t n); 63 | #ifndef timersub 64 | #define timersub(tvp, uvp, vvp) \ 65 | do { \ 66 | (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ 67 | (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ 68 | if ((vvp)->tv_usec < 0) { \ 69 | (vvp)->tv_sec--; \ 70 | (vvp)->tv_usec += 1000000; \ 71 | } \ 72 | } while (0) 73 | #endif 74 | 75 | void 76 | debug_printf(const char *format, ...); 77 | 78 | void 79 | debug_printf_clean(const char *format, ...); 80 | 81 | void 82 | debug_printf_stack(const char *format, ...); 83 | 84 | void 85 | debug_set_target(FILE *fp); 86 | 87 | #define FUZZER_ASSERT(x) if (!(x)) { printf("USRSCTP assertion failed: function %s, file %s, line %d.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); abort(); } 88 | 89 | 90 | #endif /* __PROGRAMS_HELPER_H__ */ 91 | -------------------------------------------------------------------------------- /programs/test_libmgmt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Michael Tuexen 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _WIN32 32 | #include 33 | #endif 34 | #include "usrsctp.h" 35 | 36 | int 37 | main(void) 38 | { 39 | int i; 40 | 41 | for (i = 0; i < 10000; i++) { 42 | usrsctp_init(0, NULL, NULL); 43 | while (usrsctp_finish() != 0) { 44 | #ifdef _WIN32 45 | Sleep(1000); 46 | #else 47 | sleep(1); 48 | #endif 49 | } 50 | } 51 | return (0); 52 | } 53 | -------------------------------------------------------------------------------- /programs/test_timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Michael Tuexen 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #ifndef _WIN32 35 | #include 36 | #endif 37 | #include 38 | 39 | int 40 | main(void) 41 | { 42 | unsigned int i; 43 | 44 | usrsctp_init(0, NULL, NULL); 45 | printf("Entering the loop\n"); 46 | for (i = 0; i < 1000000; i++) { 47 | usrsctp_register_address(NULL); 48 | usrsctp_deregister_address(NULL); 49 | } 50 | printf("Exited the loop\n"); 51 | while (usrsctp_finish() != 0) { 52 | #ifdef _WIN32 53 | Sleep(1000); 54 | #else 55 | sleep(1); 56 | #endif 57 | } 58 | return (0); 59 | } 60 | -------------------------------------------------------------------------------- /usrsctp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: usrsctp 7 | Description: SCTP implementation 8 | URL: https://github.com/sctplab/usrsctp 9 | Version: @VERSION@ 10 | Requires: 11 | Libs: -L${libdir} -lusrsctp 12 | Libs.private: -lpthread 13 | Cflags: -I${includedir} @APPCFLAGS@ 14 | -------------------------------------------------------------------------------- /usrsctplib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015-2015 Oleg Alexeenkov 3 | # Copyright (C) 2015-2020 Felix Weinrank 4 | # 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 3. Neither the name of the project nor the names of its contributors 16 | # may be used to endorse or promote products derived from this software 17 | # without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | # SUCH DAMAGE. 30 | # 31 | 32 | 33 | ################################################# 34 | # INCLUDE MODULES AND SETTINGS 35 | ################################################# 36 | 37 | set(VERSION "0.9.5.0") 38 | 39 | # Shared library API and ABI versions 40 | # Notice: shared library version must be in X.Y.Z format only 41 | set(SOVERSION_FULL "2.0.0") 42 | set(SOVERSION_SHORT "2") 43 | 44 | include(GNUInstallDirs) 45 | set(prefix ${CMAKE_INSTALL_PREFIX}) 46 | set(exec_prefix ${prefix}) 47 | set(libdir ${exec_prefix}/${CMAKE_INSTALL_LIBDIR}) 48 | set(includedir ${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) 49 | 50 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}) 51 | set(CMAKE_MACOSX_RPATH 1) 52 | 53 | include(CheckCCompilerFlag) 54 | 55 | 56 | option(SCTP_USE_MBEDTLS_SHA1 "Build with mbedtls sha1 support." OFF) 57 | 58 | add_definitions(-D__Userspace__) 59 | add_definitions(-DSCTP_SIMPLE_ALLOCATOR) 60 | add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS) 61 | 62 | if(SCTP_USE_MBEDTLS_SHA1) 63 | add_definitions(-DSCTP_USE_MBEDTLS_SHA1) 64 | find_package(MbedTLS REQUIRED) 65 | endif() 66 | 67 | 68 | ################################################# 69 | # OS DEPENDENT 70 | ################################################# 71 | 72 | check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packed_member) 73 | if (has_wno_address_of_packed_member) 74 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member") 75 | endif () 76 | 77 | check_c_compiler_flag(-Wno-deprecated-declarations has_wno_deprecated_declarations) 78 | if (has_wno_deprecated_declarations) 79 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") 80 | endif () 81 | 82 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 83 | add_definitions(-D_GNU_SOURCE) 84 | endif () 85 | 86 | if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "iOS") 87 | add_definitions(-D__APPLE_USE_RFC_2292) 88 | endif () 89 | 90 | ################################################# 91 | # MISC 92 | ################################################# 93 | 94 | if (sctp_build_shared_lib) 95 | set(BUILD_SHARED_LIBS 1) 96 | endif () 97 | 98 | find_package(Threads) 99 | 100 | ################################################# 101 | # LIBRARY FILES 102 | ################################################# 103 | 104 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 105 | 106 | list(APPEND usrsctp_root_headers 107 | user_atomic.h 108 | user_environment.h 109 | user_inpcb.h 110 | user_ip_icmp.h 111 | user_ip6_var.h 112 | user_malloc.h 113 | user_mbuf.h 114 | user_queue.h 115 | user_recv_thread.h 116 | user_route.h 117 | user_socketvar.h 118 | user_uma.h 119 | usrsctp.h 120 | ) 121 | 122 | list(APPEND usrsctp_netinet_headers 123 | netinet/sctp_asconf.h 124 | netinet/sctp_auth.h 125 | netinet/sctp_bsd_addr.h 126 | netinet/sctp_callout.h 127 | netinet/sctp_constants.h 128 | netinet/sctp_crc32.h 129 | netinet/sctp_header.h 130 | netinet/sctp_indata.h 131 | netinet/sctp_input.h 132 | netinet/sctp_lock_userspace.h 133 | netinet/sctp_os_userspace.h 134 | netinet/sctp_os.h 135 | netinet/sctp_output.h 136 | netinet/sctp_pcb.h 137 | netinet/sctp_peeloff.h 138 | netinet/sctp_process_lock.h 139 | netinet/sctp_sha1.h 140 | netinet/sctp_structs.h 141 | netinet/sctp_sysctl.h 142 | netinet/sctp_timer.h 143 | netinet/sctp_uio.h 144 | netinet/sctp_var.h 145 | netinet/sctputil.h 146 | netinet/sctp.h 147 | ) 148 | 149 | list(APPEND usrsctp_netinet6_headers 150 | netinet6/sctp6_var.h 151 | ) 152 | 153 | list(APPEND usrsctp_headers 154 | ${usrsctp_root_headers} 155 | ${usrsctp_netinet_headers} 156 | ${usrsctp_netinet6_headers} 157 | ) 158 | 159 | list(APPEND usrsctp_sources 160 | netinet/sctp_asconf.c 161 | netinet/sctp_auth.c 162 | netinet/sctp_bsd_addr.c 163 | netinet/sctp_callout.c 164 | netinet/sctp_cc_functions.c 165 | netinet/sctp_crc32.c 166 | netinet/sctp_indata.c 167 | netinet/sctp_input.c 168 | netinet/sctp_output.c 169 | netinet/sctp_pcb.c 170 | netinet/sctp_peeloff.c 171 | netinet/sctp_sha1.c 172 | netinet/sctp_ss_functions.c 173 | netinet/sctp_sysctl.c 174 | netinet/sctp_timer.c 175 | netinet/sctp_userspace.c 176 | netinet/sctp_usrreq.c 177 | netinet/sctputil.c 178 | netinet6/sctp6_usrreq.c 179 | user_environment.c 180 | user_mbuf.c 181 | user_recv_thread.c 182 | user_socket.c 183 | ) 184 | 185 | add_library(usrsctp ${usrsctp_sources} ${usrsctp_headers}) 186 | 187 | target_include_directories(usrsctp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 188 | 189 | if(SCTP_USE_MBEDTLS_SHA1) 190 | target_include_directories(usrsctp PRIVATE ${MBEDTLS_INCLUDE_DIRS}) 191 | endif() 192 | 193 | target_link_libraries(usrsctp ${CMAKE_THREAD_LIBS_INIT}) 194 | 195 | if (WIN32) 196 | message(STATUS "link library: ws2_32") 197 | target_link_libraries(usrsctp ws2_32 iphlpapi) 198 | endif () 199 | 200 | if(SCTP_USE_MBEDTLS_SHA1) 201 | target_link_libraries(usrsctp PRIVATE ${MBEDTLS_LIBRARIES}) 202 | endif() 203 | 204 | 205 | set_target_properties(usrsctp PROPERTIES IMPORT_SUFFIX "_import.lib") 206 | set_target_properties(usrsctp PROPERTIES SOVERSION ${SOVERSION_SHORT} VERSION ${SOVERSION_FULL}) 207 | 208 | ################################################# 209 | # INSTALL LIBRARY AND HEADER 210 | ################################################# 211 | 212 | install(TARGETS usrsctp DESTINATION ${CMAKE_INSTALL_LIBDIR}) 213 | install(FILES usrsctp.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 214 | 215 | ################################################# 216 | # GENERATE AND INSTALL PKG-CONFIG FILE 217 | ################################################# 218 | 219 | configure_file("${PROJECT_SOURCE_DIR}/usrsctp.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/usrsctp.pc" @ONLY) 220 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/usrsctp.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 221 | -------------------------------------------------------------------------------- /usrsctplib/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011-2012 Michael Tuexen 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | AUTOMAKE_OPTIONS = subdir-objects 32 | EXTRA_DIST = Makefile.nmake 33 | lib_LTLIBRARIES = libusrsctp.la 34 | libusrsctp_la_SOURCES = user_atomic.h \ 35 | user_environment.c user_environment.h \ 36 | user_inpcb.h \ 37 | user_ip_icmp.h \ 38 | user_ip6_var.h \ 39 | user_malloc.h \ 40 | user_mbuf.c \ 41 | user_mbuf.h \ 42 | user_queue.h \ 43 | user_recv_thread.c user_recv_thread.h \ 44 | user_route.h \ 45 | user_socket.c \ 46 | user_socketvar.h \ 47 | user_uma.h \ 48 | netinet/sctp.h \ 49 | netinet/sctp_asconf.c netinet/sctp_asconf.h \ 50 | netinet/sctp_auth.c netinet/sctp_auth.h \ 51 | netinet/sctp_bsd_addr.c netinet/sctp_bsd_addr.h \ 52 | netinet/sctp_callout.c netinet/sctp_callout.h \ 53 | netinet/sctp_cc_functions.c \ 54 | netinet/sctp_constants.h \ 55 | netinet/sctp_crc32.c netinet/sctp_crc32.h \ 56 | netinet/sctp_header.h \ 57 | netinet/sctp_indata.c netinet/sctp_indata.h \ 58 | netinet/sctp_input.c netinet/sctp_input.h \ 59 | netinet/sctp_lock_userspace.h \ 60 | netinet/sctp_os.h \ 61 | netinet/sctp_os_userspace.h \ 62 | netinet/sctp_output.c netinet/sctp_output.h \ 63 | netinet/sctp_pcb.c netinet/sctp_pcb.h \ 64 | netinet/sctp_peeloff.c netinet/sctp_peeloff.h \ 65 | netinet/sctp_process_lock.h \ 66 | netinet/sctp_sha1.c netinet/sctp_sha1.h \ 67 | netinet/sctp_ss_functions.c \ 68 | netinet/sctp_structs.h \ 69 | netinet/sctp_sysctl.c netinet/sctp_sysctl.h \ 70 | netinet/sctp_userspace.c \ 71 | netinet/sctp_timer.c netinet/sctp_timer.h \ 72 | netinet/sctp_uio.h \ 73 | netinet/sctp_usrreq.c \ 74 | netinet/sctp_var.h \ 75 | netinet/sctputil.c netinet/sctputil.h \ 76 | netinet6/sctp6_var.h \ 77 | netinet6/sctp6_usrreq.c 78 | libusrsctp_la_CFLAGS = $(LIBCFLAGS) 79 | libusrsctp_la_LDFLAGS = -version-info 2:0:0 80 | include_HEADERS = usrsctp.h 81 | 82 | -------------------------------------------------------------------------------- /usrsctplib/Makefile.nmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011-2012 Michael Tuexen 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 1. Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 3. Neither the name of the project nor the names of its contributors 15 | # may be used to endorse or promote products derived from this software 16 | # without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | # SUCH DAMAGE. 29 | # 30 | 31 | CFLAGS=/I. /W3 /WX 32 | 33 | CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS 34 | CVARSDLL=$(CVARSDLL) -D__Userspace__ 35 | CVARSDLL=$(CVARSDLL) -DINET -DINET6 36 | CVARSDLL=$(CVARSDLL) -D_LIB 37 | 38 | LINKFLAGS=/LIBPATH:. Ws2_32.lib 39 | 40 | usrsctp_OBJECTS = \ 41 | user_environment.obj \ 42 | user_mbuf.obj \ 43 | user_recv_thread.obj \ 44 | user_socket.obj \ 45 | sctp_asconf.obj \ 46 | sctp_auth.obj \ 47 | sctp_bsd_addr.obj \ 48 | sctp_callout.obj \ 49 | sctp_cc_functions.obj \ 50 | sctp_crc32.obj \ 51 | sctp_indata.obj \ 52 | sctp_input.obj \ 53 | sctp_output.obj \ 54 | sctp_pcb.obj \ 55 | sctp_peeloff.obj \ 56 | sctp_sha1.obj \ 57 | sctp_ss_functions.obj \ 58 | sctp_sysctl.obj \ 59 | sctp_timer.obj \ 60 | sctp_userspace.obj \ 61 | sctp_usrreq.obj \ 62 | sctputil.obj \ 63 | sctp6_usrreq.obj 64 | 65 | usrsctp_HEADERS = \ 66 | user_atomic.h \ 67 | user_environment.h \ 68 | user_inpcb.h \ 69 | user_ip6_var.h \ 70 | user_malloc.h \ 71 | user_mbuf.h \ 72 | user_recv_thread.h \ 73 | user_route.h \ 74 | user_socketvar.h \ 75 | user_uma.h \ 76 | user_queue.h \ 77 | user_ip_icmp.h \ 78 | user_ip6_var.h \ 79 | netinet\sctp.h \ 80 | netinet\sctp_asconf.h \ 81 | netinet\sctp_auth.h \ 82 | netinet\sctp_bsd_addr.h \ 83 | netinet\sctp_callout.h \ 84 | netinet\sctp_constants.h \ 85 | netinet\sctp_crc32.h \ 86 | netinet\sctp_header.h \ 87 | netinet\sctp_indata.h \ 88 | netinet\sctp_input.h \ 89 | netinet\sctp_lock_userspace.h \ 90 | netinet\sctp_os.h \ 91 | netinet\sctp_os_userspace.h \ 92 | netinet\sctp_output.h \ 93 | netinet\sctp_pcb.h \ 94 | netinet\sctp_peeloff.h \ 95 | netinet\sctp_process_lock.h \ 96 | netinet\sctp_sha1.h \ 97 | netinet\sctp_structs.h \ 98 | netinet\sctp_sysctl.h \ 99 | netinet\sctp_timer.h \ 100 | netinet\sctp_uio.h \ 101 | netinet\sctp_var.h \ 102 | netinet\sctputil.h \ 103 | netinet6\sctp6_var.h 104 | 105 | usrsctp.lib : $(usrsctp_OBJECTS) 106 | lib /out:usrsctp.lib $(LINKFLAGS) $(usrsctp_OBJECTS) 107 | 108 | user_environment.obj : user_environment.c $(usrsctp_HEADERS) 109 | cl $(CVARSDLL) $(CFLAGS) -c user_environment.c 110 | 111 | user_mbuf.obj : user_mbuf.c $(usrsctp_HEADERS) 112 | cl $(CVARSDLL) $(CFLAGS) -c user_mbuf.c 113 | 114 | user_recv_thread.obj: user_recv_thread.c $(usrsctp_HEADERS) 115 | cl $(CVARSDLL) $(CFLAGS) -c user_recv_thread.c 116 | 117 | user_socket.obj : user_socket.c $(usrsctp_HEADERS) 118 | cl $(CVARSDLL) $(CFLAGS) -c user_socket.c 119 | 120 | sctp_asconf.obj : netinet\sctp_asconf.c $(usrsctp_HEADERS) 121 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_asconf.c 122 | 123 | sctp_auth.obj : netinet\sctp_auth.c $(usrsctp_HEADERS) 124 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_auth.c 125 | 126 | sctp_bsd_addr.obj : netinet\sctp_bsd_addr.c $(usrsctp_HEADERS) 127 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_bsd_addr.c 128 | 129 | sctp_callout.obj : netinet\sctp_callout.c $(usrsctp_HEADERS) 130 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_callout.c 131 | 132 | sctp_cc_functions.obj : netinet\sctp_cc_functions.c $(usrsctp_HEADERS) 133 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_cc_functions.c 134 | 135 | sctp_crc32.obj : netinet\sctp_crc32.c $(usrsctp_HEADERS) 136 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_crc32.c 137 | 138 | sctp_indata.obj : netinet\sctp_indata.c $(usrsctp_HEADERS) 139 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_indata.c 140 | 141 | sctp_input.obj : netinet\sctp_input.c $(usrsctp_HEADERS) 142 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_input.c 143 | 144 | sctp_output.obj : netinet\sctp_output.c $(usrsctp_HEADERS) 145 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_output.c 146 | 147 | sctp_pcb.obj : netinet\sctp_pcb.c $(usrsctp_HEADERS) 148 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_pcb.c 149 | 150 | sctp_peeloff.obj : netinet\sctp_peeloff.c $(usrsctp_HEADERS) 151 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_peeloff.c 152 | 153 | sctp_sha1.obj : netinet\sctp_sha1.c $(usrsctp_HEADERS) 154 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_sha1.c 155 | 156 | sctp_ss_functions.obj : netinet\sctp_ss_functions.c $(usrsctp_HEADERS) 157 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_ss_functions.c 158 | 159 | sctp_sysctl.obj : netinet\sctp_sysctl.c $(usrsctp_HEADERS) 160 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_sysctl.c 161 | 162 | sctp_timer.obj : netinet\sctp_timer.c $(usrsctp_HEADERS) 163 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_timer.c 164 | 165 | sctp_userspace.obj : netinet\sctp_userspace.c $(usrsctp_HEADERS) 166 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_userspace.c 167 | 168 | sctp_usrreq.obj : netinet\sctp_usrreq.c $(usrsctp_HEADERS) 169 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_usrreq.c 170 | 171 | sctputil.obj : netinet\sctputil.c $(usrsctp_HEADERS) 172 | cl $(CVARSDLL) $(CFLAGS) -c netinet\sctputil.c 173 | 174 | sctp6_usrreq.obj : netinet6\sctp6_usrreq.c $(usrsctp_HEADERS) 175 | cl $(CVARSDLL) $(CFLAGS) -c netinet6\sctp6_usrreq.c 176 | 177 | clean: 178 | del *.obj 179 | del usrsctp.lib 180 | -------------------------------------------------------------------------------- /usrsctplib/meson.build: -------------------------------------------------------------------------------- 1 | # Includes 2 | include_dirs = include_directories( 3 | '.', 4 | 'netinet', 5 | 'netinet6', 6 | ) 7 | 8 | # Sources 9 | sources = files([ 10 | 'user_environment.c', 11 | 'user_mbuf.c', 12 | 'user_recv_thread.c', 13 | 'user_socket.c', 14 | ]) 15 | 16 | subdir('netinet') 17 | subdir('netinet6') 18 | 19 | # Install usrsctp.h 20 | install_headers('usrsctp.h') 21 | -------------------------------------------------------------------------------- /usrsctplib/netinet/meson.build: -------------------------------------------------------------------------------- 1 | sources += files([ 2 | 'sctp_asconf.c', 3 | 'sctp_auth.c', 4 | 'sctp_bsd_addr.c', 5 | 'sctp_callout.c', 6 | 'sctp_cc_functions.c', 7 | 'sctp_crc32.c', 8 | 'sctp_indata.c', 9 | 'sctp_input.c', 10 | 'sctp_output.c', 11 | 'sctp_pcb.c', 12 | 'sctp_peeloff.c', 13 | 'sctp_sha1.c', 14 | 'sctp_ss_functions.c', 15 | 'sctp_sysctl.c', 16 | 'sctp_timer.c', 17 | 'sctp_userspace.c', 18 | 'sctp_usrreq.c', 19 | 'sctputil.c', 20 | ]) 21 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_asconf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_ASCONF_H_ 36 | #define _NETINET_SCTP_ASCONF_H_ 37 | 38 | #if defined(_KERNEL) || defined(__Userspace__) 39 | 40 | /* 41 | * function prototypes 42 | */ 43 | extern void sctp_asconf_cleanup(struct sctp_tcb *); 44 | 45 | extern struct mbuf *sctp_compose_asconf(struct sctp_tcb *, int *, int); 46 | 47 | extern void 48 | sctp_handle_asconf(struct mbuf *, unsigned int, struct sockaddr *, 49 | struct sctp_asconf_chunk *, struct sctp_tcb *, int); 50 | 51 | extern void 52 | sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *, 53 | struct sctp_tcb *, struct sctp_nets *, int *); 54 | 55 | extern uint32_t 56 | sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t, 57 | uint32_t); 58 | 59 | extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, 60 | uint32_t val); 61 | extern void sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, 62 | struct sctp_tcb *stcb, 63 | void *ptr, uint32_t type); 64 | extern void sctp_asconf_iterator_end(void *ptr, uint32_t val); 65 | 66 | extern int32_t 67 | sctp_set_primary_ip_address_sa(struct sctp_tcb *, 68 | struct sockaddr *); 69 | 70 | extern void 71 | sctp_check_address_list(struct sctp_tcb *, struct mbuf *, int, int, 72 | struct sockaddr *, uint16_t, uint16_t, uint16_t, uint16_t); 73 | 74 | extern void 75 | sctp_assoc_immediate_retrans(struct sctp_tcb *, struct sctp_nets *); 76 | #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__) 77 | extern void 78 | sctp_net_immediate_retrans(struct sctp_tcb *, struct sctp_nets *); 79 | #endif 80 | 81 | extern void 82 | sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, 83 | struct sctp_nets *net); 84 | 85 | extern int 86 | sctp_is_addr_pending(struct sctp_tcb *, struct sctp_ifa *); 87 | #endif /* _KERNEL */ 88 | 89 | #endif /* !_NETINET_SCTP_ASCONF_H_ */ 90 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_bsd_addr.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_BSD_ADDR_H_ 36 | #define _NETINET_SCTP_BSD_ADDR_H_ 37 | 38 | #include 39 | 40 | #if defined(_KERNEL) || defined(__Userspace__) 41 | 42 | extern struct iterator_control sctp_it_ctl; 43 | void sctp_wakeup_iterator(void); 44 | 45 | void sctp_startup_iterator(void); 46 | 47 | #ifdef INET6 48 | void sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa); 49 | #endif 50 | 51 | #ifdef SCTP_PACKET_LOGGING 52 | 53 | void sctp_packet_log(struct mbuf *m); 54 | int sctp_copy_out_packet_log(uint8_t *target, int length); 55 | 56 | #endif 57 | 58 | void sctp_addr_change(struct ifaddr *ifa, int cmd); 59 | #if defined(__FreeBSD__) && !defined(__Userspace__) 60 | 61 | void sctp_addr_change_event_handler(void *, struct ifaddr *, int); 62 | #endif 63 | 64 | void sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add); 65 | 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_callout.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #if defined(__Userspace__) 36 | #include 37 | #if !defined(_WIN32) 38 | #include 39 | #include 40 | #include 41 | #endif 42 | #if defined(__native_client__) 43 | #include 44 | #endif 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #else 53 | #include 54 | #include 55 | #include 56 | #endif 57 | #include 58 | 59 | /* 60 | * Callout/Timer routines for OS that doesn't have them 61 | */ 62 | #if defined(__APPLE__) || defined(__Userspace__) 63 | static uint32_t ticks = 0; 64 | #else 65 | extern int ticks; 66 | #endif 67 | 68 | uint32_t sctp_get_tick_count(void) { 69 | uint32_t ret; 70 | 71 | SCTP_TIMERQ_LOCK(); 72 | ret = ticks; 73 | SCTP_TIMERQ_UNLOCK(); 74 | return ret; 75 | } 76 | 77 | /* 78 | * SCTP_TIMERQ_LOCK protects: 79 | * - SCTP_BASE_INFO(callqueue) 80 | * - sctp_os_timer_next: next timer to check 81 | */ 82 | static sctp_os_timer_t *sctp_os_timer_next = NULL; 83 | 84 | void 85 | sctp_os_timer_init(sctp_os_timer_t *c) 86 | { 87 | memset(c, 0, sizeof(*c)); 88 | } 89 | 90 | int 91 | sctp_os_timer_start(sctp_os_timer_t *c, uint32_t to_ticks, void (*ftn) (void *), 92 | void *arg) 93 | { 94 | int ret = 0; 95 | 96 | /* paranoia */ 97 | if ((c == NULL) || (ftn == NULL)) 98 | return (ret); 99 | 100 | SCTP_TIMERQ_LOCK(); 101 | /* check to see if we're rescheduling a timer */ 102 | if (c->c_flags & SCTP_CALLOUT_PENDING) { 103 | ret = 1; 104 | if (c == sctp_os_timer_next) { 105 | sctp_os_timer_next = TAILQ_NEXT(c, tqe); 106 | } 107 | TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe); 108 | /* 109 | * part of the normal "stop a pending callout" process 110 | * is to clear the CALLOUT_ACTIVE and CALLOUT_PENDING 111 | * flags. We don't bother since we are setting these 112 | * below and we still hold the lock. 113 | */ 114 | } 115 | 116 | /* 117 | * We could unlock/splx here and lock/spl at the TAILQ_INSERT_TAIL, 118 | * but there's no point since doing this setup doesn't take much time. 119 | */ 120 | if (to_ticks == 0) 121 | to_ticks = 1; 122 | 123 | c->c_arg = arg; 124 | c->c_flags = (SCTP_CALLOUT_ACTIVE | SCTP_CALLOUT_PENDING); 125 | c->c_func = ftn; 126 | c->c_time = ticks + to_ticks; 127 | TAILQ_INSERT_TAIL(&SCTP_BASE_INFO(callqueue), c, tqe); 128 | SCTP_TIMERQ_UNLOCK(); 129 | return (ret); 130 | } 131 | 132 | int 133 | sctp_os_timer_stop(sctp_os_timer_t *c) 134 | { 135 | SCTP_TIMERQ_LOCK(); 136 | /* 137 | * Don't attempt to delete a callout that's not on the queue. 138 | */ 139 | if ((c->c_flags & SCTP_CALLOUT_PENDING) == 0) { 140 | c->c_flags &= ~SCTP_CALLOUT_ACTIVE; 141 | SCTP_TIMERQ_UNLOCK(); 142 | return (0); 143 | } 144 | c->c_flags &= ~(SCTP_CALLOUT_ACTIVE | SCTP_CALLOUT_PENDING); 145 | if (c == sctp_os_timer_next) { 146 | sctp_os_timer_next = TAILQ_NEXT(c, tqe); 147 | } 148 | TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe); 149 | SCTP_TIMERQ_UNLOCK(); 150 | return (1); 151 | } 152 | 153 | void 154 | sctp_handle_tick(uint32_t elapsed_ticks) 155 | { 156 | sctp_os_timer_t *c; 157 | void (*c_func)(void *); 158 | void *c_arg; 159 | 160 | SCTP_TIMERQ_LOCK(); 161 | /* update our tick count */ 162 | ticks += elapsed_ticks; 163 | c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue)); 164 | while (c) { 165 | if (SCTP_UINT32_GE(ticks, c->c_time)) { 166 | sctp_os_timer_next = TAILQ_NEXT(c, tqe); 167 | TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe); 168 | c_func = c->c_func; 169 | c_arg = c->c_arg; 170 | c->c_flags &= ~SCTP_CALLOUT_PENDING; 171 | SCTP_TIMERQ_UNLOCK(); 172 | c_func(c_arg); 173 | SCTP_TIMERQ_LOCK(); 174 | c = sctp_os_timer_next; 175 | } else { 176 | c = TAILQ_NEXT(c, tqe); 177 | } 178 | } 179 | sctp_os_timer_next = NULL; 180 | SCTP_TIMERQ_UNLOCK(); 181 | } 182 | 183 | #if defined(__APPLE__) && !defined(__Userspace__) 184 | void 185 | sctp_timeout(void *arg SCTP_UNUSED) 186 | { 187 | sctp_handle_tick(SCTP_BASE_VAR(sctp_main_timer_ticks)); 188 | sctp_start_main_timer(); 189 | } 190 | #endif 191 | 192 | #if defined(__Userspace__) 193 | #define TIMEOUT_INTERVAL 10 194 | 195 | void * 196 | user_sctp_timer_iterate(void *arg) 197 | { 198 | sctp_userspace_set_threadname("SCTP timer"); 199 | for (;;) { 200 | #if defined(_WIN32) 201 | Sleep(TIMEOUT_INTERVAL); 202 | #else 203 | struct timespec amount, remaining; 204 | 205 | remaining.tv_sec = 0; 206 | remaining.tv_nsec = TIMEOUT_INTERVAL * 1000 * 1000; 207 | do { 208 | amount = remaining; 209 | } while (nanosleep(&amount, &remaining) == -1); 210 | #endif 211 | if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) { 212 | break; 213 | } 214 | sctp_handle_tick(sctp_msecs_to_ticks(TIMEOUT_INTERVAL)); 215 | } 216 | return (NULL); 217 | } 218 | 219 | void 220 | sctp_start_timer_thread(void) 221 | { 222 | /* 223 | * No need to do SCTP_TIMERQ_LOCK_INIT(); 224 | * here, it is being done in sctp_pcb_init() 225 | */ 226 | int rc; 227 | 228 | rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate); 229 | if (rc) { 230 | SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc); 231 | } else { 232 | SCTP_BASE_VAR(timer_thread_started) = 1; 233 | } 234 | } 235 | 236 | void 237 | sctp_stop_timer_thread(void) 238 | { 239 | atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1); 240 | if (SCTP_BASE_VAR(timer_thread_started)) { 241 | #if defined(_WIN32) 242 | WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE); 243 | CloseHandle(SCTP_BASE_VAR(timer_thread)); 244 | #else 245 | pthread_join(SCTP_BASE_VAR(timer_thread), NULL); 246 | #endif 247 | } 248 | } 249 | #endif 250 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_callout.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. Neither the name of the project nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _NETINET_SCTP_CALLOUT_ 34 | #define _NETINET_SCTP_CALLOUT_ 35 | 36 | /* 37 | * NOTE: the following MACROS are required for locking the callout 38 | * queue along with a lock/mutex in the OS specific headers and 39 | * implementation files:: 40 | * - SCTP_TIMERQ_LOCK() 41 | * - SCTP_TIMERQ_UNLOCK() 42 | * - SCTP_TIMERQ_LOCK_INIT() 43 | * - SCTP_TIMERQ_LOCK_DESTROY() 44 | */ 45 | 46 | #define _SCTP_NEEDS_CALLOUT_ 1 47 | 48 | #define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */ 49 | 50 | #if defined(__Userspace__) 51 | #if defined(_WIN32) 52 | #define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx)) 53 | #define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&SCTP_BASE_VAR(timer_mtx)) 54 | #define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx)) 55 | #define SCTP_TIMERQ_LOCK_DESTROY() DeleteCriticalSection(&SCTP_BASE_VAR(timer_mtx)) 56 | #else 57 | #ifdef INVARIANTS 58 | #define SCTP_TIMERQ_LOCK() KASSERT(pthread_mutex_lock(&SCTP_BASE_VAR(timer_mtx)) == 0, ("%s: timer_mtx already locked", __func__)) 59 | #define SCTP_TIMERQ_UNLOCK() KASSERT(pthread_mutex_unlock(&SCTP_BASE_VAR(timer_mtx)) == 0, ("%s: timer_mtx not locked", __func__)) 60 | #else 61 | #define SCTP_TIMERQ_LOCK() (void)pthread_mutex_lock(&SCTP_BASE_VAR(timer_mtx)) 62 | #define SCTP_TIMERQ_UNLOCK() (void)pthread_mutex_unlock(&SCTP_BASE_VAR(timer_mtx)) 63 | #endif 64 | #define SCTP_TIMERQ_LOCK_INIT() (void)pthread_mutex_init(&SCTP_BASE_VAR(timer_mtx), &SCTP_BASE_VAR(mtx_attr)) 65 | #define SCTP_TIMERQ_LOCK_DESTROY() (void)pthread_mutex_destroy(&SCTP_BASE_VAR(timer_mtx)) 66 | #endif 67 | #endif 68 | 69 | uint32_t sctp_get_tick_count(void); 70 | 71 | TAILQ_HEAD(calloutlist, sctp_callout); 72 | 73 | struct sctp_callout { 74 | TAILQ_ENTRY(sctp_callout) tqe; 75 | uint32_t c_time; /* ticks to the event */ 76 | void *c_arg; /* function argument */ 77 | void (*c_func)(void *); /* function to call */ 78 | int c_flags; /* state of this entry */ 79 | }; 80 | typedef struct sctp_callout sctp_os_timer_t; 81 | 82 | #define SCTP_CALLOUT_ACTIVE 0x0002 /* callout is currently active */ 83 | #define SCTP_CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */ 84 | 85 | void sctp_os_timer_init(sctp_os_timer_t *tmr); 86 | /* Returns 1 if pending timer was rescheduled, 0 otherwise. */ 87 | int sctp_os_timer_start(sctp_os_timer_t *, uint32_t, void (*)(void *), void *); 88 | /* Returns 1 if pending timer was stopped, 0 otherwise. */ 89 | int sctp_os_timer_stop(sctp_os_timer_t *); 90 | void sctp_handle_tick(uint32_t); 91 | 92 | #define SCTP_OS_TIMER_INIT sctp_os_timer_init 93 | /* 94 | * NOTE: The next two shouldn't be called directly outside of sctp_timer_start() 95 | * and sctp_timer_stop(), since they don't handle incrementing/decrementing 96 | * relevant reference counts. 97 | */ 98 | #define SCTP_OS_TIMER_START sctp_os_timer_start 99 | #define SCTP_OS_TIMER_STOP sctp_os_timer_stop 100 | /* MT FIXME: Is the following correct? */ 101 | #define SCTP_OS_TIMER_STOP_DRAIN SCTP_OS_TIMER_STOP 102 | #define SCTP_OS_TIMER_PENDING(tmr) ((tmr)->c_flags & SCTP_CALLOUT_PENDING) 103 | #define SCTP_OS_TIMER_ACTIVE(tmr) ((tmr)->c_flags & SCTP_CALLOUT_ACTIVE) 104 | #define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE) 105 | 106 | #if defined(__Userspace__) 107 | void sctp_start_timer_thread(void); 108 | void sctp_stop_timer_thread(void); 109 | #endif 110 | #if defined(__APPLE__) && !defined(__Userspace__) 111 | void sctp_timeout(void *); 112 | #endif 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_crc32.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_CRC32_H_ 36 | #define _NETINET_SCTP_CRC32_H_ 37 | 38 | #if defined(_KERNEL) 39 | uint32_t sctp_calculate_cksum(struct mbuf *, int32_t); 40 | #if defined(__FreeBSD__) && !defined(__Userspace__) 41 | #if defined(SCTP) || defined(SCTP_SUPPORT) 42 | void sctp_delayed_cksum(struct mbuf *, uint32_t offset); 43 | #endif 44 | #endif 45 | #endif /* _KERNEL */ 46 | #if defined(__Userspace__) 47 | uint32_t calculate_crc32c(uint32_t, const unsigned char *, unsigned int); 48 | uint32_t sctp_finalize_crc32c(uint32_t); 49 | uint32_t sctp_calculate_cksum(struct mbuf *, int32_t); 50 | #endif 51 | #endif /* __crc32c_h__ */ 52 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_indata.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_INDATA_H_ 36 | #define _NETINET_SCTP_INDATA_H_ 37 | 38 | #if defined(_KERNEL) || defined(__Userspace__) 39 | 40 | struct sctp_queued_to_read * 41 | sctp_build_readq_entry(struct sctp_tcb *stcb, 42 | struct sctp_nets *net, 43 | uint32_t tsn, uint32_t ppid, 44 | uint32_t context, uint16_t sid, 45 | uint32_t mid, uint8_t flags, 46 | struct mbuf *dm); 47 | 48 | #define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \ 49 | if (_ctl) { \ 50 | atomic_add_int(&((net)->ref_count), 1); \ 51 | memset(_ctl, 0, sizeof(struct sctp_queued_to_read)); \ 52 | (_ctl)->sinfo_stream = sid; \ 53 | TAILQ_INIT(&_ctl->reasm); \ 54 | (_ctl)->top_fsn = tfsn; \ 55 | (_ctl)->mid = mid; \ 56 | (_ctl)->sinfo_flags = (flags << 8); \ 57 | (_ctl)->sinfo_ppid = ppid; \ 58 | (_ctl)->sinfo_context = context; \ 59 | (_ctl)->fsn_included = 0xffffffff; \ 60 | (_ctl)->sinfo_tsn = tsn; \ 61 | (_ctl)->sinfo_cumtsn = tsn; \ 62 | (_ctl)->sinfo_assoc_id = sctp_get_associd((in_it)); \ 63 | (_ctl)->whoFrom = net; \ 64 | (_ctl)->data = dm; \ 65 | (_ctl)->stcb = (in_it); \ 66 | (_ctl)->port_from = (in_it)->rport; \ 67 | if ((in_it)->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { \ 68 | (_ctl)->do_not_ref_stcb = 1; \ 69 | }\ 70 | } \ 71 | } while (0) 72 | 73 | struct mbuf * 74 | sctp_build_ctl_nchunk(struct sctp_inpcb *inp, 75 | struct sctp_sndrcvinfo *sinfo); 76 | 77 | void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *); 78 | 79 | uint32_t 80 | sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc); 81 | 82 | void 83 | sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, 84 | uint32_t rwnd, int *abort_now, int ecne_seen); 85 | 86 | void 87 | sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, 88 | struct sctp_tcb *stcb, 89 | uint16_t num_seg, uint16_t num_nr_seg, uint16_t num_dup, 90 | int *abort_now, uint8_t flags, 91 | uint32_t cum_ack, uint32_t rwnd, int ecne_seen); 92 | 93 | /* draft-ietf-tsvwg-usctp */ 94 | void 95 | sctp_handle_forward_tsn(struct sctp_tcb *, 96 | struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int); 97 | 98 | struct sctp_tmit_chunk * 99 | sctp_try_advance_peer_ack_point(struct sctp_tcb *, struct sctp_association *); 100 | 101 | void sctp_service_queues(struct sctp_tcb *, struct sctp_association *); 102 | 103 | void 104 | sctp_update_acked(struct sctp_tcb *, struct sctp_shutdown_chunk *, int *); 105 | 106 | int 107 | sctp_process_data(struct mbuf **, int, int *, int, 108 | struct sctp_inpcb *, struct sctp_tcb *, 109 | struct sctp_nets *, uint32_t *); 110 | 111 | void sctp_slide_mapping_arrays(struct sctp_tcb *stcb); 112 | 113 | void sctp_sack_check(struct sctp_tcb *, int); 114 | 115 | #endif 116 | #endif 117 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_input.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_INPUT_H_ 36 | #define _NETINET_SCTP_INPUT_H_ 37 | 38 | #if defined(_KERNEL) || defined(__Userspace__) 39 | void 40 | sctp_common_input_processing(struct mbuf **, int, int, int, 41 | struct sockaddr *, struct sockaddr *, 42 | struct sctphdr *, struct sctp_chunkhdr *, 43 | uint8_t, 44 | uint8_t, 45 | #if defined(__FreeBSD__) && !defined(__Userspace__) 46 | uint8_t, uint32_t, uint16_t, 47 | #endif 48 | uint32_t, uint16_t); 49 | 50 | struct sctp_stream_reset_request * 51 | sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, 52 | struct sctp_tmit_chunk **bchk); 53 | 54 | void 55 | sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, 56 | uint16_t *list); 57 | 58 | int sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked); 59 | 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_os.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_OS_H_ 36 | #define _NETINET_SCTP_OS_H_ 37 | 38 | /* 39 | * General kernel memory allocation: 40 | * SCTP_MALLOC(element, type, size, name) 41 | * SCTP_FREE(element) 42 | * Kernel memory allocation for "soname"- memory must be zeroed. 43 | * SCTP_MALLOC_SONAME(name, type, size) 44 | * SCTP_FREE_SONAME(name) 45 | */ 46 | 47 | /* 48 | * Zone(pool) allocation routines: MUST be defined for each OS. 49 | * zone = zone/pool pointer. 50 | * name = string name of the zone/pool. 51 | * size = size of each zone/pool element. 52 | * number = number of elements in zone/pool. 53 | * type = structure type to allocate 54 | * 55 | * sctp_zone_t 56 | * SCTP_ZONE_INIT(zone, name, size, number) 57 | * SCTP_ZONE_GET(zone, type) 58 | * SCTP_ZONE_FREE(zone, element) 59 | * SCTP_ZONE_DESTROY(zone) 60 | */ 61 | 62 | #if defined(__FreeBSD__) && !defined(__Userspace__) 63 | #include 64 | #else 65 | #define MODULE_GLOBAL(_B) (_B) 66 | #endif 67 | #if defined(__Userspace__) 68 | #include 69 | #endif 70 | #if defined(__APPLE__) && !defined(__Userspace__) 71 | #include 72 | #endif 73 | #if defined(_WIN32) && !defined(__Userspace__) 74 | #include 75 | #endif 76 | 77 | /* All os's must implement this address gatherer. If 78 | * no VRF's exist, then vrf 0 is the only one and all 79 | * addresses and ifn's live here. 80 | */ 81 | #define SCTP_DEFAULT_VRF 0 82 | void sctp_init_vrf_list(int vrfid); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_peeloff.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_PEELOFF_H_ 36 | #define _NETINET_SCTP_PEELOFF_H_ 37 | #if defined(HAVE_SCTP_PEELOFF_SOCKOPT) 38 | /* socket option peeloff */ 39 | struct sctp_peeloff_opt { 40 | #if !(defined(_WIN32) && !defined(__Userspace__)) 41 | int s; 42 | #else 43 | HANDLE s; 44 | #endif 45 | sctp_assoc_t assoc_id; 46 | #if !(defined(_WIN32) && !defined(__Userspace__)) 47 | int new_sd; 48 | #else 49 | HANDLE new_sd; 50 | #endif 51 | }; 52 | #endif /* HAVE_SCTP_PEELOFF_SOCKOPT */ 53 | #if defined(_KERNEL) 54 | int sctp_can_peel_off(struct socket *, sctp_assoc_t); 55 | int sctp_do_peeloff(struct socket *, struct socket *, sctp_assoc_t); 56 | #if defined(HAVE_SCTP_PEELOFF_SOCKOPT) 57 | struct socket *sctp_get_peeloff(struct socket *, sctp_assoc_t, int *); 58 | int sctp_peeloff_option(struct proc *p, struct sctp_peeloff_opt *peeloff); 59 | #endif /* HAVE_SCTP_PEELOFF_SOCKOPT */ 60 | #endif /* _KERNEL */ 61 | #if defined(__Userspace__) 62 | int sctp_can_peel_off(struct socket *, sctp_assoc_t); 63 | int sctp_do_peeloff(struct socket *, struct socket *, sctp_assoc_t); 64 | #endif /* __Userspace__ */ 65 | #endif /* _NETINET_SCTP_PEELOFF_H_ */ 66 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_sha1.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef __NETINET_SCTP_SHA1_H__ 36 | #define __NETINET_SCTP_SHA1_H__ 37 | 38 | #include 39 | #if defined(SCTP_USE_NSS_SHA1) 40 | #include 41 | #elif defined(SCTP_USE_OPENSSL_SHA1) 42 | #include 43 | #endif 44 | 45 | struct sctp_sha1_context { 46 | #if defined(SCTP_USE_NSS_SHA1) 47 | struct PK11Context *pk11_ctx; 48 | #elif defined(SCTP_USE_OPENSSL_SHA1) 49 | SHA_CTX sha_ctx; 50 | #else 51 | unsigned int A; 52 | unsigned int B; 53 | unsigned int C; 54 | unsigned int D; 55 | unsigned int E; 56 | unsigned int H0; 57 | unsigned int H1; 58 | unsigned int H2; 59 | unsigned int H3; 60 | unsigned int H4; 61 | unsigned int words[80]; 62 | unsigned int TEMP; 63 | /* block I am collecting to process */ 64 | char sha_block[64]; 65 | /* collected so far */ 66 | int how_many_in_block; 67 | unsigned int running_total; 68 | #endif 69 | }; 70 | 71 | #if (defined(__APPLE__) && !defined(__Userspace__) && defined(KERNEL)) 72 | #ifndef _KERNEL 73 | #define _KERNEL 74 | #endif 75 | #endif 76 | 77 | #if defined(_KERNEL) || defined(__Userspace__) 78 | 79 | void sctp_sha1_init(struct sctp_sha1_context *); 80 | void sctp_sha1_update(struct sctp_sha1_context *, const unsigned char *, unsigned int); 81 | void sctp_sha1_final(unsigned char *, struct sctp_sha1_context *); 82 | 83 | #endif 84 | #endif 85 | -------------------------------------------------------------------------------- /usrsctplib/netinet/sctp_timer.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET_SCTP_TIMER_H_ 36 | #define _NETINET_SCTP_TIMER_H_ 37 | 38 | #if defined(_KERNEL) || defined(__Userspace__) 39 | 40 | #define SCTP_RTT_SHIFT 3 41 | #define SCTP_RTT_VAR_SHIFT 2 42 | 43 | struct sctp_nets * 44 | sctp_find_alternate_net(struct sctp_tcb *, struct sctp_nets *, int); 45 | 46 | int 47 | sctp_t3rxt_timer(struct sctp_inpcb *, struct sctp_tcb *, 48 | struct sctp_nets *); 49 | 50 | int 51 | sctp_t1init_timer(struct sctp_inpcb *, struct sctp_tcb *, 52 | struct sctp_nets *); 53 | 54 | int 55 | sctp_shutdown_timer(struct sctp_inpcb *, struct sctp_tcb *, 56 | struct sctp_nets *); 57 | 58 | int 59 | sctp_heartbeat_timer(struct sctp_inpcb *, struct sctp_tcb *, 60 | struct sctp_nets *); 61 | 62 | int 63 | sctp_cookie_timer(struct sctp_inpcb *, struct sctp_tcb *, 64 | struct sctp_nets *); 65 | 66 | void 67 | sctp_pathmtu_timer(struct sctp_inpcb *, struct sctp_tcb *, 68 | struct sctp_nets *); 69 | 70 | int 71 | sctp_shutdownack_timer(struct sctp_inpcb *, struct sctp_tcb *, 72 | struct sctp_nets *); 73 | int 74 | sctp_strreset_timer(struct sctp_inpcb *, struct sctp_tcb *); 75 | 76 | int 77 | sctp_asconf_timer(struct sctp_inpcb *, struct sctp_tcb *, 78 | struct sctp_nets *); 79 | 80 | void 81 | sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *); 82 | 83 | void 84 | sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *); 85 | 86 | void sctp_audit_retranmission_queue(struct sctp_association *); 87 | 88 | void sctp_iterator_timer(struct sctp_iterator *it); 89 | 90 | #if defined(__APPLE__) && !defined(__Userspace__) 91 | #if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION) 92 | void sctp_slowtimo(void); 93 | #else 94 | void sctp_gc(struct inpcbinfo *); 95 | #endif 96 | #endif 97 | #endif 98 | #endif 99 | -------------------------------------------------------------------------------- /usrsctplib/netinet6/meson.build: -------------------------------------------------------------------------------- 1 | sources += files('sctp6_usrreq.c') 2 | -------------------------------------------------------------------------------- /usrsctplib/netinet6/sctp6_var.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * a) Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * b) Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the distribution. 17 | * 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 | * contributors may be used to endorse or promote products derived 20 | * from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | * THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _NETINET6_SCTP6_VAR_H_ 36 | #define _NETINET6_SCTP6_VAR_H_ 37 | 38 | #if defined(__Userspace__) 39 | #ifdef INET 40 | extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); 41 | extern void in6_sin6_2_sin_in_sock(struct sockaddr *); 42 | extern void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 *); 43 | #endif 44 | #endif 45 | #if defined(_KERNEL) 46 | 47 | #if !defined(__Userspace__) 48 | SYSCTL_DECL(_net_inet6_sctp6); 49 | #if defined(__FreeBSD__) 50 | extern struct protosw sctp6_seqpacket_protosw, sctp6_stream_protosw; 51 | #else 52 | extern struct pr_usrreqs sctp6_usrreqs; 53 | #endif 54 | #else 55 | int sctp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *); 56 | #endif 57 | 58 | #if defined(__APPLE__) && !defined(__Userspace__) 59 | int sctp6_input(struct mbuf **, int *); 60 | int sctp6_input_with_port(struct mbuf **, int *, uint16_t); 61 | #else 62 | int sctp6_input(struct mbuf **, int *, int); 63 | int sctp6_input_with_port(struct mbuf **, int *, uint16_t); 64 | #endif 65 | int sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, 66 | struct mbuf *, struct proc *); 67 | #if defined(__APPLE__) && !defined(__Userspace__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) 68 | void sctp6_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED); 69 | #elif defined(__FreeBSD__) && !defined(__Userspace__) 70 | ip6proto_ctlinput_t sctp6_ctlinput; 71 | #else 72 | void sctp6_ctlinput(int, struct sockaddr_in6 *, ip6ctlparam *); 73 | #endif 74 | #if !((defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__)) 75 | extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *); 76 | extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *); 77 | extern void in6_sin6_2_sin_in_sock(struct sockaddr *); 78 | #endif 79 | void sctp6_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *, 80 | uint8_t, uint8_t, uint32_t); 81 | #endif 82 | #endif 83 | -------------------------------------------------------------------------------- /usrsctplib/user_environment.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009-2010 Brad Penoff 3 | * Copyright (c) 2009-2010 Humaira Kamal 4 | * Copyright (c) 2011-2012 Irene Ruengeler 5 | * Copyright (c) 2011-2012 Michael Tuexen 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _USER_ENVIRONMENT_H_ 32 | #define _USER_ENVIRONMENT_H_ 33 | /* __Userspace__ */ 34 | #include 35 | 36 | #ifdef __FreeBSD__ 37 | #ifndef _SYS_MUTEX_H_ 38 | #include 39 | #endif 40 | #endif 41 | #if defined(_WIN32) 42 | #include "netinet/sctp_os_userspace.h" 43 | #endif 44 | 45 | /* maxsockets is used in SCTP_ZONE_INIT call. It refers to 46 | * kern.ipc.maxsockets kernel environment variable. 47 | */ 48 | extern int maxsockets; 49 | 50 | /* int hz; is declared in sys/kern/subr_param.c and refers to kernel timer frequency. 51 | * See http://ivoras.sharanet.org/freebsd/vmware.html for additional info about kern.hz 52 | * hz is initialized in void init_param1(void) in that file. 53 | */ 54 | extern int hz; 55 | 56 | 57 | /* The following two ints define a range of available ephemeral ports. */ 58 | extern int ipport_firstauto, ipport_lastauto; 59 | 60 | /* nmbclusters is used in sctp_usrreq.c (e.g., sctp_init). In the FreeBSD kernel, 61 | * this is 1024 + maxusers * 64. 62 | */ 63 | extern int nmbclusters; 64 | 65 | #if !defined(_MSC_VER) && !defined(__MINGW32__) 66 | #define min(a,b) (((a)>(b))?(b):(a)) 67 | #define max(a,b) (((a)>(b))?(a):(b)) 68 | #endif 69 | 70 | void init_random(void); 71 | void read_random(void *, size_t); 72 | void finish_random(void); 73 | 74 | /* errno's may differ per OS. errno.h now included in sctp_os_userspace.h */ 75 | /* Source: /usr/src/sys/sys/errno.h */ 76 | /* #define ENOSPC 28 */ /* No space left on device */ 77 | /* #define ENOBUFS 55 */ /* No buffer space available */ 78 | /* #define ENOMEM 12 */ /* Cannot allocate memory */ 79 | /* #define EACCES 13 */ /* Permission denied */ 80 | /* #define EFAULT 14 */ /* Bad address */ 81 | /* #define EHOSTDOWN 64 */ /* Host is down */ 82 | /* #define EHOSTUNREACH 65 */ /* No route to host */ 83 | 84 | /* Source ip_output.c. extern'd in ip_var.h */ 85 | extern u_short ip_id; 86 | 87 | #if defined(__linux__) 88 | #define IPV6_VERSION 0x60 89 | #endif 90 | 91 | #if defined(INVARIANTS) 92 | #include 93 | 94 | #if defined(_WIN32) 95 | static inline void __declspec(noreturn) 96 | #else 97 | static inline void __attribute__((__noreturn__)) 98 | #endif 99 | terminate_non_graceful(void) { 100 | abort(); 101 | } 102 | 103 | #define panic(...) \ 104 | do { \ 105 | SCTP_PRINTF("%s(): ", __func__); \ 106 | SCTP_PRINTF(__VA_ARGS__); \ 107 | SCTP_PRINTF("\n"); \ 108 | terminate_non_graceful(); \ 109 | } while (0) 110 | 111 | #define KASSERT(cond, args) \ 112 | do { \ 113 | if (!(cond)) { \ 114 | panic args ; \ 115 | } \ 116 | } while (0) 117 | #else 118 | #define KASSERT(cond, args) 119 | #endif 120 | 121 | /* necessary for sctp_pcb.c */ 122 | extern int ip_defttl; 123 | #endif 124 | -------------------------------------------------------------------------------- /usrsctplib/user_ip6_var.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the project nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | */ 30 | /*- 31 | * Copyright (c) 1982, 1986, 1993 32 | * The Regents of the University of California. All rights reserved. 33 | * 34 | * Redistribution and use in source and binary forms, with or without 35 | * modification, are permitted provided that the following conditions 36 | * are met: 37 | * 1. Redistributions of source code must retain the above copyright 38 | * notice, this list of conditions and the following disclaimer. 39 | * 2. Redistributions in binary form must reproduce the above copyright 40 | * notice, this list of conditions and the following disclaimer in the 41 | * documentation and/or other materials provided with the distribution. 42 | * 3. Neither the name of the University nor the names of its contributors 43 | * may be used to endorse or promote products derived from this software 44 | * without specific prior written permission. 45 | * 46 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 47 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 48 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 49 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 50 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 51 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 52 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 54 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 55 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56 | * SUCH DAMAGE. 57 | * 58 | */ 59 | 60 | #ifndef _USER_IP6_VAR_H_ 61 | #define _USER_IP6_VAR_H_ 62 | 63 | #if defined(_WIN32) 64 | struct ip6_hdr { 65 | union { 66 | struct ip6_hdrctl { 67 | uint32_t ip6_un1_flow; /* 20 bits of flow-ID */ 68 | uint16_t ip6_un1_plen; /* payload length */ 69 | uint8_t ip6_un1_nxt; /* next header */ 70 | uint8_t ip6_un1_hlim; /* hop limit */ 71 | } ip6_un1; 72 | uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ 73 | } ip6_ctlun; 74 | struct in6_addr ip6_src; /* source address */ 75 | struct in6_addr ip6_dst; /* destination address */ 76 | }; 77 | #define ip6_vfc ip6_ctlun.ip6_un2_vfc 78 | #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow 79 | #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen 80 | #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt 81 | #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim 82 | #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim 83 | 84 | #define IPV6_VERSION 0x60 85 | #endif 86 | 87 | #if defined(_WIN32) 88 | #define s6_addr16 u.Word 89 | #endif 90 | #if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__) 91 | #define s6_addr8 __u6_addr.__u6_addr8 92 | #define s6_addr16 __u6_addr.__u6_addr16 93 | #define s6_addr32 __u6_addr.__u6_addr32 94 | #endif 95 | 96 | #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) 97 | struct route_in6 { 98 | struct rtentry *ro_rt; 99 | struct llentry *ro_lle; 100 | struct in6_addr *ro_ia6; 101 | int ro_flags; 102 | struct sockaddr_in6 ro_dst; 103 | }; 104 | #endif 105 | #define IP6_EXTHDR_GET(val, typ, m, off, len) \ 106 | do { \ 107 | struct mbuf *t; \ 108 | int tmp; \ 109 | if ((m)->m_len >= (off) + (len)) \ 110 | (val) = (typ)(mtod((m), caddr_t) + (off)); \ 111 | else { \ 112 | t = m_pulldown((m), (off), (len), &tmp); \ 113 | if (t) { \ 114 | KASSERT(t->m_len >= tmp + (len), \ 115 | ("m_pulldown malfunction")); \ 116 | (val) = (typ)(mtod(t, caddr_t) + tmp); \ 117 | } else { \ 118 | (val) = (typ)NULL; \ 119 | (m) = NULL; \ 120 | } \ 121 | } \ 122 | } while (0) 123 | 124 | #endif /* !_USER_IP6_VAR_H_ */ 125 | -------------------------------------------------------------------------------- /usrsctplib/user_recv_thread.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012 Michael Tuexen 3 | * Copyright (c) 2012 Irene Ruengeler 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _USER_RECV_THREAD_H_ 29 | #define _USER_RECV_THREAD_H_ 30 | 31 | void recv_thread_init(void); 32 | void recv_thread_destroy(void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /usrsctplib/user_route.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1980, 1986, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _USER_ROUTE_H_ 32 | #define _USER_ROUTE_H_ 33 | 34 | /* 35 | * Kernel resident routing tables. 36 | * 37 | * The routing tables are initialized when interface addresses 38 | * are set by making entries for all directly connected interfaces. 39 | */ 40 | 41 | /* 42 | * A route consists of a destination address and a reference 43 | * to a routing entry. These are often held by protocols 44 | * in their control blocks, e.g. inpcb. 45 | */ 46 | 47 | struct sctp_route { 48 | struct sctp_rtentry *ro_rt; 49 | struct sockaddr ro_dst; 50 | }; 51 | 52 | /* 53 | * These numbers are used by reliable protocols for determining 54 | * retransmission behavior and are included in the routing structure. 55 | */ 56 | struct sctp_rt_metrics_lite { 57 | uint32_t rmx_mtu; /* MTU for this path */ 58 | #if 0 59 | u_long rmx_expire; /* lifetime for route, e.g. redirect */ 60 | u_long rmx_pksent; /* packets sent using this route */ 61 | #endif 62 | }; 63 | 64 | /* 65 | * We distinguish between routes to hosts and routes to networks, 66 | * preferring the former if available. For each route we infer 67 | * the interface to use from the gateway address supplied when 68 | * the route was entered. Routes that forward packets through 69 | * gateways are marked so that the output routines know to address the 70 | * gateway rather than the ultimate destination. 71 | */ 72 | struct sctp_rtentry { 73 | #if 0 74 | struct radix_node rt_nodes[2]; /* tree glue, and other values */ 75 | /* 76 | * XXX struct rtentry must begin with a struct radix_node (or two!) 77 | * because the code does some casts of a 'struct radix_node *' 78 | * to a 'struct rtentry *' 79 | */ 80 | #define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key))) 81 | #define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask))) 82 | struct sockaddr *rt_gateway; /* value */ 83 | u_long rt_flags; /* up/down?, host/net */ 84 | #endif 85 | struct ifnet *rt_ifp; /* the answer: interface to use */ 86 | struct ifaddr *rt_ifa; /* the answer: interface address to use */ 87 | struct sctp_rt_metrics_lite rt_rmx; /* metrics used by rx'ing protocols */ 88 | long rt_refcnt; /* # held references */ 89 | #if 0 90 | struct sockaddr *rt_genmask; /* for generation of cloned routes */ 91 | caddr_t rt_llinfo; /* pointer to link level info cache */ 92 | struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */ 93 | struct rtentry *rt_parent; /* cloning parent of this route */ 94 | #endif 95 | struct mtx rt_mtx; /* mutex for routing entry */ 96 | }; 97 | 98 | #define RT_LOCK_INIT(_rt) mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK) 99 | #define RT_LOCK(_rt) mtx_lock(&(_rt)->rt_mtx) 100 | #define RT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx) 101 | #define RT_LOCK_DESTROY(_rt) mtx_destroy(&(_rt)->rt_mtx) 102 | #define RT_LOCK_ASSERT(_rt) mtx_assert(&(_rt)->rt_mtx, MA_OWNED) 103 | 104 | #define RT_ADDREF(_rt) do { \ 105 | RT_LOCK_ASSERT(_rt); \ 106 | KASSERT((_rt)->rt_refcnt >= 0, \ 107 | ("negative refcnt %ld", (_rt)->rt_refcnt)); \ 108 | (_rt)->rt_refcnt++; \ 109 | } while (0) 110 | #define RT_REMREF(_rt) do { \ 111 | RT_LOCK_ASSERT(_rt); \ 112 | KASSERT((_rt)->rt_refcnt > 0, \ 113 | ("bogus refcnt %ld", (_rt)->rt_refcnt)); \ 114 | (_rt)->rt_refcnt--; \ 115 | } while (0) 116 | #define RTFREE_LOCKED(_rt) do { \ 117 | if ((_rt)->rt_refcnt <= 1) { \ 118 | rtfree(_rt); \ 119 | } else { \ 120 | RT_REMREF(_rt); \ 121 | RT_UNLOCK(_rt); \ 122 | } \ 123 | /* guard against invalid refs */ \ 124 | _rt = NULL; \ 125 | } while (0) 126 | #define RTFREE(_rt) do { \ 127 | RT_LOCK(_rt); \ 128 | RTFREE_LOCKED(_rt); \ 129 | } while (0) 130 | #endif 131 | -------------------------------------------------------------------------------- /usrsctplib/user_uma.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009-2010 Brad Penoff 3 | * Copyright (c) 2009-2010 Humaira Kamal 4 | * Copyright (c) 2011-2012 Irene Ruengeler 5 | * Copyright (c) 2011-2012 Michael Tuexen 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _USER_UMA_H_ 32 | #define _USER_UMA_H_ 33 | 34 | #define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */ 35 | #define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */ 36 | 37 | /* __Userspace__ All these definitions will change for 38 | userspace Universal Memory Allocator (UMA). These are included 39 | for reference purposes and to avoid compile errors for the time being. 40 | */ 41 | typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags); 42 | typedef void (*uma_dtor)(void *mem, int size, void *arg); 43 | typedef int (*uma_init)(void *mem, int size, int flags); 44 | typedef void (*uma_fini)(void *mem, int size); 45 | typedef struct uma_zone * uma_zone_t; 46 | typedef struct uma_keg * uma_keg_t; 47 | 48 | struct uma_cache { 49 | int stub; /* TODO __Userspace__ */ 50 | }; 51 | 52 | struct uma_keg { 53 | int stub; /* TODO __Userspace__ */ 54 | }; 55 | 56 | struct uma_zone { 57 | char *uz_name; /* Text name of the zone */ 58 | struct mtx *uz_lock; /* Lock for the zone (keg's lock) */ 59 | uma_keg_t uz_keg; /* Our underlying Keg */ 60 | 61 | LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */ 62 | LIST_HEAD(,uma_bucket) uz_full_bucket; /* full buckets */ 63 | LIST_HEAD(,uma_bucket) uz_free_bucket; /* Buckets for frees */ 64 | 65 | uma_ctor uz_ctor; /* Constructor for each allocation */ 66 | uma_dtor uz_dtor; /* Destructor */ 67 | uma_init uz_init; /* Initializer for each item */ 68 | uma_fini uz_fini; /* Discards memory */ 69 | 70 | u_int64_t uz_allocs; /* Total number of allocations */ 71 | u_int64_t uz_frees; /* Total number of frees */ 72 | u_int64_t uz_fails; /* Total number of alloc failures */ 73 | uint16_t uz_fills; /* Outstanding bucket fills */ 74 | uint16_t uz_count; /* Highest value ub_ptr can have */ 75 | 76 | /* 77 | * This HAS to be the last item because we adjust the zone size 78 | * based on NCPU and then allocate the space for the zones. 79 | */ 80 | struct uma_cache uz_cpu[1]; /* Per cpu caches */ 81 | }; 82 | 83 | /* Prototype */ 84 | uma_zone_t 85 | uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, 86 | uma_init uminit, uma_fini fini, int align, uint32_t flags); 87 | 88 | 89 | #define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */ 90 | 91 | uma_zone_t 92 | uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, 93 | uma_init uminit, uma_fini fini, int align, uint32_t flags) { 94 | return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */ 95 | } 96 | #endif 97 | --------------------------------------------------------------------------------