From a4638fb0adfcb125fa3f6b61a16a38ae65e659ab Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Sat, 18 Feb 2012 17:32:08 +0530 Subject: [PATCH] code cleanup - replace SigMatchAppendPacket with SigMatchAppendSMToList --- src/detect-ack.c | 2 +- src/detect-asn1.c | 2 +- src/detect-csum.c | 14 +++++++------- src/detect-dsize.c | 2 +- src/detect-engine-event.c | 2 +- src/detect-flags.c | 2 +- src/detect-flow.c | 2 +- src/detect-flowbits.c | 2 +- src/detect-flowint.c | 2 +- src/detect-flowvar.c | 2 +- src/detect-fragbits.c | 2 +- src/detect-fragoffset.c | 2 +- src/detect-icmp-id.c | 2 +- src/detect-icmp-seq.c | 2 +- src/detect-icode.c | 2 +- src/detect-id.c | 2 +- src/detect-ipopts.c | 2 +- src/detect-ipproto.c | 2 +- src/detect-itype.c | 2 +- src/detect-parse.c | 26 -------------------------- src/detect-parse.h | 1 - src/detect-pktvar.c | 2 +- src/detect-rpc.c | 2 +- src/detect-sameip.c | 2 +- src/detect-seq.c | 2 +- src/detect-stream_size.c | 2 +- src/detect-tos.c | 2 +- src/detect-ttl.c | 2 +- src/detect-window.c | 2 +- 29 files changed, 33 insertions(+), 60 deletions(-) diff --git a/src/detect-ack.c b/src/detect-ack.c index c8ed77f8e8..e3ac7d3f62 100644 --- a/src/detect-ack.c +++ b/src/detect-ack.c @@ -112,7 +112,7 @@ static int DetectAckSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) } sm->ctx = data; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-asn1.c b/src/detect-asn1.c index 12eb109718..22034be461 100644 --- a/src/detect-asn1.c +++ b/src/detect-asn1.c @@ -301,7 +301,7 @@ int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, char *asn1str) { sm->type = DETECT_ASN1; sm->ctx = (void *)ad; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; diff --git a/src/detect-csum.c b/src/detect-csum.c index f0f4655f97..c462c76ff2 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -283,7 +283,7 @@ static int DetectIPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; @@ -378,7 +378,7 @@ static int DetectTCPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csu sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; @@ -473,7 +473,7 @@ static int DetectTCPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csu sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; @@ -569,7 +569,7 @@ static int DetectUDPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csu sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; @@ -665,7 +665,7 @@ static int DetectUDPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csu sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; @@ -760,7 +760,7 @@ static int DetectICMPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *cs sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; @@ -853,7 +853,7 @@ static int DetectICMPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *cs sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; diff --git a/src/detect-dsize.c b/src/detect-dsize.c index 2dae4c58ef..828c054393 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -303,7 +303,7 @@ static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr sm->type = DETECT_DSIZE; sm->ctx = (void *)dd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); SCLogDebug("dd->dsize %"PRIu16", dd->dsize2 %"PRIu16", dd->mode %"PRIu8"", dd->dsize, dd->dsize2, dd->mode); diff --git a/src/detect-engine-event.c b/src/detect-engine-event.c index 93f7a31a03..bde932042a 100644 --- a/src/detect-engine-event.c +++ b/src/detect-engine-event.c @@ -207,7 +207,7 @@ static int _DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, char sm->type = smtype; sm->ctx = (void *)de; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; error: diff --git a/src/detect-flags.c b/src/detect-flags.c index d23d9c852d..f5ae3141f0 100644 --- a/src/detect-flags.c +++ b/src/detect-flags.c @@ -498,7 +498,7 @@ static int DetectFlagsSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr sm->type = DETECT_FLAGS; sm->ctx = (void *)de; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-flow.c b/src/detect-flow.c index 446bdab1d2..8147d9fecb 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -310,7 +310,7 @@ int DetectFlowSetup (DetectEngineCtx *de_ctx, Signature *s, char *flowstr) sm->type = DETECT_FLOW; sm->ctx = (void *)fd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); /* set the signature direction flags */ if (fd->flags & FLOW_PKT_TOSERVER) { diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 83863ff7f4..762fc5fb0b 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -257,7 +257,7 @@ int DetectFlowbitSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) case DETECT_FLOWBITS_CMD_ISNOTSET: case DETECT_FLOWBITS_CMD_ISSET: /* checks, so packet list */ - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); break; case DETECT_FLOWBITS_CMD_SET: diff --git a/src/detect-flowint.c b/src/detect-flowint.c index 95ec405920..508bce52b8 100644 --- a/src/detect-flowint.c +++ b/src/detect-flowint.c @@ -390,7 +390,7 @@ static int DetectFlowintSetup(DetectEngineCtx *de_ctx, Signature *s, char *rawst case FLOWINT_MODIFIER_GT: case FLOWINT_MODIFIER_ISSET: case FLOWINT_MODIFIER_NOTSET: - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); break; } diff --git a/src/detect-flowvar.c b/src/detect-flowvar.c index 865dca6772..dddf0f84bf 100644 --- a/src/detect-flowvar.c +++ b/src/detect-flowvar.c @@ -236,7 +236,7 @@ static int DetectFlowvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *raws sm->type = DETECT_FLOWVAR; sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); if (dubbed) SCFree(str); return 0; diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index 74e9b88914..127d61d58b 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -296,7 +296,7 @@ static int DetectFragBitsSetup (DetectEngineCtx *de_ctx, Signature *s, char *raw sm->type = DETECT_FRAGBITS; sm->ctx = (void *)de; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index b94d5ed064..5e12be9e05 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -226,7 +226,7 @@ static int DetectFragOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *f sm->type = DETECT_FRAGOFFSET; sm->ctx = (void *)fragoff; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-icmp-id.c b/src/detect-icmp-id.c index 5edec50613..0d07927f1e 100644 --- a/src/detect-icmp-id.c +++ b/src/detect-icmp-id.c @@ -232,7 +232,7 @@ static int DetectIcmpIdSetup (DetectEngineCtx *de_ctx, Signature *s, char *icmpi sm->type = DETECT_ICMP_ID; sm->ctx = (void *)iid; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-icmp-seq.c b/src/detect-icmp-seq.c index fa38c73437..548184bffa 100644 --- a/src/detect-icmp-seq.c +++ b/src/detect-icmp-seq.c @@ -233,7 +233,7 @@ static int DetectIcmpSeqSetup (DetectEngineCtx *de_ctx, Signature *s, char *icmp sm->type = DETECT_ICMP_SEQ; sm->ctx = (void *)iseq; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; diff --git a/src/detect-icode.c b/src/detect-icode.c index f8f66fb70b..1a3362405d 100644 --- a/src/detect-icode.c +++ b/src/detect-icode.c @@ -255,7 +255,7 @@ static int DetectICodeSetup(DetectEngineCtx *de_ctx, Signature *s, char *icodest sm->type = DETECT_ICODE; sm->ctx = (void *)icd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-id.c b/src/detect-id.c index 51fe1de1d0..1627810f02 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -232,7 +232,7 @@ int DetectIdSetup (DetectEngineCtx *de_ctx, Signature *s, char *idstr) sm->type = DETECT_ID; sm->ctx = (void *)id_d; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index 44f8a9f641..b6c7384418 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -200,7 +200,7 @@ static int DetectIpOptsSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst sm->type = DETECT_IPOPTS; sm->ctx = (void *)de; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index bc5a71ac9b..c9b9034957 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -519,7 +519,7 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst goto error; sm->type = DETECT_IPPROTO; sm->ctx = (void *)data; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-itype.c b/src/detect-itype.c index 97db15acd9..7941ebbd96 100644 --- a/src/detect-itype.c +++ b/src/detect-itype.c @@ -255,7 +255,7 @@ static int DetectITypeSetup(DetectEngineCtx *de_ctx, Signature *s, char *itypest sm->type = DETECT_ITYPE; sm->ctx = (void *)itd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-parse.c b/src/detect-parse.c index 5011fb642f..77559f0cbc 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -189,32 +189,6 @@ void SigMatchRemoveSMFromList(Signature *s, SigMatch *sm, int sm_list) return; } -/** \brief Append a sig match to the signatures non-payload match list - * - * \param s signature - * \param new sigmatch to append - */ -void SigMatchAppendPacket(Signature *s, SigMatch *new) { - if (s->sm_lists[DETECT_SM_LIST_MATCH] == NULL) { - s->sm_lists[DETECT_SM_LIST_MATCH] = new; - s->sm_lists_tail[DETECT_SM_LIST_MATCH] = new; - new->next = NULL; - new->prev = NULL; - } else { - SigMatch *cur = s->sm_lists[DETECT_SM_LIST_MATCH]; - - for ( ; cur->next != NULL; cur = cur->next); - - cur->next = new; - new->next = NULL; - new->prev = cur; - s->sm_lists_tail[DETECT_SM_LIST_MATCH] = new; - } - - new->idx = s->sm_cnt; - s->sm_cnt++; -} - /** \brief Append a sig match to the signatures threshold list * * \param s signature diff --git a/src/detect-parse.h b/src/detect-parse.h index dabe638387..43b9e1b163 100644 --- a/src/detect-parse.h +++ b/src/detect-parse.h @@ -57,7 +57,6 @@ void SigMatchReplace(Signature *, SigMatch *, SigMatch *); void SigMatchReplaceContent(Signature *, SigMatch *, SigMatch *); void SigMatchReplaceContentToUricontent(Signature *, SigMatch *, SigMatch *); -void SigMatchAppendPacket(Signature *, SigMatch *); void SigMatchAppendThreshold(Signature *, SigMatch *); void SigMatchAppendPostMatch(Signature *, SigMatch *); void SigMatchAppendSMToList(Signature *, SigMatch *, int); diff --git a/src/detect-pktvar.c b/src/detect-pktvar.c index bb2b6470f0..9f00bc002c 100644 --- a/src/detect-pktvar.c +++ b/src/detect-pktvar.c @@ -231,7 +231,7 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst sm->type = DETECT_PKTVAR; sm->ctx = (void *)cd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); if (dubbed) SCFree(str); return 0; diff --git a/src/detect-rpc.c b/src/detect-rpc.c index b41b5c0fad..6341c80efb 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -285,7 +285,7 @@ int DetectRpcSetup (DetectEngineCtx *de_ctx, Signature *s, char *rpcstr) sm->type = DETECT_RPC; sm->ctx = (void *)rd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-sameip.c b/src/detect-sameip.c index dfad9a9aed..b67f9c5f8c 100644 --- a/src/detect-sameip.c +++ b/src/detect-sameip.c @@ -96,7 +96,7 @@ static int DetectSameipSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr sm->type = DETECT_SAMEIP; sm->ctx = NULL; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-seq.c b/src/detect-seq.c index 48e752a6fd..064782c1b2 100644 --- a/src/detect-seq.c +++ b/src/detect-seq.c @@ -111,7 +111,7 @@ static int DetectSeqSetup (DetectEngineCtx *de_ctx, Signature *s, char *optstr) } sm->ctx = data; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-stream_size.c b/src/detect-stream_size.c index fe23c1c107..159c591285 100644 --- a/src/detect-stream_size.c +++ b/src/detect-stream_size.c @@ -319,7 +319,7 @@ static int DetectStreamSizeSetup (DetectEngineCtx *de_ctx, Signature *s, char *s sm->type = DETECT_STREAM_SIZE; sm->ctx = (void *)sd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); return 0; diff --git a/src/detect-tos.c b/src/detect-tos.c index 1d2fc820b2..aa4f9342e7 100644 --- a/src/detect-tos.c +++ b/src/detect-tos.c @@ -217,7 +217,7 @@ int DetectTosSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) sm->type = DETECT_TOS; sm->ctx = (void *)tosd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-ttl.c b/src/detect-ttl.c index 2a8cbba122..89f890bda9 100644 --- a/src/detect-ttl.c +++ b/src/detect-ttl.c @@ -281,7 +281,7 @@ static int DetectTtlSetup (DetectEngineCtx *de_ctx, Signature *s, char *ttlstr) sm->type = DETECT_TTL; sm->ctx = (void *)ttld; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0; diff --git a/src/detect-window.c b/src/detect-window.c index 69c5bb6c09..d9ce412d12 100644 --- a/src/detect-window.c +++ b/src/detect-window.c @@ -216,7 +216,7 @@ int DetectWindowSetup (DetectEngineCtx *de_ctx, Signature *s, char *windowstr) sm->type = DETECT_WINDOW; sm->ctx = (void *)wd; - SigMatchAppendPacket(s, sm); + SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_MATCH); s->flags |= SIG_FLAG_REQUIRE_PACKET; return 0;