mediasoup 3.21.0 → 3.21.2

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 (56) hide show
  1. package/CHANGELOG.md +1882 -0
  2. package/node/lib/test/test-Consumer.js +111 -0
  3. package/node/lib/test/test-Producer.js +54 -0
  4. package/npm-scripts.mjs +0 -5
  5. package/package.json +9 -8
  6. package/worker/fuzzer/src/RTC/SCTP/association/FuzzerStateCookie.cpp +4 -6
  7. package/worker/include/RTC/NEW_RTCP/packet/ByePacket.hpp +165 -0
  8. package/worker/include/RTC/NEW_RTCP/packet/CompoundPacket.hpp +183 -0
  9. package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +354 -0
  10. package/worker/include/RTC/NEW_RTCP/packet/TODO_NEW_RTCP.md +17 -0
  11. package/worker/include/RTC/RTP/Codecs/Tools.hpp +2 -0
  12. package/worker/include/RTC/Router.hpp +4 -4
  13. package/worker/include/RTC/SCTP/association/Capabilities.hpp +73 -0
  14. package/worker/include/RTC/SCTP/association/NegotiatedCapabilities.hpp +7 -9
  15. package/worker/include/RTC/SCTP/association/StateCookie.hpp +38 -28
  16. package/worker/include/RTC/SCTP/packet/Chunk.hpp +11 -7
  17. package/worker/include/RTC/SCTP/packet/ErrorCause.hpp +11 -4
  18. package/worker/include/RTC/SCTP/packet/Packet.hpp +1 -1
  19. package/worker/include/RTC/SCTP/packet/Parameter.hpp +11 -4
  20. package/worker/include/RTC/SCTP/packet/TLV.hpp +2 -2
  21. package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +2 -2
  22. package/worker/include/RTC/Transport.hpp +10 -10
  23. package/worker/include/Worker.hpp +4 -4
  24. package/worker/meson.build +7 -0
  25. package/worker/scripts/clang-scripts.mjs +54 -0
  26. package/worker/src/RTC/Consumer.cpp +22 -4
  27. package/worker/src/RTC/NEW_RTCP/packet/ByePacket.cpp +266 -0
  28. package/worker/src/RTC/NEW_RTCP/packet/CompoundPacket.cpp +219 -0
  29. package/worker/src/RTC/NEW_RTCP/packet/Packet.cpp +222 -0
  30. package/worker/src/RTC/RTP/Codecs/H264.cpp +3 -0
  31. package/worker/src/RTC/RTP/Codecs/VP8.cpp +3 -0
  32. package/worker/src/RTC/Router.cpp +14 -14
  33. package/worker/src/RTC/SCTP/association/Association.cpp +23 -11
  34. package/worker/src/RTC/SCTP/association/Capabilities.cpp +87 -0
  35. package/worker/src/RTC/SCTP/association/NegotiatedCapabilities.cpp +20 -40
  36. package/worker/src/RTC/SCTP/association/StateCookie.cpp +54 -32
  37. package/worker/src/RTC/SCTP/packet/Chunk.cpp +18 -18
  38. package/worker/src/RTC/SCTP/packet/ErrorCause.cpp +18 -18
  39. package/worker/src/RTC/SCTP/packet/Packet.cpp +2 -0
  40. package/worker/src/RTC/SCTP/packet/Parameter.cpp +18 -18
  41. package/worker/src/RTC/SCTP/packet/TLV.cpp +27 -25
  42. package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
  43. package/worker/src/RTC/SvcProducerStreamManager.cpp +4 -1
  44. package/worker/src/RTC/Transport.cpp +42 -30
  45. package/worker/src/Worker.cpp +10 -10
  46. package/worker/test/include/RTC/ICE/iceCommon.hpp +1 -1
  47. package/worker/test/include/RTC/RTCP/rtcpCommon.hpp +58 -0
  48. package/worker/test/include/RTC/RTP/rtpCommon.hpp +1 -1
  49. package/worker/test/src/RTC/NEW_RTCP/packet/TestByePacket.cpp +302 -0
  50. package/worker/test/src/RTC/NEW_RTCP/rtcpCommon.cpp +29 -0
  51. package/worker/test/src/RTC/RTP/TestPacket.cpp +17 -15
  52. package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +3 -3
  53. package/worker/test/src/RTC/SCTP/association/TestCapabilities.cpp +99 -0
  54. package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +14 -16
  55. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +198 -102
  56. package/worker/test/src/RTC/SCTP/packet/parameters/TestStateCookieParameter.cpp +11 -10
