|
|
|
@ -92,30 +92,39 @@ error:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int DetectFlowbitMatchToggle (Packet *p, const DetectFlowbitsData *fd)
|
|
|
|
|
static int DetectFlowbitMatchToggle (Packet *p, const DetectFlowbitsData *fd, const int flow_locked)
|
|
|
|
|
{
|
|
|
|
|
if (p->flow == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
FlowBitToggle(p->flow,fd->idx);
|
|
|
|
|
if (flow_locked)
|
|
|
|
|
FlowBitToggleNoLock(p->flow,fd->idx);
|
|
|
|
|
else
|
|
|
|
|
FlowBitToggle(p->flow,fd->idx);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int DetectFlowbitMatchUnset (Packet *p, const DetectFlowbitsData *fd)
|
|
|
|
|
static int DetectFlowbitMatchUnset (Packet *p, const DetectFlowbitsData *fd, const int flow_locked)
|
|
|
|
|
{
|
|
|
|
|
if (p->flow == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
FlowBitUnset(p->flow,fd->idx);
|
|
|
|
|
if (flow_locked)
|
|
|
|
|
FlowBitUnsetNoLock(p->flow,fd->idx);
|
|
|
|
|
else
|
|
|
|
|
FlowBitUnset(p->flow,fd->idx);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int DetectFlowbitMatchSet (Packet *p, const DetectFlowbitsData *fd)
|
|
|
|
|
static int DetectFlowbitMatchSet (Packet *p, const DetectFlowbitsData *fd, const int flow_locked)
|
|
|
|
|
{
|
|
|
|
|
if (p->flow == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
FlowBitSet(p->flow,fd->idx);
|
|
|
|
|
if (flow_locked)
|
|
|
|
|
FlowBitSetNoLock(p->flow,fd->idx);
|
|
|
|
|
else
|
|
|
|
|
FlowBitSet(p->flow,fd->idx);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -146,6 +155,7 @@ int DetectFlowbitMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p
|
|
|
|
|
const DetectFlowbitsData *fd = (const DetectFlowbitsData *)ctx;
|
|
|
|
|
if (fd == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
const int flow_locked = det_ctx->flow_locked;
|
|
|
|
|
|
|
|
|
|
switch (fd->cmd) {
|
|
|
|
|
case DETECT_FLOWBITS_CMD_ISSET:
|
|
|
|
@ -153,11 +163,11 @@ int DetectFlowbitMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p
|
|
|
|
|
case DETECT_FLOWBITS_CMD_ISNOTSET:
|
|
|
|
|
return DetectFlowbitMatchIsnotset(p,fd);
|
|
|
|
|
case DETECT_FLOWBITS_CMD_SET:
|
|
|
|
|
return DetectFlowbitMatchSet(p,fd);
|
|
|
|
|
return DetectFlowbitMatchSet(p,fd,flow_locked);
|
|
|
|
|
case DETECT_FLOWBITS_CMD_UNSET:
|
|
|
|
|
return DetectFlowbitMatchUnset(p,fd);
|
|
|
|
|
return DetectFlowbitMatchUnset(p,fd,flow_locked);
|
|
|
|
|
case DETECT_FLOWBITS_CMD_TOGGLE:
|
|
|
|
|
return DetectFlowbitMatchToggle(p,fd);
|
|
|
|
|
return DetectFlowbitMatchToggle(p,fd,flow_locked);
|
|
|
|
|
default:
|
|
|
|
|
SCLogError(SC_ERR_UNKNOWN_VALUE, "unknown cmd %" PRIu32 "", fd->cmd);
|
|
|
|
|
return 0;
|
|
|
|
|