#include "util-debug.h"
#include "decode-events.h"
#include "util-unittest-helper.h"
+#include "util-validate.h"
static AppLayerProto al_proto_table[ALPROTO_MAX]; /**< Application layer protocol
table mapped to their
{
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
uint16_t parser_idx = 0;
AppLayerProto *p = &al_proto_table[proto];
TcpSession *ssn = NULL;
int AppLayerTransactionGetInspectId(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
AppLayerParserStateStore *parser_state_store =
(AppLayerParserStateStore *)f->alparser;
uint16_t AppLayerTransactionGetAvailId(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
AppLayerParserStateStore *parser_state_store =
(AppLayerParserStateStore *)f->alparser;
int AppLayerTransactionGetLoggableId(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
AppLayerParserStateStore *parser_state_store =
(AppLayerParserStateStore *)f->alparser;
void AppLayerTransactionUpdateLoggedId(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
AppLayerParserStateStore *parser_state_store =
(AppLayerParserStateStore *)f->alparser;
int AppLayerTransactionGetLoggedId(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
AppLayerParserStateStore *parser_state_store =
(AppLayerParserStateStore *)f->alparser;
*/
uint16_t AppLayerGetStateVersion(Flow *f) {
SCEnter();
+
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
uint16_t version = 0;
AppLayerParserStateStore *parser_state_store = NULL;
{
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
int r = 0;
AppLayerParserStateStore *parser_state_store = NULL;
AppLayerDecoderEvents *AppLayerGetDecoderEventsForFlow(Flow *f)
{
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
/* Get the parser state (if any) */
AppLayerParserStateStore *parser_state_store = NULL;
void AppLayerTriggerRawStreamReassembly(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
#ifdef DEBUG
BUG_ON(f == NULL);
#endif
#include "util-debug.h"
#include "util-print.h"
#include "util-profiling.h"
+#include "util-validate.h"
//#define PRINT
extern uint8_t engine_mode;
void *AppLayerGetProtoStateFromFlow(Flow *f) {
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
if (f == NULL) {
SCReturnPtr(NULL, "void");
}
{
SCEnter();
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
int r = 0;
#if DEBUG
if (DeStateStoreFilestoreSigsCantMatch(det_ctx->sgh, f->de_state, flags) == 1) {
SCLogDebug("disabling file storage for transaction %u", det_ctx->tx_id);
+
+ SCMutexLock(&f->m);
FileDisableStoringForTransaction(f, flags & (STREAM_TOCLIENT|STREAM_TOSERVER),
det_ctx->tx_id);
+ SCMutexUnlock(&f->m);
+
f->de_state->flags |= DE_STATE_FILE_STORE_DISABLED;
}
}
if (!(f->de_state->flags & DE_STATE_FILE_STORE_DISABLED)) {
if (DeStateStoreFilestoreSigsCantMatch(det_ctx->sgh, f->de_state, flags) == 1) {
SCLogDebug("disabling file storage for transaction");
+
+ SCMutexLock(&f->m);
FileDisableStoringForTransaction(f, flags & (STREAM_TOCLIENT|STREAM_TOSERVER),
det_ctx->tx_id);
+ SCMutexUnlock(&f->m);
+
f->de_state->flags |= DE_STATE_FILE_STORE_DISABLED;
}
}
#include "util-memcmp.h"
#include "util-print.h"
#include "app-layer-parser.h"
+#include "util-validate.h"
/** \brief switch to force magic checks on all files
* regardless of the rules.
/**
* \brief disable file storing for files in a transaction
*
- * \param f flow
+ * \param f *LOCKED* flow
* \param direction flow direction
* \param tx_id transaction id
*/
void FileDisableStoringForTransaction(Flow *f, uint8_t direction, uint16_t tx_id) {
File *ptr = NULL;
+ DEBUG_ASSERT_FLOW_LOCKED(f);
+
SCEnter();
FileContainer *ffc = AppLayerGetFilesFromFlow(f, direction);
#ifdef DEBUG_VALIDATION
+/** \brief test if a flow is locked.
+ *
+ * If trylock returns 0 it got a lock. Which means
+ * the flow was previously unlocked.
+ */
+#define DEBUG_ASSERT_FLOW_LOCKED(f) do { \
+ if ((f) != NULL) { \
+ int r = SCMutexTrylock(&(f)->m); \
+ if (r == 0) { \
+ BUG_ON(1); \
+ } \
+ } \
+} while(0)
+
/** \brief validate the integrity of the flow
*
* BUG_ON's on problems
#else /* DEBUG_VALIDATE */
+#define DEBUG_ASSERT_FLOW_LOCKED(f)
#define DEBUG_VALIDATE_FLOW(f)
#define DEBUG_VALIDATE_PACKET(p)