@@ -1,6 +1,7 @@
1
1
  #include "common.hpp"
2
- #include "RTC/SCTP/association/NegotiatedCapabilities.hpp"
2
+ #include "RTC/SCTP/association/Capabilities.hpp"
3
3
  #include "RTC/SCTP/association/StateCookie.hpp"
4
+ #include "RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp"
4
5
  #include "RTC/SCTP/public/SctpTypes.hpp"
5
6
  #include "test/include/RTC/SCTP/sctpCommon.hpp" // in worker/test/include/
6
7
  #include <catch2/catch_test_macros.hpp>
@@ -13,7 +14,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
13
14
  SECTION("StateCookie::Parse() succeeds")
14
15
  {
15
16
  // clang-format off
16
- uint8_t buffer[] =
17
+ alignas(4) uint8_t buffer[] =
17
18
  {
18
19
  // Magic 1: 0x6D73776F726B6572
19
20
  0x6D, 0x73, 0x77, 0x6F,
@@ -31,13 +32,14 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
31
32
  // Tie-Tag: 0xABCDEF0011223344
32
33
  0xAB, 0xCD, 0xEF, 0x00,
33
34
  0x11, 0x22, 0x33, 0x44,
34
- // Negotiated Capabilities
35
+ // Remote Capabilities
35
36
  // - partialReliability: 1
36
37
  // - messageInterleaving: 0
37
38
  // - re-config: 1
38
- // - zeroChecksum: 1
39
39
  // Magic 2: 0xAD81
40
- 0x00, 0b00001101, 0xAD, 0x81,
40
+ 0x00, 0b00000101, 0xAD, 0x81,
41
+ // Zero Checksum Alternate Error Detection Method: SCTP_OVER_DTLS (1)
42
+ 0x00, 0x00, 0x00, 0x01,
41
43
  // Max Outbound Streams: 15000, Max Inbound Streams: 2500
42
44
  0x3A, 0x98, 0x09, 0xC4
43
45
  };
@@ -68,14 +70,16 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
68
70
  stateCookie->GetBuffer(), stateCookie->GetLength()) ==
69
71
  RTC::SCTP::Types::SctpImplementation::MEDIASOUP);
70
72
 
71
- auto negotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
73
+ auto remoteCapabilities = stateCookie->GetRemoteCapabilities();
72
74
 
73
- REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 15000);
74
- REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2500);
75
- REQUIRE(negotiatedCapabilities.partialReliability == true);
76
- REQUIRE(negotiatedCapabilities.messageInterleaving == false);
77
- REQUIRE(negotiatedCapabilities.reConfig == true);
78
- REQUIRE(negotiatedCapabilities.zeroChecksum == true);
75
+ REQUIRE(remoteCapabilities.maxOutboundStreams == 15000);
76
+ REQUIRE(remoteCapabilities.maxInboundStreams == 2500);
77
+ REQUIRE(remoteCapabilities.partialReliability == true);
78
+ REQUIRE(remoteCapabilities.messageInterleaving == false);
79
+ REQUIRE(remoteCapabilities.reConfig == true);
80
+ REQUIRE(
81
+ remoteCapabilities.zeroChecksumAlternateErrorDetectionMethod ==
82
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::SCTP_OVER_DTLS);
79
83
 
80
84
  /* Serialize it. */
81
85
 
@@ -101,14 +105,16 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
101
105
  stateCookie->GetBuffer(), stateCookie->GetLength()) ==
102
106
  RTC::SCTP::Types::SctpImplementation::MEDIASOUP);
103
107
 
104
- negotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
108
+ remoteCapabilities = stateCookie->GetRemoteCapabilities();
105
109
 
106
- REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 15000);
107
- REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2500);
108
- REQUIRE(negotiatedCapabilities.partialReliability == true);
109
- REQUIRE(negotiatedCapabilities.messageInterleaving == false);
110
- REQUIRE(negotiatedCapabilities.reConfig == true);
111
- REQUIRE(negotiatedCapabilities.zeroChecksum == true);
110
+ REQUIRE(remoteCapabilities.maxOutboundStreams == 15000);
111
+ REQUIRE(remoteCapabilities.maxInboundStreams == 2500);
112
+ REQUIRE(remoteCapabilities.partialReliability == true);
113
+ REQUIRE(remoteCapabilities.messageInterleaving == false);
114
+ REQUIRE(remoteCapabilities.reConfig == true);
115
+ REQUIRE(
116
+ remoteCapabilities.zeroChecksumAlternateErrorDetectionMethod ==
117
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::SCTP_OVER_DTLS);
112
118
 
