mediasoup 3.19.19 → 3.19.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +4 -4
  2. package/node/lib/Worker.d.ts +1 -1
  3. package/node/lib/Worker.d.ts.map +1 -1
  4. package/node/lib/Worker.js +8 -2
  5. package/node/lib/WorkerTypes.d.ts +8 -4
  6. package/node/lib/WorkerTypes.d.ts.map +1 -1
  7. package/node/lib/index.d.ts +1 -1
  8. package/node/lib/index.d.ts.map +1 -1
  9. package/node/lib/index.js +2 -1
  10. package/node/lib/sctpParametersTypes.d.ts +3 -13
  11. package/node/lib/sctpParametersTypes.d.ts.map +1 -1
  12. package/node/lib/test/test-PlainTransport.js +8 -3
  13. package/node/lib/test/test-WebRtcTransport.js +9 -4
  14. package/package.json +10 -10
  15. package/worker/Makefile +0 -4
  16. package/worker/fuzzer/src/fuzzer.cpp +6 -5
  17. package/worker/include/RTC/DataConsumer.hpp +4 -14
  18. package/worker/include/RTC/SCTP/TODO_SCTP.md +18 -10
  19. package/worker/include/RTC/SCTP/association/Association.hpp +39 -31
  20. package/worker/include/RTC/SCTP/association/{AssociationDeferredListener.hpp → AssociationListenerDeferrer.hpp} +10 -8
  21. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +77 -0
  22. package/worker/include/RTC/SCTP/association/NegotiatedCapabilities.hpp +2 -2
  23. package/worker/include/RTC/SCTP/association/PacketSender.hpp +2 -2
  24. package/worker/include/RTC/SCTP/association/StateCookie.hpp +2 -2
  25. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +272 -0
  26. package/worker/include/RTC/SCTP/association/TCBContext.hpp +67 -0
  27. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +81 -11
  28. package/worker/include/RTC/SCTP/common/UnwrappedSequenceNumber.hpp +274 -0
  29. package/worker/include/RTC/SCTP/packet/Chunk.hpp +0 -1
  30. package/worker/include/RTC/SCTP/packet/UserData.hpp +1 -0
  31. package/worker/include/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp +14 -10
  32. package/worker/include/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp +14 -10
  33. package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +13 -2
  34. package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +7 -1
  35. package/worker/include/RTC/SCTP/public/AssociationListener.hpp +11 -0
  36. package/worker/include/RTC/SCTP/public/Message.hpp +1 -0
  37. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +4 -4
  38. package/worker/include/RTC/SctpAssociation.hpp +2 -2
  39. package/worker/include/RTC/Transport.hpp +9 -13
  40. package/worker/include/Settings.hpp +2 -1
  41. package/worker/include/Utils.hpp +130 -6
  42. package/worker/meson.build +10 -39
  43. package/worker/meson_options.txt +0 -1
  44. package/worker/scripts/package-lock.json +6 -6
  45. package/worker/src/DepLibUring.cpp +1 -1
  46. package/worker/src/RTC/DataConsumer.cpp +5 -29
  47. package/worker/src/RTC/PipeTransport.cpp +15 -12
  48. package/worker/src/RTC/PlainTransport.cpp +15 -12
  49. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +5 -5
  50. package/worker/src/RTC/RTP/RtpStream.cpp +2 -2
  51. package/worker/src/RTC/RTP/RtxStream.cpp +1 -1
  52. package/worker/src/RTC/RateCalculator.cpp +5 -5
  53. package/worker/src/RTC/SCTP/association/Association.cpp +218 -148
  54. package/worker/src/RTC/SCTP/association/{AssociationDeferredListener.cpp → AssociationListenerDeferrer.cpp} +38 -30
  55. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +244 -0
  56. package/worker/src/RTC/SCTP/association/NegotiatedCapabilities.cpp +8 -6
  57. package/worker/src/RTC/SCTP/association/PacketSender.cpp +7 -2
  58. package/worker/src/RTC/SCTP/association/StateCookie.cpp +8 -8
  59. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +512 -0
  60. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +45 -39
  61. package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +1 -1
  62. package/worker/src/RTC/SCTP/packet/errorCauses/UserInitiatedAbortErrorCause.cpp +1 -1
  63. package/worker/src/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.cpp +22 -5
  64. package/worker/src/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.cpp +22 -5
  65. package/worker/src/RTC/SCTP/tx/RetransmissionErrorCounter.cpp +1 -1
  66. package/worker/src/RTC/SctpAssociation.cpp +1 -2
  67. package/worker/src/RTC/SeqManager.cpp +4 -4
  68. package/worker/src/RTC/Transport.cpp +247 -134
  69. package/worker/src/RTC/WebRtcTransport.cpp +9 -5
  70. package/worker/src/Settings.cpp +21 -1
  71. package/worker/src/Worker.cpp +13 -10
  72. package/worker/src/lib.cpp +11 -8
  73. package/worker/tasks.py +2 -35
  74. package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +13 -12
  75. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +20 -20
  76. package/worker/test/src/RTC/SCTP/common/TestUnwrappedSequenceNumber.cpp +210 -0
  77. package/worker/test/src/RTC/SCTP/packet/chunks/TestAbortAssociationChunk.cpp +2 -2
  78. package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatAckChunk.cpp +9 -4
  79. package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatRequestChunk.cpp +5 -0
  80. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitAckChunk.cpp +1 -1
  81. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +5 -5
  82. package/worker/test/src/RTC/SCTP/packet/chunks/TestReConfigChunk.cpp +19 -20
  83. package/worker/test/src/RTC/SCTP/packet/chunks/TestUnknownChunk.cpp +3 -0
  84. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnknownErrorCause.cpp +3 -0
  85. package/worker/test/src/RTC/SCTP/packet/parameters/TestIncomingSsnResetRequestParameter.cpp +24 -27
  86. package/worker/test/src/RTC/SCTP/packet/parameters/TestOutgoingSsnResetRequestParameter.cpp +25 -30
  87. package/worker/test/src/RTC/SCTP/packet/parameters/TestStateCookieParameter.cpp +8 -6
  88. package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedExtensionsParameter.cpp +12 -0
  89. package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +5 -8
  90. package/worker/test/src/Utils/TestNumber.cpp +119 -49
  91. package/worker/test/src/tests.cpp +11 -8
