Go to the documentation of this file.
41 #define PARSE_REGEX "^\\s*(\"\\s*)?([0-9]+)(\\s*\")?\\s*$"
49 static void DetectIcmpSeqRegisterTests(
void);
53 static bool PrefilterIcmpSeqIsPrefilterable(
const Signature *s);
75 static inline bool GetIcmpSeq(
Packet *p, uint16_t *
seq)
92 SCLogDebug(
"ICMPV4_GET_SEQ(p) %"PRIu16
" (network byte order), "
107 SCLogDebug(
"ICMPV6_GET_SEQ(p) %"PRIu16
" (network byte order), "
142 if (!GetIcmpSeq(p, &seqn))
146 if (seqn == iseq->
seq)
164 char *substr[3] = {NULL, NULL, NULL};
170 pcre2_match_data *match = NULL;
172 if (ret < 1 || ret > 4) {
177 for (i = 1; i < ret; i++) {
180 SCLogError(
"pcre2_substring_get_bynumber failed");
183 substr[i-1] = (
char *)str_ptr;
192 if (substr[0] != NULL && strlen(substr[0]) != 0) {
193 if (substr[2] == NULL) {
198 if (substr[2] != NULL) {
213 for (i = 0; i < 3; i++) {
214 if (substr[i] != NULL)
215 pcre2_substring_free((PCRE2_UCHAR8 *)substr[i]);
218 pcre2_match_data_free(match);
223 pcre2_match_data_free(match);
225 for (i = 0; i < 3; i++) {
226 if (substr[i] != NULL)
227 pcre2_substring_free((PCRE2_UCHAR8 *)substr[i]);
249 iseq = DetectIcmpSeqParse(
de_ctx, icmpseqstr);
250 if (iseq == NULL)
goto error;
253 if (sm == NULL)
goto error;
264 if (sm != NULL)
SCFree(sm);
289 if (!GetIcmpSeq(p, &seqn))
292 if (seqn == ctx->
v1.
u16[0])
318 PrefilterPacketIcmpSeqSet,
319 PrefilterPacketIcmpSeqCompare,
320 PrefilterPacketIcmpSeqMatch);
323 static bool PrefilterIcmpSeqIsPrefilterable(
const Signature *s)
343 static int DetectIcmpSeqParseTest01 (
void)
346 iseq = DetectIcmpSeqParse(NULL,
"300");
357 static int DetectIcmpSeqParseTest02 (
void)
360 iseq = DetectIcmpSeqParse(NULL,
" 300 ");
370 static int DetectIcmpSeqParseTest03 (
void)
377 static void DetectIcmpSeqRegisterTests (
void)
379 UtRegisterTest(
"DetectIcmpSeqParseTest01", DetectIcmpSeqParseTest01);
380 UtRegisterTest(
"DetectIcmpSeqParseTest02", DetectIcmpSeqParseTest02);
381 UtRegisterTest(
"DetectIcmpSeqParseTest03", DetectIcmpSeqParseTest03);
#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.
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
#define ICMP_INFO_REQUEST
void(* Free)(DetectEngineCtx *, void *)
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Container for matching data for a signature group.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define ICMPV6_GET_SEQ(p)
main detection engine ctx
int StringParseUint16(uint16_t *res, int base, size_t len, const char *str)
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define ICMP6_ECHO_REQUEST
#define ICMPV4_GET_SEQ(p)
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
#define ICMP_ADDRESSREPLY
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
#define PASS
Pass the test.
#define ICMPV4_GET_TYPE(p)
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
void DetectIcmpSeqRegister(void)
Registration function for icmp_seq.
int SC_Pcre2SubstringGet(pcre2_match_data *match_data, uint32_t number, PCRE2_UCHAR **bufferptr, PCRE2_SIZE *bufflen)
SignatureInitData * init_data
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
SigMatch * SigMatchAlloc(void)
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
int PrefilterSetupPacketHeader(DetectEngineCtx *de_ctx, SigGroupHead *sgh, int sm_type, void(*Set)(PrefilterPacketHeaderValue *v, void *), bool(*Compare)(PrefilterPacketHeaderValue v, void *), void(*Match)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx))
#define SCLogError(...)
Macro used to log ERROR messages.
bool(* SupportsPrefilter)(const Signature *s)
a single match condition for a signature
#define ICMPV6_GET_TYPE(p)
#define ICMP_TIMESTAMPREPLY
void DetectIcmpSeqFree(DetectEngineCtx *, void *)
this function will free memory associated with DetectIcmpSeqData
void(* RegisterTests)(void)