Go to the documentation of this file.
35 static int g_dnp3_match_buffer_id = 0;
36 static int g_dnp3_data_buffer_id = 0;
37 static int g_dnp3_ind_buffer_id = 0;
49 static void DetectDNP3FuncRegisterTests(
void);
50 static void DetectDNP3ObjRegisterTests(
void);
55 Flow *_f,
const uint8_t flow_flags,
56 void *txv,
const int list_id)
64 if ((flow_flags & STREAM_TOSERVER && !tx->
is_request) ||
65 (flow_flags & STREAM_TOCLIENT && tx->
is_request)) {
94 SCLogError(
"Invalid argument \"%s\" supplied to dnp3_func keyword.",
str);
99 g_dnp3_match_buffer_id) == NULL) {
105 if (detect != NULL) {
106 DetectDNP3FuncFree(NULL, detect);
113 SCDetectU16Free(ptr);
124 if (detect == NULL) {
125 SCLogError(
"Invalid argument \"%s\" supplied to dnp3.ind keyword.",
str);
136 if (detect != NULL) {
137 DetectDNP3IndFree(NULL, detect);
151 static int DetectDNP3ObjParse(
const char *
str, uint8_t *
group, uint8_t *var)
153 size_t size = strlen(
str) + 1;
154 char groupstr[size], *varstr, *sep;
157 sep = strchr(groupstr,
',');
189 detect =
SCCalloc(1,
sizeof(*detect));
203 if (detect != NULL) {
240 DNP3ObjectList *objects = NULL;
248 if (objects != NULL) {
271 static void DetectDNP3FuncRegister(
void)
278 "match on the application function code found in DNP3 request and responses";
291 static void DetectDNP3IndRegister(
void)
298 "match on the DNP3 internal indicator flags in the response application header";
308 static void DetectDNP3ObjRegister(
void)
338 static void DetectDNP3DataRegister(
void)
345 "make the following content options to match on the re-assembled application buffer";
366 DetectDNP3DataRegister();
368 DetectDNP3FuncRegister();
369 DetectDNP3IndRegister();
370 DetectDNP3ObjRegister();
393 static int DetectDNP3FuncTest01(
void)
399 "(msg:\"SURICATA DNP3 Write request\"; "
400 "dnp3_func:2; sid:5000009; rev:1;)");
414 static int DetectDNP3ObjSetupTest(
void)
420 "(msg:\"SURICATA DNP3 Object Test\"; "
421 "dnp3_obj:99,99; sid:1; rev:1;)");
436 static int DetectDNP3ObjParseTest(
void)
454 static void DetectDNP3FuncRegisterTests(
void)
459 static void DetectDNP3ObjRegisterTests(
void)
#define SIGMATCH_INFO_UINT16
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
#define SIGMATCH_INFO_STICKY_BUFFER
SigTableElmt * sigmatch_table
uint8_t DetectEngineInspectBufferGeneric(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const 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.
void(* Free)(DetectEngineCtx *, void *)
SigMatch * DetectBufferGetFirstSigMatch(const Signature *s, const uint32_t buf_id)
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void DetectDNP3Register(void)
struct HtpBodyChunk_ * next
Struct to hold the list of decoded objects.
main detection engine ctx
#define TAILQ_FOREACH(var, head, field)
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
int SCDetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
#define SIG_FLAG_TOCLIENT
InspectionBuffer * InspectionBufferGet(DetectEngineThreadCtx *det_ctx, const int list_id)
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int DetectBufferTypeGetByName(const char *name)
size_t strlcpy(char *dst, const char *src, size_t siz)
int StringParseUint8(uint8_t *res, int base, size_t len, const char *str)
#define SIG_FLAG_TOSERVER
#define PASS
Pass the test.
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
DetectUintData_u8 DetectU8Data
void DetectAppLayerMpmRegister(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
register an app layer keyword for mpm
#define SIGMATCH_INFO_BITFLAGS_UINT
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)
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
int DetectBufferTypeRegister(const char *name)
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
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
#define SIGMATCH_INFO_UINT8
void InspectionBufferSetupAndApplyTransforms(DetectEngineThreadCtx *det_ctx, const int list_id, InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len, const DetectEngineTransforms *transforms)
setup the buffer with our initial data
DetectEngineCtx * DetectEngineCtxInit(void)
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
struct DetectDNP3_ DetectDNP3
DetectUintData_u16 DetectU16Data
#define SIGMATCH_INFO_ENUM_UINT
void(* RegisterTests)(void)