diff --git a/src/decode-icmpv4.c b/src/decode-icmpv4.c index 2adebd5ffe..c9d4d98311 100644 --- a/src/decode-icmpv4.c +++ b/src/decode-icmpv4.c @@ -30,7 +30,14 @@ void DecodeICMPV4(ThreadVars *t, Packet *p, uint8_t *pkt, uint16_t len) * \retval 0 Expected test value */ static int DecodeICMPV4test01(void) { - uint8_t raw_icmpv4[] = { 0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x04, 0x52, 0xab, 0x86, 0x4a, 0x84, 0x50, 0x0e, 0x00, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab }; + uint8_t raw_icmpv4[] = { + 0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x04, + 0x52, 0xab, 0x86, 0x4a, 0x84, 0x50, 0x0e, 0x00, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, + 0xab }; Packet p; ThreadVars tv; @@ -46,7 +53,14 @@ static int DecodeICMPV4test01(void) { * \retval 0 Expected test value */ static int DecodeICMPV4test02(void) { - uint8_t raw_icmpv4[] = { 0x00, 0x00, 0x57, 0x64, 0xfb, 0x55, 0x00, 0x03, 0x43, 0xab, 0x86, 0x4a, 0xf6, 0x49, 0x02, 0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f }; + uint8_t raw_icmpv4[] = { + 0x00, 0x00, 0x57, 0x64, 0xfb, 0x55, 0x00, 0x03, + 0x43, 0xab, 0x86, 0x4a, 0xf6, 0x49, 0x02, 0x00, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f }; Packet p; ThreadVars tv; @@ -62,7 +76,12 @@ static int DecodeICMPV4test02(void) { * \retval Expected test value: 0 */ static int DecodeICMPV4test03(void) { - uint8_t raw_icmpv4[] = { 0x0b, 0x00, 0x6a, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x3c, 0x64, 0x15, 0x00, 0x00, 0x01, 0x11, 0xde, 0xfd, 0xc0, 0xa8, 0x01, 0x0d, 0xd1, 0x55, 0xe3, 0x93, 0x8b, 0x12, 0x82, 0xaa, 0x00, 0x28, 0x7c, 0xdd }; + uint8_t raw_icmpv4[] = { + 0x0b, 0x00, 0x6a, 0x3d, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x3c, 0x64, 0x15, 0x00, 0x00, + 0x01, 0x11, 0xde, 0xfd, 0xc0, 0xa8, 0x01, 0x0d, + 0xd1, 0x55, 0xe3, 0x93, 0x8b, 0x12, 0x82, 0xaa, + 0x00, 0x28, 0x7c, 0xdd }; Packet p; ThreadVars tv; @@ -78,7 +97,14 @@ static int DecodeICMPV4test03(void) { * \retval 0 Expected test value */ static int DecodeICMPV4test04(void) { - uint8_t raw_icmpv4[] = { 0x03, 0x0a, 0x36, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x3c, 0x62, 0xee, 0x40, 0x00, 0x33, 0x06, 0xb4, 0x8f, 0xc0, 0xa8, 0x01, 0x0d, 0x58, 0x60, 0x16, 0x29, 0xb1, 0x0a, 0x00, 0x32, 0x3e, 0x36, 0x38, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x16, 0xd0, 0x72, 0x04, 0x00, 0x00, 0x02, 0x04, 0x05, 0x8a, 0x04, 0x02, 0x08, 0x0a }; + uint8_t raw_icmpv4[] = { + 0x03, 0x0a, 0x36, 0xc3, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x3c, 0x62, 0xee, 0x40, 0x00, + 0x33, 0x06, 0xb4, 0x8f, 0xc0, 0xa8, 0x01, 0x0d, + 0x58, 0x60, 0x16, 0x29, 0xb1, 0x0a, 0x00, 0x32, + 0x3e, 0x36, 0x38, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0xa0, 0x02, 0x16, 0xd0, 0x72, 0x04, 0x00, 0x00, + 0x02, 0x04, 0x05, 0x8a, 0x04, 0x02, 0x08, 0x0a }; Packet p; ThreadVars tv; diff --git a/src/decode-pppoe.c b/src/decode-pppoe.c index edf7302312..2b17d7a09b 100644 --- a/src/decode-pppoe.c +++ b/src/decode-pppoe.c @@ -29,21 +29,19 @@ void DecodePPPoE(ThreadVars *t, Packet *p, uint8_t *pkt, uint16_t len, PacketQue } p->pppoeh = (PPPoEHdr *)pkt; - if (p->pppoeh == NULL) return; - if (p->pppoeh->pppoe_length>0) { + if (p->pppoeh->pppoe_length > 0) { /* decode contained PPP packet */ PerfCounterIncr(COUNTER_DECODER_PPP, t->pca); DecodePPP(t, p, pkt + PPPOE_HEADER_LEN, len - PPPOE_HEADER_LEN, pq); } - } /** DecodePPPoEtest01 - * /brief Decode malformed PPPoE packet (too short) - * /retval Expected test value: 1 + * \brief Decode malformed PPPoE packet (too short) + * \retval 1 Expected test value */ static int DecodePPPoEtest01 (void) { @@ -68,19 +66,27 @@ static int DecodePPPoEtest01 (void) { } /** DecodePPPoEtest02 - * /brief Valid PPPoE packet - * /retval Expected test value: 0 + * \brief Valid PPPoE packet + * \retval 0 Expected test value */ static int DecodePPPoEtest02 (void) { - u_int8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x01, 0x00, 0x68, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x66, 0x02, 0xa3, 0x00, 0x00 - , 0xff, 0xfd, 0x91, 0x7b, 0x64, 0x00, 0x00, 0x64, 0xc0, 0x55, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 - , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x56, 0x8b, 0xa4, 0x7c, 0xfa - , 0x38, 0x78, 0xb3, 0x70, 0x3f, 0xda, 0x79, 0x50, 0x2e, 0xd7, 0x7f, 0x4d, 0x7c, 0xd2, 0xdc, 0x80 - , 0xfa, 0x66}; + uint8_t raw_pppoe[] = { + 0x11, 0x00, 0x00, 0x01, 0x00, 0x68, 0x00, 0x21, + 0x45, 0xc0, 0x00, 0x66, 0x02, 0xa3, 0x00, 0x00, + 0xff, 0xfd, 0x91, 0x7b, 0x64, 0x00, 0x00, 0x64, + 0xc0, 0x55, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x27, 0x56, 0x8b, 0xa4, 0x7c, 0xfa, + 0x38, 0x78, 0xb3, 0x70, 0x3f, 0xda, 0x79, 0x50, + 0x2e, 0xd7, 0x7f, 0x4d, 0x7c, 0xd2, 0xdc, 0x80, + 0xfa, 0x66 }; Packet p; ThreadVars tv; @@ -105,3 +111,4 @@ void DecodePPPoERegisterTests(void) { UtRegisterTest("DecodePPPoEtest01", DecodePPPoEtest01, 1); UtRegisterTest("DecodePPPoEtest02", DecodePPPoEtest02, 0); } + diff --git a/src/decode-pppoe.h b/src/decode-pppoe.h index bd065e8059..2903438341 100644 --- a/src/decode-pppoe.h +++ b/src/decode-pppoe.h @@ -21,8 +21,8 @@ typedef struct _PPPoEHdr { - unsigned pppoe_version :4; - unsigned pppoe_type :4; + unsigned pppoe_version : 4; + unsigned pppoe_type : 4; uint8_t pppoe_code; uint16_t sessin_id; uint16_t pppoe_length; @@ -37,3 +37,4 @@ typedef struct _PPPoEHdr void DecodePPPoERegisterTests(void); #endif /* __DECODE_PPPOE_H__ */ +