113
119
  /* Clone it. */
114
120
 
@@ -137,14 +143,16 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
137
143
  clonedStateCookie->GetBuffer(), clonedStateCookie->GetLength()) ==
138
144
  RTC::SCTP::Types::SctpImplementation::MEDIASOUP);
139
145
 
140
- negotiatedCapabilities = clonedStateCookie->GetNegotiatedCapabilities();
146
+ remoteCapabilities = clonedStateCookie->GetRemoteCapabilities();
141
147
 
142
- REQUIRE(negotiatedCapabilities.negotiatedMaxOutboundStreams == 15000);
143
- REQUIRE(negotiatedCapabilities.negotiatedMaxInboundStreams == 2500);
144
- REQUIRE(negotiatedCapabilities.partialReliability == true);
145
- REQUIRE(negotiatedCapabilities.messageInterleaving == false);
146
- REQUIRE(negotiatedCapabilities.reConfig == true);
147
- REQUIRE(negotiatedCapabilities.zeroChecksum == true);
148
+ REQUIRE(remoteCapabilities.maxOutboundStreams == 15000);
149
+ REQUIRE(remoteCapabilities.maxInboundStreams == 2500);
150
+ REQUIRE(remoteCapabilities.partialReliability == true);
151
+ REQUIRE(remoteCapabilities.messageInterleaving == false);
152
+ REQUIRE(remoteCapabilities.reConfig == true);
153
+ REQUIRE(
154
+ remoteCapabilities.zeroChecksumAlternateErrorDetectionMethod ==
155
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::SCTP_OVER_DTLS);
148
156
 
149
157
  delete clonedStateCookie;
150
158
  }
