csum = *( ((uint16_t *)(raw_ipv6 + 56)));
- return (csum == ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
+ FAIL_IF(csum != ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
(uint16_t *)(raw_ipv6 + 54), 68));
+ PASS;
}
static int ICMPV6CalculateInvalidChecksumtest02(void)
csum = *( ((uint16_t *)(raw_ipv6 + 56)));
- return (csum != ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
+ FAIL_IF(csum == ICMPV6CalculateChecksum((uint16_t *)(raw_ipv6 + 14 + 8),
(uint16_t *)(raw_ipv6 + 54), 68));
+ PASS;
}
-
/** \test icmpv6 message type: parameter problem, valid packet
*
* \retval retval 0 = Error ; 1 = ok
*/
static int ICMPV6ParamProbTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- retval = 0;
- goto end;
- }
+ FAIL_IF(p->icmpv6h == NULL);
- if (ICMPV6_GET_TYPE(p) != 4 || ICMPV6_GET_CODE(p) != 0 ||
- ICMPV6_GET_EMB_PROTO(p) != IPPROTO_ICMPV6) {
- SCLogDebug("ICMPv6 not processed at all");
- retval = 0;
- goto end;
- }
+ /* ICMPv6 not processed at all? */
+ FAIL_IF(ICMPV6_GET_TYPE(p) != 4 || ICMPV6_GET_CODE(p) != 0 ||
+ ICMPV6_GET_EMB_PROTO(p) != IPPROTO_ICMPV6);
/* Let's check if we retrieved the embedded ipv6 addresses correctly */
uint32_t i=0;
for (i = 0; i < 4; i++) {
- if (p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
- p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]) {
- SCLogDebug("ICMPv6 DecodePartialICMPV6 (Embedded ip6h) didn't set "
- "the src and dest ip addresses correctly");
- retval = 0;
- goto end;
- }
+ FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
+ p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]);
}
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/** \test icmpv6 message type: packet too big, valid packet
*/
static int ICMPV6PktTooBigTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- retval = 0;
- goto end;
- }
+ FAIL_IF(p->icmpv6h == NULL);
- /* Note: it has an embedded ipv6 packet but no protocol after ipv6 (IPPROTO_NONE) */
- if (ICMPV6_GET_TYPE(p) != 2 || ICMPV6_GET_CODE(p) != 0 ) {
- SCLogDebug("ICMPv6 Not processed at all");
- retval = 0;
- goto end;
- }
+ /* Note: it has an embedded ipv6 packet but no protocol after ipv6
+ * (IPPROTO_NONE) */
+ /* Check if ICMPv6 header was processed at all. */
+ FAIL_IF(ICMPV6_GET_TYPE(p) != 2 || ICMPV6_GET_CODE(p) != 0 );
/* Let's check if we retrieved the embedded ipv6 addresses correctly */
uint32_t i=0;
for (i = 0; i < 4; i++) {
- if (p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
- p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]) {
- SCLogDebug("ICMPv6 DecodePartialICMPV6 (Embedded ip6h) didn't set "
- "the src and dest ip addresses correctly");
- retval = 0;
- goto end;
- }
+ FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
+ p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]);
}
SCLogDebug("ICMPV6 IPV6 src and dst properly set");
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/** \test icmpv6 message type: time exceed, valid packet
*/
static int ICMPV6TimeExceedTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
ipv6src = (uint32_t*) &raw_ipv6[8];
ipv6dst = (uint32_t*) &raw_ipv6[24];
-
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
memset(&dtv, 0, sizeof(DecodeThreadVars));
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- retval = 0;
- goto end;
- }
+ FAIL_IF_NULL(p->icmpv6h);
/* Note: it has an embedded ipv6 packet but no protocol after ipv6 (IPPROTO_NONE) */
- if (ICMPV6_GET_TYPE(p) != 3 || ICMPV6_GET_CODE(p) != 0 ||
- ICMPV6_GET_EMB_IPV6(p)==NULL || ICMPV6_GET_EMB_PROTO(p) != IPPROTO_NONE ) {
- SCLogDebug("ICMPv6 Not processed at all");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ICMPV6_GET_TYPE(p) != 3 || ICMPV6_GET_CODE(p) != 0 ||
+ ICMPV6_GET_EMB_IPV6(p) == NULL ||
+ ICMPV6_GET_EMB_PROTO(p) != IPPROTO_NONE);
/* Let's check if we retrieved the embedded ipv6 addresses correctly */
uint32_t i=0;
for (i = 0; i < 4; i++) {
- if (p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
- p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]) {
- SCLogDebug("ICMPv6 DecodePartialICMPV6 (Embedded ip6h) didn't set "
- "the src and dest ip addresses correctly");
- retval = 0;
- goto end;
- }
+ FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
+ p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]);
}
SCLogDebug("ICMPV6 IPV6 src and dst properly set");
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/** \test icmpv6 message type: destination unreach, valid packet
*/
static int ICMPV6DestUnreachTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
ipv6src = (uint32_t*) &raw_ipv6[8];
ipv6dst = (uint32_t*) &raw_ipv6[24];
-
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
memset(&dtv, 0, sizeof(DecodeThreadVars));
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- retval = 0;
- goto end;
- }
+ FAIL_IF_NULL(p->icmpv6h);
/* Note: it has an embedded ipv6 packet but no protocol after ipv6 (IPPROTO_NONE) */
- if (ICMPV6_GET_TYPE(p) != 1 || ICMPV6_GET_CODE(p) != 0 ||
- ICMPV6_GET_EMB_IPV6(p) == NULL || ICMPV6_GET_EMB_PROTO(p) != IPPROTO_NONE ) {
- SCLogDebug("ICMPv6 Not processed at all");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ICMPV6_GET_TYPE(p) != 1 || ICMPV6_GET_CODE(p) != 0 ||
+ ICMPV6_GET_EMB_IPV6(p) == NULL ||
+ ICMPV6_GET_EMB_PROTO(p) != IPPROTO_NONE);
/* Let's check if we retrieved the embedded ipv6 addresses correctly */
uint32_t i=0;
for (i = 0; i < 4; i++) {
- if (p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
- p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]) {
- SCLogDebug("ICMPv6 DecodePartialICMPV6 (Embedded ip6h) didn't set "
- "the src and dest ip addresses correctly");
- retval = 0;
- goto end;
- }
+ FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] ||
+ p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]);
}
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**\test icmpv6 message type: echo request, valid packet
*/
static int ICMPV6EchoReqTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- goto end;
- }
+ FAIL_IF_NULL(p->icmpv6h);
SCLogDebug("ID: %u seq: %u", ICMPV6_GET_ID(p), ICMPV6_GET_SEQ(p));
printf("ICMPv6 Echo reply decode failed TYPE %u CODE %u ID %04x(%u) SEQ %04x(%u): ",
ICMPV6_GET_TYPE(p), ICMPV6_GET_CODE(p), ICMPV6_GET_ID(p), ntohs(ICMPV6_GET_ID(p)),
ICMPV6_GET_SEQ(p), ntohs(ICMPV6_GET_SEQ(p)));
- goto end;
+ FAIL;
}
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**\test icmpv6 message type: echo reply, valid packet
*/
static int ICMPV6EchoRepTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- goto end;
- }
+ FAIL_IF_NULL(p->icmpv6h);
SCLogDebug("type: %u code %u ID: %u seq: %u", ICMPV6_GET_TYPE(p),
ICMPV6_GET_CODE(p),ICMPV6_GET_ID(p), ICMPV6_GET_SEQ(p));
printf("ICMPv6 Echo reply decode failed TYPE %u CODE %u ID %04x(%u) SEQ %04x(%u): ",
ICMPV6_GET_TYPE(p), ICMPV6_GET_CODE(p), ICMPV6_GET_ID(p), ntohs(ICMPV6_GET_ID(p)),
ICMPV6_GET_SEQ(p), ntohs(ICMPV6_GET_SEQ(p)));
- goto end;
+ FAIL;
}
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/** \test icmpv6 message type: parameter problem, invalid packet
*/
static int ICMPV6ParamProbTest02(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- retval = 0;
- goto end;
- }
-
- if (ICMPV6_GET_TYPE(p) != 4 || ICMPV6_GET_CODE(p) != 0) {
- SCLogDebug("ICMPv6 Not processed at all");
- retval = 0;
- goto end;
- }
-
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_UNKNOWN_VER)) {
- SCLogDebug("ICMPv6 Error: Unknown embedded ipv6 version event not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF_NULL(p->icmpv6h);
+ FAIL_IF(ICMPV6_GET_TYPE(p) != 4 || ICMPV6_GET_CODE(p) != 0);
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_UNKNOWN_VER));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/** \test icmpv6 message type: packet too big, invalid packet
*/
static int ICMPV6PktTooBigTest02(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x30, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->icmpv6h == NULL) {
- SCLogDebug("ICMPv6 Unable to detect icmpv6 layer from ipv6");
- retval = 0;
- goto end;
- }
-
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF_NULL(p->icmpv6h);
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/** \test icmpv6 message type: time exceed, invalid packet
*/
static int ICMPV6TimeExceedTest02(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* The icmpv6 header is broken in the checksum (so we dont have a complete header) */
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_PKT_TOO_SMALL)) {
- SCLogDebug("ICMPv6 Error: event packet too small not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_PKT_TOO_SMALL));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**\test icmpv6 message type: destination unreach, invalid packet
*/
static int ICMPV6DestUnreachTest02(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_TRUNC_PKT)) {
- SCLogDebug("ICMPv6 Error: embedded ipv6 truncated packet event not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_TRUNC_PKT));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**\test icmpv6 message type: echo request, invalid packet
*/
static int ICMPV6EchoReqTest02(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**\test icmpv6 message type: echo reply, invalid packet
*/
static int ICMPV6EchoRepTest02(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**\test icmpv6 packet decoding and setting up of payload_len and payload buufer
*/
static int ICMPV6PayloadTest01(void)
{
- int retval = 0;
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x3a, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (p->payload == NULL) {
- printf("payload == NULL, expected non-NULL: ");
- goto end;
- }
+ FAIL_IF_NULL(p->payload);
+ FAIL_IF(p->payload_len != 37);
- if (p->payload_len != 37) {
- printf("payload_len %"PRIu16", expected 37: ", p->payload_len);
- goto end;
- }
-
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6RouterSolicitTestKnownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6RouterSolicitTestUnknownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6RouterAdvertTestKnownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6RouterAdvertTestUnknownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6NeighbourSolicitTestKnownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6NeighbourSolicitTestUnknownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6NeighbourAdvertTestKnownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6NeighbourAdvertTestUnknownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6RedirectTestKnownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
static int ICMPV6RedirectTestUnknownCode(void)
{
- int retval = 0;
-
static uint8_t raw_ipv6[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x08, 0x3a, 0xff,
0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (unlikely(p == NULL))
- return 0;
+ FAIL_IF_NULL(p);
IPV6Hdr ip6h;
ThreadVars tv;
DecodeThreadVars dtv;
FlowInitConfig(FLOW_QUIET);
DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
- if (!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE)) {
- SCLogDebug("ICMPv6 Error: Unknown code event is not set");
- retval = 0;
- goto end;
- }
+ FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
- retval = 1;
-end:
PACKET_RECYCLE(p);
FlowShutdown();
SCFree(p);
- return retval;
+ PASS;
}
/**