Project

General

Profile

Bug #366 » 0001-threshold-introduce-SigGetThresholdTypeIter-function.patch

Eric Leblond, 11/02/2011 09:31 AM

View differences:

src/detect-engine-threshold.c
#include "tm-threads.h"
/**
* \brief Check if a certain signature has threshold option
* \brief Return next DetectThresholdData for signature
*
* \param sig Signature pointer
* \param p Packet structure
* \param sm Pointer to a Signature Match pointer
*
* \retval tsh Return the threshold data from signature or NULL if not found
*
*
*/
DetectThresholdData *SigGetThresholdType(Signature *sig, Packet *p)
DetectThresholdData *SigGetThresholdTypeIter(Signature *sig, Packet *p, SigMatch **psm)
{
SigMatch *sm = sig->sm_lists_tail[DETECT_SM_LIST_MATCH];
SigMatch *sm = NULL;
DetectThresholdData *tsh = NULL;
if (sig == NULL)
return NULL;
if (*psm == NULL) {
sm = sig->sm_lists_tail[DETECT_SM_LIST_MATCH];
} else {
/* Iteration in progress, using provided value */
sm = *psm;
}
if (p == NULL)
return NULL;
while (sm != NULL) {
if (sm->type == DETECT_THRESHOLD || sm->type == DETECT_DETECTION_FILTER) {
tsh = (DetectThresholdData *)sm->ctx;
*psm = sm->prev;
return tsh;
}
......
}
/**
* \brief Check if a certain signature has threshold option
*
* \param sig Signature pointer
* \param p Packet structure
*
* \retval tsh Return the threshold data from signature or NULL if not found
*/
DetectThresholdData *SigGetThresholdType(Signature *sig, Packet *p)
{
return SigGetThresholdTypeIter(sig, p, NULL);
}
/**
* \brief Search for a threshold data into threshold hash table
*
* \param de_ctx Dectection Context
src/detect-engine-threshold.h
#define THRESHOLD_HASH_SIZE 0xffff
DetectThresholdData *SigGetThresholdType(Signature *, Packet *);
DetectThresholdData *SigGetThresholdTypeIter(Signature *sig, Packet *p, SigMatch **psm);
int PacketAlertThreshold(DetectEngineCtx *, DetectEngineThreadCtx *,
DetectThresholdData *, Packet *, Signature *);
void ThresholdFreeFunc(void *data);
(8-8/9)