@@ -153,7 +161,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
153
161
  {
154
162
  // Wrong Magic 1.
155
163
  // clang-format off
156
- uint8_t buffer1[] =
164
+ alignas(4) uint8_t buffer1[] =
157
165
  {
158
166
  // Magic 1: 0x6D73776F726B6573 (wrong)
159
167
  0x6D, 0x73, 0x77, 0x6F,
@@ -171,13 +179,14 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
171
179
  // Tie-Tag: 0xABCDEF0011223344
172
180
  0xAB, 0xCD, 0xEF, 0x00,
173
181
  0x11, 0x22, 0x33, 0x44,
174
- // Negotiated Capabilities
182
+ // Remote Capabilities
175
183
  // - partialReliability: 1
176
184
  // - messageInterleaving: 0
177
185
  // - re-config: 1
178
- // - zeroChecksum: 1
179
186
  // Magic 2: 0xAD81
180
- 0x00, 0b00001101, 0xAD, 0x81,
187
+ 0x00, 0b00000101, 0xAD, 0x81,
188
+ // Zero Checksum Alternate Error Detection Method: SCTP_OVER_DTLS (1)
189
+ 0x00, 0x00, 0x00, 0x01,
181
190
  // Max Outbound Streams: 15000, Max Inbound Streams: 2500
182
191
  0x3A, 0x98, 0x09, 0xC4
183
192
  };
@@ -191,7 +200,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
191
200
 
192
201
  // Wrong Magic 2.
193
202
  // clang-format off
194
- uint8_t buffer2[] =
203
+ alignas(4) uint8_t buffer2[] =
195
204
  {
196
205
  // Magic 1: 0x6D73776F726B6572
197
206
  0x6D, 0x73, 0x77, 0x6F,
@@ -209,13 +218,14 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
209
218
  // Tie-Tag: 0xABCDEF0011223344
210
219
  0xAB, 0xCD, 0xEF, 0x00,
211
220
  0x11, 0x22, 0x33, 0x44,
212
- // Negotiated Capabilities
221
+ // Remote Capabilities
213
222
  // - partialReliability: 1
214
223
  // - messageInterleaving: 0
215
224
  // - re-config: 1
216
- // - zeroChecksum: 1
217
225
  // Magic 2: 0xAD82 (instead of 0xAD81)
218
- 0x00, 0b00001101, 0xAD, 0x82,
226
+ 0x00, 0b00000101, 0xAD, 0x82,
227
+ // Zero Checksum Alternate Error Detection Method: SCTP_OVER_DTLS (1)
228
+ 0x00, 0x00, 0x00, 0x01,
219
229
  // Max Outbound Streams: 15000, Max Inbound Streams: 2500
220
230
  0x3A, 0x98, 0x09, 0xC4
221
231
  };
@@ -229,7 +239,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
229
239
 
230
240
  // Buffer too big.
231
241
  // clang-format off
232
- uint8_t buffer3[] =
242
+ alignas(4) uint8_t buffer3[] =
233
243
  {
234
244
  // Magic 1: 0x6D73776F726B6572
235
245
  0x6D, 0x73, 0x77, 0x6F,
@@ -247,13 +257,14 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
247
257
  // Tie-Tag: 0xABCDEF0011223344
248
258
  0xAB, 0xCD, 0xEF, 0x00,
249
259
  0x11, 0x22, 0x33, 0x44,
250
- // Negotiated Capabilities
260
+ // Remote Capabilities
251
261
  // - partialReliability: 1
252
262
  // - messageInterleaving: 0
253
263
  // - re-config: 1
254
- // - zeroChecksum: 1
255
264
  // Magic 2: 0xAD81
256
- 0x00, 0b00001101, 0xAD, 0x81,
265
+ 0x00, 0b00000101, 0xAD, 0x81,
266
+ // Zero Checksum Alternate Error Detection Method: SCTP_OVER_DTLS (1)
267
+ 0x00, 0x00, 0x00, 0x01,
257
268
  // Max Outbound Streams: 15000, Max Inbound Streams: 2500
258
269
  0x3A, 0x98, 0x09, 0xC4,
259
270
  // Extra bytes that shouldn't be here.
@@ -268,14 +279,88 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
268
279
  REQUIRE(!RTC::SCTP::StateCookie::Parse(buffer3, sizeof(buffer3)));
269
280
  }
270
281
 
282
+ SECTION("StateCookie::Parse() fails on a zero verification tag")
283
+ {
284
+ // Zero Local Verification Tag.
285
+ // clang-format off
286
+ alignas(4) uint8_t buffer1[] =
287
+ {
288
+ // Magic 1: 0x6D73776F726B6572
289
+ 0x6D, 0x73, 0x77, 0x6F,
290
+ 0x72, 0x6B, 0x65, 0x72,
291
+ // Local Verification Tag: 0 (invalid)
292
+ 0x00, 0x00, 0x00, 0x00,
293
+ // Remote Verification Tag: 55667788
294
+ 0x03, 0x51, 0x6C, 0x4C,
295
+ // Local Initial TSN: 12345678
296
+ 0x00, 0xBC, 0x61, 0x4E,
297
+ // Remote Initial TSN: 87654321
298
+ 0x05, 0x39, 0x7F, 0xB1,
299
+ // Remote Advertised Receiver Window Credit (a_rwnd): 66666666
300
+ 0x03, 0xF9, 0x40, 0xAA,
301
+ // Tie-Tag: 0xABCDEF0011223344
302
+ 0xAB, 0xCD, 0xEF, 0x00,
303
+ 0x11, 0x22, 0x33, 0x44,
304
+ // Remote Capabilities
305
+ // Magic 2: 0xAD81
306
+ 0x00, 0b00000101, 0xAD, 0x81,
307
+ // Zero Checksum Alternate Error Detection Method: SCTP_OVER_DTLS (1)
308
+ 0x00, 0x00, 0x00, 0x01,
309
+ // Max Outbound Streams: 15000, Max Inbound Streams: 2500
310
+ 0x3A, 0x98, 0x09, 0xC4
311
+ };
312
+ // clang-format on
313
+
314
+ // It is still recognized as a mediasoup State Cookie (magic values and
315
+ // length are fine) but Parse() must reject it.
316
+ REQUIRE(RTC::SCTP::StateCookie::IsMediasoupStateCookie(buffer1, sizeof(buffer1)) == true);
317
+ REQUIRE(!RTC::SCTP::StateCookie::Parse(buffer1, sizeof(buffer1)));
318
+
319
+ // Zero Remote Verification Tag.
320
+ // clang-format off
321
+ alignas(4) uint8_t buffer2[] =
322
+ {
323
+ // Magic 1: 0x6D73776F726B6572
324
+ 0x6D, 0x73, 0x77, 0x6F,
325
+ 0x72, 0x6B, 0x65, 0x72,
326
+ // Local Verification Tag: 11223344
327
+ 0x00, 0xAB, 0x41, 0x30,
328
+ // Remote Verification Tag: 0 (invalid)
329
+ 0x00, 0x00, 0x00, 0x00,
330
+ // Local Initial TSN: 12345678
331
+ 0x00, 0xBC, 0x61, 0x4E,
332
+ // Remote Initial TSN: 87654321
333
+ 0x05, 0x39, 0x7F, 0xB1,
334
+ // Remote Advertised Receiver Window Credit (a_rwnd): 66666666
335
+ 0x03, 0xF9, 0x40, 0xAA,
336
+ // Tie-Tag: 0xABCDEF0011223344
337
+ 0xAB, 0xCD, 0xEF, 0x00,
338
+ 0x11, 0x22, 0x33, 0x44,
339
+ // Remote Capabilities
340
+ // Magic 2: 0xAD81
341
+ 0x00, 0b00000101, 0xAD, 0x81,
342
+ // Zero Checksum Alternate Error Detection Method: SCTP_OVER_DTLS (1)
343
+ 0x00, 0x00, 0x00, 0x01,
344
+ // Max Outbound Streams: 15000, Max Inbound Streams: 2500
345
+ 0x3A, 0x98, 0x09, 0xC4
346
+ };
347
+ // clang-format on
348
+
349
+ REQUIRE(RTC::SCTP::StateCookie::IsMediasoupStateCookie(buffer2, sizeof(buffer2)) == true);
350
+ REQUIRE(!RTC::SCTP::StateCookie::Parse(buffer2, sizeof(buffer2)));
351
+ }
352
+
271
353
  SECTION("StateCookie::Factory() succeeds")
272
354
  {
273
- RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = { .negotiatedMaxOutboundStreams = 62000,
274
- .negotiatedMaxInboundStreams = 55555,
275
- .partialReliability = true,
276
- .messageInterleaving = true,
277
- .reConfig = true,
278
- .zeroChecksum = false };
355
+ RTC::SCTP::Capabilities remoteCapabilities = {
356
+ .maxOutboundStreams = 62000,
357
+ .maxInboundStreams = 55555,
358
+ .partialReliability = true,
359
+ .messageInterleaving = true,
360
+ .reConfig = true,
361
+ .zeroChecksumAlternateErrorDetectionMethod =
362
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
363
+ };
279
364
 
280
365
  auto* stateCookie = RTC::SCTP::StateCookie::Factory(
281
366
  /*buffer*/ sctpCommon::FactoryBuffer,
@@ -286,12 +371,12 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
286
371
  /*remoteInitialTsn*/ 2220222,
287
372
  /*remoteAdvertisedReceiverWindowCredit*/ 999909999,
288
373
  /*tieTag*/ 1111222233334444,
289
- negotiatedCapabilities);
374
+ remoteCapabilities);
290
375
 
291
- // Change values of the original NegotiatedCapabilities to assert that it
292
- // doesn't affect the internals of StateCookie.
293
- negotiatedCapabilities.partialReliability = false;
294
- negotiatedCapabilities.negotiatedMaxOutboundStreams = 1024;
376
+ // Change values of the original Capabilities to assert that it doesn't
377
+ // affect the internals of StateCookie.
378
+ remoteCapabilities.partialReliability = false;
379
+ remoteCapabilities.maxOutboundStreams = 1024;
295
380
 
296
381
  REQUIRE(stateCookie);
297
382
  REQUIRE(stateCookie->GetBuffer() == sctpCommon::FactoryBuffer);
@@ -311,14 +396,16 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
311
396
  stateCookie->GetBuffer(), stateCookie->GetLength()) ==
