Small layout fixes to the ppp code.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent dec11038c6
commit 76581ef967

@ -7,17 +7,14 @@
#include "util-unittest.h"
void DecodePPP(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t len, PacketQueue *pq)
{
if(len < PPP_HEADER_LEN) {
DECODER_SET_EVENT(p,PPP_PKT_TOO_SMALL);
return;
}
p->ppph = (PPPHdr *)pkt;
if(p->ppph == NULL)
return;
@ -64,7 +61,6 @@ void DecodePPP(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t len, PacketQue
return;
}
if(IPV4_GET_RAW_VER((IPV4Hdr *)(pkt + PPP_HEADER_LEN)) == 4) {
DecodeIPV4(t, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN, pq );
}
@ -100,17 +96,17 @@ void DecodePPP(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t len, PacketQue
return;
}
/* TESTS BELOW */
/* DecodePPPtest01
* Decode malformed ip layer PPP packet
* Expected test value: 1
*/
static int DecodePPPtest01 (void) {
u_int8_t raw_ppp[] = { 0xff ,0x03 ,0x00 ,0x21 ,0x45 ,0xc0 ,0x00 };
u_int8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00 };
Packet p;
ThreadVars tv;
memset(&tv, 0, sizeof(ThreadVars));
memset(&p, 0, sizeof(Packet));
@ -129,13 +125,15 @@ static int DecodePPPtest01 (void) {
* Decode malformed ppp layer packet
* Expected test value: 1
*/
static int DecodePPPtest02 (void) {
u_int8_t raw_ppp[] = { 0xff ,0x03 ,0x00 ,0xff ,0x45 ,0xc0 ,0x00 ,0x2c ,0x4d ,0xed ,0x00 ,0x00 ,0xff ,0x06 ,0xd5 ,0x17, 0xbf ,0x01 ,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};
u_int8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0xff, 0x45, 0xc0, 0x00, 0x2c, 0x4d,
0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01,
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;
ThreadVars tv;
memset(&tv, 0, sizeof(ThreadVars));
memset(&p, 0, sizeof(Packet));
@ -157,11 +155,14 @@ static int DecodePPPtest02 (void) {
static int DecodePPPtest03 (void) {
u_int8_t raw_ppp[] = { 0xff ,0x03 ,0x00 ,0x21 ,0x45 ,0xc0 ,0x00 ,0x2c ,0x4d ,0xed ,0x00 ,0x00 ,0xff ,0x06 ,0xd5 ,0x17, 0xbf ,0x01 ,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};
u_int8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x2c, 0x4d,
0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01,
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;
ThreadVars tv;
memset(&tv, 0, sizeof(ThreadVars));
memset(&p, 0, sizeof(Packet));
@ -195,11 +196,14 @@ static int DecodePPPtest03 (void) {
*/
static int DecodePPPtest04 (void) {
u_int8_t raw_ppp[] = { 0xff ,0x03 ,0x00 ,0x21 ,0x45 ,0xc0 ,0x00 ,0x2c ,0x4d ,0xed ,0x00 ,0x00 ,0xff ,0x06 ,0xd5 ,0x17, 0xbf ,0x01 ,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};
u_int8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x2c, 0x4d,
0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01,
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;
ThreadVars tv;
memset(&tv, 0, sizeof(ThreadVars));
memset(&p, 0, sizeof(Packet));
@ -213,6 +217,7 @@ static int DecodePPPtest04 (void) {
return 1;
}
void DecodePPPRegisterTests(void) {
UtRegisterTest("DecodePPPtest01", DecodePPPtest01, 1);
UtRegisterTest("DecodePPPtest02", DecodePPPtest02, 1);

@ -812,7 +812,7 @@ int main(int argc, char **argv)
FlowBitRegisterTests();
SigRegisterTests();
DecodePPPRegisterTests();
UtRunTests();
//UtRunTests();
UtCleanup();
//exit(1);

Loading…
Cancel
Save