@@ -60,6 +60,7 @@ void Settings::SetConfiguration(int argc, char* argv[])
60
60
  { "dtlsPrivateKeyFile", optional_argument, nullptr, 'p' },
61
61
  { "libwebrtcFieldTrials", optional_argument, nullptr, 'W' },
62
62
  { "disableLiburing", optional_argument, nullptr, 'd' },
63
+ { "useBuiltInSctpStack", optional_argument, nullptr, 's' },
63
64
  { nullptr, 0, nullptr, 0 }
64
65
  };
65
66
  // clang-format on
@@ -165,7 +166,23 @@ void Settings::SetConfiguration(int argc, char* argv[])
165
166
 
166
167
  if (stringValue == "true")
167
168
  {
168
- Settings::configuration.liburingDisabled = true;
169
+ Settings::configuration.disableLiburing = true;
170
+ }
171
+
172
+ break;
173
+ }
174
+
175
+ case 's':
176
+ {
177
+ stringValue = std::string(optarg);
178
+
179
+ if (stringValue == "true")
180
+ {
181
+ Settings::configuration.useBuiltInSctpStack = true;
182
+ }
183
+ else
184
+ {
185
+ Settings::configuration.useBuiltInSctpStack = false;
169
186
  }
170
187
 
171
188
  break;
@@ -382,6 +399,9 @@ void Settings::PrintConfiguration()
382
399
  MS_DEBUG_TAG(
383
400
  info, " libwebrtcFieldTrials: %s", Settings::configuration.libwebrtcFieldTrials.c_str());
384
401
  }
402
+ MS_DEBUG_TAG(info, " disableLiburing: %s", Settings::configuration.disableLiburing ? "yes" : "no");
403
+ MS_DEBUG_TAG(
404
+ info, " useBuiltInSctpStack: %s", Settings::configuration.useBuiltInSctpStack ? "yes" : "no");
385
405
 
386
406
  MS_DEBUG_TAG(info, "</configuration>");
387
407
  }
@@ -7,9 +7,8 @@
7
7
  #include "DepLibUring.hpp"
8
8
  #endif
9
9
  #include "DepLibUV.hpp"
10
- #ifndef MS_SCTP_STACK
10
+ // TODO: Remove once we only use built-in SCTP stack.
11
11
  #include "DepUsrSCTP.hpp"
12
- #endif
13
12
  #include "Logger.hpp"
14
13
  #include "MediaSoupErrors.hpp"
15
14
  #include "Settings.hpp"
@@ -42,10 +41,12 @@ Worker::Worker(::Channel::ChannelSocket* channel) : channel(channel)
42
41
  }
43
42
  #endif
44
43
 
45
- #ifndef MS_SCTP_STACK
46
- // Create the Checker instance in DepUsrSCTP.
47
- DepUsrSCTP::CreateChecker();
48
- #endif
44
+ // TODO: Remove once we only use built-in SCTP stack.
45
+ if (!Settings::configuration.useBuiltInSctpStack)
46
+ {
47
+ // Create the Checker instance in DepUsrSCTP.
48
+ DepUsrSCTP::CreateChecker();
49
+ }
49
50
 
50
51
  #ifdef MS_LIBURING_SUPPORTED
51
52
  if (DepLibUring::IsEnabled())
@@ -109,10 +110,12 @@ void Worker::Close()
109
110
  // Delete the RTC::Shared singleton.
110
111
  delete this->shared;
111
112
 
112
- #ifndef MS_SCTP_STACK
113
- // Close the Checker instance in DepUsrSCTP.
114
- DepUsrSCTP::CloseChecker();
115
- #endif
113
+ // TODO: Remove once we only use built-in SCTP stack.
114
+ if (!Settings::configuration.useBuiltInSctpStack)
115
+ {
116
+ // Close the Checker instance in DepUsrSCTP.
117
+ DepUsrSCTP::CloseChecker();
118
+ }
116
119
 