312
397
  RTC::SCTP::Types::SctpImplementation::MEDIASOUP);
313
398
 
314
- const auto retrievedNegotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
399
+ const auto retrievedRemoteCapabilities = stateCookie->GetRemoteCapabilities();
315
400
 
316
- REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxOutboundStreams == 62000);
317
- REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxInboundStreams == 55555);
318
- REQUIRE(retrievedNegotiatedCapabilities.partialReliability == true);
319
- REQUIRE(retrievedNegotiatedCapabilities.messageInterleaving == true);
320
- REQUIRE(retrievedNegotiatedCapabilities.reConfig == true);
321
- REQUIRE(retrievedNegotiatedCapabilities.zeroChecksum == false);
401
+ REQUIRE(retrievedRemoteCapabilities.maxOutboundStreams == 62000);
402
+ REQUIRE(retrievedRemoteCapabilities.maxInboundStreams == 55555);
403
+ REQUIRE(retrievedRemoteCapabilities.partialReliability == true);
404
+ REQUIRE(retrievedRemoteCapabilities.messageInterleaving == true);
405
+ REQUIRE(retrievedRemoteCapabilities.reConfig == true);
406
+ REQUIRE(
407
+ retrievedRemoteCapabilities.zeroChecksumAlternateErrorDetectionMethod ==
408
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE);
322
409
 
