|
|
|
@ -94,7 +94,7 @@ void TmqhFlowPrintAutofpHandler(void)
|
|
|
|
|
/* same as 'simple' */
|
|
|
|
|
Packet *TmqhInputFlow(ThreadVars *tv)
|
|
|
|
|
{
|
|
|
|
|
PacketQueue *q = &trans_q[tv->inq->id];
|
|
|
|
|
PacketQueue *q = tv->inq->pq;
|
|
|
|
|
|
|
|
|
|
StatsSyncCountersIfSignalled(tv);
|
|
|
|
|
|
|
|
|
@ -126,8 +126,6 @@ static int StoreQueueId(TmqhFlowCtx *ctx, char *name)
|
|
|
|
|
}
|
|
|
|
|
tmq->writer_cnt++;
|
|
|
|
|
|
|
|
|
|
uint16_t id = tmq->id;
|
|
|
|
|
|
|
|
|
|
if (ctx->queues == NULL) {
|
|
|
|
|
ctx->size = 1;
|
|
|
|
|
ctx->queues = SCMalloc(ctx->size * sizeof(TmqhFlowMode));
|
|
|
|
@ -147,7 +145,7 @@ static int StoreQueueId(TmqhFlowCtx *ctx, char *name)
|
|
|
|
|
|
|
|
|
|
memset(ctx->queues + (ctx->size - 1), 0, sizeof(TmqhFlowMode));
|
|
|
|
|
}
|
|
|
|
|
ctx->queues[ctx->size - 1].q = &trans_q[id];
|
|
|
|
|
ctx->queues[ctx->size - 1].q = tmq->pq;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -284,138 +282,98 @@ void TmqhOutputFlowIPPair(ThreadVars *tv, Packet *p)
|
|
|
|
|
|
|
|
|
|
static int TmqhOutputFlowSetupCtxTest01(void)
|
|
|
|
|
{
|
|
|
|
|
int retval = 0;
|
|
|
|
|
Tmq *tmq = NULL;
|
|
|
|
|
TmqhFlowCtx *fctx = NULL;
|
|
|
|
|
|
|
|
|
|
TmqResetQueues();
|
|
|
|
|
|
|
|
|
|
tmq = TmqCreateQueue("queue1");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
tmq = TmqCreateQueue("queue2");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
tmq = TmqCreateQueue("another");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
tmq = TmqCreateQueue("yetanother");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
Tmq *tmq1 = TmqCreateQueue("queue1");
|
|
|
|
|
FAIL_IF_NULL(tmq1);
|
|
|
|
|
Tmq *tmq2 = TmqCreateQueue("queue2");
|
|
|
|
|
FAIL_IF_NULL(tmq2);
|
|
|
|
|
Tmq *tmq3 = TmqCreateQueue("another");
|
|
|
|
|
FAIL_IF_NULL(tmq3);
|
|
|
|
|
Tmq *tmq4 = TmqCreateQueue("yetanother");
|
|
|
|
|
FAIL_IF_NULL(tmq4);
|
|
|
|
|
|
|
|
|
|
const char *str = "queue1,queue2,another,yetanother";
|
|
|
|
|
void *ctx = TmqhOutputFlowSetupCtx(str);
|
|
|
|
|
FAIL_IF_NULL(ctx);
|
|
|
|
|
|
|
|
|
|
if (ctx == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
fctx = (TmqhFlowCtx *)ctx;
|
|
|
|
|
TmqhFlowCtx *fctx = (TmqhFlowCtx *)ctx;
|
|
|
|
|
|
|
|
|
|
if (fctx->size != 4)
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NOT(fctx->size == 4);
|
|
|
|
|
|
|
|
|
|
if (fctx->queues == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NULL(fctx->queues);
|
|
|
|
|
|
|
|
|
|
if (fctx->queues[0].q != &trans_q[0])
|
|
|
|
|
goto end;
|
|
|
|
|
if (fctx->queues[1].q != &trans_q[1])
|
|
|
|
|
goto end;
|
|
|
|
|
if (fctx->queues[2].q != &trans_q[2])
|
|
|
|
|
goto end;
|
|
|
|
|
if (fctx->queues[3].q != &trans_q[3])
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[0].q == tmq1->pq);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[1].q == tmq2->pq);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[2].q == tmq3->pq);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[3].q == tmq4->pq);
|
|
|
|
|
|
|
|
|
|
retval = 1;
|
|
|
|
|
end:
|
|
|
|
|
if (fctx != NULL)
|
|
|
|
|
TmqhOutputFlowFreeCtx(fctx);
|
|
|
|
|
TmqhOutputFlowFreeCtx(fctx);
|
|
|
|
|
TmqResetQueues();
|
|
|
|
|
return retval;
|
|
|
|
|
PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int TmqhOutputFlowSetupCtxTest02(void)
|
|
|
|
|
{
|
|
|
|
|
int retval = 0;
|
|
|
|
|
Tmq *tmq = NULL;
|
|
|
|
|
TmqhFlowCtx *fctx = NULL;
|
|
|
|
|
|
|
|
|
|
TmqResetQueues();
|
|
|
|
|
|
|
|
|
|
tmq = TmqCreateQueue("queue1");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
tmq = TmqCreateQueue("queue2");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
tmq = TmqCreateQueue("another");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
tmq = TmqCreateQueue("yetanother");
|
|
|
|
|
if (tmq == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
Tmq *tmq1 = TmqCreateQueue("queue1");
|
|
|
|
|
FAIL_IF_NULL(tmq1);
|
|
|
|
|
Tmq *tmq2 = TmqCreateQueue("queue2");
|
|
|
|
|
FAIL_IF_NULL(tmq2);
|
|
|
|
|
Tmq *tmq3 = TmqCreateQueue("another");
|
|
|
|
|
FAIL_IF_NULL(tmq3);
|
|
|
|
|
Tmq *tmq4 = TmqCreateQueue("yetanother");
|
|
|
|
|
FAIL_IF_NULL(tmq4);
|
|
|
|
|
|
|
|
|
|
const char *str = "queue1";
|
|
|
|
|
void *ctx = TmqhOutputFlowSetupCtx(str);
|
|
|
|
|
FAIL_IF_NULL(ctx);
|
|
|
|
|
|
|
|
|
|
if (ctx == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
fctx = (TmqhFlowCtx *)ctx;
|
|
|
|
|
|
|
|
|
|
if (fctx->size != 1)
|
|
|
|
|
goto end;
|
|
|
|
|
TmqhFlowCtx *fctx = (TmqhFlowCtx *)ctx;
|
|
|
|
|
|
|
|
|
|
if (fctx->queues == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NOT(fctx->size == 1);
|
|
|
|
|
|
|
|
|
|
if (fctx->queues[0].q != &trans_q[0])
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NULL(fctx->queues);
|
|
|
|
|
|
|
|
|
|
retval = 1;
|
|
|
|
|
end:
|
|
|
|
|
if (fctx != NULL)
|
|
|
|
|
TmqhOutputFlowFreeCtx(fctx);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[0].q == tmq1->pq);
|
|
|
|
|
TmqhOutputFlowFreeCtx(fctx);
|
|
|
|
|
TmqResetQueues();
|
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
|
|
PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int TmqhOutputFlowSetupCtxTest03(void)
|
|
|
|
|
{
|
|
|
|
|
int retval = 0;
|
|
|
|
|
TmqhFlowCtx *fctx = NULL;
|
|
|
|
|
|
|
|
|
|
TmqResetQueues();
|
|
|
|
|
|
|
|
|
|
const char *str = "queue1,queue2,another,yetanother";
|
|
|
|
|
void *ctx = TmqhOutputFlowSetupCtx(str);
|
|
|
|
|
FAIL_IF_NULL(ctx);
|
|
|
|
|
|
|
|
|
|
if (ctx == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
TmqhFlowCtx *fctx = (TmqhFlowCtx *)ctx;
|
|
|
|
|
|
|
|
|
|
fctx = (TmqhFlowCtx *)ctx;
|
|
|
|
|
FAIL_IF_NOT(fctx->size == 4);
|
|
|
|
|
|
|
|
|
|
if (fctx->size != 4)
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NULL(fctx->queues);
|
|
|
|
|
|
|
|
|
|
if (fctx->queues == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
Tmq *tmq1 = TmqGetQueueByName("queue1");
|
|
|
|
|
FAIL_IF_NULL(tmq1);
|
|
|
|
|
Tmq *tmq2 = TmqGetQueueByName("queue2");
|
|
|
|
|
FAIL_IF_NULL(tmq2);
|
|
|
|
|
Tmq *tmq3 = TmqGetQueueByName("another");
|
|
|
|
|
FAIL_IF_NULL(tmq3);
|
|
|
|
|
Tmq *tmq4 = TmqGetQueueByName("yetanother");
|
|
|
|
|
FAIL_IF_NULL(tmq4);
|
|
|
|
|
|
|
|
|
|
if (fctx->queues[0].q != &trans_q[0])
|
|
|
|
|
goto end;
|
|
|
|
|
if (fctx->queues[1].q != &trans_q[1])
|
|
|
|
|
goto end;
|
|
|
|
|
if (fctx->queues[2].q != &trans_q[2])
|
|
|
|
|
goto end;
|
|
|
|
|
if (fctx->queues[3].q != &trans_q[3])
|
|
|
|
|
goto end;
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[0].q == tmq1->pq);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[1].q == tmq2->pq);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[2].q == tmq3->pq);
|
|
|
|
|
FAIL_IF_NOT(fctx->queues[3].q == tmq4->pq);
|
|
|
|
|
|
|
|
|
|
retval = 1;
|
|
|
|
|
end:
|
|
|
|
|
if (fctx != NULL)
|
|
|
|
|
TmqhOutputFlowFreeCtx(fctx);
|
|
|
|
|
TmqhOutputFlowFreeCtx(fctx);
|
|
|
|
|
TmqResetQueues();
|
|
|
|
|
return retval;
|
|
|
|
|
PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|
|