Unittests and style fix for detect-engine-siggroup.[ch]

remotes/origin/master-1.0.x
Anoop Saldanha 16 years ago committed by Victor Julien
parent 83d1e283bb
commit 78db80ea15

File diff suppressed because it is too large Load Diff

@ -1,3 +1,7 @@
/** Copyright (c) 2009 Open Information Security Foundation.
* \author Victor Julien <victor@inliniac.net>
*/
#ifndef __DETECT_ENGINE_SIGGROUP_H__ #ifndef __DETECT_ENGINE_SIGGROUP_H__
#define __DETECT_ENGINE_SIGGROUP_H__ #define __DETECT_ENGINE_SIGGROUP_H__
@ -45,10 +49,13 @@ int SigGroupHeadSPortHashRemove(DetectEngineCtx *, SigGroupHead *);
void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid); void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid);
void SigGroupHeadSetSigCnt(SigGroupHead *sgh, uint32_t max_idx); void SigGroupHeadSetSigCnt(SigGroupHead *sgh, uint32_t max_idx);
int SigGroupHeadBuildMatchArray (DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t max_idx); int SigGroupHeadBuildMatchArray (DetectEngineCtx *de_ctx, SigGroupHead *sgh,
uint32_t max_idx);
void SigGroupHeadFreeSigArrays(DetectEngineCtx *de_ctx); void SigGroupHeadFreeSigArrays(DetectEngineCtx *de_ctx);
int SigGroupHeadContainsSigId (DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t sid); int SigGroupHeadContainsSigId (DetectEngineCtx *de_ctx, SigGroupHead *sgh,
uint32_t sid);
#endif /* __DETECT_ENGINE_SIGGROUP_H__ */ void SigGroupHeadRegisterTests(void);
#endif /* __DETECT_ENGINE_SIGGROUP_H__ */

@ -1036,7 +1036,12 @@ int CreateGroupedAddrListCmpMpmMaxlen(DetectAddress *a, DetectAddress *b) {
* srchead is a ordered "inserted" list w/o internal overlap * srchead is a ordered "inserted" list w/o internal overlap
* *
*/ */
int CreateGroupedAddrList(DetectEngineCtx *de_ctx, DetectAddress *srchead, int family, DetectAddresssHead *newhead, uint32_t unique_groups, int (*CompareFunc)(DetectAddress *, DetectAddress *), uint32_t max_idx) { int CreateGroupedAddrList(DetectEngineCtx *de_ctx, DetectAddress *srchead,
int family, DetectAddresssHead *newhead,
uint32_t unique_groups,
int (*CompareFunc)(DetectAddress *, DetectAddress *),
uint32_t max_idx)
{
DetectAddress *tmplist = NULL, *tmplist2 = NULL, *joingr = NULL; DetectAddress *tmplist = NULL, *tmplist2 = NULL, *joingr = NULL;
char insert = 0; char insert = 0;
DetectAddress *gr, *next_gr; DetectAddress *gr, *next_gr;
@ -1541,7 +1546,7 @@ int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddresssHead *he
DetectAddress *grhead = NULL, *grdsthead = NULL, *grsighead = NULL; DetectAddress *grhead = NULL, *grdsthead = NULL, *grsighead = NULL;
/* based on the family, select the list we are using in the head */ /* based on the family, select the list we are using in the head */
grhead = GetHeadPtr(head,family); grhead = GetHeadPtr(head, family);
/* loop through the global source address list */ /* loop through the global source address list */
for (gr = grhead; gr != NULL; gr = gr->next) { for (gr = grhead; gr != NULL; gr = gr->next) {
@ -1564,6 +1569,7 @@ int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddresssHead *he
continue; continue;
tmp_s = de_ctx->sig_array[sig]; tmp_s = de_ctx->sig_array[sig];
if (tmp_s == NULL) if (tmp_s == NULL)
continue; continue;
@ -1582,7 +1588,7 @@ int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddresssHead *he
DetectAddressAdd(&tmp_gr_list,grtmp); DetectAddressAdd(&tmp_gr_list,grtmp);
} else { } else {
/* our group will only have one sig, this one. So add that. */ /* our group will only have one sig, this one. So add that. */
SigGroupHeadAppendSig(de_ctx,&lookup_gr->sh,tmp_s); SigGroupHeadAppendSig(de_ctx, &lookup_gr->sh, tmp_s);
lookup_gr->cnt++; lookup_gr->cnt++;
} }
} }
@ -1610,7 +1616,7 @@ int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddresssHead *he
if (sgh == NULL) { if (sgh == NULL) {
/* put the contents in our sig group head */ /* put the contents in our sig group head */
SigGroupHeadSetSigCnt(sgr->sh, max_idx); SigGroupHeadSetSigCnt(sgr->sh, max_idx);
SigGroupHeadBuildMatchArray(de_ctx,sgr->sh, max_idx); SigGroupHeadBuildMatchArray(de_ctx, sgr->sh, max_idx);
/* content */ /* content */
SigGroupHeadLoadContent(de_ctx, sgr->sh); SigGroupHeadLoadContent(de_ctx, sgr->sh);

@ -78,6 +78,7 @@
#include "util-debug.h" #include "util-debug.h"
#include "util-error.h" #include "util-error.h"
#include "detect-engine-siggroup.h"
/* /*
* we put this here, because we only use it here in main. * we put this here, because we only use it here in main.
@ -466,6 +467,7 @@ int main(int argc, char **argv)
SCLogRegisterTests(); SCLogRegisterTests();
SCRadixRegisterTests(); SCRadixRegisterTests();
DefragRegisterTests(); DefragRegisterTests();
SigGroupHeadRegisterTests();
if (list_unittests) { if (list_unittests) {
UtListTests(regex_arg); UtListTests(regex_arg);
} }

Loading…
Cancel
Save