117
120
  #ifdef MS_LIBURING_SUPPORTED
118
121
  if (DepLibUring::IsEnabled())
@@ -9,9 +9,8 @@
9
9
  #include "DepLibUV.hpp"
10
10
  #include "DepLibWebRTC.hpp"
11
11
  #include "DepOpenSSL.hpp"
12
- #ifndef MS_SCTP_STACK
12
+ // TODO: Remove once we only use built-in SCTP stack.
13
13
  #include "DepUsrSCTP.hpp"
14
- #endif
15
14
  #include "Logger.hpp"
16
15
  #include "MediaSoupErrors.hpp"
17
16
  #include "Settings.hpp"
@@ -148,9 +147,11 @@ extern "C" int mediasoup_worker_run(
148
147
  // Initialize static stuff.
149
148
  DepOpenSSL::ClassInit();
150
149
  DepLibSRTP::ClassInit();
151
- #ifndef MS_SCTP_STACK
152
- DepUsrSCTP::ClassInit();
153
- #endif
150
+ // TODO: Remove once we only use built-in SCTP stack.
151
+ if (!Settings::configuration.useBuiltInSctpStack)
152
+ {
153
+ DepUsrSCTP::ClassInit();
154
+ }
154
155
  #ifdef MS_LIBURING_SUPPORTED
155
156
  DepLibUring::ClassInit();
156
157
  #endif
@@ -173,9 +174,11 @@ extern "C" int mediasoup_worker_run(
173
174
  DepLibUring::ClassDestroy();
174
175
  #endif
175
176
  RTC::DtlsTransport::ClassDestroy();
176
- #ifndef MS_SCTP_STACK
177
- DepUsrSCTP::ClassDestroy();
178
- #endif
177
+ // TODO: Remove once we only use built-in SCTP stack.
178
+ if (!Settings::configuration.useBuiltInSctpStack)
179
+ {
180
+ DepUsrSCTP::ClassDestroy();
181
+ }
179
182
  DepLibUV::ClassDestroy();
180
183
 
181
184
  return 0;
package/worker/tasks.py CHANGED
@@ -369,7 +369,7 @@ def format(ctx):
369
369
  );
370
370
 
371
371
 
372
- @task
372
+ @task(pre=[call(setup, meson_args=MESON_ARGS + ' -Dms_build_tests=true'), flatc])
373
373
  def tidy(ctx):
374
374
  """
375
375
  Performs C++ code checks according to `worker/.clang-tidy` rules
@@ -383,7 +383,7 @@ def tidy(ctx):
383
383
  );
384
384
 
385
385
 
386
- @task
386
+ @task(pre=[call(setup, meson_args=MESON_ARGS + ' -Dms_build_tests=true'), flatc])
387
387
  def tidy_fix(ctx):
388
388
  """
389
389
  Performs C++ code checks according to `worker/.clang-tidy` rules and applies
@@ -496,39 +496,6 @@ def test_asan_undefined(ctx):
496
496
  );
497
497
 
498
498
 
499
- @task(pre=[call(setup, meson_args=MESON_ARGS + ' -Dms_build_tests=true -Db_sanitize=thread -Db_lundef=false'), flatc])
500
- def test_asan_thread(ctx):
501
- """
502
- Run worker test with thread Sanitizer with -fsanitize=thread
503
- """
504
- with cd_worker():
505
- ctx.run(
506
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-thread',
507
- echo=True,
508
- pty=PTY_SUPPORTED,
509
- shell=SHELL
510
- );
511
- with cd_worker():
512
- ctx.run(
513
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-thread',
514
- echo=True,
515
- pty=PTY_SUPPORTED,
516
- shell=SHELL
517
- );
518
-
519
- mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or '';
520
-
521
- with cd_worker():
522
- ctx.run(
523
- f'"{BUILD_DIR}/mediasoup-worker-test-asan-thread" --invisibles {mediasoup_test_tags}',
524
- echo=True,
525
- pty=PTY_SUPPORTED,
526
- shell=SHELL,
527
- # Exit with error if there are issues.
528
- env={**os.environ, 'TSAN_OPTIONS': 'halt_on_error=1:print_stacktrace=1'}
529
- );
530
-
531
-
532
499
  @task(pre=[call(setup, meson_args=MESON_ARGS + ' -Db_sanitize=address -Db_lundef=false'), flatc])
533
500
  def fuzzer(ctx):