323
410
  /* Parse itself and compare. */
324
411
 
@@ -345,26 +432,31 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
345
432
  parsedStateCookie->GetBuffer(), parsedStateCookie->GetLength()) ==
346
433
  RTC::SCTP::Types::SctpImplementation::MEDIASOUP);
347
434
 
348
- const auto retrievedParsedNegotiatedCapabilities = parsedStateCookie->GetNegotiatedCapabilities();
435
+ const auto retrievedParsedRemoteCapabilities = parsedStateCookie->GetRemoteCapabilities();
349
436
 
350
- REQUIRE(retrievedParsedNegotiatedCapabilities.negotiatedMaxOutboundStreams == 62000);
351
- REQUIRE(retrievedParsedNegotiatedCapabilities.negotiatedMaxInboundStreams == 55555);
352
- REQUIRE(retrievedParsedNegotiatedCapabilities.partialReliability == true);
353
- REQUIRE(retrievedParsedNegotiatedCapabilities.messageInterleaving == true);
354
- REQUIRE(retrievedParsedNegotiatedCapabilities.reConfig == true);
355
- REQUIRE(retrievedParsedNegotiatedCapabilities.zeroChecksum == false);
437
+ REQUIRE(retrievedParsedRemoteCapabilities.maxOutboundStreams == 62000);
438
+ REQUIRE(retrievedParsedRemoteCapabilities.maxInboundStreams == 55555);
439
+ REQUIRE(retrievedParsedRemoteCapabilities.partialReliability == true);
440
+ REQUIRE(retrievedParsedRemoteCapabilities.messageInterleaving == true);
441
+ REQUIRE(retrievedParsedRemoteCapabilities.reConfig == true);
442
+ REQUIRE(
443
+ retrievedParsedRemoteCapabilities.zeroChecksumAlternateErrorDetectionMethod ==
444
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE);
356
445
 
357
446
  delete parsedStateCookie;
358
447
  }
359
448
 
360
449
  SECTION("StateCookie::Write() succeeds")
361
450
  {
362
- RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = { .negotiatedMaxOutboundStreams = 62000,
363
- .negotiatedMaxInboundStreams = 55555,
364
- .partialReliability = true,
365
- .messageInterleaving = true,
366
- .reConfig = true,
367
- .zeroChecksum = false };
451
+ RTC::SCTP::Capabilities remoteCapabilities = {
452
+ .maxOutboundStreams = 62000,
453
+ .maxInboundStreams = 55555,
454
+ .partialReliability = true,
455
+ .messageInterleaving = true,
456
+ .reConfig = true,
457
+ .zeroChecksumAlternateErrorDetectionMethod =
458
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
459
+ };
368
460
 
369
461
  auto* buffer = sctpCommon::FactoryBuffer;
370
462
 
@@ -377,12 +469,12 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
377
469
  /*remoteInitialTsn*/ 2220222,
378
470
  /*remoteAdvertisedReceiverWindowCredit*/ 999909999,
379
471
  /*tieTag*/ 1111222233334444,
380
- negotiatedCapabilities);
472
+ remoteCapabilities);
381
473
 
382
- // Change values of the original NegotiatedCapabilities to assert that it
383
- // doesn't affect the internals of StateCookie.
384
- negotiatedCapabilities.partialReliability = false;
385
- negotiatedCapabilities.negotiatedMaxOutboundStreams = 1024;
474
+ // Change values of the original Capabilities to assert that it doesn't
475
+ // affect the internals of StateCookie.
476
+ remoteCapabilities.partialReliability = false;
477
+ remoteCapabilities.maxOutboundStreams = 1024;
386
478
 
