Go to the documentation of this file.
36 #define PARSE_REGEX "^\\s*\\d+\\s*$"
39 static int mqtt_reason_code_id = 0;
93 const uint8_t *
de = (
const uint8_t *)ctx;
99 if (rs_mqtt_tx_get_reason_code(txv, &
code) == 0) {
103 return rs_mqtt_tx_unsuback_has_reason_code(txv, *
de);
120 static uint8_t *DetectMQTTReasonCodeParse(
const char *rawstr)
128 SCLogError(
"invalid MQTT reason code: %s", rawstr);
159 de = DetectMQTTReasonCodeParse(rawstr);
205 static int MQTTReasonCodeTestParse01 (
void)
209 de = DetectMQTTReasonCodeParse(
"3");
214 de = DetectMQTTReasonCodeParse(
" 4");
219 de = DetectMQTTReasonCodeParse(
" 5");
224 de = DetectMQTTReasonCodeParse(
"255");
238 static int MQTTReasonCodeTestParse02 (
void)
241 de = DetectMQTTReasonCodeParse(
"6X");
256 static int MQTTReasonCodeTestParse03 (
void)
259 de = DetectMQTTReasonCodeParse(
"");
274 static int MQTTReasonCodeTestParse04 (
void)
277 de = DetectMQTTReasonCodeParse(
"256");
296 UtRegisterTest(
"MQTTReasonCodeTestParse01", MQTTReasonCodeTestParse01);
297 UtRegisterTest(
"MQTTReasonCodeTestParse02", MQTTReasonCodeTestParse02);
298 UtRegisterTest(
"MQTTReasonCodeTestParse03", MQTTReasonCodeTestParse03);
299 UtRegisterTest(
"MQTTReasonCodeTestParse04", MQTTReasonCodeTestParse04);
void DetectMQTTReasonCodeRegister(void)
Registration function for mqtt.reason_code: keyword.
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void SigMatchAppendSMToList(Signature *s, SigMatch *new, const int list)
Append a SigMatch to the list type.
void(* Free)(DetectEngineCtx *, void *)
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
main detection engine ctx
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
@ DETECT_AL_MQTT_REASON_CODE
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
int DetectBufferTypeGetByName(const char *name)
int StringParseUint8(uint8_t *res, int base, size_t len, const char *str)
#define SIG_FLAG_TOSERVER
#define PASS
Pass the test.
void DetectMQTTReasonCodeFree(DetectEngineCtx *de_ctx, void *)
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
void DetectAppLayerInspectEngineRegister2(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr2 Callback2, InspectionBufferGetDataPtr GetData)
register inspect engine at start up time
SigMatch * SigMatchAlloc(void)
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
void MQTTReasonCodeRegisterTests(void)
this function registers unit tests for MQTTReasonCode
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
uint8_t DetectEngineInspectGenericList(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
Do the content inspection & validation for a signature.
#define SCLogError(...)
Macro used to log ERROR messages.
a single match condition for a signature
void(* RegisterTests)(void)