@ -115,35 +115,6 @@ void MpmWuManberRegister (void) {
}
}
/* append an endmatch to a pattern
*
* Only used in the initialization phase */
static inline void WmEndMatchAppend ( MpmCtx * mpm_ctx , WmPattern * p ,
uint16_t offset , uint16_t depth , uint32_t pid , uint32_t sid )
{
MpmEndMatch * em = MpmAllocEndMatch ( mpm_ctx ) ;
if ( em = = NULL ) {
printf ( " ERROR: WmAllocEndMatch failed \n " ) ;
return ;
}
em - > id = pid ;
em - > sig_id = sid ;
em - > depth = depth ;
em - > offset = offset ;
if ( p - > em = = NULL ) {
p - > em = em ;
return ;
}
MpmEndMatch * m = p - > em ;
while ( m - > next ) {
m = m - > next ;
}
m - > next = em ;
}
void prt ( uint8_t * buf , uint16_t buflen ) {
uint16_t i ;
@ -319,10 +290,6 @@ static inline int WmCmpPattern(WmPattern *p, uint8_t *pat, uint16_t patlen, char
*/
void WmFreePattern ( MpmCtx * mpm_ctx , WmPattern * p ) {
if ( p & & p - > em ) {
MpmEndMatchFreeAll ( mpm_ctx , p - > em ) ;
}
if ( p & & p - > cs & & p - > cs ! = p - > ci ) {
SCFree ( p - > cs ) ;
mpm_ctx - > memory_cnt - - ;
@ -369,6 +336,7 @@ static int WmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t
p - > len = patlen ;
p - > flags = flags ;
p - > id = pid ;
/* setup the case insensitive part of the pattern */
p - > ci = SCMalloc ( patlen ) ;
@ -421,9 +389,6 @@ static int WmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t
else if ( mpm_ctx - > minlen > patlen ) mpm_ctx - > minlen = patlen ;
}
/* we need a match */
WmEndMatchAppend ( mpm_ctx , p , offset , depth , pid , sid ) ;
mpm_ctx - > total_pattern_cnt + + ;
return 0 ;
@ -783,7 +748,6 @@ uint32_t WmSearch2Hash9(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
WmThreadCtx * tctx = ( WmThreadCtx * ) mpm_thread_ctx - > ctx ;
# endif /* WUMANBER_COUNTERS */
uint32_t cnt = 0 ;
uint8_t * bufmin = buf ;
uint8_t * bufend = buf + buflen - 1 ;
uint16_t sl = ctx - > shiftlen ;
uint16_t h ;
@ -845,7 +809,7 @@ uint32_t WmSearch2Hash9(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
//printf("CI Exact match: "); prt(p->ci, p->len); printf("\n");
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
@ -857,7 +821,7 @@ uint32_t WmSearch2Hash9(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
//printf("CS Exact match: "); prt(p->cs, p->len); printf("\n");
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
@ -884,7 +848,6 @@ uint32_t WmSearch2Hash12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
WmThreadCtx * tctx = ( WmThreadCtx * ) mpm_thread_ctx - > ctx ;
# endif /* WUMANBER_COUNTERS */
uint32_t cnt = 0 ;
uint8_t * bufmin = buf ;
uint8_t * bufend = buf + buflen - 1 ;
uint16_t sl = ctx - > shiftlen ;
uint16_t h ;
@ -948,7 +911,7 @@ uint32_t WmSearch2Hash12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
//printf("CI Exact match: "); prt(p->ci, p->len); printf("\n");
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
@ -960,7 +923,7 @@ uint32_t WmSearch2Hash12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
//printf("CS Exact match: "); prt(p->cs, p->len); printf("\n");
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
@ -986,7 +949,6 @@ uint32_t WmSearch2Hash14(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
WmThreadCtx * tctx = ( WmThreadCtx * ) mpm_thread_ctx - > ctx ;
# endif /* WUMANBER_COUNTERS */
uint32_t cnt = 0 ;
uint8_t * bufmin = buf ;
uint8_t * bufend = buf + buflen - 1 ;
uint16_t sl = ctx - > shiftlen ;
uint16_t h ;
@ -1049,7 +1011,7 @@ uint32_t WmSearch2Hash14(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
if ( memcmp_lowercase ( p - > ci , buf - sl + 1 , p - > len ) = = 0 ) {
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
}
@ -1059,7 +1021,7 @@ uint32_t WmSearch2Hash14(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
if ( memcmp ( p - > cs , buf - sl + 1 , p - > len ) = = 0 ) {
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
}
@ -1084,7 +1046,6 @@ uint32_t WmSearch2Hash15(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
WmThreadCtx * tctx = ( WmThreadCtx * ) mpm_thread_ctx - > ctx ;
# endif /* WUMANBER_COUNTERS */
uint32_t cnt = 0 ;
uint8_t * bufmin = buf ;
uint8_t * bufend = buf + buflen - 1 ;
uint16_t sl = ctx - > shiftlen ;
uint16_t h ;
@ -1148,7 +1109,7 @@ uint32_t WmSearch2Hash15(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
//printf("CI Exact match: "); prt(p->ci, p->len); printf("\n");
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
}
@ -1159,7 +1120,7 @@ uint32_t WmSearch2Hash15(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
//printf("CS Exact match: "); prt(p->cs, p->len); printf("\n");
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
}
@ -1184,7 +1145,6 @@ uint32_t WmSearch2Hash16(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
WmThreadCtx * tctx = ( WmThreadCtx * ) mpm_thread_ctx - > ctx ;
# endif /* WUMANBER_COUNTERS */
uint32_t cnt = 0 ;
uint8_t * bufmin = buf ;
uint8_t * bufend = buf + buflen - 1 ;
uint16_t sl = ctx - > shiftlen ;
uint16_t h ;
@ -1247,7 +1207,7 @@ uint32_t WmSearch2Hash16(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
if ( memcmp_lowercase ( p - > ci , buf - sl + 1 , p - > len ) = = 0 ) {
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
}
@ -1257,7 +1217,7 @@ uint32_t WmSearch2Hash16(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM
if ( memcmp ( p - > cs , buf - sl + 1 , p - > len ) = = 0 ) {
COUNT ( tctx - > stat_loop_match + + ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf - sl + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
} else {
COUNT ( tctx - > stat_loop_no_match + + ) ;
}
@ -1303,11 +1263,11 @@ uint32_t WmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcher
if ( p - > flags & MPM_PATTERN_FLAG_NOCASE ) {
if ( wm_tolower ( * buf ) = = p - > ci [ 0 ] ) {
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
}
} else {
if ( * buf = = p - > cs [ 0 ] ) {
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > em, ( buf + 1 - bufmin ) , p - > len ) ;
cnt + = MpmVerifyMatch ( mpm_thread_ctx , pmq , p - > id ) ;
}
}
}