Go to the documentation of this file.
23 static int DetectVlanIdMatch(
26 const DetectVlanIdData *vdata = (
const DetectVlanIdData *)
ctx;
32 switch (vdata->layer) {
33 case DETECT_VLAN_ID_ANY:
34 for (
int i = 0; i < p->
vlan_idx; i++) {
40 case DETECT_VLAN_ID_ALL:
41 for (
int i = 0; i < p->
vlan_idx; i++) {
48 if (vdata->layer < 0) {
49 if (((int16_t)p->
vlan_idx) + vdata->layer < 0) {
64 SCDetectVlanIdFree(ptr);
69 DetectVlanIdData *vdata = SCDetectVlanIdParse(rawstr);
77 DetectVlanIdFree(
de_ctx, vdata);
89 DetectVlanIdData vdata;
90 vdata.du16.mode =
ctx->v1.u8[0];
91 vdata.layer =
ctx->v1.u8[1];
92 vdata.du16.arg1 =
ctx->v1.u16[2];
93 vdata.du16.arg2 =
ctx->v1.u16[3];
98 if (DetectVlanIdMatch(det_ctx, p, NULL, (
const SigMatchCtx *)&vdata)) {
99 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
105 const DetectVlanIdData *a = smctx;
106 v->
u8[0] = a->du16.mode;
108 v->
u16[2] = a->du16.arg1;
109 v->
u16[3] = a->du16.arg2;
114 const DetectVlanIdData *a = smctx;
115 if (v.
u8[0] == a->du16.mode && v.
u8[1] == a->layer && v.
u16[2] == a->du16.arg1 &&
116 v.
u16[3] == a->du16.arg2)
124 PrefilterPacketVlanIdSet, PrefilterPacketVlanIdCompare, PrefilterPacketVlanIdMatch);
127 static bool PrefilterVlanIdIsPrefilterable(
const Signature *s)
144 static int DetectVlanLayersMatch(
155 rs_detect_u8_free(ptr);
168 SCLogError(
"number of layers out of range %s", rawstr);
174 DetectVlanLayersFree(
de_ctx, du8);
182 static void PrefilterPacketVlanLayersMatch(
188 du8.mode =
ctx->v1.u8[0];
189 du8.arg1 =
ctx->v1.u8[1];
190 du8.arg2 =
ctx->v1.u8[2];
192 if (DetectVlanLayersMatch(det_ctx, p, NULL, (
const SigMatchCtx *)&du8)) {
193 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
203 static bool PrefilterVlanLayersIsPrefilterable(
const Signature *s)
#define SIG_MASK_REQUIRE_REAL_PKT
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
Container for matching data for a signature group.
main detection engine ctx
void DetectVlanLayersRegister(void)
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
DetectUintData_u8 * DetectU8Parse(const char *u8str)
This function is used to parse u8 options passed via some u8 keyword.
DetectUintData_u8 DetectU8Data
void PrefilterPacketU8Set(PrefilterPacketHeaderValue *v, void *smctx)
int PrefilterSetupPacketHeader(DetectEngineCtx *de_ctx, SigGroupHead *sgh, int sm_type, SignatureMask mask, void(*Set)(PrefilterPacketHeaderValue *v, void *), bool(*Compare)(PrefilterPacketHeaderValue v, void *), void(*Match)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx))
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8)
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
#define SCLogError(...)
Macro used to log ERROR messages.
bool(* SupportsPrefilter)(const Signature *s)
bool PrefilterPacketU8Compare(PrefilterPacketHeaderValue v, void *smctx)
void DetectVlanIdRegister(void)
uint16_t vlan_id[VLAN_MAX_LAYERS]
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
#define SIG_FLAG_REQUIRE_PACKET