52 if (
len <
sizeof(NshHdr)) {
56 if (!PacketIncreaseCheckLayers(
p)) {
61 const NshHdr *hdr = (
const NshHdr *)pkt;
98 uint32_t
spi = ((
spi_si & 0xFFFFFF00) >> 8);
99 uint8_t si = (uint8_t)(
spi_si & 0xFF);
129 static uint8_t valid_nsh_packet[] = { 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x02, 0x02, 0x45, 0x10,
130 0x00, 0x3c, 0x78, 0x8f, 0x40, 0x00, 0x3f, 0x06, 0x79, 0x05, 0x0b, 0x06, 0x06, 0x06, 0x33, 0x06,
131 0x06, 0x06, 0xbd, 0x2e, 0x00, 0x16, 0xc9, 0xee, 0x07, 0x62, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,
132 0x16, 0xd0, 0x2f, 0x36, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4, 0x04, 0x02, 0x08, 0x0a, 0xa9, 0x5f,
133 0x7f, 0xed, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07 };
135 static int DecodeNSHTestHeaderTooSmall(
void)
154 static int DecodeNSHTestUnsupportedVersion(
void)
166 valid_nsh_packet[0] = 0xFF;
168 valid_nsh_packet[0] = 0x00;
175 static int DecodeNSHTestPacketTooSmall(
void)
194 static int DecodeNSHTestReservedType(
void)
206 valid_nsh_packet[2] = 0x00;
208 valid_nsh_packet[2] = 0x02;
215 static int DecodeNSHTestInvalidType(
void)
227 valid_nsh_packet[2] = 0x01;
229 valid_nsh_packet[2] = 0x02;
235 static int DecodeNSHTestUnsupportedType(
void)
247 valid_nsh_packet[2] = 0x03;
249 valid_nsh_packet[2] = 0x02;
256 static int DecodeNSHTestUnknownPayload(
void)
268 valid_nsh_packet[3] = 0x99;
270 valid_nsh_packet[3] = 0x01;
282 UtRegisterTest(
"DecodeNSHTestHeaderTooSmall", DecodeNSHTestHeaderTooSmall);
283 UtRegisterTest(
"DecodeNSHTestUnsupportedVersion", DecodeNSHTestUnsupportedVersion);
284 UtRegisterTest(
"DecodeNSHTestPacketTooSmall", DecodeNSHTestPacketTooSmall);
285 UtRegisterTest(
"DecodeNSHTestReservedType", DecodeNSHTestReservedType);
286 UtRegisterTest(
"DecodeNSHTestInvalidType", DecodeNSHTestInvalidType);
287 UtRegisterTest(
"DecodeNSHTestUnsupportedType", DecodeNSHTestUnsupportedType);
288 UtRegisterTest(
"DecodeNSHTestUnknownPayload", DecodeNSHTestUnknownPayload);