387
479
  /* Parse the buffer. */
388
480
 
@@ -407,14 +499,16 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
407
499
  stateCookie->GetBuffer(), stateCookie->GetLength()) ==
408
500
  RTC::SCTP::Types::SctpImplementation::MEDIASOUP);
409
501
 
410
- const auto retrievedNegotiatedCapabilities = stateCookie->GetNegotiatedCapabilities();
502
+ const auto retrievedRemoteCapabilities = stateCookie->GetRemoteCapabilities();
411
503
 
412
- REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxOutboundStreams == 62000);
413
- REQUIRE(retrievedNegotiatedCapabilities.negotiatedMaxInboundStreams == 55555);
414
- REQUIRE(retrievedNegotiatedCapabilities.partialReliability == true);
415
- REQUIRE(retrievedNegotiatedCapabilities.messageInterleaving == true);
416
- REQUIRE(retrievedNegotiatedCapabilities.reConfig == true);
417
- REQUIRE(retrievedNegotiatedCapabilities.zeroChecksum == false);
504
+ REQUIRE(retrievedRemoteCapabilities.maxOutboundStreams == 62000);
505
+ REQUIRE(retrievedRemoteCapabilities.maxInboundStreams == 55555);
506
+ REQUIRE(retrievedRemoteCapabilities.partialReliability == true);
507
+ REQUIRE(retrievedRemoteCapabilities.messageInterleaving == true);
508
+ REQUIRE(retrievedRemoteCapabilities.reConfig == true);
509
+ REQUIRE(
510
+ retrievedRemoteCapabilities.zeroChecksumAlternateErrorDetectionMethod ==
511
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE);
418
512
 
419
513
  delete stateCookie;
420
514
  }
