| 1 |
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly> |
| 2 |
// SPDX-License-Identifier: MIT |
| 3 |
|
| 4 |
package sctp |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/assert" |
| 10 |
) |
| 11 |
|
| 12 |
func TestChunkInit_UnrecognizedParameters(t *testing.T) { |
| 13 |
initChunkHeader := []byte{ |
| 14 |
0x55, 0xb9, 0x64, 0xa5, 0x00, 0x02, 0x00, 0x00, |
| 15 |
0x04, 0x00, 0x08, 0x00, 0xe8, 0x6d, 0x10, 0x30, |
| 16 |
} |
| 17 |
|
| 18 |
unrecognizedSkip := append([]byte{}, initChunkHeader...) |
| 19 |
unrecognizedSkip = append(unrecognizedSkip, byte(paramHeaderUnrecognizedActionSkip), 0xFF, 0x00, 0x04, 0x00) |
| 20 |
|
| 21 |
initCommonChunk := &chunkInitCommon{} |
| 22 |
assert.NoError(t, initCommonChunk.unmarshal(unrecognizedSkip)) |
| 23 |
assert.Equal(t, 1, len(initCommonChunk.unrecognizedParams)) |
| 24 |
assert.Equal(t, paramHeaderUnrecognizedActionSkip, initCommonChunk.unrecognizedParams[0].unrecognizedAction) |
| 25 |
|
| 26 |
unrecognizedStop := append([]byte{}, initChunkHeader...) |
| 27 |
unrecognizedStop = append(unrecognizedStop, byte(paramHeaderUnrecognizedActionStop), 0xFF, 0x00, 0x04, 0x00) |
| 28 |
|
| 29 |
initCommonChunk = &chunkInitCommon{} |
| 30 |
assert.NoError(t, initCommonChunk.unmarshal(unrecognizedStop)) |
| 31 |
assert.Equal(t, 1, len(initCommonChunk.unrecognizedParams)) |
| 32 |
assert.Equal(t, paramHeaderUnrecognizedActionStop, initCommonChunk.unrecognizedParams[0].unrecognizedAction) |
| 33 |
} |