-/* Copyright (C) 2007-2010 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
/** \brief Handle flowvar candidate list in det_ctx:
* - clean up the list
- * - enforce storage for type ALWAYS (luajit) */
-void DetectFlowvarProcessList(DetectEngineThreadCtx *det_ctx, Flow *f)
+ * - enforce storage for type ALWAYS (luajit)
+ * Only called from DetectFlowvarProcessList() when flowvarlist is not NULL .
+ */
+void DetectFlowvarProcessListInternal(DetectFlowvarList *fs, Flow *f)
{
- DetectFlowvarList *fs, *next;
-
- SCLogDebug("det_ctx->flowvarlist %p", det_ctx->flowvarlist);
+ DetectFlowvarList *next;
- if (det_ctx->flowvarlist != NULL) {
- fs = det_ctx->flowvarlist;
- while (fs != NULL) {
- next = fs->next;
+ do {
+ next = fs->next;
- if (fs->type == DETECT_FLOWVAR_TYPE_ALWAYS) {
- BUG_ON(f == NULL);
- SCLogDebug("adding to the flow %u:", fs->idx);
- //PrintRawDataFp(stdout, fs->buffer, fs->len);
-
- FlowVarAddStr(f, fs->idx, fs->buffer, fs->len);
- /* memory at fs->buffer is now the responsibility of
- * the flowvar code. */
- } else {
- SCFree(fs->buffer);
- }
- SCFree(fs);
- fs = next;
- }
+ if (fs->type == DETECT_FLOWVAR_TYPE_ALWAYS) {
+ BUG_ON(f == NULL);
+ SCLogDebug("adding to the flow %u:", fs->idx);
+ //PrintRawDataFp(stdout, fs->buffer, fs->len);
- det_ctx->flowvarlist = NULL;
- }
+ FlowVarAddStr(f, fs->idx, fs->buffer, fs->len);
+ /* memory at fs->buffer is now the responsibility of
+ * the flowvar code. */
+ } else
+ SCFree(fs->buffer);
+ SCFree(fs);
+ fs = next;
+ } while (fs != NULL);
}
-
-/* Copyright (C) 2007-2010 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
int DetectFlowvarPostMatchSetup(Signature *s, uint16_t idx);
int DetectFlowvarStoreMatch(DetectEngineThreadCtx *, uint16_t, uint8_t *, uint16_t, int);
-void DetectFlowvarProcessList(DetectEngineThreadCtx *det_ctx, Flow *);
-#endif /* __DETECT_FLOWVAR_H__ */
+/* For use only by DetectFlowvarProcessList() */
+void DetectFlowvarProcessListInternal(DetectFlowvarList *fs, Flow *f);
+static inline void DetectFlowvarProcessList(DetectEngineThreadCtx *det_ctx, Flow *f)
+{
+ DetectFlowvarList *fs = det_ctx->flowvarlist;
+
+ SCLogDebug("det_ctx->flowvarlist %p", fs);
+ if (fs != NULL) {
+ det_ctx->flowvarlist = NULL;
+ DetectFlowvarProcessListInternal(fs, f);
+ }
+}
+
+#endif /* __DETECT_FLOWVAR_H__ */