@@ -423,7 +517,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
423
517
  {
424
518
  // usrsctp generated State Cookie.
425
519
  // clang-format off
426
- uint8_t buffer1[] =
520
+ alignas(4) uint8_t buffer1[] =
427
521
  {
428
522
  // Magic 1: 0x4B414D452D425344
429
523
  0x4B, 0x41, 0x4D, 0x45,
@@ -451,7 +545,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
451
545
 
452
546
  // dcSCTP generated State Cookie.
453
547
  // clang-format off
454
- uint8_t buffer2[] =
548
+ alignas(4) uint8_t buffer2[] =
455
549
  {
456
550
  // Magic 1: 0x6463534354503030
457
551
  0x64, 0x63, 0x53, 0x43,
@@ -474,7 +568,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
474
568
 
475
569
  // State Cookie generated by unknown implementation.
476
570
  // clang-format off
477
- uint8_t buffer3[] =
571
+ alignas(4) uint8_t buffer3[] =
478
572
  {
479
573
  // Magic 1: 0x1122334455667788
480
574
  0x11, 0x22, 0x33, 0x44,
@@ -495,7 +589,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
495
589
 
496
590
  // Too short State Cookie so we don't know.
497
591
  // clang-format off
498
- uint8_t buffer4[] =
592
+ alignas(4) uint8_t buffer4[] =
499
593
  {
500
594
  // Magic 1: 0xAABBCCDD
501
595
  0xAA, 0xBB, 0xCC, 0xDD,
@@ -510,13 +604,14 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
510
604
 
511
605
  SECTION("authenticated StateCookie::Write() and StateCookie::VerifyMac() succeed")
512
606
  {
513
- const RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = {
514
- .negotiatedMaxOutboundStreams = 62000,
515
- .negotiatedMaxInboundStreams = 55555,
516
- .partialReliability = true,
517
- .messageInterleaving = true,
518
- .reConfig = true,
519
- .zeroChecksum = false
607
+ const RTC::SCTP::Capabilities remoteCapabilities = {
608
+ .maxOutboundStreams = 62000,
609
+ .maxInboundStreams = 55555,
610
+ .partialReliability = true,
611
+ .messageInterleaving = true,
612
+ .reConfig = true,
613
+ .zeroChecksumAlternateErrorDetectionMethod =
614
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
520
615
  };
521
616
 
522
617
  const uint8_t macKey[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
@@ -534,7 +629,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
534
629
  /*remoteInitialTsn*/ 2220222,
535
630
  /*remoteAdvertisedReceiverWindowCredit*/ 999909999,
536
631
  /*tieTag*/ 1111222233334444,
537
- negotiatedCapabilities,
632
+ remoteCapabilities,
538
633
  /*creationTimestampMs*/ creationTimestampMs,
539
634
  /*macKey*/ macKey,
540
635
  /*macKeyLength*/ sizeof(macKey));
@@ -599,20 +694,21 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
599
694
 
600
695
  SECTION("StateCookie::VerifyMac() fails on a non-authenticated (plain) cookie")
601
696
  {
602
- const RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = {
603
- .negotiatedMaxOutboundStreams = 62000,
604
- .negotiatedMaxInboundStreams = 55555,
605
- .partialReliability = true,
606
- .messageInterleaving = true,
607
- .reConfig = true,
608
- .zeroChecksum = false
697
+ const RTC::SCTP::Capabilities remoteCapabilities = {
698
+ .maxOutboundStreams = 62000,
699
+ .maxInboundStreams = 55555,
700
+ .partialReliability = true,
701
+ .messageInterleaving = true,
702
+ .reConfig = true,
703
+ .zeroChecksumAlternateErrorDetectionMethod =
704
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
609
705
  };
610
706
 
611
707
  const uint8_t macKey[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
612
708
 
613
709
  auto* buffer = sctpCommon::FactoryBuffer;
614
710
 
615
- // Write a plain (44 bytes) cookie.
711
+ // Write a plain (48 bytes) cookie.
616
712
  RTC::SCTP::StateCookie::Write(
617
713
  /*buffer*/ buffer,
618
714
  /*bufferLength*/ RTC::SCTP::StateCookie::StateCookieLength,
@@ -622,7 +718,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
622
718
  /*remoteInitialTsn*/ 2220222,
623
719
  /*remoteAdvertisedReceiverWindowCredit*/ 999909999,
624
720
  /*tieTag*/ 1111222233334444,
625
- negotiatedCapabilities);
721
+ remoteCapabilities);
626
722
 
627
723
  // A plain cookie has no MAC, so `VerifyMac()` must fail regardless of the
628
724
  // key.
@@ -1,9 +1,9 @@
1
1
  #include "common.hpp"
2
- #include "MediaSoupErrors.hpp"
3
- #include "RTC/SCTP/association/NegotiatedCapabilities.hpp"
2
+ #include "RTC/SCTP/association/Capabilities.hpp"
4
3
  #include "RTC/SCTP/association/StateCookie.hpp"
5
4
  #include "RTC/SCTP/packet/Parameter.hpp"
6
5
  #include "RTC/SCTP/packet/parameters/StateCookieParameter.hpp"
6
+ #include "RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp"
7
7
  #include "test/include/RTC/SCTP/sctpCommon.hpp"
8
8
  #include <catch2/catch_test_macros.hpp>
9
9
  #include <cstring> // std::memset()
@@ -183,13 +183,14 @@ SCENARIO("State Cookie Parameter (7)", "[serializable][sctp][parameter]")
183
183
  /* Modify it. */
184
184
 
185
185
  // Create a StateCookie.
186
- const RTC::SCTP::NegotiatedCapabilities negotiatedCapabilities = {
187
- .negotiatedMaxOutboundStreams = 62000,
188
- .negotiatedMaxInboundStreams = 55555,
189
- .partialReliability = true,
190
- .messageInterleaving = true,
191
- .reConfig = true,
192
- .zeroChecksum = false
186
+ const RTC::SCTP::Capabilities remoteCapabilities = {
187
+ .maxOutboundStreams = 62000,
188
+ .maxInboundStreams = 55555,
189
+ .partialReliability = true,
190
+ .messageInterleaving = true,
191
+ .reConfig = true,
192
+ .zeroChecksumAlternateErrorDetectionMethod =
193
+ RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
193
194
  };
194
195
 
195
196
  // Build the StateCookie in place within the StateCookieParameter.
@@ -200,7 +201,7 @@ SCENARIO("State Cookie Parameter (7)", "[serializable][sctp][parameter]")
200
201
  /*remoteInitialTsn*/ 2220222,
201
202
  /*remoteAdvertisedReceiverWindowCredit*/ 999909999,
202
203
  /*tieTag*/ 1111222233334444,
203
- negotiatedCapabilities);
204
+ remoteCapabilities);
204
205
 
205
206
  REQUIRE(parameter->HasCookie() == true);
206
207
  REQUIRE(parameter->GetCookieLength() == RTC::SCTP::StateCookie::StateCookieLength);