@ -45,20 +45,26 @@
static pcre * parse_regex ;
static pcre_extra * parse_regex_study ;
int Detect Decod eEventMatch ( ThreadVars * , DetectEngineThreadCtx * , Packet * , Signature * , SigMatch * ) ;
static int Detect Decod eEventSetup ( DetectEngineCtx * , Signature * , char * ) ;
void Decod eEventRegisterTests( void ) ;
int Detect Engin eEventMatch ( ThreadVars * , DetectEngineThreadCtx * , Packet * , Signature * , SigMatch * ) ;
static int Detect Engin eEventSetup ( DetectEngineCtx * , Signature * , char * ) ;
void Engin eEventRegisterTests( void ) ;
/**
* \ brief Registration function for decode - event : keyword
*/
void DetectDecodeEventRegister ( void ) {
void DetectEngineEventRegister ( void ) {
sigmatch_table [ DETECT_ENGINE_EVENT ] . name = " engine-event " ;
sigmatch_table [ DETECT_ENGINE_EVENT ] . Match = DetectEngineEventMatch ;
sigmatch_table [ DETECT_ENGINE_EVENT ] . Setup = DetectEngineEventSetup ;
sigmatch_table [ DETECT_ENGINE_EVENT ] . Free = NULL ;
sigmatch_table [ DETECT_ENGINE_EVENT ] . RegisterTests = EngineEventRegisterTests ;
sigmatch_table [ DETECT_ENGINE_EVENT ] . flags | = SIGMATCH_DEONLY_COMPAT ;
sigmatch_table [ DETECT_DECODE_EVENT ] . name = " decode-event " ;
sigmatch_table [ DETECT_DECODE_EVENT ] . Match = DetectDecodeEventMatch ;
sigmatch_table [ DETECT_DECODE_EVENT ] . Setup = DetectDecodeEventSetup ;
sigmatch_table [ DETECT_DECODE_EVENT ] . Match = Detect Engin eEventMatch;
sigmatch_table [ DETECT_DECODE_EVENT ] . Setup = Detect Engin eEventSetup;
sigmatch_table [ DETECT_DECODE_EVENT ] . Free = NULL ;
sigmatch_table [ DETECT_DECODE_EVENT ] . RegisterTests = DecodeEventRegisterTests ;
sigmatch_table [ DETECT_DECODE_EVENT ] . flags | = SIGMATCH_DEONLY_COMPAT ;
const char * eb ;
@ -97,11 +103,11 @@ error:
* \ retval 0 no match
* \ retval 1 match
*/
int Detect Decod eEventMatch ( ThreadVars * t , DetectEngineThreadCtx * det_ctx , Packet * p , Signature * s , SigMatch * m )
int Detect Engin eEventMatch ( ThreadVars * t , DetectEngineThreadCtx * det_ctx , Packet * p , Signature * s , SigMatch * m )
{
SCEnter ( ) ;
Detect DecodeEventData * de = ( DetectDecod eEventData * ) m - > ctx ;
Detect EngineEventData * de = ( DetectEngin eEventData * ) m - > ctx ;
if ( DECODER_ISSET_EVENT ( p , de - > event ) ) {
SCReturnInt ( 1 ) ;
@ -118,10 +124,10 @@ int DetectDecodeEventMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packe
* \ retval de pointer to DetectFlowData on success
* \ retval NULL on failure
*/
Detect DecodeEventData * DetectDecod eEventParse ( char * rawstr )
Detect EngineEventData * DetectEngin eEventParse ( char * rawstr )
{
int i ;
Detect Decod eEventData * de = NULL ;
Detect Engin eEventData * de = NULL ;
# define MAX_SUBSTRINGS 30
int ret = 0 , res = 0 , found = 0 ;
int ov [ MAX_SUBSTRINGS ] ;
@ -154,7 +160,7 @@ DetectDecodeEventData *DetectDecodeEventParse (char *rawstr)
goto error ;
}
de = SCMalloc ( sizeof ( Detect Decod eEventData) ) ;
de = SCMalloc ( sizeof ( Detect Engin eEventData) ) ;
if ( de = = NULL )
goto error ;
@ -176,12 +182,12 @@ error:
* \ retval 0 on Success
* \ retval - 1 on Failure
*/
static int Detect Decod eEventSetup ( DetectEngineCtx * de_ctx , Signature * s , char * rawstr )
static int Detect Engin eEventSetup ( DetectEngineCtx * de_ctx , Signature * s , char * rawstr )
{
Detect Decod eEventData * de = NULL ;
Detect Engin eEventData * de = NULL ;
SigMatch * sm = NULL ;
de = Detect Decod eEventParse( rawstr ) ;
de = Detect Engin eEventParse( rawstr ) ;
if ( de = = NULL )
goto error ;
@ -189,7 +195,7 @@ static int DetectDecodeEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *
if ( sm = = NULL )
goto error ;
sm - > type = DETECT_ DECOD E_EVENT;
sm - > type = DETECT_ ENGIN E_EVENT;
sm - > ctx = ( void * ) de ;
SigMatchAppendPacket ( s , sm ) ;
@ -202,11 +208,11 @@ error:
}
/**
* \ brief this function will free memory associated with Detect Decod eEventData
* \ brief this function will free memory associated with Detect Engin eEventData
*
* \ param de pointer to Detect Decod eEventData
* \ param de pointer to Detect Engin eEventData
*/
void Detect DecodeEventFree( DetectDecod eEventData * de ) {
void Detect EngineEventFree( DetectEngin eEventData * de ) {
if ( de ) SCFree ( de ) ;
}
@ -216,13 +222,13 @@ void DetectDecodeEventFree(DetectDecodeEventData *de) {
# ifdef UNITTESTS
/**
* \ test Decod eEventTestParse01 is a test for a valid decode - event value
* \ test Engin eEventTestParse01 is a test for a valid decode - event value
*/
int Decod eEventTestParse01 ( void ) {
Detect Decod eEventData * de = NULL ;
de = Detect Decod eEventParse( " ipv4.pkt_too_small " ) ;
int Engin eEventTestParse01 ( void ) {
Detect Engin eEventData * de = NULL ;
de = Detect Engin eEventParse( " ipv4.pkt_too_small " ) ;
if ( de ) {
Detect Decod eEventFree( de ) ;
Detect Engin eEventFree( de ) ;
return 1 ;
}
@ -231,13 +237,13 @@ int DecodeEventTestParse01 (void) {
/**
* \ test Decod eEventTestParse02 is a test for a valid upper + lower case decode - event value
* \ test Engin eEventTestParse02 is a test for a valid upper + lower case decode - event value
*/
int Decod eEventTestParse02 ( void ) {
Detect Decod eEventData * de = NULL ;
de = Detect Decod eEventParse( " PPP.pkt_too_small " ) ;
int Engin eEventTestParse02 ( void ) {
Detect Engin eEventData * de = NULL ;
de = Detect Engin eEventParse( " PPP.pkt_too_small " ) ;
if ( de ) {
Detect Decod eEventFree( de ) ;
Detect Engin eEventFree( de ) ;
return 1 ;
}
@ -245,13 +251,13 @@ int DecodeEventTestParse02 (void) {
}
/**
* \ test Decod eEventTestParse03 is a test for a valid upper case decode - event value
* \ test Engin eEventTestParse03 is a test for a valid upper case decode - event value
*/
int Decod eEventTestParse03 ( void ) {
Detect Decod eEventData * de = NULL ;
de = Detect Decod eEventParse( " IPV6.PKT_TOO_SMALL " ) ;
int Engin eEventTestParse03 ( void ) {
Detect Engin eEventData * de = NULL ;
de = Detect Engin eEventParse( " IPV6.PKT_TOO_SMALL " ) ;
if ( de ) {
Detect Decod eEventFree( de ) ;
Detect Engin eEventFree( de ) ;
return 1 ;
}
@ -259,13 +265,13 @@ int DecodeEventTestParse03 (void) {
}
/**
* \ test Decod eEventTestParse04 is a test for an invalid upper case decode - event value
* \ test Engin eEventTestParse04 is a test for an invalid upper case decode - event value
*/
int Decod eEventTestParse04 ( void ) {
Detect Decod eEventData * de = NULL ;
de = Detect Decod eEventParse( " IPV6.INVALID_EVENT " ) ;
int Engin eEventTestParse04 ( void ) {
Detect Engin eEventData * de = NULL ;
de = Detect Engin eEventParse( " IPV6.INVALID_EVENT " ) ;
if ( de ) {
Detect Decod eEventFree( de ) ;
Detect Engin eEventFree( de ) ;
return 1 ;
}
@ -273,13 +279,13 @@ int DecodeEventTestParse04 (void) {
}
/**
* \ test Decod eEventTestParse05 is a test for an invalid char into the decode - event value
* \ test Engin eEventTestParse05 is a test for an invalid char into the decode - event value
*/
int Decod eEventTestParse05 ( void ) {
Detect Decod eEventData * de = NULL ;
de = Detect Decod eEventParse( " IPV-6,INVALID_CHAR " ) ;
int Engin eEventTestParse05 ( void ) {
Detect Engin eEventData * de = NULL ;
de = Detect Engin eEventParse( " IPV-6,INVALID_CHAR " ) ;
if ( de ) {
Detect Decod eEventFree( de ) ;
Detect Engin eEventFree( de ) ;
return 1 ;
}
@ -287,15 +293,15 @@ int DecodeEventTestParse05 (void) {
}
/**
* \ test Decod eEventTestParse06 is a test for match function with valid decode - event value
* \ test Engin eEventTestParse06 is a test for match function with valid decode - event value
*/
int Decod eEventTestParse06 ( void ) {
int Engin eEventTestParse06 ( void ) {
Packet * p = SCMalloc ( SIZE_OF_PACKET ) ;
if ( p = = NULL )
return 0 ;
ThreadVars tv ;
int ret = 0 ;
Detect Decod eEventData * de = NULL ;
Detect Engin eEventData * de = NULL ;
SigMatch * sm = NULL ;
@ -305,7 +311,7 @@ int DecodeEventTestParse06 (void) {
DECODER_SET_EVENT ( p , PPP_PKT_TOO_SMALL ) ;
de = Detect Decod eEventParse( " ppp.pkt_too_small " ) ;
de = Detect Engin eEventParse( " ppp.pkt_too_small " ) ;
if ( de = = NULL )
goto error ;
@ -318,7 +324,7 @@ int DecodeEventTestParse06 (void) {
sm - > type = DETECT_DECODE_EVENT ;
sm - > ctx = ( void * ) de ;
ret = Detect Decod eEventMatch( & tv , NULL , p , NULL , sm ) ;
ret = Detect Engin eEventMatch( & tv , NULL , p , NULL , sm ) ;
if ( ret ) {
SCFree ( p ) ;
@ -334,15 +340,15 @@ error:
# endif /* UNITTESTS */
/**
* \ brief this function registers unit tests for Decod eEvent
* \ brief this function registers unit tests for Engin eEvent
*/
void Decod eEventRegisterTests( void ) {
void Engin eEventRegisterTests( void ) {
# ifdef UNITTESTS
UtRegisterTest ( " DecodeEventTestParse01" , Decod eEventTestParse01, 1 ) ;
UtRegisterTest ( " DecodeEventTestParse02" , Decod eEventTestParse02, 1 ) ;
UtRegisterTest ( " DecodeEventTestParse03" , Decod eEventTestParse03, 1 ) ;
UtRegisterTest ( " DecodeEventTestParse04" , Decod eEventTestParse04, 0 ) ;
UtRegisterTest ( " DecodeEventTestParse05" , Decod eEventTestParse05, 0 ) ;
UtRegisterTest ( " DecodeEventTestParse06" , Decod eEventTestParse06, 1 ) ;
UtRegisterTest ( " EngineEventTestParse01" , Engin eEventTestParse01, 1 ) ;
UtRegisterTest ( " EngineEventTestParse02" , Engin eEventTestParse02, 1 ) ;
UtRegisterTest ( " EngineEventTestParse03" , Engin eEventTestParse03, 1 ) ;
UtRegisterTest ( " EngineEventTestParse04" , Engin eEventTestParse04, 0 ) ;
UtRegisterTest ( " EngineEventTestParse05" , Engin eEventTestParse05, 0 ) ;
UtRegisterTest ( " EngineEventTestParse06" , Engin eEventTestParse06, 1 ) ;
# endif /* UNITTESTS */
}