}
-void DetectReplaceExecute(Packet *p, DetectReplaceList *replist)
+void DetectReplaceExecuteInternal(Packet *p, DetectReplaceList *replist)
{
DetectReplaceList *tlist = NULL;
- if (p == NULL)
- return;
-
SCLogDebug("replace: Executing match");
while(replist) {
memcpy(replist->found, replist->cd->replace, replist->cd->replace_len);
}
-void DetectReplaceFree(DetectReplaceList *replist)
+void DetectReplaceFreeInternal(DetectReplaceList *replist)
{
DetectReplaceList *tlist = NULL;
while(replist) {
-/* Copyright (C) 2011 Open Information Security Foundation
+/* Copyright (C) 2011-2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#define __DETECT_REPLACE_H__
DetectReplaceList * DetectReplaceAddToList(DetectReplaceList *replist, uint8_t *found, DetectContentData *cd);
-void DetectReplaceExecute(Packet *p, DetectReplaceList *replist);
-void DetectReplaceFree(DetectReplaceList *replist);
+
+/* Internal functions are only called via the inline functions below. */
+void DetectReplaceExecuteInternal(Packet *p, DetectReplaceList *replist);
+void DetectReplaceFreeInternal(DetectReplaceList *replist);
+
+static inline void DetectReplaceExecute(Packet *p, DetectEngineThreadCtx *det_ctx)
+{
+ if (p == NULL || det_ctx->replist == NULL)
+ return;
+ DetectReplaceExecuteInternal(p, det_ctx->replist);
+ det_ctx->replist = NULL;
+}
+
+static inline void DetectReplaceFree(DetectEngineThreadCtx *det_ctx)
+{
+ if (det_ctx->replist) {
+ DetectReplaceFreeInternal(det_ctx->replist);
+ det_ctx->replist = NULL;
+ }
+}
+
void DetectReplaceRegister (void);
#endif
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
}
}
- DetectReplaceExecute(p, det_ctx->replist);
- det_ctx->replist = NULL;
+ DetectReplaceExecute(p, det_ctx);
if (s->flags & SIG_FLAG_FILESTORE)
DetectFilestorePostMatch(tv, det_ctx, p, s);
alerts++;
next:
DetectFlowvarProcessList(det_ctx, pflow);
- DetectReplaceFree(det_ctx->replist);
- det_ctx->replist = NULL;
+ DetectReplaceFree(det_ctx);
RULE_PROFILING_END(det_ctx, s, smatch, p);
det_ctx->flags = 0;