534
501
  """
@@ -17,10 +17,10 @@ SCENARIO("SCTP Negotiated Capabilities", "[sctp][negotiatedcapabilities]")
17
17
  {
18
18
  RTC::SCTP::SctpOptions sctpOptions{};
19
19
 
20
- sctpOptions.maxOutboundStreams = 8192;
21
- sctpOptions.maxInboundStreams = 2048;
22
- sctpOptions.enablePartialReliability = true;
23
- sctpOptions.enableMessageInterleaving = true;
20
+ sctpOptions.announcedMaxOutboundStreams = 8192;
21
+ sctpOptions.announcedMaxInboundStreams = 2048;
22
+ sctpOptions.enablePartialReliability = true;
23
+ sctpOptions.enableMessageInterleaving = true;
24
24
  sctpOptions.zeroChecksumAlternateErrorDetectionMethod =
25
25
  RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::SCTP_OVER_DTLS;
26
26
 
@@ -51,8 +51,8 @@ SCENARIO("SCTP Negotiated Capabilities", "[sctp][negotiatedcapabilities]")
51
51
 
52
52
  delete remoteChunk;
53
53
 
54
- REQUIRE(negotiatedCapabilities.maxOutboundStreams == 1024);
55
- REQUIRE(negotiatedCapabilities.maxInboundStreams == 2048);
54
+ REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 1024);
55
+ REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2048);
56
56
  REQUIRE(negotiatedCapabilities.partialReliability == true);
57
57
  REQUIRE(negotiatedCapabilities.messageInterleaving == true);
58
58
  REQUIRE(negotiatedCapabilities.reConfig == true);
@@ -63,10 +63,10 @@ SCENARIO("SCTP Negotiated Capabilities", "[sctp][negotiatedcapabilities]")
63
63
  {
64
64
  RTC::SCTP::SctpOptions sctpOptions{};
65
65
 
66
- sctpOptions.maxOutboundStreams = 1000;
67
- sctpOptions.maxInboundStreams = 2000;
68
- sctpOptions.enablePartialReliability = true;
69
- sctpOptions.enableMessageInterleaving = true;
66
+ sctpOptions.announcedMaxOutboundStreams = 1000;
67
+ sctpOptions.announcedMaxInboundStreams = 2000;
68
+ sctpOptions.enablePartialReliability = true;
69
+ sctpOptions.enableMessageInterleaving = true;
70
70
  sctpOptions.zeroChecksumAlternateErrorDetectionMethod =
71
71
  RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::SCTP_OVER_DTLS;
72
72
 
@@ -96,6 +96,7 @@ SCENARIO("SCTP Negotiated Capabilities", "[sctp][negotiatedcapabilities]")
96
96
  remoteChunk->BuildParameterInPlace<RTC::SCTP::ZeroChecksumAcceptableParameter>();
97
97
 
98
98
  remoteZeroChecksumAcceptableParameter->SetAlternateErrorDetectionMethod(
99
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
99
100
  static_cast<RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod>(666));
100
101
  remoteZeroChecksumAcceptableParameter->Consolidate();
101
102
 
@@ -104,8 +105,8 @@ SCENARIO("SCTP Negotiated Capabilities", "[sctp][negotiatedcapabilities]")
104
105
 
105
106
  delete remoteChunk;
106
107
 
107
- REQUIRE(negotiatedCapabilities.maxOutboundStreams == 1000);
108
- REQUIRE(negotiatedCapabilities.maxInboundStreams == 2000);
108
+ REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 1000);
109
+ REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2000);
109
110
  REQUIRE(negotiatedCapabilities.partialReliability == true);
110
111
  REQUIRE(negotiatedCapabilities.messageInterleaving == false);
111
112
  REQUIRE(negotiatedCapabilities.reConfig == false);
@@ -70,8 +70,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
70
70
 
71
71
  auto negotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
72
72
 
73
- REQUIRE(negotiatedCapabilities.maxOutboundStreams == 15000);
74
- REQUIRE(negotiatedCapabilities.maxInboundStreams == 2500);
73
+ REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 15000);
74
+ REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2500);
75
75
  REQUIRE(negotiatedCapabilities.partialReliability == true);
76
76
  REQUIRE(negotiatedCapabilities.messageInterleaving == false);
77
77
  REQUIRE(negotiatedCapabilities.reConfig == true);
@@ -103,8 +103,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
103
103
 
104
104
  negotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
105
105
 
106
- REQUIRE(negotiatedCapabilities.maxOutboundStreams == 15000);
107
- REQUIRE(negotiatedCapabilities.maxInboundStreams == 2500);
106
+ REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 15000);
107
+ REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2500);
108
108
  REQUIRE(negotiatedCapabilities.partialReliability == true);
109
109
  REQUIRE(negotiatedCapabilities.messageInterleaving == false);
110
110
  REQUIRE(negotiatedCapabilities.reConfig == true);
@@ -139,8 +139,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
139
139
 
140
140
  negotiatedCapabilities = clonedStateCookie->GetNegotiatedCapabilities();
141
141
 
142
- REQUIRE(negotiatedCapabilities.maxOutboundStreams == 15000);
143
- REQUIRE(negotiatedCapabilities.maxInboundStreams == 2500);
142
+ REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 15000);
143
+ REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2500);
144
144
  REQUIRE(negotiatedCapabilities.partialReliability == true);
145
145
  REQUIRE(negotiatedCapabilities.messageInterleaving == false);
146
146
  REQUIRE(negotiatedCapabilities.reConfig == true);
@@ -270,8 +270,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
270
270
 
271
271
  SECTION("StateCookie::Factory() succeeds")
272
272
  {
273
- RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = { .maxOutboundStreams = 62000,
274
- .maxInboundStreams = 55555,
273
+ RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = { .negotiatedMaxOutboundStreams = 62000,
274
+ .negotiatedMaxInboundStreams = 55555,
275
275
  .partialReliability = true,
276
276
  .messageInterleaving = true,
277
277
  .reConfig = true,
@@ -290,8 +290,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
290
290
 
291
291
  // Change values of the original NegotiatedCapabilities to assert that it
292
292
  // doesn't affect the internals of StateCookie.
293
- negotiatedCapabilities.partialReliability = false;
294
- negotiatedCapabilities.maxOutboundStreams = 1024;
293
+ negotiatedCapabilities.partialReliability = false;
294
+ negotiatedCapabilities.negotiatedMaxOutboundStreams = 1024;
295
295
 
296
296
  REQUIRE(stateCookie);
297
297
  REQUIRE(stateCookie->GetBuffer() == sctpCommon::FactoryBuffer);
@@ -313,8 +313,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
313
313
 
314
314
  const auto retrievedNegotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
315
315
 
316
- REQUIRE(retrievedNegotiatedCapabilities.maxOutboundStreams == 62000);
317
- REQUIRE(retrievedNegotiatedCapabilities.maxInboundStreams == 55555);
316
+ REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxOutboundStreams == 62000);
317
+ REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxInboundStreams == 55555);
318
318
  REQUIRE(retrievedNegotiatedCapabilities.partialReliability == true);
319
319
  REQUIRE(retrievedNegotiatedCapabilities.messageInterleaving == true);
320
320
  REQUIRE(retrievedNegotiatedCapabilities.reConfig == true);
@@ -347,8 +347,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
347
347
 
348
348
  const auto retrievedParsedNegotiatedCapabilities = parsedStateCookie->GetNegotiatedCapabilities();
349
349
 
350
- REQUIRE(retrievedParsedNegotiatedCapabilities.maxOutboundStreams == 62000);
351
- REQUIRE(retrievedParsedNegotiatedCapabilities.maxInboundStreams == 55555);
350
+ REQUIRE(retrievedParsedNegotiatedCapabilities.negotiatedMaxOutboundStreams == 62000);
351
+ REQUIRE(retrievedParsedNegotiatedCapabilities.negotiatedMaxInboundStreams == 55555);
352
352
  REQUIRE(retrievedParsedNegotiatedCapabilities.partialReliability == true);
353
353
  REQUIRE(retrievedParsedNegotiatedCapabilities.messageInterleaving == true);
354
354
  REQUIRE(retrievedParsedNegotiatedCapabilities.reConfig == true);
@@ -359,8 +359,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
359
359
 
360
360
  SECTION("StateCookie::Write() succeeds")
361
361
  {
362
- RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = { .maxOutboundStreams = 62000,
363
- .maxInboundStreams = 55555,
362
+ RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = { .negotiatedMaxOutboundStreams = 62000,
363
+ .negotiatedMaxInboundStreams = 55555,
364
364
  .partialReliability = true,
365
365
  .messageInterleaving = true,
366
366
  .reConfig = true,
@@ -381,8 +381,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
381
381
 
382
382
  // Change values of the original NegotiatedCapabilities to assert that it
383
383
  // doesn't affect the internals of StateCookie.
384
- negotiatedCapabilities.partialReliability = false;
385
- negotiatedCapabilities.maxOutboundStreams = 1024;
384
+ negotiatedCapabilities.partialReliability = false;
385
+ negotiatedCapabilities.negotiatedMaxOutboundStreams = 1024;
386
386
 
387
387
  /* Parse the buffer. */
388
388
 
@@ -409,8 +409,8 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
409
409
 
410
410
  const auto retrievedNegotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
411
411
 
412
- REQUIRE(retrievedNegotiatedCapabilities.maxOutboundStreams == 62000);
413
- REQUIRE(retrievedNegotiatedCapabilities.maxInboundStreams == 55555);
412
+ REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxOutboundStreams == 62000);
413
+ REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxInboundStreams == 55555);
414
414
  REQUIRE(retrievedNegotiatedCapabilities.partialReliability == true);
415
415
  REQUIRE(retrievedNegotiatedCapabilities.messageInterleaving == true);
416
416
  REQUIRE(retrievedNegotiatedCapabilities.reConfig == true);
@@ -0,0 +1,210 @@
1
+ #include "common.hpp"
2
+ #include "RTC/SCTP/common/UnwrappedSequenceNumber.hpp"
3
+ #include <catch2/catch_test_macros.hpp>
4
+
5
+ SCENARIO("SCTP UnwrappedSequenceNumber", "[sctp]")
6
+ {
7
+ using TestSequence = RTC::SCTP::UnwrappedSequenceNumber<uint16_t>;
8
+
9
+ SECTION("simple unwrapping")
10
+ {
11
+ TestSequence::Unwrapper unwrapper;
12
+
13
+ TestSequence s0 = unwrapper.Unwrap(0);
14
+ TestSequence s1 = unwrapper.Unwrap(1);
15
+ TestSequence s2 = unwrapper.Unwrap(2);
16
+ TestSequence s3 = unwrapper.Unwrap(3);
17
+
18
+ REQUIRE(s0 < s1);
19
+ REQUIRE(s0 < s2);
20
+ REQUIRE(s0 < s3);
21
+ REQUIRE(s1 < s2);
22
+ REQUIRE(s1 < s3);
23
+ REQUIRE(s2 < s3);
24
+
25
+ REQUIRE(TestSequence::Difference(s1, s0) == 1);
26
+ REQUIRE(TestSequence::Difference(s2, s0) == 2);
27
+ REQUIRE(TestSequence::Difference(s3, s0) == 3);
28
+
29
+ REQUIRE(s1 > s0);
30
+ REQUIRE(s2 > s0);
31
+ REQUIRE(s3 > s0);
32
+ REQUIRE(s2 > s1);
33
+ REQUIRE(s3 > s1);
34
+ REQUIRE(s3 > s2);
35
+
36
+ s0.Increment();
37
+ REQUIRE(s0 == s1);
38
+
39
+ s1.Increment();
40
+ REQUIRE(s1 == s2);
41
+
42
+ s2.Increment();
43
+ REQUIRE(s2 == s3);
44
+
45
+ REQUIRE(TestSequence::AddTo(s0, 2) == s3);
46
+ }
47
+
48
+ SECTION("mid value unwrapping")
49
+ {
50
+ TestSequence::Unwrapper unwrapper;
51
+
52
+ TestSequence s0 = unwrapper.Unwrap(0x7FFE);
53
+ TestSequence s1 = unwrapper.Unwrap(0x7FFF);
54
+ TestSequence s2 = unwrapper.Unwrap(0x8000);
55
+ TestSequence s3 = unwrapper.Unwrap(0x8001);
56
+
57
+ REQUIRE(s0 < s1);
58
+ REQUIRE(s0 < s2);
59
+ REQUIRE(s0 < s3);
60
+ REQUIRE(s1 < s2);
61
+ REQUIRE(s1 < s3);
62
+ REQUIRE(s2 < s3);
63
+
64
+ REQUIRE(TestSequence::Difference(s1, s0) == 1);
65
+ REQUIRE(TestSequence::Difference(s2, s0) == 2);
66
+ REQUIRE(TestSequence::Difference(s3, s0) == 3);
67
+
68
+ REQUIRE(s1 > s0);
69
+ REQUIRE(s2 > s0);
70
+ REQUIRE(s3 > s0);
71
+ REQUIRE(s2 > s1);
72
+ REQUIRE(s3 > s1);
73
+ REQUIRE(s3 > s2);
74
+
75
+ s0.Increment();
76
+ REQUIRE(s0 == s1);
77
+
78
+ s1.Increment();
79
+ REQUIRE(s1 == s2);
80
+
81
+ s2.Increment();
82
+ REQUIRE(s2 == s3);
83
+
84
+ REQUIRE(TestSequence::AddTo(s0, 2) == s3);
85
+ }
86
+
87
+ SECTION("wrapped unwrapping")
88
+ {
89
+ TestSequence::Unwrapper unwrapper;
90
+
91
+ TestSequence s0 = unwrapper.Unwrap(0xFFFE);
92
+ TestSequence s1 = unwrapper.Unwrap(0xFFFF);
93
+ TestSequence s2 = unwrapper.Unwrap(0x0000);
94
+ TestSequence s3 = unwrapper.Unwrap(0x0001);
95
+
96
+ REQUIRE(s0 < s1);
97
+ REQUIRE(s0 < s2);
98
+ REQUIRE(s0 < s3);
99
+ REQUIRE(s1 < s2);
100
+ REQUIRE(s1 < s3);
101
+ REQUIRE(s2 < s3);
102
+
103
+ REQUIRE(TestSequence::Difference(s1, s0) == 1);
104
+ REQUIRE(TestSequence::Difference(s2, s0) == 2);
105
+ REQUIRE(TestSequence::Difference(s3, s0) == 3);
106
+
107
+ REQUIRE(s1 > s0);
108
+ REQUIRE(s2 > s0);
109
+ REQUIRE(s3 > s0);
110
+ REQUIRE(s2 > s1);
111
+ REQUIRE(s3 > s1);
112
+ REQUIRE(s3 > s2);
113
+
114
+ s0.Increment();
115
+ REQUIRE(s0 == s1);
116
+
117
+ s1.Increment();
118
+ REQUIRE(s1 == s2);
119
+
120
+ s2.Increment();
121
+ REQUIRE(s2 == s3);
122
+
123
+ REQUIRE(TestSequence::AddTo(s0, 2) == s3);
124
+ }
125
+
126
+ SECTION("wrap around a few times")
127
+ {
128
+ TestSequence::Unwrapper unwrapper;
129
+
130
+ const TestSequence s0 = unwrapper.Unwrap(0);
131
+ TestSequence prev = s0;
132
+
133
+ for (uint32_t i{ 1 }; i < 65536 * 3; ++i)
134
+ {
135
+ const auto wrapped = static_cast<uint16_t>(i);
136
+ const TestSequence si = unwrapper.Unwrap(wrapped);
137
+
138
+ REQUIRE(s0 < si);
139
+ REQUIRE(prev < si);
140
+
141
+ prev = si;
142
+ }
143
+ }
144
+
145
+ SECTION("increment is same as wrapped")
146
+ {
147
+ TestSequence::Unwrapper unwrapper;
148
+
149
+ TestSequence s0 = unwrapper.Unwrap(0);
150
+ TestSequence prev = s0;
151
+
152
+ for (uint32_t i{ 1 }; i < 65536 * 2; ++i)
153
+ {
154
+ const auto wrapped = static_cast<uint16_t>(i);
155
+ const TestSequence si = unwrapper.Unwrap(wrapped);
156
+
157
+ s0.Increment();
158
+ REQUIRE(s0 == si);
159
+
160
+ prev = si;
161
+ }
162
+ }
163
+
164
+ SECTION("unwrapping larger number is always larger")
165
+ {
166
+ TestSequence::Unwrapper unwrapper;
167
+
168
+ for (uint32_t i{ 1 }; i < 65536 * 2; ++i)
169
+ {
170
+ const auto wrapped = static_cast<uint16_t>(i);
171
+ const TestSequence si = unwrapper.Unwrap(wrapped);
172
+
173
+ REQUIRE(unwrapper.Unwrap(wrapped + 1) > si);
174
+ REQUIRE(unwrapper.Unwrap(wrapped + 5) > si);
175
+ REQUIRE(unwrapper.Unwrap(wrapped + 10) > si);
176
+ REQUIRE(unwrapper.Unwrap(wrapped + 100) > si);
177
+ }
178
+ }
179
+
180
+ SECTION("unwrapping smaller number is always smaller")
181
+ {
182
+ TestSequence::Unwrapper unwrapper;
183
+
184
+ for (uint32_t i{ 1 }; i < 65536 * 2; ++i)
185
+ {
186
+ const auto wrapped = static_cast<uint16_t>(i);
187
+ const TestSequence si = unwrapper.Unwrap(wrapped);
188
+
189
+ REQUIRE(unwrapper.Unwrap(wrapped - 1) < si);
190
+ REQUIRE(unwrapper.Unwrap(wrapped - 5) < si);
191
+ REQUIRE(unwrapper.Unwrap(wrapped - 10) < si);
192
+ REQUIRE(unwrapper.Unwrap(wrapped - 100) < si);
193
+ }
194
+ }
195
+
196
+ SECTION("difference is absolute")
197
+ {
198
+ TestSequence::Unwrapper unwrapper;
199
+ const TestSequence thisValue = unwrapper.Unwrap(10);
200
+ const TestSequence otherValue = TestSequence::AddTo(thisValue, 100);
201
+
202
+ REQUIRE(TestSequence::Difference(thisValue, otherValue) == 100);
203
+ REQUIRE(TestSequence::Difference(otherValue, thisValue) == 100);
204
+
205
+ const TestSequence minusValue = TestSequence::AddTo(thisValue, -100);
206
+
207
+ REQUIRE(TestSequence::Difference(thisValue, minusValue) == 100);
208
+ REQUIRE(TestSequence::Difference(minusValue, thisValue) == 100);
209
+ }
210
+ }
@@ -47,7 +47,7 @@ SCENARIO("SCTP Abort Association Chunk (6)", "[serializable][sctp][chunk]")
47
47
 
48
48
  REQUIRE(chunk->GetT() == true);
49
49
 
50
- auto* errorCause1 =
50
+ const auto* errorCause1 =
51
51
  reinterpret_cast<const RTC::SCTP::StaleCookieErrorCause*>(chunk->GetErrorCauseAt(0));
52
52
 
53
53
  CHECK_SCTP_ERROR_CAUSE(
@@ -268,7 +268,7 @@ SCENARIO("SCTP Abort Association Chunk (6)", "[serializable][sctp][chunk]")
268
268
 
269
269
  REQUIRE(chunk->GetT() == true);
270
270
 
271
- auto* obtainedErrorCause1 =
271
+ const auto* obtainedErrorCause1 =
272
272
  reinterpret_cast<const RTC::SCTP::StaleCookieErrorCause*>(chunk->GetErrorCauseAt(0));
273
273
 
274
274
  CHECK_SCTP_ERROR_CAUSE(
@@ -53,7 +53,7 @@ SCENARIO("SCTP Hearbeat Acknowledgement Chunk (5)", "[serializable][sctp][chunk]
53
53
  /*canHaveErrorCauses*/ false,
54
54
  /*errorCausesCount*/ 0);
55
55
 
56
- auto* parameter1 =
56
+ const auto* parameter1 =
57
57
  reinterpret_cast<const RTC::SCTP::HeartbeatInfoParameter*>(chunk->GetParameterAt(0));
58
58
 
59
59
  CHECK_SCTP_PARAMETER(
@@ -77,13 +77,15 @@ SCENARIO("SCTP Hearbeat Acknowledgement Chunk (5)", "[serializable][sctp][chunk]
77
77
  // This should be padding.
78
78
  REQUIRE(parameter1->GetInfo()[7] == 0x00);
79
79
 
80
- auto* parameter2 = reinterpret_cast<const RTC::SCTP::UnknownParameter*>(chunk->GetParameterAt(1));
80
+ const auto* parameter2 =
81
+ reinterpret_cast<const RTC::SCTP::UnknownParameter*>(chunk->GetParameterAt(1));
81
82
 
82
83
  CHECK_SCTP_PARAMETER(
83
84
  /*parameter*/ parameter2,
84
85
  /*buffer*/ nullptr,
85
86
  /*bufferLength*/ 8,
86
87
  /*length*/ 8,
88
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
87
89
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
88
90
  /*unknownType*/ true,
89
91
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -144,6 +146,7 @@ SCENARIO("SCTP Hearbeat Acknowledgement Chunk (5)", "[serializable][sctp][chunk]
144
146
  /*buffer*/ nullptr,
145
147
  /*bufferLength*/ 8,
146
148
  /*length*/ 8,
149
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
147
150
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
148
151
  /*unknownType*/ true,
149
152
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -156,7 +159,7 @@ SCENARIO("SCTP Hearbeat Acknowledgement Chunk (5)", "[serializable][sctp][chunk]
156
159
 
157
160
  /* Clone it. */
158
161
 
159
- auto* clonedChunk = chunk->Clone(sctpCommon::CloneBuffer, sizeof(sctpCommon::CloneBuffer));
162
+ const auto* clonedChunk = chunk->Clone(sctpCommon::CloneBuffer, sizeof(sctpCommon::CloneBuffer));
160
163
 
161
164
  std::memset(sctpCommon::SerializeBuffer, 0x00, sizeof(sctpCommon::SerializeBuffer));
162
165
 
@@ -207,6 +210,7 @@ SCENARIO("SCTP Hearbeat Acknowledgement Chunk (5)", "[serializable][sctp][chunk]
207
210
  /*buffer*/ nullptr,
208
211
  /*bufferLength*/ 8,
209
212
  /*length*/ 8,
213
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
210
214
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
211
215
  /*unknownType*/ true,
212
216
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -314,7 +318,8 @@ SCENARIO("SCTP Hearbeat Acknowledgement Chunk (5)", "[serializable][sctp][chunk]
314
318
 
315
319
  /* Parse itself and compare. */
316
320
 
317
- auto* parsedChunk = RTC::SCTP::HeartbeatAckChunk::Parse(chunk->GetBuffer(), chunk->GetLength());
321
+ const auto* parsedChunk =
322
+ RTC::SCTP::HeartbeatAckChunk::Parse(chunk->GetBuffer(), chunk->GetLength());
318
323
 
319
324
  delete chunk;
320
325
 
@@ -86,6 +86,7 @@ SCENARIO("SCTP Hearbeat Request Chunk (4)", "[serializable][sctp][chunk]")
86
86
  /*buffer*/ nullptr,
87
87
  /*bufferLength*/ 8,
88
88
  /*length*/ 8,
89
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
89
90
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
90
91
  /*unknownType*/ true,
91
92
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -148,6 +149,7 @@ SCENARIO("SCTP Hearbeat Request Chunk (4)", "[serializable][sctp][chunk]")
148
149
  /*buffer*/ nullptr,
149
150
  /*bufferLength*/ 8,
150
151
  /*length*/ 8,
152
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
151
153
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
152
154
  /*unknownType*/ true,
153
155
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -213,6 +215,7 @@ SCENARIO("SCTP Hearbeat Request Chunk (4)", "[serializable][sctp][chunk]")
213
215
  /*buffer*/ nullptr,
214
216
  /*bufferLength*/ 8,
215
217
  /*length*/ 8,
218
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
216
219
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
217
220
  /*unknownType*/ true,
218
221
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -309,6 +312,7 @@ SCENARIO("SCTP Hearbeat Request Chunk (4)", "[serializable][sctp][chunk]")
309
312
  /*buffer*/ nullptr,
310
313
  /*bufferLength*/ 8,
311
314
  /*length*/ 8,
315
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
312
316
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
313
317
  /*unknownType*/ true,
314
318
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);
@@ -374,6 +378,7 @@ SCENARIO("SCTP Hearbeat Request Chunk (4)", "[serializable][sctp][chunk]")
374
378
  /*buffer*/ nullptr,
375
379
  /*bufferLength*/ 8,
376
380
  /*length*/ 8,
381
+ // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
377
382
  /*parameterType*/ static_cast<RTC::SCTP::Parameter::ParameterType>(49159),
378
383
  /*unknownType*/ true,
379
384
  /*actionForUnknownParameterType*/ RTC::SCTP::Parameter::ActionForUnknownParameterType::SKIP_AND_REPORT);