More PacketGetFromMalloc() to allocate packets.

pull/360/merge
Ken Steele 13 years ago committed by Victor Julien
parent 394f99e32c
commit 9c7b411a5d

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2011 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -1141,7 +1141,7 @@ static int Unified2Test01 (void) {
0x05, 0xb4, 0x04, 0x02, 0x08, 0x0a, 0x00, 0x1c,
0x28, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,
0x03, 0x06};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int ret;
@ -1149,12 +1149,9 @@ static int Unified2Test01 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1230,7 +1227,7 @@ static int Unified2Test02 (void) {
0x00, 0x00, 0x02, 0x04, 0x05, 0xa0, 0x04, 0x02,
0x08, 0x0a, 0x00, 0x0a, 0x22, 0xa8, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x03, 0x05 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int ret;
@ -1238,12 +1235,9 @@ static int Unified2Test02 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1325,7 +1319,7 @@ static int Unified2Test03 (void) {
0x69, 0x6e, 0x67, 0x2e, 0x66, 0x72, 0x65, 0x65,
0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x65, 0x74,
0x0d, 0x0a};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int ret;
@ -1333,12 +1327,9 @@ static int Unified2Test03 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1414,7 +1405,7 @@ static int Unified2Test04 (void) {
0xea, 0x37, 0x00, 0x17, 0x6d, 0x0b, 0xba, 0xc3,
0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x10, 0x20,
0xdd, 0xe1, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int ret;
@ -1422,12 +1413,9 @@ static int Unified2Test04 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;
@ -1501,7 +1489,7 @@ static int Unified2Test05 (void) {
0x05, 0xb4, 0x04, 0x02, 0x08, 0x0a, 0x00, 0x1c,
0x28, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,
0x03, 0x06};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int ret;
@ -1509,12 +1497,9 @@ static int Unified2Test05 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
PACKET_INITIALIZE(p);
p->alerts.cnt++;
p->alerts.alerts[p->alerts.cnt-1].s = &s;
p->alerts.alerts[p->alerts.cnt-1].s->id = 1;

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -270,15 +270,13 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
static int DecodeGREtest01 (void) {
uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre), NULL);
@ -312,15 +310,13 @@ static int DecodeGREtest02 (void) {
0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01,
0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre), NULL);
@ -355,15 +351,13 @@ static int DecodeGREtest03 (void) {
0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre), NULL);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -639,16 +639,13 @@ void DecodeIPV4OptionsPrint(Packet *p) {
/** \test IPV4 with no options. */
int DecodeIPV4OptionsNONETest01(void) {
uint8_t raw_opts[] = { };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
uint8_t *data = (uint8_t *)p;
uint16_t i;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
if (rc != 0) {
DecodeIPV4OptionsPrint(p);
@ -675,16 +672,13 @@ int DecodeIPV4OptionsEOLTest01(void) {
uint8_t raw_opts[] = {
IPV4_OPT_EOL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
uint8_t *data = (uint8_t *)p;
uint16_t i;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
if (rc != 0) {
DecodeIPV4OptionsPrint(p);
@ -711,16 +705,13 @@ int DecodeIPV4OptionsNOPTest01(void) {
uint8_t raw_opts[] = {
IPV4_OPT_NOP, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
uint8_t *data = (uint8_t *)p;
uint16_t i;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
if (rc != 0) {
DecodeIPV4OptionsPrint(p);
@ -751,14 +742,11 @@ int DecodeIPV4OptionsRRTest01(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_rr, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -785,14 +773,11 @@ int DecodeIPV4OptionsRRTest02(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_rr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -814,14 +799,11 @@ int DecodeIPV4OptionsRRTest03(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_rr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -843,14 +825,11 @@ int DecodeIPV4OptionsRRTest04(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_rr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -868,14 +847,11 @@ int DecodeIPV4OptionsQSTest01(void) {
uint8_t raw_opts[] = {
IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",qs=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_qs, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -898,14 +874,11 @@ int DecodeIPV4OptionsQSTest02(void) {
uint8_t raw_opts[] = {
IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",qs=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_qs, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -927,14 +900,11 @@ int DecodeIPV4OptionsTSTest01(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ts=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ts, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -961,14 +931,11 @@ int DecodeIPV4OptionsTSTest02(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ts=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ts, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -990,14 +957,11 @@ int DecodeIPV4OptionsTSTest03(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ts=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ts, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1019,14 +983,11 @@ int DecodeIPV4OptionsTSTest04(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ts=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ts, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1045,14 +1006,11 @@ int DecodeIPV4OptionsSECTest01(void) {
IPV4_OPT_SEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",sec=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_sec, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -1076,14 +1034,11 @@ int DecodeIPV4OptionsSECTest02(void) {
IPV4_OPT_SEC, 0x0a, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",sec=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_sec, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1105,14 +1060,11 @@ int DecodeIPV4OptionsLSRRTest01(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",lsrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_lsrr, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -1139,14 +1091,11 @@ int DecodeIPV4OptionsLSRRTest02(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",lsrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_lsrr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1168,14 +1117,11 @@ int DecodeIPV4OptionsLSRRTest03(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",lsrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_lsrr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1197,14 +1143,11 @@ int DecodeIPV4OptionsLSRRTest04(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",lsrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_lsrr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1224,14 +1167,11 @@ int DecodeIPV4OptionsCIPSOTest01(void) {
0x00, 0x03, 0x00, 0xef, 0x00, 0xef, 0x00, 0x06,
0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_cipso, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -1254,14 +1194,11 @@ int DecodeIPV4OptionsSIDTest01(void) {
uint8_t raw_opts[] = {
IPV4_OPT_SID, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",sid=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_sid, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -1284,14 +1221,11 @@ int DecodeIPV4OptionsSIDTest02(void) {
uint8_t raw_opts[] = {
IPV4_OPT_SID, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",sid=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_sid, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1313,14 +1247,11 @@ int DecodeIPV4OptionsSSRRTest01(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ssrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ssrr, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -1347,14 +1278,11 @@ int DecodeIPV4OptionsSSRRTest02(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ssrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ssrr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1376,14 +1304,11 @@ int DecodeIPV4OptionsSSRRTest03(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ssrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ssrr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1405,14 +1330,11 @@ int DecodeIPV4OptionsSSRRTest04(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",ssrr=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_ssrr, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1430,14 +1352,11 @@ int DecodeIPV4OptionsRTRALTTest01(void) {
uint8_t raw_opts[] = {
IPV4_OPT_RTRALT, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rtralt=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_rtralt, (uintmax_t)&p.IPV4_OPTS[0]);
if ( (rc == 0)
@ -1460,14 +1379,11 @@ int DecodeIPV4OptionsRTRALTTest02(void) {
uint8_t raw_opts[] = {
IPV4_OPT_RTRALT, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
int rc;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
rc = DecodeIPV4Options(p, raw_opts, sizeof(raw_opts));
//printf("rc=%d,cnt=%" PRIu16 ",type=%" PRIu8 ",len=%" PRIu8 ",rtralt=%" PRIuMAX "/%" PRIuMAX "\n", rc, p.IPV4_OPTS_CNT, p.IPV4_OPTS[0].type, p.IPV4_OPTS[0].len, (uintmax_t)p.ip4vars.o_rtralt, (uintmax_t)&p.IPV4_OPTS[0]);
if (rc != 0) {
@ -1546,7 +1462,7 @@ int DecodeIPV4DefragTest01(void)
0x80, 0x00, 0xb1, 0xa3, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -1557,9 +1473,7 @@ int DecodeIPV4DefragTest01(void)
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
DefragInit();
@ -1685,7 +1599,7 @@ int DecodeIPV4DefragTest02(void)
0xb1, 0xa3,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -1696,9 +1610,7 @@ int DecodeIPV4DefragTest02(void)
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
DefragInit();
@ -1815,7 +1727,7 @@ int DecodeIPV4DefragTest03(void)
};
Flow *f = NULL;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -1826,9 +1738,7 @@ int DecodeIPV4DefragTest03(void)
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
DefragInit();

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -736,10 +736,10 @@ static int DecodeIPV6FragTest01 (void) {
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20,
};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
Packet *p1 = PacketGetFromAlloc();
if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
Packet *p2 = PacketGetFromAlloc();
if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
@ -754,15 +754,8 @@ static int DecodeIPV6FragTest01 (void) {
memset(&pq, 0, sizeof(PacketQueue));
memset(&tv, 0, sizeof(ThreadVars));
memset(p1, 0, SIZE_OF_PACKET);
p1->pkt = (uint8_t *)(p1 + 1);
memset(p2, 0, SIZE_OF_PACKET);
p2->pkt = (uint8_t *)(p2 + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
PACKET_INITIALIZE(p1);
PACKET_INITIALIZE(p2);
PacketCopyData(p1, raw_frag1, sizeof(raw_frag1));
PacketCopyData(p2, raw_frag2, sizeof(raw_frag2));
@ -813,7 +806,7 @@ static int DecodeIPV6RouteTest01 (void) {
0x00, 0x00, 0x00, 0x00, 0x50, 0x02, 0x20, 0x00,
0xfa, 0x87, 0x00, 0x00,
};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
Packet *p1 = PacketGetFromAlloc();
if (unlikely(p1 == NULL))
return 0;
ThreadVars tv;
@ -825,12 +818,8 @@ static int DecodeIPV6RouteTest01 (void) {
memset(&pq, 0, sizeof(PacketQueue));
memset(&tv, 0, sizeof(ThreadVars));
memset(p1, 0, SIZE_OF_PACKET);
p1->pkt = (uint8_t *)(p1 + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
PACKET_INITIALIZE(p1);
PacketCopyData(p1, raw_pkt1, sizeof(raw_pkt1));
DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -138,15 +138,13 @@ void DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
*/
static int DecodePPPtest01 (void) {
uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), NULL);
@ -172,15 +170,13 @@ static int DecodePPPtest02 (void) {
0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00,
0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), NULL);
@ -208,15 +204,13 @@ static int DecodePPPtest03 (void) {
0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00,
0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
FlowInitConfig(FLOW_QUIET);
@ -267,15 +261,13 @@ static int DecodePPPtest04 (void) {
0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00,
0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
FlowInitConfig(FLOW_QUIET);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -228,15 +228,13 @@ void DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_
static int DecodePPPOEtest01 (void) {
uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
@ -267,7 +265,7 @@ static int DecodePPPOEtest02 (void) {
0x55, 0x56, 0x57, 0x41, 0x42, 0x43, 0x44, 0x45,
0x46, 0x47, 0x48, 0x49 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -275,8 +273,6 @@ static int DecodePPPOEtest02 (void) {
int ret = 0;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
FlowInitConfig(FLOW_QUIET);
@ -316,15 +312,13 @@ static int DecodePPPOEtest03 (void) {
0x65, 0x73, 0x68, 0x6f, 0x6f, 0x74
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
@ -349,15 +343,13 @@ static int DecodePPPOEtest04 (void) {
0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
@ -385,15 +377,13 @@ static int DecodePPPOEtest05 (void) {
0x20, 0x2d, 0x20, 0x65, 0x73, 0x68, 0x73, 0x68
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -83,7 +83,7 @@ static int DecodeRawTest01 (void) {
0x29, 0x9c, 0x00, 0x00, 0x02, 0x04, 0x05, 0x8c,
0x04, 0x02, 0x08, 0x0a, 0x00, 0xdd, 0x1a, 0x39,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -91,8 +91,6 @@ static int DecodeRawTest01 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
if (PacketCopyData(p, raw_ip, sizeof(raw_ip)) == -1) {
SCFree(p);
@ -129,7 +127,7 @@ static int DecodeRawTest02 (void) {
0x70, 0x02, 0x40, 0x00, 0xb8, 0xc8, 0x00, 0x00,
0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -137,8 +135,6 @@ static int DecodeRawTest02 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
if (PacketCopyData(p, raw_ip, sizeof(raw_ip)) == -1) {
SCFree(p);
@ -175,7 +171,7 @@ static int DecodeRawTest03 (void) {
0x34, 0x40, 0x67, 0x31, 0x3b, 0x63, 0x61, 0x74,
0x20, 0x6b, 0x65, 0x79, 0x3b };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
@ -183,8 +179,6 @@ static int DecodeRawTest03 (void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
if (PacketCopyData(p, raw_ip, sizeof(raw_ip)) == -1) {
SCFree(p);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2011 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -301,7 +301,7 @@ static int TCPGetWscaleTest01(void)
0x8a, 0xaf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
0x04, 0x02, 0x08, 0x0a, 0x00, 0x62, 0x88, 0x28,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
@ -309,8 +309,6 @@ static int TCPGetWscaleTest01(void)
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&ip4h, 0, sizeof(IPV4Hdr));
@ -349,7 +347,7 @@ static int TCPGetWscaleTest02(void)
0x8a, 0xaf, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4,
0x04, 0x02, 0x08, 0x0a, 0x00, 0x62, 0x88, 0x28,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x0f};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
@ -357,8 +355,6 @@ static int TCPGetWscaleTest02(void)
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&ip4h, 0, sizeof(IPV4Hdr));
@ -395,7 +391,7 @@ static int TCPGetWscaleTest03(void)
0xdd, 0xa3, 0x6f, 0xf8, 0x80, 0x10, 0x05, 0xb4,
0x7c, 0x70, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
0x00, 0x62, 0x88, 0x9e, 0x00, 0x00, 0x00, 0x00};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
@ -403,8 +399,6 @@ static int TCPGetWscaleTest03(void)
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&ip4h, 0, sizeof(IPV4Hdr));
@ -445,7 +439,7 @@ static int TCPGetSackTest01(void)
static uint8_t raw_tcp_sack[] = {
0xf1, 0x59, 0x13, 0xfc, 0xf1, 0x59, 0x1f, 0x64,
0xf1, 0x59, 0x08, 0x94, 0xf1, 0x59, 0x0e, 0x48 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
@ -453,8 +447,6 @@ static int TCPGetSackTest01(void)
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&ip4h, 0, sizeof(IPV4Hdr));

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -111,15 +111,13 @@ void DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
*/
static int DecodeVLANtest01 (void) {
uint8_t raw_vlan[] = { 0x00, 0x20, 0x08 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan), NULL);
@ -148,15 +146,13 @@ static int DecodeVLANtest02 (void) {
0x4d, 0x3d, 0x5a, 0x61, 0x80, 0x10, 0x6b, 0x50,
0x3c, 0x4c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan), NULL);
@ -186,15 +182,13 @@ static int DecodeVLANtest03 (void) {
0x4d, 0x3d, 0x5a, 0x61, 0x80, 0x10, 0x6b, 0x50,
0x3c, 0x4c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
FlowInitConfig(FLOW_QUIET);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -1323,7 +1323,7 @@ int DetectFlowintTestPacket01Real()
sizeof(pkt11)
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
@ -1364,7 +1364,7 @@ int DetectFlowintTestPacket01Real()
int i;
for (i = 0;i < 11;i++) {
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PACKET_INITIALIZE(p);
DecodeEthernet(&th_v, &dtv, p, pkts[i], pktssizes[i], NULL);
SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
@ -1657,7 +1657,7 @@ int DetectFlowintTestPacket02Real()
sizeof(pkt11)
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
@ -1700,7 +1700,7 @@ int DetectFlowintTestPacket02Real()
/* Decode the packets, and test the matches*/
for (i = 0;i < 11;i++) {
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PACKET_INITIALIZE(p);
DecodeEthernet(&th_v, &dtv, p, pkts[i], pktssizes[i], NULL);
SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
@ -1995,7 +1995,7 @@ int DetectFlowintTestPacket03Real()
sizeof(pkt11)
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
@ -2032,7 +2032,7 @@ int DetectFlowintTestPacket03Real()
/* Decode the packets, and test the matches*/
for (i = 0;i < 11;i++) {
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PACKET_INITIALIZE(p);
DecodeEthernet(&th_v, &dtv, p, pkts[i], pktssizes[i], NULL);
SigMatchSignatures(&th_v, de_ctx, det_ctx, p);

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -408,7 +408,7 @@ int DetectIcmpIdMatchTest02 (void) {
0x51, 0xa6, 0xbb, 0x35, 0x59, 0x8a, 0x5a, 0xe2,
0x00, 0x14, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
@ -417,8 +417,6 @@ int DetectIcmpIdMatchTest02 (void) {
DetectEngineThreadCtx *det_ctx = NULL;
IPV4Hdr ip4h;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&ip4h, 0, sizeof(IPV4Hdr));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&th_v, 0, sizeof(ThreadVars));

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Open Information Security Foundation
/* Copyright (C) 2012-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -132,7 +132,7 @@ error:
static int DetectL3protoTestSig1(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
@ -142,8 +142,6 @@ static int DetectL3protoTestSig1(void) {
IPV4Hdr ip4h;
memset(&th_v, 0, sizeof(th_v));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
p->src.family = AF_INET;
p->dst.family = AF_INET;
@ -217,7 +215,7 @@ end:
static int DetectL3protoTestSig2(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
@ -227,8 +225,6 @@ static int DetectL3protoTestSig2(void) {
IPV6Hdr ip6h;
memset(&th_v, 0, sizeof(th_v));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
p->src.family = AF_INET6;
p->dst.family = AF_INET6;
@ -301,7 +297,7 @@ end:
static int DetectL3protoTestSig3(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
@ -311,8 +307,6 @@ static int DetectL3protoTestSig3(void) {
IPV6Hdr ip6h;
memset(&th_v, 0, sizeof(th_v));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
p->src.family = AF_INET6;
p->dst.family = AF_INET6;

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Open Information Security Foundation
/* Copyright (C) 2011-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -217,7 +217,7 @@ int DetectReplaceLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, ch
int result = 0;
Packet *p = NULL;
p = SCMalloc(SIZE_OF_PACKET);
p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
@ -230,8 +230,6 @@ int DetectReplaceLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, ch
SCLogDebug("replace: looks like a second run");
}
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketCopyData(p, raw_eth_pkt, pktsize);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&th_v, 0, sizeof(th_v));

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -387,7 +387,7 @@ static int DetectStreamSizeParseTest03 (void) {
TcpSession ssn;
ThreadVars tv;
DetectEngineThreadCtx dtx;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature s;
@ -399,8 +399,6 @@ static int DetectStreamSizeParseTest03 (void) {
memset(&ssn, 0, sizeof(TcpSession));
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtx, 0, sizeof(DetectEngineThreadCtx));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
memset(&sm, 0, sizeof(SigMatch));
memset(&client, 0, sizeof(TcpStream));
@ -464,7 +462,7 @@ static int DetectStreamSizeParseTest04 (void) {
TcpSession ssn;
ThreadVars tv;
DetectEngineThreadCtx dtx;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature s;
@ -476,8 +474,6 @@ static int DetectStreamSizeParseTest04 (void) {
memset(&ssn, 0, sizeof(TcpSession));
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtx, 0, sizeof(DetectEngineThreadCtx));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&s, 0, sizeof(Signature));
memset(&sm, 0, sizeof(SigMatch));
memset(&client, 0, sizeof(TcpStream));

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -525,7 +525,7 @@ end:
static int DetectTtlTestSig1(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
@ -535,8 +535,6 @@ static int DetectTtlTestSig1(void) {
IPV4Hdr ip4h;
memset(&th_v, 0, sizeof(th_v));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&ip4h, 0, sizeof(ip4h));
p->src.family = AF_INET;

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -3629,7 +3629,7 @@ void StreamTcpReassembleTriggerRawReassembly(TcpSession *ssn) {
static int StreamTcpReassembleStreamTest(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -3644,8 +3644,6 @@ static int StreamTcpReassembleStreamTest(TcpStream *stream) {
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -3989,7 +3987,7 @@ static int StreamTcpCheckQueue (uint8_t *stream_contents, StreamMsgQueue *q, uin
static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -4004,8 +4002,6 @@ static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) {
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
@ -4106,7 +4102,7 @@ static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) {
static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -4121,8 +4117,6 @@ static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) {
StreamMsgQueueSetMinChunkLen(FLOW_PKT_TOCLIENT, 4096);
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -4222,7 +4216,7 @@ static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) {
static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -4237,8 +4231,6 @@ static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) {
StreamMsgQueueSetMinChunkLen(FLOW_PKT_TOCLIENT, 4096);
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -4941,7 +4933,7 @@ static int StreamTcpTestMissedPacket (TcpReassemblyThreadCtx *ra_ctx,
TcpSession *ssn, uint32_t seq, uint32_t ack, uint8_t *payload,
uint16_t len, uint8_t th_flags, uint8_t flowflags, uint8_t state)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return -1;
Flow f;
@ -4953,8 +4945,6 @@ static int StreamTcpTestMissedPacket (TcpReassemblyThreadCtx *ra_ctx,
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
memset(&tv, 0, sizeof (ThreadVars));
@ -5539,7 +5529,7 @@ end:
static int StreamTcpReassembleTest32(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -5565,8 +5555,6 @@ static int StreamTcpReassembleTest32(void) {
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -5629,7 +5617,7 @@ end:
static int StreamTcpReassembleTest33(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -5649,8 +5637,6 @@ static int StreamTcpReassembleTest33(void) {
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -5710,7 +5696,7 @@ static int StreamTcpReassembleTest33(void) {
static int StreamTcpReassembleTest34(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -5730,8 +5716,6 @@ static int StreamTcpReassembleTest34(void) {
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -5792,7 +5776,7 @@ static int StreamTcpReassembleTest34(void) {
/** \test Test the bug 56 condition */
static int StreamTcpReassembleTest35(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -5812,8 +5796,6 @@ static int StreamTcpReassembleTest35(void) {
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -5861,7 +5843,7 @@ static int StreamTcpReassembleTest35(void) {
/** \test Test the bug 57 condition */
static int StreamTcpReassembleTest36(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -5881,8 +5863,6 @@ static int StreamTcpReassembleTest36(void) {
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&f, 0, sizeof (Flow));
memset(&tcph, 0, sizeof (TCPHdr));
ThreadVars tv;
@ -5937,7 +5917,7 @@ static int StreamTcpReassembleTest37(void) {
PacketQueue pq;
ThreadVars tv;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
@ -5947,9 +5927,6 @@ static int StreamTcpReassembleTest37(void) {
StreamMsgQueueSetMinChunkLen(FLOW_PKT_TOSERVER, 10);
StreamMsgQueueSetMinChunkLen(FLOW_PKT_TOCLIENT, 10);
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&stream, 0, sizeof (TcpStream));
memset(&pq,0,sizeof(PacketQueue));
memset(&ssn, 0, sizeof (TcpSession));
@ -6022,7 +5999,7 @@ static int StreamTcpReassembleTest37(void) {
static int StreamTcpReassembleTest38 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow f;
@ -6031,9 +6008,6 @@ static int StreamTcpReassembleTest38 (void) {
Port dp;
struct in_addr in;
TcpSession ssn;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&f, 0, sizeof (Flow));
@ -6180,15 +6154,12 @@ static int StreamTcpReassembleTest39 (void) {
SCEnter();
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));
@ -6389,15 +6360,12 @@ end:
static int StreamTcpReassembleTest40 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));
@ -6631,15 +6599,12 @@ end:
static int StreamTcpReassembleTest41 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));
@ -6818,15 +6783,12 @@ end:
static int StreamTcpReassembleTest43 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));
@ -7056,15 +7018,12 @@ end:
static int StreamTcpReassembleTest45 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));
@ -7174,16 +7133,13 @@ end:
static int StreamTcpReassembleTest46 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
ThreadVars tv;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));
@ -7296,16 +7252,13 @@ end:
static int StreamTcpReassembleTest47 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
TcpSession ssn;
ThreadVars tv;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(&tcph, 0, sizeof (TCPHdr));

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -116,15 +116,11 @@ void PacketPoolInit(intmax_t max_pending_packets) {
SCLogDebug("preallocating packets... packet size %" PRIuMAX "", (uintmax_t)SIZE_OF_PACKET);
int i = 0;
for (i = 0; i < max_pending_packets; i++) {
/* XXX pkt alloc function */
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered while allocating a packet. Exiting...");
exit(EXIT_FAILURE);
}
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
PacketPoolStorePacket(p);
}
SCLogInfo("preallocated %"PRIiMAX" packets. Total memory %"PRIuMAX"",

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -2454,11 +2454,9 @@ static int B2gCudaTest01(void)
pb->packets_offset_buffer[0] = 0;
pb->packets_payload_offset_buffer[0] = 0;
p = SCMalloc(SIZE_OF_PACKET);
p = PacketGetFromAlloc();
if (unlikely(p == NULL))
goto end;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
pb->packets_address_buffer[0] = p;
p->payload_len = strlen(string);
@ -2595,13 +2593,11 @@ static int B2gCudaTest02(void)
memset(p, 0, sizeof(p));
for (i = 0; i < no_of_pkts; i++) {
p[i] = SCMalloc(SIZE_OF_PACKET);
p[i] = PacketGetFromAlloc();
if (p[i] == NULL) {
printf("error allocating memory\n");
exit(EXIT_FAILURE);
}
memset(p[i], 0, SIZE_OF_PACKET);
p[i]->pkt = (uint8_t *)(p[i] + 1);
DecodeEthernet(&tv, &dtv, p[i], raw_eth, sizeof(raw_eth), NULL);
}
@ -2815,13 +2811,11 @@ static int B2gCudaTest03(void)
FlowInitConfig(FLOW_QUIET);
for (i = 0; i < no_of_pkts; i++) {
p[i] = SCMalloc(SIZE_OF_PACKET);
p[i] = PacketGetFromAlloc();
if (p[i] == NULL) {
printf("error allocating memory\n");
exit(EXIT_FAILURE);
}
memset(p[i], 0, SIZE_OF_PACKET);
p[i]->pkt = (uint8_t *)(p[i] + 1);
DecodeEthernet(&tv, &dtv, p[i], raw_eth, sizeof(raw_eth), NULL);
}

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -79,11 +79,9 @@ Packet *UTHBuildPacketIPV6Real(uint8_t *payload, uint16_t payload_len,
uint16_t sport, uint16_t dport) {
uint32_t in[4];
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return NULL;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
TimeSet(&p->ts);
@ -166,11 +164,9 @@ Packet *UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len,
uint16_t sport, uint16_t dport) {
struct in_addr in;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return NULL;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = ((uint8_t *)p) + sizeof(*p);
struct timeval tv;
TimeGet(&tv);
@ -291,13 +287,11 @@ Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkt
int i = 0;
for (; i < numpkts; i++) {
p[i] = SCMalloc(SIZE_OF_PACKET);
p[i] = PacketGetFromAlloc();
if (p[i] == NULL) {
SCFree(p);
return NULL;
}
memset(p[i], 0, SIZE_OF_PACKET);
p[i]->pkt = (uint8_t *)(p[i] + 1);
DecodeEthernet(&th_v, &dtv, p[i], raw_eth[i], pktsize[i], NULL);
}
return p;
@ -315,11 +309,9 @@ Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkt
Packet *UTHBuildPacketFromEth(uint8_t *raw_eth, uint16_t pktsize) {
DecodeThreadVars dtv;
ThreadVars th_v;
Packet *p = SCMalloc(SIZE_OF_PACKET);
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return NULL;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&th_v, 0, sizeof(th_v));

Loading…
Cancel
Save