53 if (
len <
sizeof(NshHdr)) {
57 if (!PacketIncreaseCheckLayers(p)) {
62 const NshHdr *hdr = (
const NshHdr *)pkt;
70 uint16_t length = (
SCNtohs(hdr->ver_flags_len) & 0x003f) * 4;
99 uint32_t
spi = ((
spi_si & 0xFFFFFF00) >> 8);
100 uint8_t si = (uint8_t)(
spi_si & 0xFF);
109 if (
len - length > USHRT_MAX) {
114 if (
len - length > USHRT_MAX) {
133 static uint8_t valid_nsh_packet[] = { 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x02, 0x02, 0x45, 0x10,
134 0x00, 0x3c, 0x78, 0x8f, 0x40, 0x00, 0x3f, 0x06, 0x79, 0x05, 0x0b, 0x06, 0x06, 0x06, 0x33, 0x06,
135 0x06, 0x06, 0xbd, 0x2e, 0x00, 0x16, 0xc9, 0xee, 0x07, 0x62, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02,
136 0x16, 0xd0, 0x2f, 0x36, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4, 0x04, 0x02, 0x08, 0x0a, 0xa9, 0x5f,
137 0x7f, 0xed, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07 };
139 static int DecodeNSHTestHeaderTooSmall(
void)
158 static int DecodeNSHTestUnsupportedVersion(
void)
170 valid_nsh_packet[0] = 0xFF;
171 DecodeNSH(&
tv, &
dtv, p, valid_nsh_packet,
sizeof(valid_nsh_packet));
172 valid_nsh_packet[0] = 0x00;
179 static int DecodeNSHTestPacketTooSmall(
void)
198 static int DecodeNSHTestReservedType(
void)
210 valid_nsh_packet[2] = 0x00;
211 DecodeNSH(&
tv, &
dtv, p, valid_nsh_packet,
sizeof(valid_nsh_packet));
212 valid_nsh_packet[2] = 0x02;
219 static int DecodeNSHTestInvalidType(
void)
231 valid_nsh_packet[2] = 0x01;
232 DecodeNSH(&
tv, &
dtv, p, valid_nsh_packet,
sizeof(valid_nsh_packet));
233 valid_nsh_packet[2] = 0x02;
239 static int DecodeNSHTestUnsupportedType(
void)
251 valid_nsh_packet[2] = 0x03;
252 DecodeNSH(&
tv, &
dtv, p, valid_nsh_packet,
sizeof(valid_nsh_packet));
253 valid_nsh_packet[2] = 0x02;
260 static int DecodeNSHTestUnknownPayload(
void)
272 valid_nsh_packet[3] = 0x99;
273 DecodeNSH(&
tv, &
dtv, p, valid_nsh_packet,
sizeof(valid_nsh_packet));
274 valid_nsh_packet[3] = 0x01;
286 UtRegisterTest(
"DecodeNSHTestHeaderTooSmall", DecodeNSHTestHeaderTooSmall);
287 UtRegisterTest(
"DecodeNSHTestUnsupportedVersion", DecodeNSHTestUnsupportedVersion);
288 UtRegisterTest(
"DecodeNSHTestPacketTooSmall", DecodeNSHTestPacketTooSmall);
289 UtRegisterTest(
"DecodeNSHTestReservedType", DecodeNSHTestReservedType);
290 UtRegisterTest(
"DecodeNSHTestInvalidType", DecodeNSHTestInvalidType);
291 UtRegisterTest(
"DecodeNSHTestUnsupportedType", DecodeNSHTestUnsupportedType);
292 UtRegisterTest(
"DecodeNSHTestUnknownPayload", DecodeNSHTestUnknownPayload);