提交 e06c153c authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update Catch and usrsctp

上级 e6f9feb7
......@@ -6,6 +6,8 @@
* Update NPM deps.
* Add `LICENSE` and `PATENTS` files in `libwebrtc` dependency (issue #495).
* Added `worker/src/Utils/README_BASE64_UTILS` (issue #497).
* Update `Catch` to 2.13.4.
* Update `usrsctp`.
### 3.6.29
......
......@@ -47,7 +47,7 @@
"testRegex": "test/test.*\\.js"
},
"dependencies": {
"@types/node": "^14.14.16",
"@types/node": "^14.14.19",
"awaitqueue": "^2.3.3",
"debug": "^4.3.1",
"h264-profile-level-id": "^1.0.1",
......@@ -60,10 +60,10 @@
"@types/debug": "^4.1.5",
"@types/random-number": "0.0.0",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"cross-env": "^7.0.3",
"eslint": "^7.16.0",
"eslint": "^7.17.0",
"eslint-plugin-jest": "^24.1.3",
"gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27",
......
......@@ -3,8 +3,15 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
# Header-only rule to export catch2/catch.hpp.
cc_library(
name = "catch2",
hdrs = ["single_include/catch2/catch.hpp"],
visibility = ["//visibility:public"],
includes = ["single_include/"],
name = "catch2",
hdrs = ["single_include/catch2/catch.hpp"],
includes = ["single_include/"],
visibility = ["//visibility:public"],
)
cc_library(
name = "catch2_with_main",
srcs = ["src/catch_with_main.cpp"],
visibility = ["//visibility:public"],
deps = ["//:catch2"],
)
......@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
project(Catch2 LANGUAGES CXX VERSION 2.13.2)
project(Catch2 LANGUAGES CXX VERSION 2.13.4)
# Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
......@@ -103,6 +103,12 @@ endif()
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
add_library(Catch2::Catch2 ALIAS Catch2)
# Hacky support for compiling the impl into a static lib
add_library(Catch2WithMain ${CMAKE_CURRENT_LIST_DIR}/src/catch_with_main.cpp)
target_link_libraries(Catch2WithMain PUBLIC Catch2)
add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain)
# Only perform the installation steps when Catch is not being used as
# a subproject via `add_subdirectory`, or the destinations will break,
# see https://github.com/catchorg/Catch2/issues/1373
......@@ -121,7 +127,7 @@ if (NOT_SUBPROJECT)
# create and install an export set for catch target as Catch2::Catch
install(
TARGETS
Catch2
Catch2 Catch2WithMain
EXPORT
Catch2Targets
DESTINATION
......
......@@ -2,14 +2,14 @@
![catch logo](artwork/catch2-logo-small.png)
[![Github Releases](https://img.shields.io/github/release/catchorg/catch2.svg)](https://github.com/catchorg/catch2/releases)
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2)
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=v2.x)](https://travis-ci.org/catchorg/Catch2)
[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2)
[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2)
[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/v2.x/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/6JUH8Eybx4CtvkJS)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.13.2/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
<a href="https://github.com/catchorg/Catch2/releases/download/v2.13.4/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released!
......
......@@ -19,7 +19,7 @@ coverage:
codecov:
branch: master
branch: v2.x
comment:
layout: "diff"
......@@ -10,7 +10,7 @@ class CatchConan(ConanFile):
homepage = url
license = "BSL-1.0"
exports = "LICENSE.txt"
exports_sources = ("single_include/*", "CMakeLists.txt", "CMake/*", "contrib/*")
exports_sources = ("single_include/*", "CMakeLists.txt", "CMake/*", "contrib/*", "src/*")
generators = "cmake"
def package(self):
......
......@@ -202,4 +202,5 @@ endfunction()
set(_CATCH_DISCOVER_TESTS_SCRIPT
${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake
CACHE INTERNAL "Catch2 full path to CatchAddTests.cmake helper file"
)
......@@ -108,7 +108,8 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
ParseAndAddCatchTests_RemoveComments(Contents)
# Find definition of test names
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*,[ \t\n]*\"[^\"]*\"([^\(\)]+(\\([^\)]*\\))*)*\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
# https://regex101.com/r/JygOND/1
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^\,\)]*)*\\)[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests)
ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
......@@ -119,6 +120,14 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
)
endif()
# check CMP0110 policy for new add_test() behavior
if(POLICY CMP0110)
cmake_policy(GET CMP0110 _cmp0110_value) # new add_test() behavior
else()
# just to be thorough explicitly set the variable
set(_cmp0110_value)
endif()
foreach(TestName ${Tests})
# Strip newlines
string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}")
......@@ -193,14 +202,18 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
# Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were neccessary,
# only with CMake 3.18.0 the escaped double quotes confuse the call. This change is reverted in 3.18.1
if(NOT ${CMAKE_VERSION} VERSION_EQUAL "3.18")
# And properly introduced in 3.19 with the CMP0110 policy
if(_cmp0110_value STREQUAL "NEW" OR ${CMAKE_VERSION} VERSION_EQUAL "3.18")
ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to NEW, no need for add_test(\"\") workaround")
else()
ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to OLD adding \"\" for add_test() workaround")
set(CTestName "\"${CTestName}\"")
endif()
# Handle template test cases
if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*")
set(Name "${Name} - *")
endif()
# Handle template test cases
if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*")
set(Name "${Name} - *")
endif()
# Add the test and set its properties
add_test(NAME "${CTestName}" COMMAND ${OptionalCatchTestLauncher} $<TARGET_FILE:${TestTarget}> ${Name} ${AdditionalCatchParameters})
......@@ -228,6 +241,7 @@ endfunction()
# entry point
function(ParseAndAddCatchTests TestTarget)
message(DEPRECATION "ParseAndAddCatchTest: function deprecated because of possibility of missed test cases. Consider using 'catch_discover_tests' from 'Catch.cmake'")
ParseAndAddCatchTests_PrintDebugMessage("Started parsing ${TestTarget}")
get_target_property(SourceFiles ${TestTarget} SOURCES)
ParseAndAddCatchTests_PrintDebugMessage("Found the following sources: ${SourceFiles}")
......
......@@ -57,7 +57,7 @@ with automatically registering their `TEST_CASE`s with CTest. They
can be found in the `contrib` folder, and are
1) `Catch.cmake` (and its dependency `CatchAddTests.cmake`)
2) `ParseAndAddCatchTests.cmake`
2) `ParseAndAddCatchTests.cmake` (deprecated)
If Catch2 has been installed in system, both of these can be used after
doing `find_package(Catch2 REQUIRED)`. Otherwise you need to add them
......@@ -176,10 +176,17 @@ the output file name e.g. ".xml".
### `ParseAndAddCatchTests.cmake`
⚠ This script is [deprecated](https://github.com/catchorg/Catch2/pull/2120)
in Catch 2.13.4 and superseded by the above approach using `catch_discover_tests`.
See [#2092](https://github.com/catchorg/Catch2/issues/2092) for details.
`ParseAndAddCatchTests` works by parsing all implementation files
associated with the provided target, and registering them via CTest's
`add_test`. This approach has some limitations, such as the fact that
commented-out tests will be registered anyway.
commented-out tests will be registered anyway. More serious, only a
subset of the assertion macros currently available in Catch can be
detected by this script and tests with any macros that cannot be
parsed are *silently ignored*.
#### Usage
......
......@@ -21,8 +21,8 @@ to the codebase itself.
## Using Git(Hub)
Ongoing development happens in the `master` branch for Catch2 v2, and in
`dev-v3` for the next major version, v3.
Ongoing development happens in the `v2.x` branch for Catch2 v2, and in
`devel` for the next major version, v3.
Commits should be small and atomic. A commit is atomic when, after it is
applied, the codebase, tests and all, still works as expected. Small
......
......@@ -72,6 +72,13 @@ Instead you will have to write this:
REQUIRE_THAT(foo(), m1 || m2 || m3);
```
### `ParseAndAddCatchTests.cmake`
The CMake/CTest integration using `ParseAndAddCatchTests.cmake` is deprecated,
as it can be replaced by `Catch.cmake` that provides the function
`catch_discover_tests` to get tests directly from a CMake target via the
command line interface instead of parsing C++ code with regular expressions.
## Planned changes
......
......@@ -94,6 +94,9 @@ A thread-safe header-only mocking framework for C++14.
## Applications & Tools
### [App Mesh](https://github.com/laoshanxi/app-mesh)
A high available cloud native micro-service application management platform implemented by modern C++.
### [ArangoDB](https://github.com/arangodb/arangodb)
ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values.
......
......@@ -2,6 +2,8 @@
# Release notes
**Contents**<br>
[2.13.4](#2134)<br>
[2.13.3](#2133)<br>
[2.13.2](#2132)<br>
[2.13.1](#2131)<br>
[2.13.0](#2130)<br>
......@@ -43,6 +45,33 @@
[Even Older versions](#even-older-versions)<br>
## 2.13.4
### Improvements
* Improved the hashing algorithm used for shuffling test cases (#2070)
* `TEST_CASE`s that differ only in the last character should be properly shuffled
* Note that this means that v2.13.4 gives you a different order of test cases than 2.13.3, even given the same seed.
### Miscellaneous
* Deprecated `ParseAndAddCatchTests` CMake integration (#2092)
* It is impossible to implement it properly for all the different test case variants Catch2 provides, and there are better options provided.
* Use `catch_discover_tests` instead, which uses runtime information about available tests.
* Fixed bug in `catch_discover_tests` that would cause it to fail when used in specific project structures (#2119)
* Added Bazel build file
* Added an experimental static library target to CMake
## 2.13.3
### Fixes
* Fixed possible infinite loop when combining generators with section filter (`-c` option) (#2025)
### Miscellaneous
* Fixed `ParseAndAddCatchTests` not finding `TEST_CASE`s without tags (#2055, #2056)
* `ParseAndAddCatchTests` supports `CMP0110` policy for changing behaviour of `add_test` (#2057)
* This was the shortlived change in CMake 3.18.0 that temporarily broke `ParseAndAddCatchTests`
## 2.13.2
### Improvements
......@@ -666,7 +695,7 @@ than `single_include/catch.hpp`.**
* CLR objects (`T^`) can now be stringified (#1216)
* This affects code compiled as C++/CLI
* Added `PredicateMatcher`, a matcher that takes an arbitrary predicate function (#1236)
* See [documentation for details](https://github.com/catchorg/Catch2/blob/master/docs/matchers.md)
* See [documentation for details](https://github.com/catchorg/Catch2/blob/v2.x/docs/matchers.md)
### Others
* Modified CMake-installed pkg-config to allow `#include <catch.hpp>`(#1239)
......@@ -694,7 +723,7 @@ than `single_include/catch.hpp`.**
* Added an option to warn (+ exit with error) when no tests were ran (#1158)
* Use as `-w NoTests`
* Added provisional support for Emscripten (#1114)
* [Added a way to override the fallback stringifier](https://github.com/catchorg/Catch2/blob/master/docs/configuration.md#fallback-stringifier) (#1024)
* [Added a way to override the fallback stringifier](https://github.com/catchorg/Catch2/blob/v2.x/docs/configuration.md#fallback-stringifier) (#1024)
* This allows project's own stringification machinery to be easily reused for Catch
* `Catch::Session::run()` now accepts `char const * const *`, allowing it to accept array of string literals (#1031, #1178)
* The embedded version of Clara was bumped to v1.1.3
......
......@@ -5,6 +5,7 @@
[Short answer](#short-answer)<br>
[Long answer](#long-answer)<br>
[Practical example](#practical-example)<br>
[Using the static library Catch2WithMain](#using-the-static-library-catch2withmain)<br>
[Other possible solutions](#other-possible-solutions)<br>
Several people have reported that test code written with Catch takes much longer to compile than they would expect. Why is that?
......@@ -64,6 +65,39 @@ tests-factorial.cpp:11: failed: Factorial(0) == 1 for: 0 == 1
Failed 1 test case, failed 1 assertion.
```
## Using the static library Catch2WithMain
Catch2 also provides a static library that implements the runner. Note
that this support is experimental, due to interactions between Catch2 v2
implementation and C++ linking limitations.
As with the `Catch2` target, the `Catch2WithMain` CMake target can be used
either from a subdirectory, or from installed build.
### CMake
```cmake
add_executable(tests-factorial tests-factorial.cpp)
target_link_libraries(tests-factorial Catch2::Catch2WithMain)
```
### bazel
```python
cc_test(
name = "hello_world_test",
srcs = [
"test/hello_world_test.cpp",
],
deps = [
"lib_hello_world",
"@catch2//:catch2_with_main",
],
)
```
## Other possible solutions
You can also opt to sacrifice some features in order to speed-up Catch's compilation times. For details see the [documentation on Catch's compile-time configuration](configuration.md#other-toggles).
......
......@@ -13,7 +13,7 @@
## Getting Catch2
The simplest way to get Catch2 is to download the latest [single header version](https://raw.githubusercontent.com/catchorg/Catch2/master/single_include/catch2/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file.
The simplest way to get Catch2 is to download the latest [single header version](https://raw.githubusercontent.com/catchorg/Catch2/v2.x/single_include/catch2/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file.
Alternative ways of getting Catch2 include using your system package
manager, or installing it using [its CMake package](cmake-integration.md#installing-catch2-from-git-repository).
......
......@@ -11,7 +11,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 2
#define CATCH_VERSION_PATCH 4
#ifdef __clang__
# pragma clang system_header
......
......@@ -71,13 +71,53 @@ namespace Catch {
// `SECTION`s.
// **The check for m_children.empty cannot be removed**.
// doing so would break `GENERATE` _not_ followed by `SECTION`s.
const bool should_wait_for_child =
!m_children.empty() &&
std::find_if( m_children.begin(),
m_children.end(),
[]( TestCaseTracking::ITrackerPtr tracker ) {
return tracker->hasStarted();
} ) == m_children.end();
const bool should_wait_for_child = [&]() {
// No children -> nobody to wait for
if ( m_children.empty() ) {
return false;
}
// If at least one child started executing, don't wait
if ( std::find_if(
m_children.begin(),
m_children.end(),
[]( TestCaseTracking::ITrackerPtr tracker ) {
return tracker->hasStarted();
} ) != m_children.end() ) {
return false;
}
// No children have started. We need to check if they _can_
// start, and thus we should wait for them, or they cannot
// start (due to filters), and we shouldn't wait for them
auto* parent = m_parent;
// This is safe: there is always at least one section
// tracker in a test case tracking tree
while ( !parent->isSectionTracker() ) {
parent = &( parent->parent() );
}
assert( parent &&
"Missing root (test case) level section" );
auto const& parentSection =
static_cast<SectionTracker&>( *parent );
auto const& filters = parentSection.getFilters();
// No filters -> no restrictions on running sections
if ( filters.empty() ) {
return true;
}
for ( auto const& child : m_children ) {
if ( child->isSectionTracker() &&
std::find( filters.begin(),
filters.end(),
static_cast<SectionTracker&>( *child )
.trimmedName() ) !=
filters.end() ) {
return true;
}
}
return false;
}();
// This check is a bit tricky, because m_generator->next()
// has a side-effect, where it consumes generator's current
......
......@@ -22,24 +22,28 @@ namespace Catch {
namespace {
struct TestHasher {
explicit TestHasher(Catch::SimplePcg32& rng_instance) {
basis = rng_instance();
basis <<= 32;
basis |= rng_instance();
}
using hash_t = uint64_t;
uint64_t basis;
explicit TestHasher( hash_t hashSuffix ):
m_hashSuffix{ hashSuffix } {}
uint64_t operator()(TestCase const& t) const {
// Modified FNV-1a hash
static constexpr uint64_t prime = 1099511628211;
uint64_t hash = basis;
for (const char c : t.name) {
uint32_t operator()( TestCase const& t ) const {
// FNV-1a hash with multiplication fold.
const hash_t prime = 1099511628211u;
hash_t hash = 14695981039346656037u;
for ( const char c : t.name ) {
hash ^= c;
hash *= prime;
}
return hash;
hash ^= m_hashSuffix;
hash *= prime;
const uint32_t low{ static_cast<uint32_t>( hash ) };
const uint32_t high{ static_cast<uint32_t>( hash >> 32 ) };
return low * high;
}
private:
hash_t m_hashSuffix;
};
} // end unnamed namespace
......@@ -58,9 +62,9 @@ namespace Catch {
case RunTests::InRandomOrder: {
seedRng( config );
TestHasher h( rng() );
TestHasher h{ config.rngSeed() };
using hashedTest = std::pair<uint64_t, TestCase const*>;
using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>;
std::vector<hashedTest> indexed_tests;
indexed_tests.reserve( unsortedTestCases.size() );
......
......@@ -233,6 +233,14 @@ namespace TestCaseTracking {
m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() );
}
std::vector<std::string> const& SectionTracker::getFilters() const {
return m_filters;
}
std::string const& SectionTracker::trimmedName() const {
return m_trimmed_name;
}
} // namespace TestCaseTracking
using TestCaseTracking::ITracker;
......
......@@ -163,6 +163,10 @@ namespace TestCaseTracking {
void addInitialFilters( std::vector<std::string> const& filters );
void addNextFilters( std::vector<std::string> const& filters );
//! Returns filters active in this tracker
std::vector<std::string> const& getFilters() const;
//! Returns whitespace-trimmed name of the tracked section
std::string const& trimmedName() const;
};
} // namespace TestCaseTracking
......
......@@ -37,7 +37,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 2, "", 0 );
static Version version( 2, 13, 4, "", 0 );
return version;
}
......
......@@ -419,6 +419,33 @@ set_tests_properties(FilteredSection-1 PROPERTIES FAIL_REGULAR_EXPRESSION "No te
add_test(NAME FilteredSection-2 COMMAND $<TARGET_FILE:SelfTest> \#1394\ nested -c NestedRunSection -c s1)
set_tests_properties(FilteredSection-2 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
add_test(
NAME
FilteredSection::GeneratorsDontCauseInfiniteLoop-1
COMMAND
$<TARGET_FILE:SelfTest> "#2025: original repro" -c "fov_0"
)
set_tests_properties(FilteredSection::GeneratorsDontCauseInfiniteLoop-1
PROPERTIES
PASS_REGULAR_EXPRESSION "inside with fov: 0" # This should happen
FAIL_REGULAR_EXPRESSION "inside with fov: 1" # This would mean there was no filtering
)
# GENERATE between filtered sections (both are selected)
add_test(
NAME
FilteredSection::GeneratorsDontCauseInfiniteLoop-2
COMMAND
$<TARGET_FILE:SelfTest> "#2025: same-level sections"
-c "A"
-c "B"
)
set_tests_properties(FilteredSection::GeneratorsDontCauseInfiniteLoop-2
PROPERTIES
PASS_REGULAR_EXPRESSION "All tests passed \\(4 assertions in 1 test case\\)"
)
# AppVeyor has a Python 2.7 in path, but doesn't have .py files as autorunnable
add_test(NAME ApprovalTests COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/scripts/approvalTests.py $<TARGET_FILE:SelfTest>)
set_tests_properties(ApprovalTests PROPERTIES FAIL_REGULAR_EXPRESSION "Results differed")
......
......@@ -402,3 +402,28 @@ TEST_CASE("#1514: stderr/stdout is not captured in tests aborted by an exception
// FAIL aborts the test by throwing a Catch exception
FAIL("1514");
}
TEST_CASE( "#2025: -c shouldn't cause infinite loop", "[sections][generators][regression][.approvals]" ) {
SECTION( "Check cursor from buffer offset" ) {
auto bufPos = GENERATE_REF( range( 0, 44 ) );
WHEN( "Buffer position is " << bufPos ) { REQUIRE( 1 == 1 ); }
}
}
TEST_CASE("#2025: original repro", "[sections][generators][regression][.approvals]") {
auto fov = GENERATE(true, false);
DYNAMIC_SECTION("fov_" << fov) {
std::cout << "inside with fov: " << fov << '\n';
}
}
TEST_CASE("#2025: same-level sections", "[sections][generators][regression][.approvals]") {
SECTION("A") {
SUCCEED();
}
auto i = GENERATE(1, 2, 3);
SECTION("B") {
REQUIRE(i < 4);
}
}
......@@ -79,13 +79,15 @@ class Version:
f.write( line + "\n" )
def updateReadmeFile(version):
import updateWandbox
# Wandbox no longer accepts the single-header upload, skip
# import updateWandbox
downloadParser = re.compile( r'<a href=\"https://github.com/catchorg/Catch2/releases/download/v\d+\.\d+\.\d+/catch.hpp\">' )
success, wandboxLink = updateWandbox.uploadFiles()
if not success:
print('Error when uploading to wandbox: {}'.format(wandboxLink))
exit(1)
# success, wandboxLink = updateWandbox.uploadFiles()
# if not success:
# print('Error when uploading to wandbox: {}'.format(wandboxLink))
# exit(1)
f = open( readmePath, 'r' )
lines = []
for line in f:
......@@ -94,8 +96,8 @@ def updateReadmeFile(version):
f = open( readmePath, 'w' )
for line in lines:
line = downloadParser.sub( r'<a href="https://github.com/catchorg/Catch2/releases/download/v{0}/catch.hpp">'.format(version.getVersionString()) , line)
if '[![Try online](https://img.shields.io/badge/try-online-blue.svg)]' in line:
line = '[![Try online](https://img.shields.io/badge/try-online-blue.svg)]({0})'.format(wandboxLink)
# if '[![Try online](https://img.shields.io/badge/try-online-blue.svg)]' in line:
# line = '[![Try online](https://img.shields.io/badge/try-online-blue.svg)]({0})'.format(wandboxLink)
f.write( line + "\n" )
......@@ -127,8 +129,8 @@ def updateVersionDefine(version):
def updateVersionPlaceholder(filename, version):
with open(filename, 'rb') as file:
lines = file.readlines()
placeholderRegex = re.compile(b' in Catch X.Y.Z')
replacement = ' in Catch {}.{}.{}'.format(version.majorVersion, version.minorVersion, version.patchNumber).encode('ascii')
placeholderRegex = re.compile(b'in Catch X.Y.Z')
replacement = 'in Catch {}.{}.{}'.format(version.majorVersion, version.minorVersion, version.patchNumber).encode('ascii')
with open(filename, 'wb') as file:
for line in lines:
file.write(placeholderRegex.sub(replacement, line))
......
/*
* Catch v2.13.2
* Generated: 2020-10-07 11:32:53.302017
* Catch v2.13.4
* Generated: 2020-12-29 14:48:00.116107
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
......@@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 2
#define CATCH_VERSION_PATCH 4
#ifdef __clang__
# pragma clang system_header
......@@ -7602,6 +7602,10 @@ namespace TestCaseTracking {
void addInitialFilters( std::vector<std::string> const& filters );
void addNextFilters( std::vector<std::string> const& filters );
//! Returns filters active in this tracker
std::vector<std::string> const& getFilters() const;
//! Returns whitespace-trimmed name of the tracked section
std::string const& trimmedName() const;
};
} // namespace TestCaseTracking
......@@ -12571,13 +12575,53 @@ namespace Catch {
// `SECTION`s.
// **The check for m_children.empty cannot be removed**.
// doing so would break `GENERATE` _not_ followed by `SECTION`s.
const bool should_wait_for_child =
!m_children.empty() &&
std::find_if( m_children.begin(),
m_children.end(),
[]( TestCaseTracking::ITrackerPtr tracker ) {
return tracker->hasStarted();
} ) == m_children.end();
const bool should_wait_for_child = [&]() {
// No children -> nobody to wait for
if ( m_children.empty() ) {
return false;
}
// If at least one child started executing, don't wait
if ( std::find_if(
m_children.begin(),
m_children.end(),
[]( TestCaseTracking::ITrackerPtr tracker ) {
return tracker->hasStarted();
} ) != m_children.end() ) {
return false;
}
// No children have started. We need to check if they _can_
// start, and thus we should wait for them, or they cannot
// start (due to filters), and we shouldn't wait for them
auto* parent = m_parent;
// This is safe: there is always at least one section
// tracker in a test case tracking tree
while ( !parent->isSectionTracker() ) {
parent = &( parent->parent() );
}
assert( parent &&
"Missing root (test case) level section" );
auto const& parentSection =
static_cast<SectionTracker&>( *parent );
auto const& filters = parentSection.getFilters();
// No filters -> no restrictions on running sections
if ( filters.empty() ) {
return true;
}
for ( auto const& child : m_children ) {
if ( child->isSectionTracker() &&
std::find( filters.begin(),
filters.end(),
static_cast<SectionTracker&>( *child )
.trimmedName() ) !=
filters.end() ) {
return true;
}
}
return false;
}();
// This check is a bit tricky, because m_generator->next()
// has a side-effect, where it consumes generator's current
......@@ -14082,24 +14126,28 @@ namespace Catch {
namespace {
struct TestHasher {
explicit TestHasher(Catch::SimplePcg32& rng_instance) {
basis = rng_instance();
basis <<= 32;
basis |= rng_instance();
}
using hash_t = uint64_t;
uint64_t basis;
explicit TestHasher( hash_t hashSuffix ):
m_hashSuffix{ hashSuffix } {}
uint64_t operator()(TestCase const& t) const {
// Modified FNV-1a hash
static constexpr uint64_t prime = 1099511628211;
uint64_t hash = basis;
for (const char c : t.name) {
uint32_t operator()( TestCase const& t ) const {
// FNV-1a hash with multiplication fold.
const hash_t prime = 1099511628211u;
hash_t hash = 14695981039346656037u;
for ( const char c : t.name ) {
hash ^= c;
hash *= prime;
}
return hash;
hash ^= m_hashSuffix;
hash *= prime;
const uint32_t low{ static_cast<uint32_t>( hash ) };
const uint32_t high{ static_cast<uint32_t>( hash >> 32 ) };
return low * high;
}
private:
hash_t m_hashSuffix;
};
} // end unnamed namespace
......@@ -14117,9 +14165,9 @@ namespace Catch {
case RunTests::InRandomOrder: {
seedRng( config );
TestHasher h( rng() );
TestHasher h{ config.rngSeed() };
using hashedTest = std::pair<uint64_t, TestCase const*>;
using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>;
std::vector<hashedTest> indexed_tests;
indexed_tests.reserve( unsortedTestCases.size() );
......@@ -14449,6 +14497,14 @@ namespace TestCaseTracking {
m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() );
}
std::vector<std::string> const& SectionTracker::getFilters() const {
return m_filters;
}
std::string const& SectionTracker::trimmedName() const {
return m_trimmed_name;
}
} // namespace TestCaseTracking
using TestCaseTracking::ITracker;
......@@ -15264,7 +15320,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 2, "", 0 );
static Version version( 2, 13, 4, "", 0 );
return version;
}
......
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
name: Build with CMake
on:
push:
branches: [ master, github-actions ]
pull_request:
branches: [ master ]
jobs:
build:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
cmake_build_type: [Debug, RelWithDebInfo]
sctp_invariants: [ON, OFF]
sctp_inet6: [ON, OFF]
sctp_inet: [ON, OFF]
sctp_debug: [ON, OFF]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
path: 'usrsctp_source'
- name: Prepare dirs
shell: bash
run: |
mkdir -p cmake_build
mkdir -p cmake_install
- name: Generate CMake project
shell: bash
run: |
cd cmake_build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-Dsctp_debug=${{ matrix.sctp_debug }} \
-Dsctp_invariants=${{ matrix.sctp_invariants }} \
-Dsctp_inet6=${{ matrix.sctp_inet6 }} \
-Dsctp_inet=${{ matrix.sctp_inet }} \
-Dsctp_build_programs=ON \
-Dsctp_build_fuzzer=OFF \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cmake_install \
${GITHUB_WORKSPACE}/usrsctp_source
- name: Build and install project
shell: bash
run: |
cmake --build cmake_build \
--parallel 2 \
--config ${{ matrix.cmake_build_type }} \
--target install \
--clean-first
......@@ -69,7 +69,7 @@ endif ()
option(sctp_werror "Treat warning as error" 1)
option(sctp_link_programs_static "Link example programs static" 0)
option(sctp_build_shared_lib "Build USRSCTP as shared library" 0)
option(sctp_build_programs "Build example programs" 1)
......@@ -83,12 +83,6 @@ if (sctp_sanitizer_address AND sctp_sanitizer_memory)
message(FATAL_ERROR "Can not compile with both sanitizer options")
endif ()
if (sctp_link_programs_static OR WIN32)
set(programs_link_library "usrsctp-static")
else ()
set(programs_link_library "usrsctp")
endif ()
#################################################
# CHECK FOR TYPES AND FUNCTIONS
......@@ -259,9 +253,9 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Appl
endif ()
if (sctp_build_fuzzer)
set(CMAKE_BUILD_TYPE "DEBUG")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fsanitize=fuzzer-no-link")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
endif ()
endif ()
......
#
# Copyright (C) 2015-2015 Oleg Alexeenkov
# Copyright (C) 2015-2019 Felix Weinrank
# Copyright (C) 2015-2020 Felix Weinrank
#
# All rights reserved.
#
......@@ -116,7 +116,7 @@ foreach (source_file ${check_programs})
target_link_libraries(
${source_file_we}
${programs_link_library}
"usrsctp"
${CMAKE_THREAD_LIBS_INIT}
)
endforeach ()
......@@ -217,14 +217,6 @@ main(int argc, char *argv[])
Sleep(1*1000);
#else
sleep(1);
#endif
}
usrsctp_close(listening_socket);
while (usrsctp_finish() != 0) {
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
return (0);
......
......@@ -72,7 +72,7 @@ int inputAvailable(void)
tv.tv_usec = 0;
FD_ZERO(&fds);
#if defined(_WIN32) && !defined(__MINGW32__)
FD_SET(_fileno(stdin), &fds);
FD_SET((SOCKET)_fileno(stdin), &fds);
select(_fileno(stdin) + 1, &fds, NULL, NULL, &tv);
#else
FD_SET(STDIN_FILENO, &fds);
......@@ -308,7 +308,6 @@ main(int argc, char *argv[])
while (!done && !input_done) {
if (inputAvailable()) {
if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
buffer[strlen(buffer)] = '\0';
usrsctp_sendv(sock, buffer, strlen(buffer), NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0);
} else {
if (usrsctp_shutdown(sock, SHUT_WR) < 0) {
......
......@@ -30,7 +30,7 @@
/*
* Usage: daytime_server [local_encaps_port] [remote_encaps_port]
*
*
* Example
* Server: $ ./daytime_server 11111 22222
* Client: $ ./client 127.0.0.1 13 0 22222 11111
......@@ -128,13 +128,5 @@ main(int argc, char *argv[])
}
usrsctp_close(conn_sock);
}
usrsctp_close(sock);
while (usrsctp_finish() != 0) {
#ifdef _WIN32
Sleep(SLEEP * 1000);
#else
sleep(SLEEP);
#endif
}
return (0);
}
......@@ -136,14 +136,6 @@ main(int argc, char *argv[])
Sleep(1*1000);
#else
sleep(1);
#endif
}
usrsctp_close(sock);
while (usrsctp_finish() != 0) {
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
return (0);
......
......@@ -107,7 +107,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
rcv.rcv_sid,
rcv.rcv_ssn,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
(uint32_t)ntohl(rcv.rcv_ppid),
rcv.rcv_context);
}
free(data);
......@@ -221,7 +221,7 @@ main(int argc, char *argv[])
rcv_info.rcv_sid,
rcv_info.rcv_ssn,
rcv_info.rcv_tsn,
ntohl(rcv_info.rcv_ppid),
(uint32_t)ntohl(rcv_info.rcv_ppid),
rcv_info.rcv_context,
(flags & MSG_EOR) ? 1 : 0);
} else {
......
......@@ -128,7 +128,7 @@ handle_upcall(struct socket *sock, void *data, int flgs)
rn.recvv_rcvinfo.rcv_sid,
rn.recvv_rcvinfo.rcv_ssn,
rn.recvv_rcvinfo.rcv_tsn,
ntohl(rn.recvv_rcvinfo.rcv_ppid),
(uint32_t)ntohl(rn.recvv_rcvinfo.rcv_ppid),
rn.recvv_rcvinfo.rcv_context);
}
}
......@@ -220,14 +220,6 @@ main(int argc, char *argv[])
Sleep(1*1000);
#else
sleep(1);
#endif
}
usrsctp_close(sock);
while (usrsctp_finish() != 0) {
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
return (0);
......
......@@ -107,7 +107,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
rcv.rcv_sid,
rcv.rcv_ssn,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
(uint32_t)ntohl(rcv.rcv_ppid),
rcv.rcv_context);
if (flags & MSG_EOR) {
struct sctp_sndinfo snd_info;
......@@ -236,7 +236,7 @@ main(int argc, char *argv[])
rcv_info.rcv_sid,
rcv_info.rcv_ssn,
rcv_info.rcv_tsn,
ntohl(rcv_info.rcv_ppid),
(uint32_t)ntohl(rcv_info.rcv_ppid),
rcv_info.rcv_context,
(flags & MSG_EOR) ? 1 : 0);
if (flags & MSG_EOR) {
......
......@@ -130,7 +130,7 @@ handle_upcall(struct socket *sock, void *data, int flgs)
rn.recvv_rcvinfo.rcv_sid,
rn.recvv_rcvinfo.rcv_ssn,
rn.recvv_rcvinfo.rcv_tsn,
ntohl(rn.recvv_rcvinfo.rcv_ppid),
(uint32_t)ntohl(rn.recvv_rcvinfo.rcv_ppid),
rn.recvv_rcvinfo.rcv_context);
if (flags & MSG_EOR) {
struct sctp_sndinfo snd_info;
......@@ -237,14 +237,6 @@ main(int argc, char *argv[])
Sleep(1*1000);
#else
sleep(1);
#endif
}
usrsctp_close(sock);
while (usrsctp_finish() != 0) {
#ifdef _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
return (0);
......
......@@ -142,7 +142,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
rcv.rcv_sid,
rcv.rcv_ssn,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
(uint32_t)ntohl(rcv.rcv_ppid),
rcv.rcv_context);
}
free(data);
......@@ -248,7 +248,7 @@ main(int argc, char *argv[])
usrsctp_register_address((void *)&fd);
#ifdef _WIN32
if ((tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL)) == NULL) {
fprintf(stderr, "CreateThread() failed with error: %d\n", GetLastError());
fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError());
exit(EXIT_FAILURE);
}
#else
......
......@@ -132,7 +132,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
rcv.rcv_sid,
rcv.rcv_ssn,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
(uint32_t)ntohl(rcv.rcv_ppid),
rcv.rcv_context);
}
free(data);
......@@ -238,7 +238,7 @@ main(int argc, char *argv[])
#endif
#ifdef _WIN32
if ((tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL)) == NULL) {
fprintf(stderr, "CreateThread() failed with error: %d\n", GetLastError());
fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError());
exit(EXIT_FAILURE);
}
#else
......
......@@ -143,7 +143,7 @@ receive_cb(struct socket *s, union sctp_sockstore addr, void *data,
rcv.rcv_sid,
rcv.rcv_ssn,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
(uint32_t)ntohl(rcv.rcv_ppid),
rcv.rcv_context);
}
free(data);
......@@ -246,7 +246,7 @@ main(int argc, char *argv[])
usrsctp_register_address((void *)&fd);
#ifdef _WIN32
if ((tid = CreateThread(NULL, 0, &handle_packets, (void *)&fd, 0, NULL)) == NULL) {
fprintf(stderr, "CreateThread() failed with error: %d\n", GetLastError());
fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError());
exit(EXIT_FAILURE);
}
#else
......@@ -276,28 +276,5 @@ main(int argc, char *argv[])
perror("usrsctp_accept");
}
}
usrsctp_close(s);
usrsctp_deregister_address((void *)&fd);
while (usrsctp_finish() != 0) {
#ifdef _WIN32
Sleep(SLEEP * 1000);
#else
sleep(SLEEP);
#endif
}
#ifdef _WIN32
TerminateThread(tid, 0);
WaitForSingleObject(tid, INFINITE);
if (closesocket(fd) == SOCKET_ERROR) {
fprintf(stderr, "closesocket() failed with error: %d\n", WSAGetLastError());
}
WSACleanup();
#else
pthread_cancel(tid);
pthread_join(tid, NULL);
if (close(fd) < 0) {
perror("close");
}
#endif
return (0);
}
/*-
* Copyright (c) 2019 -2020 Felix Weinrank
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
......@@ -299,7 +325,7 @@ handle_send_failed_event(struct sctp_send_failed_event *ssfe)
fprintf(debug_target, "(flags = %x) ", ssfe->ssfe_flags);
}
fprintf(debug_target, "message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x",
ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
(uint32_t)ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
ssfe->ssfe_info.snd_flags, ssfe->ssfe_error);
n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event);
for (i = 0; i < n; i++) {
......
/*-
* Copyright (c) 2019 Felix Weinrank
* Copyright (c) 2020 Felix Weinrank
*
* All rights reserved.
*
......@@ -84,4 +84,7 @@ debug_printf_stack(const char *format, ...);
void
debug_set_target(FILE *fp);
#define FUZZER_ASSERT(x) if (!(x)) { printf("USRSCTP assertion failed: function %s, file %s, line %d.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); abort(); }
#endif /* __PROGRAMS_HELPER_H__ */
......@@ -1125,7 +1125,7 @@ handle_send_failed_event(struct sctp_send_failed_event *ssfe)
printf("(flags = %x) ", ssfe->ssfe_flags);
}
printf("message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x",
ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
(uint32_t)ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
ssfe->ssfe_info.snd_flags, ssfe->ssfe_error);
n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event);
for (i = 0; i < n; i++) {
......
......@@ -84,7 +84,11 @@ get_milliseconds_count(void)
}
static void
#ifdef _WIN32
handle_events(SOCKET sock, struct socket* s, void* sconn_addr)
#else
handle_events(int sock, struct socket* s, void* sconn_addr)
#endif
{
char *dump_buf;
ssize_t length;
......@@ -112,7 +116,11 @@ handle_events(int sock, struct socket* s, void* sconn_addr)
FD_ZERO(&rfds);
FD_SET(sock, &rfds);
#ifdef _WIN32
select(0 /* ignored */, &rfds, NULL, NULL, &tv);
#else
select(sock + 1, &rfds, NULL, NULL, &tv);
#endif
if (FD_ISSET(sock, &rfds)) {
length = recv(sock, buf, MAX_PACKET_SIZE, 0);
......@@ -190,7 +198,7 @@ on_socket_readable(struct socket* s) {
rcv_info.rcv_sid,
rcv_info.rcv_ssn,
rcv_info.rcv_tsn,
ntohl(rcv_info.rcv_ppid),
(uint32_t)ntohl(rcv_info.rcv_ppid),
rcv_info.rcv_context);
}
}
......
......@@ -183,8 +183,8 @@ handle_connection(void *arg)
unsigned long messages = 0;
unsigned long long first_length = 0;
unsigned long long sum = 0;
unsigned long long round_bytes;
struct timeval round_start;
unsigned long long round_bytes = 0;
struct timeval round_start = (struct timeval){0};
time_t round_timeout = 0;
conn_sock = *(struct socket **)arg;
......@@ -204,10 +204,10 @@ handle_connection(void *arg)
gettimeofday(&time_start, NULL);
if (round_duration > 0) {
round_bytes = 0;
gettimeofday(&round_start, NULL);
round_timeout = calc_round_timeout(round_start);
}
while (n > 0) {
recv_calls++;
if (flags & MSG_NOTIFICATION) {
......@@ -760,7 +760,7 @@ int main(int argc, char **argv)
}
#ifdef _WIN32
if ((tid = CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL)) == NULL) {
fprintf(stderr, "CreateThread() failed with error: %d\n", GetLastError());
fprintf(stderr, "CreateThread() failed with error: %lu\n", GetLastError());
#else
if ((rc = pthread_create(&tid, NULL, &handle_connection, (void *)conn_sock)) != 0) {
fprintf(stderr, "pthread_create: %s\n", strerror(rc));
......
#
# Copyright (C) 2015-2015 Oleg Alexeenkov
# Copyright (C) 2015-2019 Felix Weinrank
# Copyright (C) 2015-2020 Felix Weinrank
#
# All rights reserved.
#
......@@ -76,6 +76,9 @@ endif ()
# MISC
#################################################
if (sctp_build_shared_lib)
set(BUILD_SHARED_LIBS 1)
endif ()
#################################################
......@@ -163,19 +166,15 @@ list(APPEND usrsctp_sources
user_socket.c
)
add_library(usrsctp SHARED ${usrsctp_sources} ${usrsctp_headers})
add_library(usrsctp-static STATIC ${usrsctp_sources} ${usrsctp_headers})
add_library(usrsctp ${usrsctp_sources} ${usrsctp_headers})
target_include_directories(usrsctp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(usrsctp-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if (WIN32)
message(STATUS "link library: ws2_32")
target_link_libraries(usrsctp ws2_32 iphlpapi.lib)
target_link_libraries(usrsctp-static ws2_32 iphlpapi.lib)
target_link_libraries(usrsctp ws2_32 iphlpapi)
endif ()
set_target_properties(usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp")
set_target_properties(usrsctp PROPERTIES IMPORT_SUFFIX "_import.lib")
set_target_properties(usrsctp PROPERTIES SOVERSION 1 VERSION 1.0.0)
......@@ -188,5 +187,5 @@ endif ()
# INSTALL LIBRARY AND HEADER
#################################################
install(TARGETS usrsctp usrsctp-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS usrsctp DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES usrsctp.h DESTINATION include)
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 366750 2020-10-16 10:44:48Z tuexen $");
#endif
#ifndef _NETINET_SCTP_H_
......@@ -43,10 +43,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $
#if defined(__APPLE__) || defined(__linux__)
#include <stdint.h>
#endif
#include <sys/types.h>
#if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed))
#else
......@@ -191,7 +189,6 @@ struct sctp_paramhdr {
#define SCTP_STREAM_RESET_INCOMING 0x00000001
#define SCTP_STREAM_RESET_OUTGOING 0x00000002
/* here on down are more implementation specific */
#define SCTP_SET_DEBUG_LEVEL 0x00001005
#define SCTP_CLR_STAT_LOG 0x00001007
......@@ -213,7 +210,6 @@ struct sctp_paramhdr {
#define SCTP_PCB_STATUS 0x00001104
#define SCTP_GET_NONCE_VALUES 0x00001105
/* Special hook for dynamically setting primary for all assoc's,
* this is a write only option that requires root privilege.
*/
......@@ -336,7 +332,6 @@ struct sctp_paramhdr {
/* First-come, first-serve */
#define SCTP_SS_FIRST_COME 0x00000005
/* fragment interleave constants
* setting must be one of these or
* EINVAL returned.
......@@ -607,7 +602,6 @@ struct sctp_error_auth_invalid_hmac {
#define SCTP_MOBILITY_FASTHANDOFF 0x00000002
#define SCTP_MOBILITY_PRIM_DELETED 0x00000004
/* Smallest PMTU allowed when disabling PMTU discovery */
#define SCTP_SMALLEST_PMTU 512
/* Largest PMTU allowed when disabling PMTU discovery */
......@@ -632,9 +626,9 @@ struct sctp_error_auth_invalid_hmac {
*/
#define SCTP_MAX_SACK_DELAY 500 /* per RFC4960 */
#define SCTP_MAX_HB_INTERVAL 14400000 /* 4 hours in ms */
#define SCTP_MIN_COOKIE_LIFE 1000 /* 1 second in ms */
#define SCTP_MAX_COOKIE_LIFE 3600000 /* 1 hour in ms */
/* Types of logging/KTR tracing that can be enabled via the
* sysctl net.inet.sctp.sctp_logging. You must also enable
* SUBSYS tracing.
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 363194 2020-07-14 20:32:50Z tuexen $");
__FBSDID("$FreeBSD$");
#endif
#include <netinet/sctp_os.h>
......@@ -584,7 +584,6 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
SCTP_MOBILITY_PRIM_DELETED) &&
(stcb->asoc.primary_destination->dest_state &
SCTP_ADDR_UNCONFIRMED) == 0) {
sctp_timer_stop(SCTP_TIMER_TYPE_PRIM_DELETED,
stcb->sctp_ep, stcb, NULL,
SCTP_FROM_SCTP_ASCONF + SCTP_LOC_1);
......@@ -738,7 +737,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
sctp_m_freem(m_ack);
return;
}
if (param_length <= sizeof(struct sctp_paramhdr)) {
if (param_length < sizeof(struct sctp_asconf_paramhdr)) {
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: param length (%u) too short\n", param_length);
sctp_m_freem(m_ack);
return;
......@@ -1008,7 +1007,6 @@ sctp_asconf_nets_cleanup(struct sctp_tcb *stcb, struct sctp_ifn *ifn)
}
}
void
sctp_assoc_immediate_retrans(struct sctp_tcb *stcb, struct sctp_nets *dstnet)
{
......@@ -1369,7 +1367,6 @@ sctp_asconf_queue_mgmt(struct sctp_tcb *stcb, struct sctp_ifa *ifa,
return (0);
}
/*
* add an asconf operation for the given ifa and type.
* type = SCTP_ADD_IP_ADDRESS, SCTP_DEL_IP_ADDRESS, SCTP_SET_PRIM_ADDR.
......@@ -1780,7 +1777,7 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
sctp_asconf_ack_clear(stcb);
return;
}
if (param_length < sizeof(struct sctp_paramhdr)) {
if (param_length < sizeof(struct sctp_asconf_paramhdr)) {
sctp_asconf_ack_clear(stcb);
return;
}
......@@ -2061,7 +2058,6 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
}
int
sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, uint32_t val SCTP_UNUSED)
{
......@@ -2125,7 +2121,6 @@ sctp_asconf_iterator_ep_end(struct sctp_inpcb *inp, void *ptr, uint32_t val SCTP
laddr->action = 0;
break;
}
}
} else if (l->action == SCTP_DEL_IP_ADDRESS) {
LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
......@@ -2272,7 +2267,6 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
*/
stcb->asoc.cc_functions.sctp_set_initial_cc_param(stcb, net);
net->RTO = 0;
}
}
} else if (type == SCTP_SET_PRIM_ADDR) {
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 362377 2020-06-19 12:35:29Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_ASCONF_H_
......@@ -61,7 +61,6 @@ extern uint32_t
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t,
uint32_t);
extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr,
uint32_t val);
extern void sctp_asconf_iterator_stcb(struct sctp_inpcb *inp,
......@@ -69,7 +68,6 @@ extern void sctp_asconf_iterator_stcb(struct sctp_inpcb *inp,
void *ptr, uint32_t type);
extern void sctp_asconf_iterator_end(void *ptr, uint32_t val);
extern int32_t
sctp_set_primary_ip_address_sa(struct sctp_tcb *,
struct sockaddr *);
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 362054 2020-06-11 13:34:09Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 365071 2020-09-01 21:19:14Z mjg $");
#endif
#include <netinet/sctp_os.h>
......@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 362054 2020-06-11 13:34:09Z tue
#define SCTP_AUTH_DEBUG2 (SCTP_BASE_SYSCTL(sctp_debug_on) & SCTP_DEBUG_AUTH2)
#endif /* SCTP_DEBUG */
void
sctp_clear_chunklist(sctp_auth_chklist_t *chklist)
{
......@@ -101,7 +100,6 @@ sctp_copy_chunklist(sctp_auth_chklist_t *list)
return (new_list);
}
/*
* add a chunk to the required chunks list
*/
......@@ -241,7 +239,6 @@ sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks,
return (size);
}
/*
* allocate structure space for a key of length keylen
*/
......@@ -458,7 +455,6 @@ sctp_compute_hashkey(sctp_key_t *key1, sctp_key_t *key2, sctp_key_t *shared)
return (new_key);
}
sctp_sharedkey_t *
sctp_alloc_sharedkey(void)
{
......@@ -632,7 +628,6 @@ sctp_copy_skeylist(const struct sctp_keyhead *src, struct sctp_keyhead *dest)
return (count);
}
sctp_hmaclist_t *
sctp_alloc_hmaclist(uint16_t num_hmacs)
{
......@@ -826,7 +821,6 @@ sctp_free_authinfo(sctp_authinfo_t *authinfo)
/* SCTP_FREE(authinfo, SCTP_M_AUTH_??); */
}
uint32_t
sctp_get_auth_chunk_len(uint16_t hmac_algo)
{
......@@ -1166,7 +1160,6 @@ sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id)
return (0);
}
/*-
* clear any cached key(s) if they match the given key id on an association.
* the cached key(s) will be recomputed and re-cached at next use.
......@@ -1579,7 +1572,6 @@ sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset,
m, auth_offset, auth->hmac);
}
static void
sctp_zero_m(struct mbuf *m, uint32_t m_offset, uint32_t size)
{
......@@ -1645,10 +1637,8 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
"SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
shared_key_id, hmac_id);
#if defined(__Userspace__)
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#if defined(__Userspace__) && defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
return (0);
#endif
#endif
/* is the indicated HMAC supported? */
if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) {
......@@ -1800,7 +1790,6 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
&stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked);
}
/*-
* validates the AUTHentication related parameters in an INIT/INIT-ACK
* Note: currently only used for INIT as INIT-ACK is handled inline
......@@ -1915,7 +1904,6 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
saw_asconf = 1;
if (chunks->chunk_types[i] == SCTP_ASCONF_ACK)
saw_asconf_ack = 1;
}
if (num_chunks)
got_chklist = 1;
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 338749 2018-09-18 10:53:07Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_AUTH_H_
......@@ -99,8 +99,6 @@ typedef struct sctp_authinformation {
uint16_t recv_keyid; /* last recv keyid (cached) */
} sctp_authinfo_t;
/*
* Macros
*/
......@@ -149,7 +147,6 @@ extern void sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t keyid);
extern void sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid,
int so_locked);
/* hmac list handling */
extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs);
extern void sctp_free_hmaclist(sctp_hmaclist_t *list);
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 358080 2020-02-18 19:41:55Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 366426 2020-10-04 15:37:34Z tuexen $");
#endif
#include <netinet/sctp_os.h>
......@@ -78,8 +78,8 @@ MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");
/* Global NON-VNET structure that controls the iterator */
struct iterator_control sctp_it_ctl;
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
static void
sctp_cleanup_itqueue(void)
{
......@@ -244,7 +244,6 @@ sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
#endif /* __Userspace__ */
#endif /* INET6 */
#if !defined(__Userspace__)
static uint32_t
sctp_is_desired_interface_type(struct ifnet *ifn)
......@@ -294,13 +293,14 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
return (result);
}
#endif
#if defined(__APPLE__) && !defined(__Userspace__)
int
sctp_is_vmware_interface(struct ifnet *ifn)
{
return (strncmp(ifnet_name(ifn), "vmnet", 5) == 0);
}
#endif
#if defined(_WIN32) && defined(__Userspace__)
......@@ -476,7 +476,6 @@ sctp_init_ifns_for_vrf(int vrfid)
#endif
}
#endif
#if defined(__APPLE__) && !defined(__Userspace__)
static void
sctp_init_ifns_for_vrf(int vrfid)
......@@ -555,7 +554,6 @@ sctp_init_ifns_for_vrf(int vrfid)
ifnet_list_free(ifnetlist);
}
#endif
#if defined(__FreeBSD__) && !defined(__Userspace__)
static void
sctp_init_ifns_for_vrf(int vrfid)
......@@ -719,7 +717,6 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
#endif
(void *)ifa, ifa->ifa_addr, ifa_flags, 1);
} else {
sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr,
#if defined(__APPLE__) && !defined(__Userspace__)
ifnet_index(ifa->ifa_ifp),
......@@ -791,7 +788,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
m_freem(m);
return (NULL);
}
KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", __FUNCTION__));
KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", __func__));
}
#endif
#ifdef SCTP_MBUF_LOGGING
......@@ -845,7 +842,6 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
return (m);
}
#ifdef SCTP_PACKET_LOGGING
void
sctp_packet_log(struct mbuf *m)
......@@ -921,7 +917,6 @@ sctp_packet_log(struct mbuf *m)
SCTP_BASE_VAR(packet_log_end));
SCTP_BASE_VAR(packet_log_end) = 0;
goto no_log;
}
lenat = (int *)&SCTP_BASE_VAR(packet_log_buffer)[thisbegin];
*lenat = total_len;
......@@ -947,7 +942,6 @@ sctp_packet_log(struct mbuf *m)
atomic_subtract_int(&SCTP_BASE_VAR(packet_log_writers), 1);
}
int
sctp_copy_out_packet_log(uint8_t *target, int length)
{
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_BSD_ADDR_H_
......@@ -49,7 +49,6 @@ void sctp_wakeup_iterator(void);
void sctp_startup_iterator(void);
#ifdef INET6
void sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa);
#endif
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 363440 2020-07-23 01:35:24Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_CONSTANTS_H_
......@@ -42,8 +42,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 363440 2020-07-23 01:35:24
#if defined(_WIN32) && defined(__Userspace__)
extern void getwintimeofday(struct timeval *tv);
#endif
#endif
/* IANA assigned port number for SCTP over UDP encapsulation */
#define SCTP_OVER_UDP_TUNNELING_PORT 9899
......@@ -92,13 +92,11 @@ extern void getwintimeofday(struct timeval *tv);
/* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */
#define SCTP_AUDIT_SIZE 256
#define SCTP_KTRHEAD_NAME "sctp_iterator"
#define SCTP_KTHREAD_PAGES 0
#define SCTP_MCORE_NAME "sctp_core_worker"
/* If you support Multi-VRF how big to
* make the initial array of VRF's to.
*/
......@@ -268,7 +266,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_LOCK_UNKNOWN 2
/* number of associations by default for zone allocation */
#define SCTP_MAX_NUM_OF_ASOC 40000
/* how many addresses per assoc remote and local */
......@@ -393,7 +390,6 @@ extern void getwintimeofday(struct timeval *tv);
#define IS_SCTP_CONTROL(a) (((a)->chunk_type != SCTP_DATA) && ((a)->chunk_type != SCTP_IDATA))
#define IS_SCTP_DATA(a) (((a)->chunk_type == SCTP_DATA) || ((a)->chunk_type == SCTP_IDATA))
/* SCTP parameter types */
/*************0x0000 series*************/
#define SCTP_HEARTBEAT_INFO 0x0001
......@@ -458,7 +454,6 @@ extern void getwintimeofday(struct timeval *tv);
/* mask to get sticky */
#define SCTP_STICKY_OPTIONS_MASK 0x0c
/*
* SCTP states for internal state machine
*/
......@@ -562,12 +557,11 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_IS_TIMER_TYPE_VALID(t) (((t) > SCTP_TIMER_TYPE_NONE) && \
((t) < SCTP_TIMER_TYPE_LAST))
#if defined(__APPLE__) && !defined(__Userspace__)
/* Number of ticks to run the main timer at in msec */
#define SCTP_MAIN_TIMER_DEFAULT 10
#endif
#endif
/* max number of TSN's dup'd that I will hold */
#define SCTP_MAX_DUP_TSNS 20
......@@ -618,7 +612,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_RTO_LOWER_BOUND (1000) /* 1 sec is ms */
#define SCTP_RTO_INITIAL (3000) /* 3 sec in ms */
#define SCTP_INP_KILL_TIMEOUT 20 /* number of ms to retry kill of inpcb */
#define SCTP_ASOC_KILL_TIMEOUT 10 /* number of ms to retry kill of inpcb */
......@@ -629,7 +622,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_DEF_PMTU_RAISE_SEC 600 /* 10 min between raise attempts */
/* How many streams I request initially by default */
#define SCTP_OSTREAM_INITIAL 10
#define SCTP_ISTREAM_INITIAL 2048
......@@ -712,7 +704,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */
#define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */
/*
* SCTP upper layer notifications
*/
......@@ -835,7 +826,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_DONOT_SETSCOPE 0
#define SCTP_DO_SETSCOPE 1
/* This value determines the default for when
* we try to add more on the send queue., if
* there is room. This prevents us from cycling
......@@ -918,7 +908,6 @@ extern void getwintimeofday(struct timeval *tv);
} \
} while (0)
#define SCTP_RETRAN_DONE -1
#define SCTP_RETRAN_EXIT -2
......@@ -974,7 +963,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_SO_LOCKED 1
#define SCTP_SO_NOT_LOCKED 0
/*-
* For address locks, do we hold the lock?
*/
......@@ -1008,7 +996,6 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_GETPTIME_TIMEVAL(x) gettimeofday(x, NULL)
#endif
#endif
#if defined(_KERNEL)
#define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x))
#define SCTP_GETPTIME_TIMEVAL(x) (microuptime(x))
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 366114 2020-09-24 12:26:06Z tuexen $");
#endif
#ifndef _NETINET_SCTP_HEADER_H_
......@@ -66,7 +66,6 @@ struct sctp_ipv4addr_param {
#define SCTP_V6_ADDR_BYTES 16
struct sctp_ipv6addr_param {
struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */
uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */
......@@ -110,14 +109,12 @@ struct sctp_heartbeat_info_param {
char address[SCTP_ADDRMAX];
} SCTP_PACKED;
/* draft-ietf-tsvwg-prsctp */
/* PR-SCTP supported parameter */
struct sctp_prsctp_supported_param {
struct sctp_paramhdr ph;
} SCTP_PACKED;
/* draft-ietf-tsvwg-addip-sctp */
struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */
struct sctp_paramhdr ph;/* a SCTP parameter header */
......@@ -129,14 +126,12 @@ struct sctp_asconf_addr_param { /* an ASCONF address parameter */
struct sctp_ipv6addr_param addrp; /* max storage size */
} SCTP_PACKED;
struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
uint32_t local_vtag;
uint32_t remote_vtag;
uint32_t local_vtag;
uint32_t remote_vtag;
} SCTP_PACKED;
struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
struct sctp_ipv4addr_param addrp; /* max storage size */
......@@ -149,7 +144,6 @@ struct sctp_supported_chunk_types_param {
uint8_t chunk_types[];
} SCTP_PACKED;
/*
* Structures for DATA chunks
*/
......@@ -260,7 +254,6 @@ struct sctp_init_msg {
#define sctp_init_ack_chunk sctp_init_chunk
#define sctp_init_ack_msg sctp_init_msg
/* Selective Ack (SACK) */
struct sctp_gap_ack_block {
uint16_t start; /* Gap Ack block start */
......@@ -297,7 +290,6 @@ struct sctp_nr_sack_chunk {
struct sctp_nr_sack nr_sack;
} SCTP_PACKED;
/* Heartbeat Request (HEARTBEAT) */
struct sctp_heartbeat {
struct sctp_heartbeat_info_param hb_info;
......@@ -312,7 +304,6 @@ struct sctp_heartbeat_chunk {
#define sctp_heartbeat_ack sctp_heartbeat
#define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
/* Abort Asssociation (ABORT) */
struct sctp_abort_chunk {
struct sctp_chunkhdr ch;
......@@ -324,27 +315,23 @@ struct sctp_abort_msg {
struct sctp_abort_chunk msg;
} SCTP_PACKED;
/* Shutdown Association (SHUTDOWN) */
struct sctp_shutdown_chunk {
struct sctp_chunkhdr ch;
uint32_t cumulative_tsn_ack;
} SCTP_PACKED;
/* Shutdown Acknowledgment (SHUTDOWN ACK) */
struct sctp_shutdown_ack_chunk {
struct sctp_chunkhdr ch;
} SCTP_PACKED;
/* Operation Error (ERROR) */
struct sctp_error_chunk {
struct sctp_chunkhdr ch;
/* optional error causes follow */
} SCTP_PACKED;
/* Cookie Echo (COOKIE ECHO) */
struct sctp_cookie_echo_chunk {
struct sctp_chunkhdr ch;
......@@ -436,7 +423,6 @@ struct sctp_chunk_desc {
uint32_t tsn_ifany;
} SCTP_PACKED;
struct sctp_pktdrop_chunk {
struct sctp_chunkhdr ch;
uint32_t bottle_bw;
......@@ -487,10 +473,10 @@ struct sctp_stream_reset_response_tsn {
} SCTP_PACKED;
struct sctp_stream_reset_add_strm {
struct sctp_paramhdr ph;
uint32_t request_seq;
uint16_t number_of_streams;
uint16_t reserved;
struct sctp_paramhdr ph;
uint32_t request_seq;
uint16_t number_of_streams;
uint16_t reserved;
} SCTP_PACKED;
#define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */
......@@ -563,43 +549,41 @@ struct sctp_auth_chunk {
#ifndef SCTP_MAX_OVERHEAD
#ifdef INET6
#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
sizeof(struct sctphdr) + \
sizeof(struct sctp_ecne_chunk) + \
sizeof(struct sctp_sack_chunk) + \
sizeof(struct ip6_hdr))
sizeof(struct sctphdr) + \
sizeof(struct sctp_ecne_chunk) + \
sizeof(struct sctp_sack_chunk) + \
sizeof(struct ip6_hdr))
#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
sizeof(struct sctphdr) + \
sizeof(struct ip6_hdr))
sizeof(struct sctphdr) + \
sizeof(struct ip6_hdr))
#define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
sizeof(struct sctphdr))
sizeof(struct sctphdr))
#else
#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
sizeof(struct sctphdr) + \
sizeof(struct sctp_ecne_chunk) + \
sizeof(struct sctp_sack_chunk) + \
sizeof(struct ip))
sizeof(struct sctphdr) + \
sizeof(struct sctp_ecne_chunk) + \
sizeof(struct sctp_sack_chunk) + \
sizeof(struct ip))
#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
sizeof(struct sctphdr) + \
sizeof(struct ip))
sizeof(struct sctphdr) + \
sizeof(struct ip))
#define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
sizeof(struct sctphdr))
sizeof(struct sctphdr))
#endif /* INET6 */
#endif /* !SCTP_MAX_OVERHEAD */
#define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
sizeof(struct sctphdr) + \
sizeof(struct ip))
sizeof(struct sctphdr) + \
sizeof(struct ip))
#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
sizeof(struct sctphdr))
sizeof(struct sctphdr))
#if defined(_WIN32) && !defined(__Userspace__)
#include <packoff.h>
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 361116 2020-05-16 19:26:39Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_INDATA_H_
......@@ -44,12 +44,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 361116 2020-05-16 19:26:39Z t
struct sctp_queued_to_read *
sctp_build_readq_entry(struct sctp_tcb *stcb,
struct sctp_nets *net,
uint32_t tsn, uint32_t ppid,
uint32_t context, uint16_t sid,
uint32_t mid, uint8_t flags,
struct mbuf *dm);
struct sctp_nets *net,
uint32_t tsn, uint32_t ppid,
uint32_t context, uint16_t sid,
uint32_t mid, uint8_t flags,
struct mbuf *dm);
#define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \
if (_ctl) { \
......@@ -76,11 +75,9 @@ sctp_build_readq_entry(struct sctp_tcb *stcb,
} \
} while (0)
struct mbuf *
sctp_build_ctl_nchunk(struct sctp_inpcb *inp,
struct sctp_sndrcvinfo *sinfo);
struct sctp_sndrcvinfo *sinfo);
void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *);
......@@ -89,7 +86,7 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc);
void
sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
uint32_t rwnd, int *abort_now, int ecne_seen);
uint32_t rwnd, int *abort_now, int ecne_seen);
void
sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
......@@ -101,7 +98,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
/* draft-ietf-tsvwg-usctp */
void
sctp_handle_forward_tsn(struct sctp_tcb *,
struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int);
struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int);
struct sctp_tmit_chunk *
sctp_try_advance_peer_ack_point(struct sctp_tcb *, struct sctp_association *);
......@@ -113,8 +110,8 @@ sctp_update_acked(struct sctp_tcb *, struct sctp_shutdown_chunk *, int *);
int
sctp_process_data(struct mbuf **, int, int *, int,
struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *, uint32_t *);
struct sctp_inpcb *, struct sctp_tcb *,
struct sctp_nets *, uint32_t *);
void sctp_slide_mapping_arrays(struct sctp_tcb *stcb);
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 326672 2017-12-07 22:19:08Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_INPUT_H_
......@@ -56,9 +56,9 @@ struct sctp_stream_reset_request *
sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq,
struct sctp_tmit_chunk **bchk);
void sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries,
uint16_t *list);
void
sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries,
uint16_t *list);
int sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked);
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_OS_H_
......@@ -69,15 +69,12 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexe
#else
#define MODULE_GLOBAL(_B) (_B)
#endif
#if defined(__Userspace__)
#include <netinet/sctp_os_userspace.h>
#endif
#if defined(__APPLE__) && !defined(__Userspace__)
#include <netinet/sctp_os_macosx.h>
#endif
#if defined(_WIN32) && !defined(__Userspace__)
#include <netinet/sctp_os_windows.h>
#endif
......
......@@ -283,7 +283,7 @@ typedef char* caddr_t;
#else /* !defined(Userspace_os_Windows) */
#include <sys/socket.h>
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__native_client__) || defined(__Fuchsia__)
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__native_client__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN_PTHREADS__)
#include <pthread.h>
#endif
typedef pthread_mutex_t userland_mutex_t;
......@@ -509,7 +509,7 @@ struct sx {int dummy;};
#if !defined(_WIN32)
#include <netinet/ip6.h>
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(_WIN32)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__EMSCRIPTEN__)
#include "user_ip6_var.h"
#else
#include <netinet6/ip6_var.h>
......@@ -1132,7 +1132,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a
#define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0)
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__)
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
int
timingsafe_bcmp(const void *, const void *, size_t);
#endif
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 362054 2020-06-11 13:34:09Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 366114 2020-09-24 12:26:06Z tuexen $");
#endif
#ifndef _NETINET_SCTP_OUTPUT_H_
......@@ -44,38 +44,34 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 362054 2020-06-11 13:34:09Z t
#if defined(_KERNEL) || defined(__Userspace__)
struct mbuf *
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
struct sctp_scoping *scope,
struct mbuf *m_at,
int cnt_inits_to,
uint16_t *padding_len, uint16_t *chunk_len);
struct sctp_scoping *scope,
struct mbuf *m_at,
int cnt_inits_to,
uint16_t *padding_len, uint16_t *chunk_len);
int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
int
sctp_is_address_in_scope(struct sctp_ifa *ifa,
struct sctp_scoping *scope,
int do_update);
int do_update);
int
sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
struct sctp_ifa *
sctp_source_address_selection(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
sctp_route_t *ro, struct sctp_nets *net,
int non_asoc_addr_ok, uint32_t vrf_id);
struct sctp_tcb *stcb,
sctp_route_t *ro, struct sctp_nets *net,
int non_asoc_addr_ok, uint32_t vrf_id);
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
int
sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
int
sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
#endif
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int);
......@@ -93,24 +89,23 @@ sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
struct mbuf *
sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
struct sctp_chunkhdr *, int *, int *);
struct sctp_chunkhdr *, int *, int *);
void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
int
sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *,
struct sctp_nets *);
struct sctp_nets *);
void sctp_send_cookie_ack(struct sctp_tcb *);
void
sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
struct sctp_nets *);
struct sctp_nets *);
void
sctp_remove_from_wheel(struct sctp_tcb *stcb,
struct sctp_association *asoc,
struct sctp_stream_out *strq, int holds_lock);
struct sctp_association *asoc,
struct sctp_stream_out *strq, int holds_lock);
void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
......@@ -139,10 +134,9 @@ void sctp_fix_ecn_echo(struct sctp_association *);
void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
#define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \
sizeof(struct sctp_idata_chunk) : \
sizeof(struct sctp_data_chunk))
sizeof(struct sctp_idata_chunk) : \
sizeof(struct sctp_data_chunk))
#if defined(__FreeBSD__) && !defined(__Userspace__)
int
......@@ -179,18 +173,15 @@ void
sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
int, int, int);
void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
void
sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t);
void
sctp_send_deferred_reset_response(struct sctp_tcb *,
struct sctp_stream_reset_list *,
int);
struct sctp_stream_reset_list *,
int);
void
sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *,
......@@ -210,12 +201,13 @@ sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
#endif
uint32_t, uint16_t);
void sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *,
void
sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *,
#if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t,
uint8_t, uint32_t, uint16_t,
#endif
uint32_t, uint16_t);
uint32_t, uint16_t);
#endif /* _KERNEL || __Userspace__ */
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 362106 2020-06-12 16:31:13Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_PCB_H_
......@@ -147,7 +147,6 @@ struct sctp_tagblock {
struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
};
struct sctp_epinfo {
#if defined(__FreeBSD__) && !defined(__Userspace__)
#ifdef INET
......@@ -277,7 +276,6 @@ struct sctp_epinfo {
#endif
};
struct sctp_base_info {
/* All static structures that
* anchor the system must be here.
......@@ -440,7 +438,6 @@ struct sctp_pcbtsn_rlog {
};
#define SCTP_READ_LOG_SIZE 135 /* we choose the number to make a pcb a page */
struct sctp_inpcb {
/*-
* put an inpcb in front of it all, kind of a waste but we need to
......@@ -451,7 +448,6 @@ struct sctp_inpcb {
char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
~SCTP_ALIGNM1];
} ip_inp;
#if defined(__APPLE__) && !defined(__Userspace__)
/* leave some space in case i386 inpcb is bigger than ppc */
uint8_t padding[128];
......@@ -461,7 +457,7 @@ struct sctp_inpcb {
struct sctp_readhead read_queue;
LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */
/* hash of all endpoints for model */
/* hash of all endpoints for model */
LIST_ENTRY(sctp_inpcb) sctp_hash;
/* count of local addresses bound, 0 if bound all */
int laddr_count;
......@@ -640,11 +636,8 @@ struct sctp_tcb {
#endif
};
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <netinet/sctp_lock_bsd.h>
#elif defined(__APPLE__) && !defined(__Userspace__)
/*
* Apple MacOS X 10.4 "Tiger"
......@@ -678,7 +671,7 @@ struct sctp_tcb {
* the real definition.
*/
#if defined(__FreeBSD__) && !defined(__Userspace__)
VNET_DECLARE(struct sctp_base_info, system_base_info) ;
VNET_DECLARE(struct sctp_base_info, system_base_info);
#else
extern struct sctp_base_info system_base_info;
#endif
......@@ -720,12 +713,9 @@ void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu);
void sctp_free_ifn(struct sctp_ifn *sctp_ifnp);
void sctp_free_ifa(struct sctp_ifa *sctp_ifap);
void sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr,
uint32_t ifn_index, const char *if_name);
struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
......@@ -806,7 +796,6 @@ sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
void sctp_delete_from_timewait(uint32_t, uint16_t, uint16_t);
int sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport);
......
......@@ -30,7 +30,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 362173 2020-06-14 09:50:00Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 365071 2020-09-01 21:19:14Z mjg $");
#endif
#include <netinet/sctp_pcb.h>
......@@ -185,7 +185,6 @@ sctp_ss_default_remove(struct sctp_tcb *stcb, struct sctp_association *asoc,
return;
}
static struct sctp_stream_out *
sctp_ss_default_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net,
struct sctp_association *asoc)
......@@ -396,7 +395,6 @@ rrp_again:
return;
}
/*
* Priority algorithm.
* Always prefers streams based on their priority id.
......@@ -418,7 +416,6 @@ sctp_ss_prio_clear(struct sctp_tcb *stcb, struct sctp_association *asoc,
TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.prio.next_spoke);
strq->ss_params.prio.next_spoke.tqe_next = NULL;
strq->ss_params.prio.next_spoke.tqe_prev = NULL;
}
asoc->ss_data.last_out_stream = NULL;
if (holds_lock == 0) {
......@@ -903,7 +900,6 @@ sctp_ss_fcfs_remove(struct sctp_tcb *stcb, struct sctp_association *asoc,
return;
}
static struct sctp_stream_out *
sctp_ss_fcfs_select(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net,
struct sctp_association *asoc)
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 364268 2020-08-16 11:50:37Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_STRUCTS_H_
......@@ -65,7 +65,6 @@ struct sctp_timer {
uint32_t stopped_from;
};
struct sctp_foo_stuff {
struct sctp_inpcb *inp;
uint32_t lineno;
......@@ -73,7 +72,6 @@ struct sctp_foo_stuff {
int updown;
};
/*
* This is the information we track on each interface that we know about from
* the distant end.
......@@ -163,7 +161,6 @@ struct sctp_iterator {
#define SCTP_ITERATOR_DO_ALL_INP 0x00000001
#define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002
TAILQ_HEAD(sctpiterators, sctp_iterator);
struct sctp_copy_all {
......@@ -293,7 +290,6 @@ struct rtcc_cc {
uint8_t last_inst_ind; /* Last saved inst indication */
};
struct sctp_nets {
TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */
......@@ -436,7 +432,6 @@ struct sctp_nets {
#endif
};
struct sctp_data_chunkrec {
uint32_t tsn; /* the TSN of this transmit */
uint32_t mid; /* the message identifier of this transmit */
......@@ -475,7 +470,6 @@ struct chk_id {
uint8_t can_take_data;
};
struct sctp_tmit_chunk {
union {
struct sctp_data_chunkrec data;
......@@ -604,7 +598,6 @@ struct sctp_stream_in {
TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending);
/* Round-robin schedulers */
struct ss_rr {
/* next link in wheel */
......@@ -921,7 +914,6 @@ struct sctp_association {
/* last place I got a control from */
struct sctp_nets *last_control_chunk_from;
/*
* wait to the point the cum-ack passes req->send_reset_at_tsn for
* any req on the list.
......@@ -985,7 +977,6 @@ struct sctp_association {
/* Original seq number I used ??questionable to keep?? */
uint32_t init_seq_number;
/* The Advanced Peer Ack Point, as required by the PR-SCTP */
/* (A1 in Section 4.2) */
uint32_t advanced_peer_ack_point;
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 361934 2020-06-08 20:23:20Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 365071 2020-09-01 21:19:14Z mjg $");
#endif
#include <netinet/sctp_os.h>
......@@ -175,8 +175,8 @@ sctp_init_sysctls()
SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
#endif
}
#if defined(_WIN32) && !defined(__Userspace__)
void
sctp_finish_sysctls()
{
......@@ -727,8 +727,8 @@ sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS)
}
return (error);
}
#if defined(__APPLE__) && !defined(__Userspace__)
int sctp_is_vmware_interface(struct ifnet *);
static int
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 361895 2020-06-07 14:39:20Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 366750 2020-10-16 10:44:48Z tuexen $");
#endif
#ifndef _NETINET_SCTP_SYSCTL_H_
......@@ -241,7 +241,6 @@ struct sctp_sysctl {
#define SCTPCTL_FRMAXBURST_MAX 0xFFFFFFFF
#define SCTPCTL_FRMAXBURST_DEFAULT SCTP_DEF_FRMAX_BURST
/* maxchunks: Default max chunks on queue per asoc */
#define SCTPCTL_MAXCHUNKS_DESC "Default max chunks on queue per asoc"
#define SCTPCTL_MAXCHUNKS_MIN 0
......@@ -344,10 +343,10 @@ struct sctp_sysctl {
#define SCTPCTL_INIT_RTO_MAX_MAX 0xFFFFFFFF
#define SCTPCTL_INIT_RTO_MAX_DEFAULT SCTP_RTO_UPPER_BOUND
/* valid_cookie_life: Default cookie lifetime in sec */
#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in seconds"
#define SCTPCTL_VALID_COOKIE_LIFE_MIN 0
#define SCTPCTL_VALID_COOKIE_LIFE_MAX 0xFFFFFFFF
/* valid_cookie_life: Default cookie lifetime in ms */
#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in ms"
#define SCTPCTL_VALID_COOKIE_LIFE_MIN SCTP_MIN_COOKIE_LIFE
#define SCTPCTL_VALID_COOKIE_LIFE_MAX SCTP_MAX_COOKIE_LIFE
#define SCTPCTL_VALID_COOKIE_LIFE_DEFAULT SCTP_DEFAULT_COOKIE_LIFE
/* init_rtx_max: Default maximum number of retransmission for INIT chunks */
......@@ -595,16 +594,12 @@ struct sctp_sysctl {
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_MIN 0
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX 1
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX
#endif
#if defined(__APPLE__) && !defined(__Userspace__)
#define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP"
#define SCTPCTL_OUTPUT_UNLOCKED_MIN 0
#define SCTPCTL_OUTPUT_UNLOCKED_MAX 1
#define SCTPCTL_OUTPUT_UNLOCKED_DEFAULT SCTPCTL_OUTPUT_UNLOCKED_MIN
#endif
#if defined(__APPLE__) && !defined(__Userspace__)
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_DESC "Address watchdog limit"
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_MIN 0
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_MAX 0xFFFFFFFF
......@@ -614,8 +609,8 @@ struct sctp_sysctl {
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN 0
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_MAX 0xFFFFFFFF
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN
#endif
#endif
#if defined(_KERNEL) || defined(__Userspace__)
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
#if defined(SYSCTL_DECL)
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 362054 2020-06-11 13:34:09Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 365071 2020-09-01 21:19:14Z mjg $");
#endif
#define _IP_VHL
......@@ -499,7 +499,6 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
uint32_t tsnlast, tsnfirst;
int recovery_cnt = 0;
/* none in flight now */
audit_tf = 0;
fir = 0;
......@@ -810,7 +809,6 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
return (0);
}
int
sctp_t3rxt_timer(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 359195 2020-03-21 16:12:19Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_TIMER_H_
......@@ -99,6 +99,5 @@ void sctp_slowtimo(void);
void sctp_gc(struct inpcbinfo *);
#endif
#endif
#endif
#endif
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 362473 2020-06-21 23:12:56Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_UIO_H_
......@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 362473 2020-06-21 23:12:56Z tuex
#define _KERNEL
#endif
#endif
#if !defined(_WIN32)
#if !defined(_KERNEL)
#include <stdint.h>
......@@ -129,7 +128,6 @@ struct sctp_initmsg {
* all sendrcvinfo's need a verfid for SENDING only.
*/
#define SCTP_ALIGN_RESV_PAD 92
#define SCTP_ALIGN_RESV_PAD_SHORT 76
......@@ -441,7 +439,6 @@ struct sctp_setadaption {
uint32_t ssb_adaption_ind;
};
/*
* Partial Delivery API event
*/
......@@ -458,7 +455,6 @@ struct sctp_pdapi_event {
/* indication values */
#define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001
/*
* authentication key event
*/
......@@ -478,7 +474,6 @@ struct sctp_authkey_event {
#define SCTP_AUTH_NO_AUTH 0x0002
#define SCTP_AUTH_FREE_KEY 0x0003
struct sctp_sender_dry_event {
uint16_t sender_dry_type;
uint16_t sender_dry_flags;
......@@ -486,7 +481,6 @@ struct sctp_sender_dry_event {
sctp_assoc_t sender_dry_assoc_id;
};
/*
* Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT
*/
......@@ -534,7 +528,6 @@ struct sctp_stream_change_event {
#define SCTP_STREAM_CHANGE_DENIED 0x0004
#define SCTP_STREAM_CHANGE_FAILED 0x0008
/* SCTP notification event */
struct sctp_tlv {
uint16_t sn_type;
......@@ -1137,7 +1130,6 @@ struct sctpstat {
#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
/***********************************/
/* And something for us old timers */
/***********************************/
......@@ -1171,7 +1163,6 @@ struct sctpstat {
#endif
/***********************************/
struct xsctp_inpcb {
uint32_t last;
uint32_t flags;
......
......@@ -32,7 +32,7 @@
#include <sys/timeb.h>
#include <iphlpapi.h>
#if !defined(__MINGW32__)
#pragma comment(lib, "IPHLPAPI.lib")
#pragma comment(lib, "iphlpapi.lib")
#endif
#endif
#include <netinet/sctp_os_userspace.h>
......@@ -126,7 +126,7 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
}
#endif
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__)
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
int
timingsafe_bcmp(const void *b1, const void *b2, size_t n)
{
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 364353 2020-08-18 19:25:03Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 366750 2020-10-16 10:44:48Z tuexen $");
#endif
#include <netinet/sctp_os.h>
......@@ -64,7 +64,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 364353 2020-08-18 19:25:03Z t
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/eventhandler.h>
#endif
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
#include <netinet/sctp_peeloff.h>
#endif /* HAVE_SCTP_PEELOFF_SOCKOPT */
......@@ -192,6 +191,9 @@ sctp_finish(void)
#if defined(_WIN32) && !defined(__Userspace__)
sctp_finish_sysctls();
#endif
#if defined(__Userspace__)
finish_random();
#endif
}
#endif
......@@ -571,7 +573,6 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred,
"Get the ucred of a SCTP connection");
#endif
#ifdef INET
#if defined(_WIN32) || defined(__Userspace__)
int
......@@ -863,10 +864,7 @@ sctp_close(struct socket *so)
#endif
return;
}
#else
int
sctp_detach(struct socket *so)
{
......@@ -948,7 +946,6 @@ sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
struct mbuf *control, struct proc *p);
#endif
int
#if defined(__FreeBSD__) && !defined(__Userspace__)
sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
......@@ -1257,7 +1254,6 @@ sctp_flush(struct socket *so, int how)
so->so_snd.sb_cc = 0;
so->so_snd.sb_mbcnt = 0;
so->so_snd.sb_mb = NULL;
}
return (0);
}
......@@ -1439,8 +1435,6 @@ sctp_fill_user_address(struct sockaddr *dst, struct sockaddr *src)
return (0);
}
static size_t
sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
......@@ -1993,7 +1987,6 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
/* FIX ME: do we want to pass in a vrf on the connect call? */
vrf_id = inp->def_vrf_id;
/* We are GOOD to go */
stcb = sctp_aloc_assoc(inp, sa, &error, 0, vrf_id,
inp->sctp_ep.pre_open_stream_count,
......@@ -2079,7 +2072,6 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
} \
}
#define SCTP_CHECK_AND_CAST(destp, srcp, type, size) {\
if (size < sizeof(type)) { \
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); \
......@@ -3243,8 +3235,6 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
*/
sstat->sstat_penddata = (stcb->asoc.cnt_on_reasm_queue +
stcb->asoc.cnt_on_all_streams);
sstat->sstat_instrms = stcb->asoc.streamincnt;
sstat->sstat_outstrms = stcb->asoc.streamoutcnt;
sstat->sstat_fragmentation_point = sctp_get_frag_point(stcb, &stcb->asoc);
......@@ -3753,43 +3743,27 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
break;
}
case SCTP_RECVRCVINFO:
{
int onoff;
if (*optsize < sizeof(int)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
} else {
SCTP_INP_RLOCK(inp);
onoff = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVRCVINFO);
*(int *)optval = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVRCVINFO);
SCTP_INP_RUNLOCK(inp);
}
if (error == 0) {
/* return the option value */
*(int *)optval = onoff;
*optsize = sizeof(int);
}
break;
}
case SCTP_RECVNXTINFO:
{
int onoff;
if (*optsize < sizeof(int)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
} else {
SCTP_INP_RLOCK(inp);
onoff = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVNXTINFO);
*(int *)optval = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_RECVNXTINFO);
SCTP_INP_RUNLOCK(inp);
}
if (error == 0) {
/* return the option value */
*(int *)optval = onoff;
*optsize = sizeof(int);
}
break;
}
case SCTP_DEFAULT_SNDINFO:
{
struct sctp_sndinfo *info;
......@@ -5432,7 +5406,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_RUNLOCK(inp);
}
}
break;
}
......@@ -5671,7 +5644,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
break;
}
/* Do any streams have data queued? */
for ( i = 0; i< stcb->asoc.streamoutcnt; i++) {
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
if (!TAILQ_EMPTY(&stcb->asoc.strmout[i].outqueue)) {
goto busy_out;
}
......@@ -6080,8 +6053,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if ((stcb != NULL) && (net == NULL)) {
#ifdef INET
if (addr->sa_family == AF_INET) {
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)addr;
if (sin->sin_addr.s_addr != INADDR_ANY) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
......@@ -6520,18 +6493,20 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_CHECK_AND_CAST(sasoc, optval, struct sctp_assocparams, optsize);
SCTP_FIND_STCB(inp, stcb, sasoc->sasoc_assoc_id);
if (sasoc->sasoc_cookie_life) {
if (sasoc->sasoc_cookie_life > 0) {
/* boundary check the cookie life */
if (sasoc->sasoc_cookie_life < 1000)
sasoc->sasoc_cookie_life = 1000;
if (sasoc->sasoc_cookie_life < SCTP_MIN_COOKIE_LIFE) {
sasoc->sasoc_cookie_life = SCTP_MIN_COOKIE_LIFE;
}
if (sasoc->sasoc_cookie_life > SCTP_MAX_COOKIE_LIFE) {
sasoc->sasoc_cookie_life = SCTP_MAX_COOKIE_LIFE;
}
}
if (stcb) {
if (sasoc->sasoc_asocmaxrxt)
if (sasoc->sasoc_asocmaxrxt > 0) {
stcb->asoc.max_send_times = sasoc->sasoc_asocmaxrxt;
if (sasoc->sasoc_cookie_life) {
}
if (sasoc->sasoc_cookie_life > 0) {
stcb->asoc.cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life);
}
SCTP_TCB_UNLOCK(stcb);
......@@ -6541,9 +6516,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (sasoc->sasoc_asocmaxrxt)
if (sasoc->sasoc_asocmaxrxt > 0) {
inp->sctp_ep.max_send_times = sasoc->sasoc_asocmaxrxt;
if (sasoc->sasoc_cookie_life) {
}
if (sasoc->sasoc_cookie_life > 0) {
inp->sctp_ep.def_cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life);
}
SCTP_INP_WUNLOCK(inp);
......@@ -7223,8 +7199,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if ((stcb != NULL) && (net == NULL)) {
#ifdef INET
if (addr->sa_family == AF_INET) {
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)addr;
if (sin->sin_addr.s_addr != INADDR_ANY) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
......@@ -7404,8 +7380,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if ((stcb != NULL) && (net == NULL)) {
#ifdef INET
if (addr->sa_family == AF_INET) {
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)addr;
if (sin->sin_addr.s_addr != INADDR_ANY) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
......@@ -7887,7 +7863,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
#if defined(__Userspace__)
/* TODO __Userspace__ falls into this code for IPv6 stuff at the moment... */
#endif
#if !defined(_WIN32) && !defined(__linux__)
#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__)
switch (addr->sa_family) {
#ifdef INET6
case AF_INET6:
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 363323 2020-07-19 12:34:19Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_VAR_H_
......@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 363323 2020-07-19 12:34:19Z tuex
extern struct pr_usrreqs sctp_usrreqs;
#endif
#define sctp_feature_on(inp, feature) (inp->sctp_features |= feature)
#define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature)
#define sctp_is_feature_on(inp, feature) ((inp->sctp_features & feature) == feature)
......@@ -187,7 +186,6 @@ extern struct pr_usrreqs sctp_usrreqs;
}
#if defined(__FreeBSD__) && !defined(__Userspace__)
#define sctp_free_remote_addr(__net) { \
if ((__net)) { \
if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
......@@ -227,9 +225,7 @@ extern struct pr_usrreqs sctp_usrreqs;
SCTP_BUF_TYPE(m) != MT_OOBDATA) \
atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
}
#else /* FreeBSD Version <= 500000 or non-FreeBSD */
#define sctp_free_remote_addr(__net) { \
if ((__net)) { \
if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
......@@ -367,7 +363,6 @@ struct sctp_inpcb;
struct sctp_tcb;
struct sctphdr;
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
void sctp_close(struct socket *so);
#else
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 364268 2020-08-16 11:50:37Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 365071 2020-09-01 21:19:14Z mjg $");
#endif
#ifndef _NETINET_SCTP_UTIL_H_
......@@ -64,7 +64,6 @@ sctp_log_trace(uint32_t fr, const char *str SCTP_UNUSED, uint32_t a, uint32_t b,
#define sctp_get_associd(stcb) ((sctp_assoc_t)stcb->asoc.assoc_id)
/*
* Function prototypes
*/
......@@ -173,7 +172,6 @@ sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp,
struct sctp_inpcb *new_inp,
struct sctp_tcb *stcb, int waitflags);
void sctp_stop_timers_for_shutdown(struct sctp_tcb *);
/* Stop all timers for association and remote addresses. */
......@@ -196,7 +194,6 @@ sctp_abort_association(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *,
#endif
uint32_t, uint16_t);
/* We choose to abort via user input */
void
sctp_abort_an_association(struct sctp_inpcb *, struct sctp_tcb *,
......@@ -364,7 +361,6 @@ void sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t, uint16_t, uint16_t,
void sctp_log_nagle_event(struct sctp_tcb *stcb, int action);
#ifdef SCTP_MBUF_LOGGING
void
sctp_log_mb(struct mbuf *m, int from);
......@@ -398,7 +394,6 @@ void sctp_log_map(uint32_t, uint32_t, uint32_t, int);
void sctp_print_mapping_array(struct sctp_association *asoc);
void sctp_clr_stat_log(void);
#ifdef SCTP_AUDITING_ENABLED
void
sctp_auditing(int, struct sctp_inpcb *, struct sctp_tcb *,
......
......@@ -34,7 +34,7 @@
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 361895 2020-06-07 14:39:20Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 365071 2020-09-01 21:19:14Z mjg $");
#endif
#include <netinet/sctp_os.h>
......@@ -105,7 +105,7 @@ void
in6_sin_2_v4mapsin6(const struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
{
memset(sin6, 0, sizeof(struct sockaddr_in6));
sin6->sin6_family = AF_INET6;
sin6->sin6_family = AF_INET6;
#ifdef HAVE_SIN6_LEN
sin6->sin6_len = sizeof(struct sockaddr_in6);
#endif
......@@ -116,9 +116,9 @@ in6_sin_2_v4mapsin6(const struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
((uint32_t *)&sin6->sin6_addr)[2] = htonl(0xffff);
((uint32_t *)&sin6->sin6_addr)[3] = sin->sin_addr.s_addr;
#else
sin6->sin6_addr.s6_addr32[0] = 0;
sin6->sin6_addr.s6_addr32[0] = 0;
sin6->sin6_addr.s6_addr32[1] = 0;
sin6->sin6_addr.s6_addr32[2] = htonl(0xffff);
sin6->sin6_addr.s6_addr32[2] = htonl(0xffff);
sin6->sin6_addr.s6_addr32[3] = sin->sin_addr.s_addr;
#endif
}
......@@ -299,7 +299,6 @@ sctp6_input(struct mbuf **i_pak, int *offp)
return (sctp6_input_with_port(i_pak, offp, 0));
}
#endif
#if defined(__FreeBSD__)
int
sctp6_input(struct mbuf **i_pak, int *offp, int proto SCTP_UNUSED)
......@@ -658,7 +657,6 @@ out:
SYSCTL_PROC(_net_inet6_sctp6, OID_AUTO, getcred, CTLTYPE_OPAQUE | CTLFLAG_RW,
0, 0,
sctp6_getcred, "S,ucred", "Get the ucred of a SCTP6 connection");
#endif
/* This is the same as the sctp_abort() could be made common */
......@@ -911,7 +909,6 @@ out:
return (error);
}
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#if !defined(__Userspace__)
static void
......@@ -949,16 +946,13 @@ sctp6_disconnect(struct socket *so)
return (sctp_disconnect(so));
}
int
#if defined(__FreeBSD__) && !defined(__Userspace__)
sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
struct mbuf *control, struct thread *p);
#else
sctp_sendm(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
struct mbuf *control, struct proc *p);
#endif
#if !defined(_WIN32) && !defined(__Userspace__)
......@@ -1560,7 +1554,6 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam)
return (error);
}
#if !defined(__Userspace__)
static int
sctp6_getpeeraddr(struct socket *so, struct sockaddr **nam)
......@@ -1710,7 +1703,7 @@ sctp6_usrreq(so, req, m, nam, control, p)
switch (family) {
case PF_INET:
error = in_control(so, (long)m, (caddr_t)nam,
(struct ifnet *)control );
(struct ifnet *)control);
break;
#ifdef INET6
case PF_INET6:
......
......@@ -68,7 +68,8 @@ extern int nmbclusters;
#endif
void init_random(void);
int read_random(void *, int);
void read_random(void *, size_t);
void finish_random(void);
/* errno's may differ per OS. errno.h now included in sctp_os_userspace.h */
/* Source: /usr/src/sys/sys/errno.h */
......@@ -90,7 +91,11 @@ extern u_short ip_id;
#if defined(INVARIANTS)
#include <stdlib.h>
#if defined(_WIN32)
static inline void
#else
static inline void __attribute__((__noreturn__))
#endif
terminate_non_graceful(void) {
abort();
}
......
......@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
......
......@@ -39,7 +39,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
......@@ -87,13 +87,11 @@ struct ip6_hdr {
#if defined(_WIN32)
#define s6_addr16 u.Word
#endif
#if !defined(_WIN32)
#if !defined(__linux__)
#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__)
#define s6_addr8 __u6_addr.__u6_addr8
#define s6_addr16 __u6_addr.__u6_addr16
#define s6_addr32 __u6_addr.__u6_addr32
#endif
#endif
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
struct route_in6 {
......
差异被折叠。
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论